Hello,

Sign up to join our community!

Welcome Back,

Please sign in to your account!

Forgot Password,

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask a question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

SAP EWM Help Latest Questions

  • 0
  • 0
DPM125
Beginner

Building an Adobe Form Driver Program in SAP: Sales Order Example with VBAK & VBAP

Imagine a business requirement in Sales & Distribution (SD):

  • The sales team needs a printable Sales Order Form that shows both header details (from VBAK: order number, date, sold-to party, order type) and line item details (from VBAP: material, description, quantity, UoM).

  • This form will be sent to customers as an official order confirmation in PDF format.

  • Since the form must be interactive and professional, SAP Adobe Forms are chosen over Smart Forms.

 

REPORT zdemo_adobe_form.

*———————————————————-*
* Data Declarations
*———————————————————-*
TABLES: vbak, vbap.

DATA: lv_vbeln TYPE vbak-vbeln, “Sales Order
lt_vbak TYPE TABLE OF vbak,
lt_vbap TYPE TABLE OF vbap.

* Form interface structures
DATA: gs_output TYPE zstr_output, “Custom structure for Adobe Form
gt_items TYPE STANDARD TABLE OF zstr_items.

*———————————————————-*
* Selection Screen
*———————————————————-*
PARAMETERS: p_vbeln TYPE vbak-vbeln OBLIGATORY.

*———————————————————-*
* Start-of-selection
*———————————————————-*
START-OF-SELECTION.

” Fetch Sales Order Header
SELECT SINGLE *
INTO vbak
FROM vbak
WHERE vbeln = p_vbeln.

IF sy-subrc = 0.
” Fetch Sales Order Items
SELECT *
INTO TABLE lt_vbap
FROM vbap
WHERE vbeln = p_vbeln.
ELSE.
MESSAGE ‘Sales Order not found’ TYPE ‘E’.
ENDIF.

*———————————————————-*
* Prepare Data for Adobe Form
*———————————————————-*
CLEAR gs_output.
gs_output-vbeln = vbak-vbeln.
gs_output-erdat = vbak-erdat.
gs_output-auart = vbak-auart.
gs_output-kunnr = vbak-kunnr.

CLEAR gt_items.
LOOP AT lt_vbap INTO DATA(ls_vbap).
DATA(ls_item) = VALUE zstr_items(
posnr = ls_vbap-posnr
matnr = ls_vbap-matnr
arktx = ls_vbap-arktx
kwmeng = ls_vbap-kwmeng
vrkme = ls_vbap-vrkme
).
APPEND ls_item TO gt_items.
ENDLOOP.

gs_output-items = gt_items.

*———————————————————-*
* Call Adobe Form
*———————————————————-*
DATA: lo_fm_name TYPE rs38l_fnam,
lv_fm_name TYPE rs38l_fnam.

” Function module generated automatically when you activate the form
CALL FUNCTION ‘FP_FUNCTION_MODULE_NAME’
EXPORTING
i_name = ‘ZADOBE_FORM’ ” Adobe Form name in SFP
IMPORTING
e_funcname = lv_fm_name.

” Open spool request
CALL FUNCTION ‘FP_JOB_OPEN’
CHANGING
ie_outputparams = gs_outputparams
EXCEPTIONS
cancel = 1
usage_error = 2
system_error = 3
internal_error = 4.

” Call generated FM
CALL FUNCTION lv_fm_name
EXPORTING
/1bcdwb/docparams = gs_docparams
is_header = gs_output
IMPORTING
/1bcdwb/formoutput = gs_formoutput.

” Close spool request
CALL FUNCTION ‘FP_JOB_CLOSE’
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3.

MESSAGE ‘Adobe Form called successfully’ TYPE ‘I’.

Related Questions

Leave an answer

Leave an answer