Differences between template and table:
Tamplate
1. Template is used to print the data in a fixed rows and fixed columns
2. Template does not contain a loop.
3. In template lines are not reusable
4. Template does not contains any sections
Table
1. Table is used to print the data in a dynamic columns and dynamic rows
2. Table contains a loop
3. In table lines are reusable
4. Table contains 3 sections ( header, mainarea, footer)
Working with Labels:
Labels are used to print the same data in all the pages.
Note: – Now-a-days most of the companies used zebra printers to print the labels. Because the cost of label is cheap, quality is good. Gum thickness is also good. Zebra printers don’t support sap script. It supports smart forms. So we must design the labels through smart form.
MCHA (Material Batch Table)
MATNR ——-> Material Number
WERKS ——-> Plant Number
CHARG ——–> Batch Number
HSDAT ———> Mfg.Date
VFDAT ———> Exp.date
Object : Based on the given material number & number of labels design the accepted labels as shown in the below.
Material :_____________________
Plant :_________________________
Batch :_________________________
MFG.DT:_________________________
EXP.DT:__________________________
At the time of label design, the BASIS people create page format based on the label width & height through ‘SPAD’ transaction & given to us. Based on this page format we design the label.
Smart form name: ZBBSTE_M_AK8.
Form Interface
Import
I_MATNR TYPE MCHA-MATNR I_NOL TYPE I
Global definitions
Â
Types
TYPES: BEGIN OF TY_MCHA,
MATNR TYPE MCHA-MATNR, WERKS TYPE MCHA-WERKS, CHARG TYPE MCHA-CHARG, HSDAT TYPE MCHA-HSDAT, VFDAT TYPE MCHA-VFDAT, END OF TY_MCHA.
TYPES: BEGIN OF TY,
NO TYPE SYINDEX, END OF TY.
Global data:
WA_MCHA TYPE TY_MCHA
IT_MCHA TYPE TABLE OF TY_MCHA
WA TYPE TY
IT TYPE TABLE OF TY
Initialization:
I_MATNR WA_MCHA
I_NOL WA
IT
SELECT SINGLE MATNR WERKS CHARG HSDAT VFDAT FROM MCHA INTO WA_MCHA WHERE MATNR = I_MATNR.
DO I_NOL TIMES.
WA-NO = SY-INDEX.
APPEND WA TO IT.
ENDDO.
Double click on main window in the left panel.
Click on output options tab. Provide the co ordinates. Left margin: 1CM width: 18.5 CM
Upper margin: 1 CM Window height 2.5 CM
Select the main window in the left panel. Right click -> create -> flow logic -> loop.
Double click on loop. Click on data tab.
Provide (IT into WA).
Select the loop. Right click -> Create -> Text. Double click on text.
MATERIAL : &WA_MCHA-MATNR&
PLANT : &WA_MCHA-WERKS&
BATCH : &WA_MCHA-CHARG&
MFG.DT : &WA_MCHA-HSDAT&
EXP.DT : &WA_MCHA-VFDAT&
PARAMETER: P_MATNR TYPE MCHA-MATNR,
P_NOL TYPE I.
CALL FUNCTION ‘/1BCDWB/SF00000201’ EXPORTING
I_MATNR = P_MATNR
I_NOL = P_NOL.
Control break statement / event in internal table:
Control break statements are work with in the loop of internal table. Before using the control break statements. We must sort the internal table based on At new field.
Control break statements are
1. At First
2. At New <field name>
3. At End of <field name>
4. At last
Each control break statement ends with Endat.
AT FIRST: –
This is an event which is triggered at the first record of internal table.
Advantage: – This is used to display the header information for internal table.
AT NEW <field name>: –
It’s an event which is triggered at the first record of each block.
Advantage: – It’s used to display the individual headings
AT END OF <field name>:
This is an event which is triggered at the last record of each block.
Advantage: -This is used to display the sub total.
AT LAST: –
This is an event which is triggered at the last record of internal table.
Advantage: – It’s used to display the grand totals.
Â
Object:Based on the given sales document numbers,to display the sales item details as shown in the figure.
REPORT:ZBBST_O_AB_CALLS.
TABLES VBAP.
SELECT-OPTIONS S_VBELN FOR VBAP-VBELN.
TYPES : BEGIN OF TY_VBAP,
       VBELN TYPE VBAP-VBELN,
       POSNR TYPE VBAP-POSNR,
       KWMENG TYPE VBAP-KWMENG,
       MEINS TYPE VBAP-MEINS,
       NETWR TYPE VBAP-NETWR,
END OF TY_VBAP.
DATA : WA_VBAP TYPE TY_VBAP,
       IT_VBAP TYPE TABLE OF TY_VBAP.
DATA V1 TYPE VBAP-NETWR.
DATA V2 TYPE VBAP-NETWR.
SELECT VBELN POSNR KWMENG MEINS NETWR FROM VBAP INTO TABLE IT_VBAP WHERE VBELN IN S_VBELN.
SORT IT_VBAP BY VBELN.
LOOP AT IT_VBAP INTO WA_VBAP. AT FIRST.
WRITE ‘Hello Welcome’. ENDAT.
AT NEW VBELN.
WRITE / WA_VBAP-VBELN COLOR 4. ENDAT.
WRITE :/ WA_VBAP-POSNR,WA_VBAP-KWMENG,WA_VBAP-MEINS,WA_VBAP-NETWR. V1 = V1 + WA_VBAP-NETWR.
V2 = V2 + WA_VBAP-NETWR.
AT END OF VBELN.
WRITE :/23 ‘SUBTOTAL’,V1 COLOR 3. CLEAR V1.
ENDAT.
AT LAST.
WRITE :/20 ‘GRAND TOTAL’,V2 COLOR 5. ENDAT.
ENDLOOP.
Events in SMARTFORMS:
It’s an event which is triggered at the first record of each block.
ADV: – It’s used to display the individual headings
This is similar as at new field name in the control break statement.Â
Event on sort end: –
It’s an event which is triggered at the last record of each block.
ADV: – It’s used to display the subtotals.
This is similar as at end of field name in the control break statement.
Object: Based on the given sales document numbers, to display the sales document item details as shown in the below by using ‘SMARTFORMS’.
Note: – If you want to declare the select-options in the smart form then we must declare one structure with the following fields in the data dictionary & later we refer the structure in the tables tab of form interface in the smart form.
Sign -> (C, 1)
Option -> (C, 2)
SMART FORM NAME: ZBBSTE_K_LO7
FORM INTERFACE
Table
I_SVBELN LIKE ZSP_O_STR
Global definitions
TYPES
TYPES: BEGIN OF TY_VBAP,
       VBELN TYPE VBAP-VBELN,
       POSNR TYPE VBAP-POSNR,
       KWMENG TYPE VBAP-KWMENG,
       MEINS TYPE VBAP-MEINS,
       NETWR TYPE VBAP-NETWR,
END OF TY_VBAP.
Global data
Wa_vbap type ty_vbap
It_vbap type table of ty_vbap
V1 type vbap-netwr
V2 type vbap-netwr
Initialization
I_svbeln it_vbap
Wa_vbap v2
It_vbap
Select VBELN POSNR KWMENG MEINS NETWR From VBAP Into table IT_VBAP Where VBELN in I_svbeln.
LOOP AT IT_VBAP INTO WA_VBAP.
V2 = V2 + WA_VBAP-NETWR.
ENDLOOP.
Select the main window in the left panel. Right click -> create -> text.
Double click on text. Click on editor. * grand total: &v2(zc)&
Click on back. Select the main window once again. Right click -> create -> flow logic -> loop.
Double click on loop. In the data tab provide.
It_vbap into wa_vbap
In the below sort criteria block provide field name is VBELN. Select the check box ‘event on sort begin’. Select the ‘event on sort begin’ in the left panel. Right click -> create -> text.
Double click on text.
* &wa_vbap-vbeln&
Select the loop in left panel. Right click -> create -> text.
Double click on the text. Click on editor.
* &wa_vbap-posnr& &wa_vbap-kwmeng(zc)& &wa_vbap-meins& &wa_vbap-netpr(zc)&
Click on back. Select the text in left panel. Right click -> create -> flow logic -> program lines.
Double click on code in the left panel. Provide input, output parameters.
Wa_vbap v1
V1 = v1 + wa_vbap-netwr
Double click on loop in the left panel. In the sort criteria block provide field name as Ebeln and select the check box event on sort end. Select the event on sort end in left panel. Right click -> create -> text. Double click on text.
* Sub total: &v1(zc)&
Click on back. Select the text in left panel. Right click -> create -> flow logic -> program lines.
Double click on code. Implement the logic & input parameter is v1.
Clear v1.
Save, check, activate.
In the menu bar click on environment -> function module name. based on this function module we develop the print program.
TABLES VBAP.
SELECT-OPTIONS S_VBELN FOR VBAP-VBELN.
CALL FUNCTION ‘/1BCDWB/SF00000265’
TABLES
I_SVBELN = S_VBELN.
Note : Smart forms are client independent that means if we create the smart form in any one of the client, then it automatically reflected in all other clients in the same server.
Why SAP smartforms are client independent
Whenever, we activate the smart forms then it generate function module, function modules are client independent so smart form is client independent
OR
Smart forms in SAP use text editor to print the symbols, text editors are client independent so smart form is client independent.
Note : In real time for complex objects, we develop the total program in print program and transfers the
displayed data into smart form layout and print.
Here we must create one structure with the transferred fields in the data dictionary. Based on the structure we declare the work area in import tab and internal table in tables tab of form interface in the smart form layout.
Object : Based on the given company codes, to display the company codes, customer numbers and recon account by using smart forms and develop the total object in print program.
Note : In this object, we must create one structure with BUKRS,KUNNR,AKONT in SE11 transaction and based on this structure we declare the internal table in tables tab of form interface.
Structure name : ZSW_P_BBS1 (Created in se11)
SMARTFORM LAYOUT
SMARTFORM NAME : ZBBSHE_C_MA8
FORM INTERFACE:
TABLES TAB:
I_IT LIKE ZSW_P_BBS1
GLOBAL DEFINITION IN LEFT PANNEL
Global data tab
WA TYPE ZSP_O_STR1
Expand the page in left pannel
Expand the main window
Select the main windowïƒ right clickïƒ createïƒ flowlogicïƒ loop
Double click on loop
in data tab
Loop at I_IT into WA
Select the loop in the left pannel-> right click-> crate-> text
Double clikc on text editor
&WA-BUKRS& &WA-KUNNR& &WA-AKONT&
Click on back
Save, check and activate
in the menubar -> click on enivironment-> click on function module
Based on the function module, we develop the print program
Print program
REPORT ZMAUD1_P_SH7.
TABLES T001.
SELECT-OPTIONS S_BUKRS FOR T001-BUKRS.
TYPES : BEGIN OF TY_KNB1,
BUKRS TYPE KNB1-BUKRS,
KUNNR TYPE KNB1-KUNNR,
AKONT TYPE KNB1-AKONT,
END OF TY_KNB1.
DATA IT_KNB1 TYPE TABLE OF TY_KNB1.
DATA V_FM TYPE RS38L_FNAM.
select BUKRS KUNNR AKONT from KNB1 Into table IT_KNB1 Where BUKRS In S_BUKRS.
CALL FUNCTION ‘SSF_FUNCTION_MODULE_NAME’
EXPORTING
FORMNAME = ‘ZMAUD_O_LK7’
IMPORTING
FM_NAME = V_FM.
CALL FUNCTION V_FM
TABLES
I_IT = IT_KNB1.
Folder:
This is used to print the continuous text without any page break.
This functionality is similar as protect & endprotecthgui8y7 control command in sap-script.
Alternative:
This acts like if & end if control command in the sap-script.
Command:
This is used to break the page. This is similar as new page control command in sap-script.
Note: -By using static break points (Break-point keyword) we can debug the smart form & also placing the dynamic break points in the function module we can debug the smart form.
Note: – In the real time output device isn’t always LP01. depending on the printer type (Laser printer,
Dot Matrix printer) & language (English, Chinese, Japanese) the output device is created by BASIS people through ‘SPAD’ transaction.
Â
Â
Difference Between SAPSCRIPT and SMARTFORMS
SAP SCRIPTS
- Multiple Page formats aren't possible in SAP-Script.
- Labels are possible in SAP-script.
- With out a main window we can't create SAP-Script.
- SAP-SCRIPT is a client dependent that means if you create a script in one client that's not reflected into all other clients in same server.
- Control commands are worked in SAP-SCRIPT (Protect, top, bottom)
- Colors aren't possible in this.
- Water mark / background picture isn't possible in script.
- Paragraph & character formats aren't reusable in script.
- By using `RSTXDBUG' standard program we can debug the script.
- We maintain the backup of script in .TXT
- When ever we activate the script it won't generates function module.
- We can't develop the code in script.
- We can convert script to smart form.
- Script s suitable for complex coding
SMARTFORM
- Multiple page formats are possible in SMARTFORMS.
- Labels aren't possible in smart form.
- Without a Main window we can design smart forms.
- Smart form is client independent. That means if we create smart form function module in any one of the client then automatically reflect into all other clients in same server.
- Control commands are aren't possible in smart form.
- Colors are possible in smart form.
- Watermark background picture is possible in smart form.
- Paragraph & character formats are reusable in smart form.
- By using static break points (break-point) we can debug the smart form.
- We maintain the backup of smart form in .XML
- When ever we activate the smart form it generates a function module.
- We can develop the code in smart form.
- We can't convert smart form to script.
- Smart form is suitable for complex design.
This is all about smartforms in sap abap tutorials with step by step.