cancel
Showing results for 
Search instead for 
Did you mean: 

Loop in Smartform

Former Member
0 Kudos

Dear fellow ABAPers

I've created a SMARTFORM with one page and the next page is itself.

i need to make a loop with in a loop. The outer loop is based on the number of entries in the internal table passed in the FM, within that ,the inner loop is based on a value in a field in the structure of outer loop.

ie DO <n> times....ENDDO within a LOOP...ENDLOOP.

<n> will flow from the field in the outerloop.

my SF structure is

First page

Main window

Loop1

Loop2

Text

for evey iteration of DO a new page to be triggered and details to be printed.

Please give me a solution

Regards

Prabumanoharan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

in the main window you have your first loop. table node or loop node.

within this node you create your second loop, also a table node or a loop node.

when the second loop is finished put a command node with page-break.

this should work.

Regards,

Guido

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi all

Thanks for all ur answers

I've solved that issue , the method i followed is as follows

first loop is based on the number of entries

second loop has to pass <n> times based on a value from the first loop..

in first loop i've inserted a program line and populated a new internal table with <n> records using DO...ENDDO

under the LOOP1 (after command) , created LOOP2 and looped it based on the new internal table

since the (main) window can print only contents of one page, it gave me required number of pages.

i don't know whether this approach is efficient enough, but it solved my problem .

Regards

Prabumanoharan

Former Member
0 Kudos

Thanks

Former Member
0 Kudos

Hi,

wt i understand from your requirement is ,

You have to create 'n' pages and details on each page.

For this try this.

1. Declare var as 1.

Create loop or table node with rows 0 to n.

create command node with condition var > 1. "In main area of table.

*for first time it wil not create page and print on first page itself.

create code .

var = var + 1.

2. Second loop.

Print all details.

Former Member
0 Kudos

Hi,

declare two variables in global definitions...

one for capturing the lines in the outer loop internal table

and the second one a counter variable

main window

create program code node -> capture the number of lines in the variable using describe table stmt.

loop -> outer loop.

create program code node... increment the counter variable

loop -> inner loop

after the inner loop--> create command node and in the field condtions

specify the condition

counter variable < total lines

regards

padma

naimesh_patel
Active Contributor
0 Kudos

After your LOOP2, you can introduce the Control Node. Set the Control node to go on your desired page.

Regards,

Naimesh Patel

Former Member
0 Kudos

Hi Naimesh

I've used a command line to call the req page, but the loop has to continue for <n> times , whereas it is executing only one time.

Regards

Prabumanoharan

naimesh_patel
Active Contributor
0 Kudos

Oh .. may be because the page is getting started again so it will take a new value in the <n>.

I would suggest to handle this in your print program. Make DO.. ENDDO in your program and call the Smartform in the loop of DO .. ENDDO.

Regards,

Naimesh Patel

Former Member
0 Kudos

if do that , can i've continuous printing of the output

ie, will it be stored under single spool request...

Regards

Prabumanoharan

naimesh_patel
Active Contributor
0 Kudos

For the first pass, you have to set the Control parameter TDNEWID = 'X' and for rest of the calls make it clear.


CONTROL-TDNEWID = 'X'.

Regards,

Naimesh Patel