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

looping the tables

Former Member
0 Likes
917

hi experts,

I have a typical requiremnt .i need to get some numbers during section screen .i have created a smartform with a table in it .according to the number i have selected at selection screen .the tables should be printed that much times .how to do this.?

hi experts,

I have a typical requiremnt .i need to get some numbers during section screen .i have created a smartform with a table in it .according to the number i have selected at selection screen .the tables should be printed that much times .how to do this.?

7 REPLIES 7
Read only

amit_khare
Active Contributor
0 Likes
895

Use DO-ENDDO loop.

e.g.

DO # OF TIMES VARYING info-ocd

FROM MY-ocd01

NEXT MY-ocd02

VARYING info-odt

FROM MY-odT01

NEXT MY-odT02

VARYING info-otm

FROM MY-otm01

NEXT MY-otm02 .

Regards,

Amit

Reward all helpful replies.

Read only

0 Likes
895

WHERE I HAVE TO WRITE THIS CODE AMIT?

Read only

Former Member
0 Likes
895

Hi,

While looping for smart form write the condition as follows.

<b>IF <Value from selection screen> = SY_TABIX.

EXIT.

ENDIF.</b>

This will exit from the loop.

Regards,

Ranjit Thakur.

<b>Please Mark The Helpful Answer.</b>

Read only

0 Likes
895

where to write this code ranjith .

in table DATA or

in table conditions

mani

Read only

0 Likes
895

Hi Manikandan,

While you are calling the SMARTFORM, you can pass the Number that you select in the selection screen as one of the parameters.

Now in SMARTFORMS, display the TABLE.

Use PROGRAM LINES.

Initialize a counter variable. Put a DO ENDDO loop for the Number selected in selection screen of your program.

Introduce COMMAND where you can set a condition like IF Counter <= (Number selected in selection scren), call NEXT PAGE.

This would help you print the table, number of times according to the n umber selected.

<b>Reward points for useful answers.</b>

Best Regards,

Ram.

Hope this solves your issue.

<b>Reward for informatory answers.</b>

Best Regards,

Ram.

Read only

0 Likes
895

ram upto table lines it is working properly .

no of times i have given 3 .so it goes 3 times and counter also becomes 3 .but the window is displaying only once .

pls tell me what to do in command line .

in condition tab i have given

fieldname = c(my counter variable)

comparison value = times (the number i have given in selection screen )

in general attributes i have ticked the options for next page .

i have copied first page and pasted as second page .

whjat else to do?

Read only

0 Likes
895

Hi Manikandan,

The flow would be like this:

MAIN WINDOW

FIRST PAGE

1. Print the Table lines - First Time

2. Once you print the table, in PROGRAM LINES - Increment the counter (Initialized variable) by ONE. Here check if it less than or Equal to Varaible(Selection screen number) before initializing.

3. Now using COMMAND LINES - in condition tab check if Counter <= Variable(Selection screen number). If yes, then GOTO NEXT PAGE.

4. In MAIN WINDOW or FIRST PAGE Attributes (Am not sure), the NEXT PAGE option is available. Here also you need to default it to the same page again, So that the same page appears again.

This would be the object flow. Try few things out here and you should be able to print the tables with out any issues.

If you are still not very clear about the flow, please try SFTRACE - this will help you to DEBUG the smartform which would help you inturn to know whats happening exactly (Object Flow) when it is getting executed.

For help on SFTRACE

http://help.sap.com/saphelp_erp2004/helpdata/en/49/c3d8a4a05b11d5b6ef006094192fe3/frameset.htm

Hope this helps you solve the issue.

<b>Reward points for helpful answers.</b>

Best Regards,

Ram.