Hi All,
Often I get the question to create a Adobe form for showing some data. For multiple reasons, like accessing the PDF by an URL or just to store the PDF, I had to archive the Adobe form in Archivelink. Every time I had to search for the right function modules. So for all of you and myself I put it all together on SCN.
Data declaration:
DATA: fm_name TYPE rs38l_fnam, fp_docparams TYPE sfpdocparams, fp_outputparams TYPE sfpoutputparams, ls_FORMOUTPUT TYPE FPFORMOUTPUT, pdf TYPE xstring, LS_OUTDOC TYPE TOADT, LT_ARCHIVOBJECT TYPE TABLE OF DOCS, LT_BINARCHIVOBJECT TYPE TABLE OF TBL1024.
For archiving the PDF and NOT showing we have to set the following parameter before we move on:
FP_OUTPUTPARAMS-GETPDF = 'X'.
After this configuration we can open the spool:
CALL FUNCTION 'FP_JOB_OPEN' "& Form Processing: Call Form CHANGING ie_outputparams = fp_outputparams EXCEPTIONS cancel = 1 usage_error = 2 system_error = 3 internal_error = 4 OTHERS = 5.
Next step is to get the name of the Adobe form. This can change while transporting to another system so you have to use this FM with the name of the Adobe form in SFP:
CALL FUNCTION 'FP_FUNCTION_MODULE_NAME' "& Form Processing Generation EXPORTING i_name = 'Z_NAME_OF_PDF_IN_SFP' IMPORTING e_funcname = fm_name.
Then we are ready to call the Adobe form and in case is necessary pass some data:
fp_docparams-langu = 'NL'. *&--- Call the generated function module CALL FUNCTION fm_name EXPORTING /1bcdwb/docparams = fp_docparams data = data IMPORTING /1BCDWB/FORMOUTPUT = ls_FORMOUTPUT EXCEPTIONS usage_error = 1 system_error = 2 internal_error = 3.
After this step we can close the spool:
CALL FUNCTION 'FP_JOB_CLOSE' * IMPORTING * E_RESULT = EXCEPTIONS usage_error = 1 system_error = 2 internal_error = 3 OTHERS = 4.
Now we have our generated PDF in ls_formoutput-PDF. Before we archive this PDF we have to do some config, go to SPRO:
Create a new document type:
Link this document type to your SAP object:
All other configurations was already available in my case.
Because I want to overwrite my previouse PDF, I will delete that one first by using the following FM:
AR_OBJECT is the document type
OBJECT_ID is the name of the document
SAP_OBJECT is the object type
CALL FUNCTION 'ARCHIV_DELETE_META' EXPORTING * ARCHIV_ID = ' ' * ARC_DOC_ID = ' ' AR_OBJECT = 'ZTYPE' DELETE_FLAG = 2 OBJECT_ID = 'temp' SAP_OBJECT = 'ZOBJECT' CLIENT = sy-mandt * SINGLE_ENTRY = ' ' * DOCUMENTCLASS = NO_AUTH_CHECK = 'X' * IMPORTING * ALL_CONNECTIONS_DELETED = EXCEPTIONS ERROR_CONNECTIONTABLE = 1 ERROR_PARAMETER = 2 ERROR_ARCHIV = 3 ERROR_KERNEL = 4 ERROR_COMMUNICATIONTABLE = 5 ERROR_AUTHORITY = 6 OTHERS = 7 .
Now I'm going to archive my new version with the name temp:
AR_OBJECT is the document type
OBJECT_ID is the name of the document
SAP_OBJECT is the object type
the tables can stay empty.
CALL FUNCTION 'ARCHIV_CREATE_TABLE' EXPORTING AR_OBJECT = 'ZTYPE' * DEL_DATE = OBJECT_ID = 'temp' SAP_OBJECT = 'ZOBJECT' * FLENGTH = DOC_TYPE = 'PDF' DOCUMENT = ls_FORMOUTPUT-PDF MANDT = SY-MANDT IMPORTING OUTDOC = LS_OUTDOC TABLES ARCHIVOBJECT = LT_ARCHIVOBJECT BINARCHIVOBJECT = LT_BINARCHIVOBJECT EXCEPTIONS ERROR_ARCHIV = 1 ERROR_COMMUNICATIONTABLE = 2 ERROR_CONNECTIONTABLE = 3 ERROR_KERNEL = 4 ERROR_PARAMETER = 5 ERROR_USER_EXIT = 6 ERROR_MANDANT = 7 OTHERS = 8.
If everything went well, your document should be stored in Archivlink.
Hope it's helpful!
Kinde regards,
Wouter