Skip to Content
author's profile photo Former Member
Former Member

Loop in Smartform

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2008 at 09:57 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 18, 2008 at 01:49 PM

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

    Regards,

    Naimesh Patel

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2008 at 10:41 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2008 at 12:48 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 23, 2008 at 01:38 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.