Sometimes, we may need to use loops in smart forms to display data, below is the example of using loop s to display data.
Go to T-code SMARTFORMS, provide name as ZSAPN_LOOPS and click on create.
Double click on global definitions, go to types tab and add below code.
types: BEGIN OF ty_mara, matnr type mara-matnr, mtart type mara-mtart, meins type mara-meins, end of ty_mara.
Go to global data tab and create table and work area.
Go to initialization tab and add below code to get material details.
select * FROM mara into CORRESPONDING FIELDS OF TABLE it_mara UP TO 50 ROWS.
Double click on main window, right click -> create -> flow logic -> loop.
Add internal table IT_MARA and work area WA_MARA as looping parameters.
Right click on loop, create -> text.
Click on insert icon and insert work area fields.
Similarly insert all work area fields.
Save, activate and execute (F8).
It will go to function module, execute.
Again execute and provide OutputDevice as LP01, print preview.