Today I want to teach you how to create a simple SmartForms.

SmartForms it’s a very robust program which I think is far much better than the good old SAP script, it’s very recommended to use SmartForms when creating print out form such as Invoice, Sales Order, Delivery Order, etc. Okay now let’s start our training today. 1. First execute TCODE smartforms 2. Create a new smartform program, just name it as ZSFEXERCISE and click CREATE.

3. On Global Settings, click Form Interface and on your right select the TABLES tab. Here you can define internal table to use for the report fields structure, you can define more than 1 table depending on your program requirements. In this example let’s create 1 internal table named ITAB using table SPFLI field structure.

4. Next go to Pages and Windows section (Below Global Settings), open the %PAGE1 New Page folder until you find MAIN Main Window folder, after that Right click > Create > Table This will create an internal table that can get the query result from the report interface.

5. In this next screen, you will see an empty box that will act as the main body of your report to display the report data. But first we need to define how many columns we want to have on this report, to do this just click Draw Lines And Columns (Pencil button) button and draw a vertical lines on the box to create the report columns. In this example, I drew 3 vertical lines that will create 4 report columns.

6. Now go to Main Area (below the header), right click the Main Area > Create > Table Line. This will one new line 1 just below the main area section, on the right screen you can see the Output Table section, now select the Line Type selection box and click on %LTYP1. After that, you can see that all 4 columns we created earlier in step 5.

7. Now we need to attach internal table columns to display on this smartforms columns, right click the first column > Create > Text this will create a new text icon just below the first CELL

Column.

8. Click on the TEXT1 icon we just created earlier, and click on the General Attributes tab.

9. Click on the insert field button.

10. Now this is very important, to define internal table field column on smartforms, you must type &itab-columnname& (begin and ended with a &). In this example I want this first column to display the carrid column in the SPFLI table, then I will write &itab-carrid&

11. Now repeat step 8 and 9 to display these other 3 columns.
• •

&itab-connid& (on Cell2) &itab-cityfrom& (on Cell3)

On the Main Window.• &itab-cityto& (on Cell4) 12. Now copy and paste this code below. click on the TABLE section. See picture below for a clearer view. create a program ZRPTEXERCISE 15. In this part you have to define the internal table name used to display the data. DATA T_SPFLI TYPE TABLE OF SPFLI WITH HEADER LINE. 13. After that Click Activate Now the last step would be to create a program that will be the interface to call this smartform. REPORT ZRPTEXERCISE. 14. Execute SE38. In this example we’re using ITAB. .

SELECT * INTO TABLE ITAB FROM SPFLI. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. DATA ITAB LIKE STANDARD TABLE OF SPFLI WITH HEADER LINE. CALL FUNCTION FUNC_NAME * EXPORTING * ARCHIVE_INDEX = * ARCHIVE_INDEX_TAB = * ARCHIVE_PARAMETERS = * CONTROL_PARAMETERS = * MAIL_APPL_OBJ = * MAIL_RECIPIENT = * MAIL_SENDER = * OUTPUT_OPTIONS = * USER_SETTINGS = 'X' * IMPORTING * DOCUMENT_OUTPUT_INFO = * JOB_OUTPUT_INFO = * JOB_OUTPUT_OPTIONS = TABLES itab = ITAB * EXCEPTIONS * FORMATTING_ERROR = 1 * INTERNAL_ERROR = 2 * SEND_ERROR = 3 * USER_CANCELED = 4 * OTHERS = 5 . IF sy-subrc <> 0. Here’s the Smartforms beautiful report display. CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING formname = 'ZSFEXERCISE' * VARIANT = ' ' * DIRECT_CALL = ' ' IMPORTING FM_NAME = FUNC_NAME * EXCEPTIONS * NO_FORM = 1 * NO_FUNCTION_MODULE = 2 * OTHERS = 3 .DATA FUNC_NAME TYPE RS38L_FNAM. . ENDIF. START-OF-SELECTION. Now run the program. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. IF sy-subrc <> 0. 16.

Popularity: 97% [?] Getting started with Smart Forms (Building a simple application) By Sunitha Go to transaction “Smartforms”. .

expand “Pages and Windows” à New Page. Enter a short description for the form. we will print a simple text using our form. To create a text. In this example. Select Create à Text .Enter a name for the form and click on Create. Select Main Window and Right click on that.

SAVE and Activate the Smart form. To know the function module that is generated upon activation of this smart form. Also enter the text you want to see on the form.Give a name to the text and short description. click on Environment à Function module name. .

You would be navigated to the function builder with the function module defaulting to the one that is generated earlier. . Test the smart form by clicking on Test.Following popup with the function module would appear. Click on execute.

Since we do not have any parameters to pass on. Enter a short description for the form. click on Execute. Printing Address using Smart Forms By Sunitha Go to transaction “Smartforms”. . Enter a name for the form and click on Create.

right click on “Main Window”. To display the address on the form.Expand “Pages and Windows” and click on “%PAGE1”. . Rename the page to your needs and add a short description to the same. select Create à Address Following screen appears.

The output would be similar as shown below: . Now pick an address number from that table. add provide the same in the “Address Number” as shown below: Save and Activate the form.Enter a name to the Address and add a short description for the same. Now execute the Smart form. You all might be aware that Addresses are stored in the table ADRC.

A pop up would appear displaying the function module name.Calling Smart Form using Driver Program By Sunitha Let us prepare a driver program for the Smart Form that displays the address (Click here to for the demo on ADDRESS). Check the function module that is generated when the Smart Form is activated by clicking on Environment à Function Module Name. . This is a simple demo and doesn’t contain any parameter passing in this example.

* To call a smart form. Execute the program for the output. we would need to call the function module that * is generated. . CALL FUNCTION '/1BCDWB/SF00000359' * EXPORTING * ARCHIVE_INDEX = * ARCHIVE_INDEX_TAB = * ARCHIVE_PARAMETERS = * CONTROL_PARAMETERS = * MAIL_APPL_OBJ = * MAIL_RECIPIENT = * MAIL_SENDER = * OUTPUT_OPTIONS = * USER_SETTINGS = 'X' * IMPORTING * DOCUMENT_OUTPUT_INFO = * JOB_OUTPUT_INFO = * JOB_OUTPUT_OPTIONS = * EXCEPTIONS * FORMATTING_ERROR = 1 * INTERNAL_ERROR = 2 * SEND_ERROR = 3 * USER_CANCELED = 4 * OTHERS = 5 . ENDIF. IF sy-subrc <> 0. Let us create a driver program with a simple call to the above generated function module: REPORT Zcall_smartform. click here. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. * Calling the generated function module directly is not an efficient * method.We would use this function module in our driver program to call this function module. For efficient method.

To pass the values from the driver program to Smart Form. Go to transaction SMARTFORMS and create a Smart Form.Passing data to the Smart Forms Scenario: Let us take a simple scenario of passing Material Number and Material description from Driver program to the Smart Form. . Click on Global Settings à Form Interface. we need to define the form interface with the parameters to be passed on.

we need to click on “Insert Field”. . To add a field.Now define the import parameters for MATNR and MAKTX (From table MAKT) Now create a Text in the Main window to display the above two parameters.

.Enter the field names between the ‘&’ (Ampersand) as shown below: Similarly create for Description.

Save and Activate the Smart Form. Enter the values as shown below and click on execute. Test run the Smart Form by clicking on Execute. .

Working with Secondary Window Create a Smart Form using the transaction SMARTFORMS. To create a Secondary Window. Right click on Page à Create à Window (as shown below) A secondary window is created. . To position the secondary window to meet our needs. click on Form Painter.

Following screen appears: The highlighted window in the above screenshot is the secondary window. . Move the secondary window (and even stretch) according to your needs.

Now let us write some content in these areas. Now select the Page à Secondary Window Right click on Secondary Window à Create à Text Write some text inside.To close the above page design. . click on Form Painter again.

second one as Bank copy and the third one say College copy. In this demo. Save and activate the Smart Form. Test run the Smart Form.Similarly. we would print in the Copies window whether it is bank copy. Create a secondary window as shown below: . company copy or others. create some text in the Main window as well. you would get the following output: emo on Copies Window (Real time scenario) Scenario: To print three copies of a particular document and the first copy should mention as Customer copy. Create a Smart Form using the transaction SMARTFORMS.

Select Window type as “Copies Window” as shown below: Also name your window and give it a proper description. Do not change any other settings. .

Adjust the window size using the Form Painter available on the application toolbar. We would define a string. We would use this field to print the owner of the copy. Define a variable in the global definition as shown below: . The variable SFSY-COPYCOUNT would provide us count of the copy whether it is a first copy. which would hold the name of the copy (bank copy and others) depending on the value of SFSY-COPYCOUNT. second copy and others.

Now select your Copies window. right click – Select Create à Flow Logic à Program Lines Enter the following code: .

Now include a text in the Main window as well with some content.Do not forget to enter the variable TEXT in the output parameters. just enter the field name as shown below by selecting insert field. Save and activate. In this. Test your Smart Form. right click Create à Text. Now create a text by selecting the Copies window. .

enter the number of copies as 3 Check the output: .In the print preview screen.

cenario: In this demo. we would create a small text as shown below with outline numbering as shown below Go to transaction “SmartStyles” Enter a style name and click on Create. .

. click on folder “Paragraph Formats” and click on Create (as shown in the above screenshot)..Following screen appears: To create a paragraph. Following pop-up appears: Enter a paragraph format name.2. Now select the tab “Numbering and Outline”: Enter the Top Outline Paragraph as the current paragraph name and select “1.3.” from the list for the Numbering Type. Enter a suitable description for your graph and enter the left margin value as 2 CH.

only numbering would appear like 1.” instead of “1.2.3 without the parent number prefixing. 2.1. 2.1.. 1.. . If this is selected.1.3…” Also.2.). 13. the values would be displayed as “11. 1. check the “Number Chaining” Box. In the tab “Numbering and Outline” of P2. Now go to transaction “SmartForms”. If the left delimiter is not mentioned.2. do the following: Select the “Top Outline Paragraph” as “P1” and put the left delimiter as “.2. the parent value would be displayed (like 1.”. 1. Save and activate your Smart Style. 12. If this is not checked..Now create another paragraph format P2 as per the above method. in the same window.

Select the icon “Txt Editor” (Though the text could be written directly on this screen. Now go to tab “General Attributes”. we are avoiding this method for easy understanding to the consultants who are used with SAP Script editor) Now to change the editor.Create a Smart Form and create a text in the Main Window: Select the tab “Output Options” to mention the Smart Style to be used. Click on “Goto” -> Change Editor .

Here enter the desired text: Return to the main screen of the Text. The screen would appear as follows: .

Types. Following would be the output: Smart Forms . .Working with Loop By Venkat Step1: Provide the name of the smart form is YDEMO_LOOP on the initial screen of the smart form and meaningful description. Initialization and etc. Step2: Now go to Global definitions where we can define the Global data. Test run the Smart Form. Define Structure using Types Parameter as shown below.Save and activate the Smart Form. In Types parameters we usually define user defined data types. Step3: Now define the internal table and work area in Global Data parameter.

.Step4: In Initialization parameter. We have to mention the output result in the output parameter so that we can use it further. Step5: Create a LOOP statement as shown below. Here in this case we are outputting IT_TAB and we are going to use this IT_TAB further in the LOOP in the Flow Logic. we can write a code as shown below.

paragraph formats and Tabs. Step7: To create the character. Here SMART STYLE is created to define Tab positions for the columns. The following screen appears.Step6: Now Loop the internal table. Step8: Create a node for PARAGRAPH FORMAT as shown below. The transaction for create smart style is SMARTSTYLE or we can be created the initial screen of SMARTFORMS. we use the smart style. . Step9: Now define the Tabs as shown below.

Step11: Now create a text element for the loop statement. Step12: Save and activate the smart form. The output is as shown below. .Step10: Now Import SMART STYLE in to the SMART FORM as shown below.

YASH Technologies Step1: Go to transaction smart forms.Using Text Modules in Smart Forms By Jaya Vani B. .

Step 2: Click on create. and create a smart form. The following screen appears: Step 3: Enter the required text and save. . Go back to smart forms initial screen. Now this text can be included in our smart form.

Step 5:In the text box general attributes TAB select Text module from the drop down list .Step 4: In the Main window create a text box.

In normal case. Using MS Word as Editor in SAP Script and Smart Forms By Surekha This document details the procedure in using Microsoft Word as editor in SAP Script / Smart Forms. the following editor would appear: . Step 7: The text in the text Module will be copied into the Text Editor. Step 9: Save and activate. when you try opening the editor in Smart Forms.Step 6: Give the name of the Text Module created and click on COPY button. Execute and check the print preview.

do the following: Go to transaction I18N (Internationalization).Click on the editor button. Click on I18N Menu à I18N Customizing à I18N System Configuration (as shown in the screenshot below) . The following editor appears: Now to change the above editor to MS Word.

The following screen appears: If you would like to use MS Word Editor in both Script and Smartforms. then check the both checkboxes as shown below: .

Now the following popup appears (related to Smartforms Editor): Click on Yes to proceed.Click on Activate. . The following popup appears (related to SAPScript Editor): Click on Yes.

Result: In the SmartForms: In SAP Script: You can anytime revert to old editor by deactivation MS Word editor option using the transaction I18N.Now the MS Word editor is available for both SAP Script and Smartforms. .

Sign up to vote on this title
UsefulNot useful