Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Loop in SMARTFORMS

Former Member
0 Likes
1,356

Hi,

I need to run a loop in smartforms. I'm not using any internal tables. Based on the value of a variable, the loop should run.

For eg. the variable VAR1 = 5. The loop should run 5 times and display 5 pages and in each page the VAR1 values should be decreased by 1 ie 5, 4, 3, 2, 1 or any order ascending or descending.

Hope you got my requirement. Do revert in case of any clarifications.

Any help would be rewarded.

Regards,

Senthil Kumar.

5 REPLIES 5
Read only

Former Member
0 Likes
871

Check the below code.

*Calling Smartform

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = g_form

IMPORTING

fm_name = g_fm_name

EXCEPTIONS

no_form = 1

no_function_module = 2

OTHERS = 3.

LOOP AT VARI.

*Calling FM generated from the smartform

CALL FUNCTION g_fm_name

EXPORTING

control_parameters = g_control

output_options = g_output

user_settings = ' '

var = vari

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5.

vari = vari - 1.

ENDLOOP.

Read only

Former Member
0 Likes
871

Hai,

You just try this,

Right click on the window node -> Create -> Flow logic -> Program lines

You apply your logic like <b>Do 5 times... Enddo</b>

Reward if found helpfull,

Regards ,

Rakesh.

Read only

Former Member
0 Likes
871

hi senthil,

In the smartform,

add a LOOP element into your main window.

In the DATA tab of your loop element uncheck the internal table option.

Then in the conditions tab,

put the name of your variable (VAR1) and its value. put less than equal to(<=) in the comparision column.

then in your LOOP element add a program line element by right clciking on it.

Write your logic to increase of decrease the value of your variable accordingly.

Regards

Ravish Garg

PS: Reward points if useful

Read only

Former Member
0 Likes
871

Hi,

This one u can write code in Program lines and check the page no according to u can pass value to the given variable

Regards,

Nandha

Reward if it helps

Read only

Former Member
0 Likes
871

I think it's not possible to not use internal table in LOOP.

You can just pass internal table with one field from your print program, and then LOOP into that internal table.

Populating that internal table should be something like this:

*For ascending:

loop = 1.

DO n TIMES.

CLEAR wa_loop.

wa_loop = loop.

loop = loop + 1.

APPEND wa_loop TO t_loop.

ENDDO.

*For descending:

loop = n.

DO n TIMES.

CLEAR wa_loop.

wa_loop = loop.

loop = loop - 1.

APPEND wa_loop TO t_loop.

ENDDO.

Hope it'll do.