Label Printing Using Smart Forms
Label Printing Using Smart Forms
It is believed that SAP has not provided any functionary to create labels in Smart form and this is
considered as one of its disadvantage. In this document we will learn how to create labels using
Smart form.
To understand this document you should have fair idea about how Smart form works. Also this
document will not explain the programming part required to fetch the data which is used to create
labels.
Below is the kind of output we expect form this label printing form.
Step1:-
Suppose we have all the data used to create labels available in our Smart form in table IT_FINAL
which is exported thorough driver program to Smart form.
Now our requirement is to print the labels in the manner shown below.
Label1 Label2
Label3 Label4
Label5 Label6
i.e. odd labels on left side and even on right. Your requirement might vary from this one and you need
to do the changes in layout and logic accordingly.
To implement this requirement cerate 5 secondary window and a main window all of the size of label
box, in 1st page of Smart form as shown below.
Last window which print the last label on the page should be the main window, so that the next
page will be triggered if more labels needs to be printed.
1
Step2:-
As per the current requirement every 6 th row will cerate last label on the page and any further row if
exist will trigger the next page.
Move every 6th row from IT_FINAL to IT_MAIN and delete the same from IT_FINAL.
2
Now we have IT_FINAL which contain data to be printed in 5 secondary windows and IT_MAIN which
contain data for main window.
Step3:-
Create 5 work areas wa_1, wa_2, wa_3, wa_4, wa_5 of the type of line of IT_FINAL in the global
declaration area.
Write code to move 1st 5 rows from IT_FINAL to the above declared work areas and then delete those
5 rows form internal; table as shown in the below screen-shot.
Step 4:-
Now create a text node in every window and pass the label data from wa_1 to text node of 1st
secondary window and so on.
3
Every Node has a condition that it will execute only if the corresponding work area value is not initial.
And instead of
window for every node tick the checkbox to draw frame lines, so that frame is printed only if the text
node has data to print.
Step 5:-
Now in the Main window create a table node in the table painter create a line type with one row whose
width is equal to the width of label to be printed.
4
Under the data tab pass IT_MAIN.
Step 6:-
Now in the Main WindowàMain Area of table create a row with line type created above and in the cell
create a text node and pass the corresponding data which needs to be printed in the label.
5
Step 7:-
Create a command line after table node which will call page1 itself
The reason why command line is used is suppose we have 15 labels to be printed then it will be like
Page1->6 Page2-> 6 and Page3->3 labels respectively.
Initially IT_FINAL will have 13 and IT_MAIN will have 2 rows which are for 6 th and 12th label. After 12th
label is printed main table will not have any more data to print. The command line will check if any
6
more labels are yet to be printed by checking entries in IT_FINAL table. If yes it will trigger 3 rd page
which print the last three labels.
7
Output Page1:-
Ou
8
tput Page2:-
Output Page3:-