Use ABAP code to create a utility that allows you to download standard or custom SAP Smart Forms. With it, you’ll be able to download all SAP Smart Forms or a selection that you have defined, eliminating a normally laborious process.
Key Concept
SAP Smart Forms are used for printing documents that companies normally send outside of the company. These include sales orders, purchase orders, delivery notes, invoices, and quotations.
As an ABAP programmer, you have times when you want to download your work — whether it’s programs, custom SAP Smart Forms, applications, enhancements, or tables — to a different local system or external media. You might need to take it to another machine or another project that could benefit from the work you’ve developed.
Let’s take SAP Smart Forms as an example. Say you have 100 SAP Smart Forms that you wanted to move to another machine. The usual process involves downloading each form individually, resulting in a repetitive, time-consuming process. I’ve developed a utility with ABAP code that allows you to download all custom or standard SAP Smart Forms in one effort. There is no third-party tool involved; it is completely based on the SAP system. To run it, you should have some basic knowledge of ABAP. I’ll start by showing you what the process to download SAP Smart Forms usually requires, and then I’ll show you the code involved in my process.
The Usual Process
The typical way to download SAP Smart Forms directly is by using transaction SMARTFORMS. Use transaction SMARTFORMS and press Enter to see the main SAP Smart Forms screen (
Figure 1).
Figure 1
Main screen of SAP Smart Forms
Enter the name of the SAP Smart Form you want to download (e.g., zwas_test) (
Figure 2). Follow menu path Utilities > Download Form to bring up the screen in
Figure 3.
Figure 2
Enter the SAP Smart Form name
Figure 3
Download the SAP Smart Form
Press Enter or click the green check mark icon and the screen in
Figure 4 appears. Choose the location to save the SAP Smart Form and click the Save button.
Figure 4
Save the SAP Smart Form
You would then need to repeat all these steps for every resulting SAP Smart Form. Now let’s look at the utility I’ve developed to simplify this process.
Utility to Download SAP Smart Forms
By using this utility, you can download all your custom and standard SAP Smart Forms, or you can download any single SAP Smart Form by entering its name in the selection screen.
Now I’ll show you the code for the utility.
Figure 5 shows the tables stxfadm, which contains all SAP Smart Forms names, and ssfscreen, which is being used in the selection screen parameter name. You will use it later on in the code.
Figure 5
The tables of the utility
Figure 6 contains the code to use for the selection screen.
Figure 6
Code for the selection screen
Now let’s look at the code for the data definitions and declarations that you need for downloading SAP Smart Forms.
Figure 7 shows the code for variables, internal tables, and types, and you should include it right after the code in
Figure 6.
Figure 7
Code for data declarations and definitions
Now you need to code the data selection of the SAP Smart Forms you want to download.
Figure 8 shows the code that retrieves all the SAP Smart Forms you want to download from table stxfadm. Then it shows you creating object sfrm and loading details for each SAP Smart Form and downloading it in XML format using the subroutine dwld_in_xml. This code should come directly after the code in
Figure 7.
Figure 8
Code for data selection
Then you need to code the path selection for where to save your SAP Smart Forms.
Figure 9 shows code for a dialog box that appears when you press F4 in the first parameter of the selection screen. It asks you for the path details for where you want to save your SAP Smart Form. Once you have selected your path, all your SAP Smart Forms are saved there. The function for displaying this dialog box is GUI_FILE_SAVE_DIALOG. The code in
Figure 9 should appear directly after the code in
Figure 8.
Figure 9
Code for the path to save your SAP Smart Forms
Now you need to define where you are going to download your SAP Smart Form. The system makes an XML file of the SAP Smart Form.
Figure 10 shows the code to convert your SAP Smart Form to XML format and make the XML file, which you can then download and save to the path that you defined. The code in
Figure 10 should come right after the code in
Figure 9.
Figure 10
Code for the XML file
After creating your program and entering the code in
Figures 5 through
10, save your program and make a transaction code of it. Alternatively, you can run the utility via transactions SE38 or SA38. You can download the entire code at the bottom of this article.
Now let’s look at the utility you’ve created. In this utility, there are only two parameters that you use: File path, where you want to save your SAP Smart Forms, and SAP Smart Form, which is the name of the form that you want to download. If you wanted to download all your custom SAP Smart Forms, enter Z* and Y* (because all custom SAP Smart Forms start with a Z or Y).
Figures 11 and
12 show the selection screen of this utility.
Figure 11 is the main selection screen and
Figure 12 shows how you can enter multiple SAP Smart Forms names in the selection screen. After you’ve filled in these selections, click the execute icon or press F8 to bring up the screen in
Figure 13 with the selection criteria you have selected in the
Figure 11.
Figure 11
Selection screen of the utility
Figure 12
Dialog box for entering multiple SAP Smart Forms
Figure 13
Main selection screen for downloading SAP Smart Forms
Click the execute icon or press F8 and all custom SAP Smart Forms are downloaded into the path specified in the File path field. Similarly, you can download all your standard SAP Smart Forms into the path by either entering the complete SAP Smart Form name or by entering letters that are common to multiple forms (e.g., sds*).
Exceptions
There are a few exceptions to this utility. Note that these limitations apply with the standard transaction SMARTFORMS as well.
- You can’t download any SAP smart style used in the SAP Smart Form. They are handled in transaction SMARTSTYLES.
- You can’t download any logo or picture used in the SAP Smart Form. These are handled via transaction SE78 and there is a different mechanism for downloading them, so the utility only downloads the logo name, not the logo itself.
- You can’t download any of the custom dictionary structure used in the SAP Smart Form. You can download the structure via transaction SE11 or another utility.
- You can’t download any other custom dictionary object used in the SAP Smart Form.
Qazi Wasif Ali
Qazi Wasif Ali is an SAP ABAP certified consultant at Descon Engineering Limited in Pakistan. He has more than six years of SAP ABAP experience. He has a degree in computer science and has worked in industries such as packaging, beverages, and chemicals. Previously, he worked at Siemens Pakistan and Abacus Consulting. Qazi has also participated in support projects.
You may contact the author at
qaziwasifali786@gmail.com.
If you have comments about this article or publication, or would like to submit an article idea, please contact the
editor.