Showing posts with label Function Modules. Show all posts
Showing posts with label Function Modules. Show all posts

Oct 12, 2026

Function Module to Call Adobe Form in Sap Abap

 To call an Adobe Form in SAP ABAP, you use a sequence of specific function modules: FP_JOB_OPEN to initialize the print/output job, FP_FUNCTION_MODULE_NAME to retrieve the name of the generated function module for your form, the generated function module itself to pass data and generate the PDF, and FP_JOB_CLOSE to close the job.

Key Function Modules Sequence
  1. FP_JOB_OPEN
    • Purpose: Opens the print or output job and configures output parameters (such as preview, no dialog, or printer destination).
    • Key Parameter: IE_OUTPUTPARAMS (Type: SFPOUTPUTPARAMS / SFP_OUTPARAMS).
  2. FP_FUNCTION_MODULE_NAME
    • Purpose: Looks up the runtime name of the generated function module associated with your Adobe Form name.
    • Key Parameters:
      • I_NAME (Passing your Adobe Form name)
      • E_FUNCNAME (Importing the resulting generated function module name) 
  3. Generated Function Module (Dynamic Name)
    • Purpose: Executes the form routine, processes the interface data, and returns the PDF output.
    • Key Parameters:
      • Exporting: /1BCDWB/DOCPARAMS (Type: SFP_DOCPARAMS for language, country, etc.)
      • Importing: /1BCDWB/FORM_OUTPUT (Type: FPFORM_OUTPUT containing the generated PDF XSTRING)
      • Plus any custom importing parameters defined in your Adobe Form interface. 
  4. FP_JOB_CLOSE
    • Purpose: Closes the print job and finalizes the spool request or output generation. 


Example ABAP Code Structure
Example ABAP Code Structure
DATA: lv_fm_name     TYPE funcname,
      ls_outputparams TYPE sfpoutputparams,
      ls_docparams    TYPE sfpdocparams,
      ls_form_output  TYPE fpform_output.

* 1. Set output parameters (e.g., no dialog, enable preview or PDF get)
ls_outputparams-nodialog = 'X'.
ls_outputparams-getpdf   = 'X'. " Use if you want XSTRING PDF back in ABAP

CALL FUNCTION 'FP_JOB_OPEN'
  CHANGING
    ie_outputparams = ls_outputparams
  EXCEPTIONS
    cancel          = 1
    usage_error     = 2
    system_error    = 3
    internal_error  = 4
    OTHERS          = 5.

IF sy-subrc <> 0.
  " Handle error
ENDIF.

* 2. Get the generated function module name for the Adobe Form
CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
  EXPORTING
    i_name     = 'ZYOUR_ADOBE_FORM_NAME' " Replace with your Adobe Form name
  IMPORTING
    e_funcname = lv_fm_name.

IF sy-subrc <> 0.
  " Handle error
ENDIF.

* 3. Set document parameters (language, country)
ls_docparams-langu = sy-langu.

* 4. Call the generated function module
CALL FUNCTION lv_fm_name
  EXPORTING
    /1bcdwb/docparams = ls_docparams
    " <your_custom_interface_parameters> = ...
  IMPORTING
    /1bcdwb/form_output = ls_form_output
  EXCEPTIONS
    usage_error       = 1
    system_error      = 2
    internal_error    = 3
    OTHERS            = 4.

IF sy-subrc <> 0.
  " Handle error
ENDIF.

* 5. Close the job
CALL FUNCTION 'FP_JOB_CLOSE'
  EXCEPTIONS
    usage_error    = 1
    system_error   = 2
    internal_error = 3
    OTHERS         = 4.


Helpful Resources

Jun 30, 2026

How to Move Files between Directories on the Application Server?

SAP developers natively accomplish this using one of three standard methods: standard ABAP dataset commands, OS-level commands via SXPG_COMMAND_EXECUTE, or specialized functions like ARCHIVFILE_SERVER_TO_SERVER. 

Option 1: Native ABAP Statements (Recommended & Safest)
The cleanest, platform-independent approach is to copy the file content data line-by-line using datasets and then delete the original file. This completely eliminates operating system dependencies. 
abap
DATA: lv_line TYPE string.

" 1. Open the original source file
OPEN DATASET p_src_file FOR INPUT IN BINARY MODE.
IF sy-subrc = 0.
  
  " 2. Open the destination target file
  OPEN DATASET p_tgt_file FOR OUTPUT IN BINARY MODE.
  IF sy-subrc = 0.
    
    " 3. Read line by line and transfer data
    DO.
      READ DATASET p_src_file INTO lv_line.
      IF sy-subrc <> 0.
        EXIT.
      ENDIF.
      TRANSFER lv_line TO p_tgt_file.
    ENDDO.
    
    CLOSE DATASET p_tgt_file.
  ENDIF.
  
  CLOSE DATASET p_src_file.
  
  " 4. Delete the source file once successfully transferred
  IF sy-subrc = 0.
    DELETE DATASET p_src_file.
  ENDIF.
ENDIF.

Option 2: Function Module ARCHIVFILE_SERVER_TO_SERVER
You can utilize the standard function module ARCHIVFILE_SERVER_TO_SERVER to replicate a copy of the file on the server and then pair it with a DELETE DATASET statement. [1, 2]
  • Limitation: The source and target parameter variables have a maximum length of 70 characters. If your filepath or filename structure exceeds this limitation, you must utilize Option 1 instead. [1]
abap
CALL FUNCTION 'ARCHIVFILE_SERVER_TO_SERVER'
  EXPORTING
    sourcepath       = p_src_file
    targetpath       = p_tgt_file
  EXCEPTIONS
    error_file       = 1
    OTHERS           = 2.

IF sy-subrc = 0.
  DELETE DATASET p_src_file. " Removes original file to complete the move action
ENDIF.

Option 3: Function Module SXPG_COMMAND_EXECUTE
If you are moving exceptionally large files, executing an operating system level command (mv for Unix/Linux or move for Windows) is the fastest option since it changes file pointers rather than rewriting raw blocks. 
  1. Create a custom OS command (e.g., ZMV) mapped to your OS type in transaction SM69.
  2. Call the function module programmatically: 
abap
DATA: lv_parameters TYPE btcxpgpar,
      lv_status     TYPE btcxpgstat.

" Concatenate source and target paths as arguments for the terminal command
CONCATENATE p_src_file p_tgt_file INTO lv_parameters SEPARATED BY space.

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
  EXPORTING
    commandname         = 'ZMV'
    additional_parameters = lv_parameters
  IMPORTING
    status              = lv_status
  EXCEPTIONS
    no_permission       = 1
    command_not_found   = 2
    security_risk       = 3
    OTHERS              = 4.

If you would like to proceed with setting up one of these options, let me know:
  • What is the average size of the files you are moving?
  • Will your typical filepaths exceed 70 characters?
  • Which Operating System (Unix, Linux, Windows) is your SAP application server running on?