SmartForms it’s a very robust program which 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.
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.
REPORT ZRPTEXERCISE.
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)
&itab-cityto& (on Cell4)
12. On the Main Window, click on the TABLE section. In this part you have to define the internal table name used to display the data. In this example we’re using ITAB.
See picture below for a clearer view.
13. After that Click Activate
Now the last step would be to create a program that will be the interface to call this smartform.
14. Execute SE38, create a program ZRPTEXERCISE
15. Now copy and paste this code below.
REPORT ZRPTEXERCISE.
DATA T_SPFLI TYPE TABLE OF SPFLI WITH HEADER LINE.
DATA FUNC_NAME TYPE RS38L_FNAM.
DATA ITAB LIKE STANDARD TABLE OF SPFLI WITH HEADER LINE.
START-OF-SELECTION.
SELECT * INTO TABLE ITAB FROM SPFLI.
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
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
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.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
15. Now copy and paste this code below.
Very good
ReplyDeletehow to prepare sap fico accounts payable please give me information
ReplyDelete