cancel
Showing results for 
Search instead for 
Did you mean: 

How to print table in a loop for n times

Former Member
0 Kudos

Hi ,

I created an internal table and assigned that to loop element and within that i created a table element and hoping to print table for n times.but it is printing only one time and i did put another code statement along with table in the loop and it is getting executed for n times but i dont understand the problem with table elements.

are there any special conditions need to be met

Let me know the solution

Thanks

Bala Duvvuri

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Try to create New program lines in the loop. There write break <your username> in it. See if the loop to write the table is getting executed n times.

Answers (2)

Answers (2)

sreemsft
Contributor
0 Kudos

Hi Bala,

Lets say that we have two tables..

SFLIGHT and SBOOK

First we need to populate both the tables, assume that we have both the tables in the Global data section. Also declare work area in the same global data section.

Now, we can use a Loop and Table with in Loop.

1) Loop

IT_SFLIGHT INTO WA_SFLIGHT " Define like this in loop Data tab

Now, here you can use a template and display the data of the WA_SFLIGHT

2) TABLE

You can create a table under the loop,

IT_SBOOK INTO WA_SBOOK " Define this in TABLE DATA Tab

Add conditions in where condition of data section..

CARRID = WA_SFLIGHT-CARRID

CONNID = WA_SFLIGHT-CONNID

FLDATE = WA_SFLIGHT-FLDATE

Create line type in table and add the same in main area of a table and display the WA_SBOOK data.

I hope it helps.

Thanks,

Sreekanth

Former Member
0 Kudos

hi,

may i know what data are u assigning to the table..

i guess ur prob can be solved in this way..pls try this..

if 1 internal table..

maintain a global variable for the count..and increment it in the program lines and use it in the condition of loop.

assign the internal table to the loop field in table->data tab.

if 2 internal tables..

assign 1 internal table to the loop element.

assign second internal table to the loop field in table ->data tab.

hope this will be helpful ..

Thanks and Regards..

KC