Embedding Attachments in SAP ADOBE Form
Embedding Attachments in SAP ADOBE Form
Embedding Attachments in SAP ADOBE Form
There is a common requirement given by client wherein they ask to generate PDF files (output) based on
the data entered in SAP WebDynpro ABAP input screen.
Simple Text
Formatted Text
Attachment etc.…
This article deals with displaying ATTACHMENTS in attachment section of output form (SAP ADOBE
form) and approach to achieve it.
Please refer to below image.
Note: This document is not specific to WebDynpro ABAP and can be leveraged as far as data (Input
Form + Attachment) can be supplied to methods/FM mentioned in below sections.
Challenges
1. Transferring the Data from SAP WebDynpro input screen to SAP ADOBE form.
Pre-requisite
Understanding on
1. WebDynpro ABAP
2. ABAP
Facts
1. Details (content/mime type/filename) about the attachments can be retrieved via
CONTENT_NODE in case WebDynpro screen is used for uploading the attachments.
Steps
CALL FUNCTION
To get ‘FP_FUNCTION_MODULE_NA
Function ME’
Importing
Module
FP_FUNCTION_MODUL parameter for EXPORTING
1 name of
E_NAME FM is ‘PDF i_name
the PDF
template name’
form/ = FORM_TEMPLATE_NAME
Template IMPORTING
e_funcname = FM_NAME.
fp_outputparams-nodialog
= ‘X’.
fp_outputparams-nopreview =
‘X’.
fp_outputparams-dest
= ‘LOCL’.
fp_outputparams-device
= ‘PRINTER’.
fp_outputparams-reqnew
‘FP_JOB_OPEN’
CHANGING
ie_outputparams =
fp_outputparams.
EXPORTING
/1bcdwb/docparams =
Importing fp_docparams
be interface VAL1
FM name for PDF form to the PDF and so get all EXCEPTIONS
3
(received from S.No.1) form/Tem the data for the
usage_error =
plate interface
1
parameters
this FM. 2
internal_error =
OTHERS
= 99.
CALL FUNCTION
‘FP_JOB_CLOSE’
IMPORTING
system_error = 2
internal_error = 3
OTHERS = 99.
‘RSPO_ADSP_GET_PARTLIST’
EXPORTING
rqident
Based on
= SPOOL_ID
Returns theRESULTpara
= adsp_partlist
EXCEPTIONS
OTHERS = 99.
ID
navindex = ‘1’
old_document
= adsp_old_document
IMPORTING
pdf_data
variable.
= LV_CONTENT (XSTRING)
LV_CONTEN
Twill be used
inSTEP3. TABLES
partlist
= adsp_partlist
EXCEPTIONS
no_such_job = 1
wrong_jobtype = 2
OTHERS = 99.
Note: In above table, all the words in BOLD/ITALIC, needs to be defined and passed as per
requirement.
While uploading the attachments (refer to picture on Requirement Section) you can get of below values for
all the attachments:
Value of above attributes will be available in CONTEXT NODE for all the attachments.
Note: This is not specific to WebDynpro ABAP, but can be used anywhere in ABAP, as far as above
mentioned 3 attributes can be retrieved.
Merge the content received from above steps i.e. Generate Input content in PDF template andGenerate
Attachment content
DATA lv_dest TYPE rfcdest VALUE ‘ADS’.
DATA lv_full_content TYPE xstring.
DATA lo_pdfobj TYPE REF TO if_fp_pdf_object.
DATA lo_fpex TYPE REF TO cx_fp_runtime.
lv_dest = cl_fp=>get_ads_connection( ).
TRY.
“Create PDF Object.
lo_pdfobj = cl_fp=>get_reference( )->create_pdf_object( connection = lv_dest ).
“Set document
lo_pdfobj->set_document( pdfdata = lv_content ).
“Set attachment.
lo_pdfobj->set_attachments( attachments = lt_attachments ).
“Execute, call ADS.
lo_pdfobj->execute( ).
“Get result..
lo_pdfobj->get_document( IMPORTING pdfdata = lv_full_content ).
CATCH cx_fp_runtime INTO lo_fpex.
ENDTRY.
After execution of above code, variable ‘LV_FULL_CONTENT’ which is of type XSTRING, will have
PDF content (INPUT DATA + ATTACHMENTS).
Dynamically create a PDF file and store in some on ContentServer example DMS
Download it as PDF, by using below code