Вы находитесь на странице: 1из 13

Template,Table,Loop,Command in Smartform

SDN Community Contribution


(This is not an official SAP document.)

Disclaimer & Liability Notice


This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade. SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk. SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.

2005 SAP AG

The SAP Developer Network: http://sdn.sap.com

Template,Table,Loop,Command in Smartform

Applies To:
SAP 4.6C - Smartforms

Summary
This document explains how to use Table, Template, Loop, and Command to display the set of records in Smartforms. By: J.Jayanthi Company: Wipro Technologies Date: 22.08.2005

Table of Contents
Applies To:........................................................................................................................................2 Summary ..........................................................................................................................................2 Table of Contents .............................................................................................................................2 Procedure .........................................................................................................................................2 Template....................................................................................................................................4 Command ..................................................................................................................................5 Loop...........................................................................................................................................5 Table..........................................................................................................................................6 Code Sample..7 Output Screen: Template .................................................................................................................8 Output Screen: Loop ........................................................................................................................9 Output Screen:Table ........................................................................................................................9 Author Bio.10

2005 SAP AG

The SAP Developer Network: http://sdn.sap.com

Template,Table,Loop,Command in Smartform

Procedure
1. Go to transaction SMARTFORMS. 2. Create a Form (say zzz_test1). 3. In Global Definitions->Global Data, 4. Variable Name ZZZ_MAKT ITAB WA Type Assignment TYPE Reference Type ZZZ_MAKT

TYPE STANDARD TABLE OF ZZZ_MAKT TYPE ZZZ_MAKT

5. In Main window->Output Options, fill the necessary details as shown below.

2005 SAP AG

The SAP Developer Network: http://sdn.sap.com

Template,Table,Loop,Command in Smartform

6. Then right click Main window and create Program line. 7. In Code, give ZZZ_MAKT as input parameter and itab as output parameter. 8. Write the following in the coding part. select * from zzz_makt into table itab.

Template
1. Right click Code and create a Loop. 2. In its Data tab, Internal Table ITAB into wa

2005 SAP AG

The SAP Developer Network: http://sdn.sap.com

Template,Table,Loop,Command in Smartform
3. Right Click the Loop and Create a Template. In that, design the Template as shown below by selecting Pattern to display Output.

4. Create three text elements (say Text2, Text4, Text3). 5. Drag ZMATNR, ZMAKTX and PICK from the Field list and put in the above mentioned Text Elements-> General Attributes respectively. 6. In Text2->Output Options , make the Line and Column as 1 and 1 respectively. 7. In Text4->Output Options , make the Line and Column as 1 and 2 respectively.

2005 SAP AG

The SAP Developer Network: http://sdn.sap.com

Template,Table,Loop,Command in Smartform
8. In Text3->Output Options , make the Line and Column as 1 and 3 respectively.

Command
1. Right Click the Loop and create a Command (say %COMMAND2). Make the Command after Template (move accordingly). We are making use of Command to page break. 2. In Command->General Attributes, check mark Go to new page and give the page no. (say %PAGE). 3. Then right Click the %CODE1 and create another loop and move it after %COMMAND2.

Loop
1. In Loop->Data, Internal table itab into wa. The settings of Loop->Output options is shown below [Since in the output, we are going to display a box with border].

2005 SAP AG

The SAP Developer Network: http://sdn.sap.com

Template,Table,Loop,Command in Smartform

2. Create a text element (say %TEXT1) under that Loop and design the Text->General Attributes as below.

2005 SAP AG

The SAP Developer Network: http://sdn.sap.com

Template,Table,Loop,Command in Smartform

3. Create a Command (say %Command1) under %Loop1 and do as we did before for %Command2.

Table
1. Right click %Code1 and Create a Table [say %Table1]. 2. Design Table->Table tab as below.

2005 SAP AG

The SAP Developer Network: http://sdn.sap.com

Template,Table,Loop,Command in Smartform

3. In Table->Data, Internal table itab into wa. 4. Create three Text Element by right clicking %Table1 [say %CELL1, %CELL2, %CELL3]. 5. Drag ZMATNR, ZMAKTX, PICK from fieldlist and put in the created text elements. 6. In CELL1->Output Options, 7. Check mark New Line and New Cell and choose the Line type as Line1 which we created in Table>Table. 8. For CELL2 and CELL3, check mark New Cell in Output options.

2005 SAP AG

The SAP Developer Network: http://sdn.sap.com

Template,Table,Loop,Command in Smartform
Code Sample
REPORT zzz_jaytest3 . * Variable Declaration data : v_form_name TYPE rs38l_fnam. call function 'SSF_FUNCTION_MODULE_NAME' exporting formname = 'ZZZ_TEST1' importing fm_name = v_form_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 v_form_name 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.

Output Screen: Template


Then you can see the following output after executing the program in SE38.The following is the Output for TEMPLATE:

2005 SAP AG

The SAP Developer Network: http://sdn.sap.com

10

Template,Table,Loop,Command in Smartform

Output Screen: Loop


This is the Output for LOOP:

2005 SAP AG

The SAP Developer Network: http://sdn.sap.com

11

Template,Table,Loop,Command in Smartform

Output Screen: Table


This is the Output for TABLE:

2005 SAP AG

The SAP Developer Network: http://sdn.sap.com

12

Template,Table,Loop,Command in Smartform

Author Bio
J.Jayanthi works as Senior Software Engineer at Wipro Technologies.

2005 SAP AG

The SAP Developer Network: http://sdn.sap.com

13

Вам также может понравиться