Archiving a Smartform
I was working on a smartform associated with an output type where it was required to trigger an output with the following requirements.
- Archive the output triggered into an external repository, like doculink
- Convert the smartform to PDF
- Store the PDF on the SAP UNIX directory
- Send the PDF as an attachment in an email and archive the same(Transmission Medium = ‘5’)
I was able to fulfill all the above requirements, except archiving of the outputs which led me to do extensive research on this concept and subsequently found a solution for the same.
In this blog, I would like to share my knowledge on this as I have seen many threads asking for solution on this.
1. What is archiving?
Archiving is the process of storing data in an external repository which can be reused and viewed as and when needed and which is governed in SAP by the storage mode.
SAP allows outputs to be triggered in three storage modes:
- Print only – Printout is issued and no archiving of the output issued
- Archive only – The output is only archived
- Print and archive – Print out is issued and also output is archived
2. Why archiving is needed?
Archiving allows us to store the related documents together under one folder with information such as date on which the outputs was triggered.
3. How to view the archived documents?
Method 1: Transaction code J6NY allows us to see all the archived documents under the required folder for the required output with trigger date.
For example, all vendor POs will be under one folder named Vendor Purchasing Folder. Search the document with PO number.
Method 2: Display Originals in communication method
Under messages, select the output successfully processed (Green indicator) , click on “Communication method” then click on “Displ. originals”. You will be redirected to where the document is archived.
4. Required settings to archive
To archive the document with the output type, required document type has to be maintained under Storage system in NACE settings.
5. Parameters on which archiving of smartforms depends.
- CONTROL_PARAMETERS
- OUTPUT_OPTIONS
- ARCHIVE_INDEX
- ARCHIVE_PARAMETERS
ABAP approach to archive the outputs:
STEP 1:
"Structure for Smartform Control Parameters
DATA : gst_control_param TYPE ssfctrlop.
"Set the GETOTF field to blank
gst_control_param-getotf = ''.
STEP 2:
"Structure for Smartform Output Options
DATA : gst_output_options TYPE ssfcompop.
"Set the TDARMOD TO 2 ( Archive only) / 3 (Print and Archive)
gst_output_options-tdarmod = '2'.
OR
gst_output_options-tdarmod = '3'.
STEP3:
Call the smartform with the below parameters
CALL FUNCTION gw_fm_name
EXPORTING
archive_index = toa_dara
archive_parameters = arc_params
control_parameters = gst_control_param
output_options = gst_output
That’s all , call the smartform with these parameters set as required,the output triggered will get archived in the repository. But to convert the smartform output to PDF and attach in the email we need to get the OTF of the smartform called which will be achieved by setting the GETOTF field ‘X’ as below.
gst_control_param-getotf = 'X'. "Get OTF of the smartform
But by doing so it fails to archive the document so to overcome you can call the smartform twice with GETOTF = ‘Blank’ and GETOTF = ‘X’, first one to archive and second one to get otf which can be converted into PDF.
Note : Archiving with Transmission medium as External Send (NAST-NACHA = ‘5’)
When output is triggered with transmission medium as external send, the output fails to archive as the GETOTF field is set to ‘X’. So in such case call the smartform twice as explained above.
Summary:
- To archive, GETOTF = space and TDARMOD = 2 or 3
- To get OTF, GETOTF = ‘X’ which can be converted into PDF and can be uploaded onto the SAP UNIX server.
Hi Ravi,
Nice article.
Thanks for sharing.
Thanking You All..!!
Hi Ravi,
Informative blog.
Thanks for sharing.
Nice Blog.
🙂
Nice .
Its very inforamtive!
Thanks for Sharing
Nice.
Thanks for Informative Knowledge
Thanks buddy. informative. saved my time 🙂
Hello Ravi,
Incase of Doculink this is built in functionality you can use J8AF to convert automatically.
Thanks,
Kolusu
Maybe late reply, but this helped me a lot. We call the form for mail and when the call is done - we convert it to mail with additional parameters like subject, sender and body text. So we needed to archive this email so with your suggestion we are able to do it.
The only issue we experienced with calling the form twice is that it generated a spool. As an addition, we have a LOCL device driver and if user saved the document, the local windows driver ALSO wanted to create a PDF. This is because you call the function twice. The reason for this, is the tdarmod = '3' (Print AND archive) you pass to the function module (output_options-tdarmod). We fixed this to set the tdarmod in the archiving 'function call' to '2' (Archive). No spool and unwanted LOCL popup anymore. Maybe this helps someone else. Thanks.
Hi,
Very nice article.
Can you please explain where do we specify the folder name in which we archive the document .
Thanks.