ERPClimb logoERPClimb
Adobe Forms
ABAP Developmentintermediate 9 min read

Adobe Forms Part 5: The Driver Program Pattern

Preview · a free account unlocks the full lesson

Key takeaway

Write a production-grade Adobe Form driver: selection, data preparation per document, FP JOB OPEN once, FP FUNCTION MODULE NAME, per-document calls with SFPDOCPARAMS (language, country), error handling with exceptions and messages, FP JOB CLOSE with result, and the output-control entry routine.

In this lessonShow sections

Visual overview

Adobe Forms Part 5: The Driver Program Pattern — learning sheetFlow: Build the driver from the code example for your form → Print 3 documents in one job and check SP01 → Force an error (inactive form) and verify the message handling. Key ideas: STRUCTURE; OUTPUT CONTROL VARIANT; DATA PREPARATION; ERROR HANDLING. Watch out: If FP_JOB_OPEN fails or the job is not closed, the whole run fails — handle exceptions and always close.ERPClimb.com / ABAP / LESSON 5/10 / LEARNING SHEETAdobe Forms Part 5: The Driver Program Pattern1 · HOW IT FLOWS1Build the driver from thecode example for yourform2Print 3 documents in onejob and check SP013Force an error (inactiveform) and verify themessage handling2 · KEY IDEAS EXPLAINEDStructure1. Selection (documents, printer, preview/PDF).Output Control VariantFORM entry USING return_code us_screen:NAST-OBJKY, NAST-SPRAS, NAST-LDEST, TNAPR-SFORM(the "PDF/SmartForm Form" field of the…Set return_code and write NAST_PROTOCOL_UPDATEmessages.Data PreparationA class or FORM per document: read header, items,partner addresses, texts; compute presentationvalues. Reusable for Smart Forms and Adobe forms…Error HandlingFP_FUNCTION_MODULE_NAME raises class-basedexceptions (CX_FP_API_*).The generated FM has classic exceptions(USAGE_ERROR, SYSTEM_ERROR, INTERNAL_ERROR) —sy-msg fields contain the reason (often ADS…3 · REMEMBER · WATCH OUTRememberOne FP_JOB_OPEN before the loop, one generated FM call per document,one FP_JOB_CLOSE after — all documents in one spool job.SFPDOCPARAMS sets language (LANGU) and country (COUNTRY) per document— they control translations and locale formatting.In output control, the driver's ENTRY routine reads NAST (document,printer, language) just like with Smart Forms.!Watch outIf FP_JOB_OPEN fails or the job isnot closed, the whole run fails —handle exceptions and always close.4 · IN A REAL PROJECTA migrated billing driver opened and closed an Adobe job per invoice. The nightly run of 8,000 invoicesproduced 8,000 spool requests and took four hours, mostly ADS connection overhead. Refactoring to one job withper-document calls reduced it to one spool and 50 minutes. The driver also started passing the customer's…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Part 4 designed the form's interface; now the driver program needs to fill that interface and actually run the print job.

The general pattern is one FP_JOB_OPEN call before the loop, one call to the generated function module per document inside the loop, and one FP_JOB_CLOSE call after the loop, so that all the documents end up in a single spool job together.

SFPDOCPARAMS sets the language (LANGU) and country (COUNTRY) per document, which controls translations and locale-specific formatting for that particular document. In output control, the driver's ENTRY routine reads NAST for the document, printer, and language, exactly the way it does with Smart Forms.

One thing to handle carefully: if FP_JOB_OPEN fails, or the job never gets properly closed, the entire run fails, so exceptions need to be handled and the job needs to always be closed.

The overall structure runs like this: first comes the selection step, picking the documents, printer, and whether you want a preview or a PDF; then FP_JOB_OPEN, passing SFPOUTPUTPARAMS with settings like dest, nodialog, preview, getpdf, and reqimm; then a call to FP_FUNCTION_MODULE_NAME to resolve the generated function module's name; then the main loop, which prepares the data for each document, sets SFPDOCPARAMS, calls the function module, and handles any errors; and finally FP_JOB_CLOSE, optionally returning results like the number of pages produced and the spool IDs generated.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Referenced SAP objects

Reviewed reference pages for the objects this page mentions.

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.