Application Development 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: 

How to apply loop 2 times in table of smart-forms ?

Former Member
0 Kudos

Hi,

I developed a Smart form but data is not coming properly in Item table(body) ?

I run this smart-form by driver program, I have two internal tables one for header data another for item data,

I debug both tables, my data is coming correctly..

then I created structure for both tables and pass this structure in SM .

after that I passed loop(for header data) in table(under data tab)  loop i_tab to WA.

then I passed 2nd loop for item data in main body(create a loop)  loop j_tab to WA

after that(I execute drive program) my output is coming this type

PO no             Po type              date

item                quantity             amount

30006             BS                       22.11.2007              <---header data is coming properly

3                       kg                         3770.5                <--- but item data its showing only last records

i want print herder data under their item data , but problem is that, the herder data is coming correctly but not coming item data properly

. i Checked my item data internal table(its have 3 records) but in output its showing only last record.

how to solve this problem ?

thanks

29 REPLIES 29

Former Member
0 Kudos

Hi Sandeep,

How you design the main window, pleaes paste the screenshot to here.

regards,

Archer

0 Kudos

hi, my smartform screenshot is here, any one can help me ?

screenshot is below here..........

the output is showing only last record of item data

but in internal table of item, it have 3 records, see here below screenshot, but in output its show only last record of item data, its my error only

former_member185414
Active Contributor
0 Kudos

Hi,

In the loop at item's internal table have you specified the where condition to match the header value with all the corresponding item values?

BR.

0 Kudos

my data is coming from driver program means separately like  header data in itab  and item data in J_tab  but in smartforms we can passed only one loop under table so I passed itab to WA for header data, its data coming properly but for item data, i created a loop in main window j_tab to WA1,

its showing only last record in output(but it have 3 records)   ?

akshatrander1990
Explorer
0 Kudos

Hi Sandeep,

You are using  2 loops. In both the internal tables there should be at least one primary key.

Put a condition on the second LOOP of the primary key.

Lets take an example :

1st internal table having EKKO Data (header data)

2nd Internal table having EKPO data (item data)

Put 1st LOOP on EKKO Data.

Put 2nd LOOP on EKPO Data with condition ebeln eq ekko-ebeln.

This will work.

Regards

Akshat

0 Kudos

HI,

I knew, primary key relation and my data is coming in internal table in driver program..

but i passed this tables in smart-form then i passed loop in main table and 2nd loop on main window(i created this loop)  after that my header data(ekko) is coming but not coming item data properly 

0 Kudos

HI Sandeep,

Thats fine. You are saying that your data is perfect in internal tables.

But your 2nd LOOP is based on the First LOOP. So you have to put a where condition in the second LOOP so that it will work on the basis of your first LOOP value.

Regards

Akshat

0 Kudos

I tried your way ...........

Main window--->table-->data tab--> loop itab to WA---- this loop for header data..

then created 2nd loop under main area-- loop j_tab to WA1--- this for item data

then passed where condition -- field name                    comparison value

                                                          ebeln              =             wa-ebeln.

but stil output is same, its showing last record of item data

thanks

0 Kudos

hi sandeep,

you have two loops ( header, item ).

first loop with item data, and then loop with header data with where condition use primery key of the both.

so you will print the both header and item information.

0 Kudos

I tried your way ...........

Main window--->table-->data tab--> loop itab to WA---- this loop for header data..

then created 2nd loop under main area-- loop j_tab to WA1--- this for item data

then passed where condition -- field name                    comparison value

                                                          ebeln              =             wa-ebeln.

but stil output is same, its showing last record of item data

thanks

0 Kudos

any one can help me ?

ipravir
Active Contributor
0 Kudos

Hi Sandeep,

As per your requirement, i would suggest, create a Single Internal Table with CHAR columns types.

Arrange your all Header and Item information in Driver program it self as per your final output

30006             BS                       22.11.2007              <---header data is coming properly

3                       kg                         3770.5                <--- but item data its showing only last records

And finally pass that Internal table to SM to display the Information.

Note: If you want to differentiate the Information like, Header Information should be display as different, Make a another New Line Item in Table (in SM) with different system like bold, and Pass a flag column for new Header value,

Header Col1 Header Col2Header Col3 Flag
Item Col1Item Col2Item Col2
Item Col1Item Col2Item Col2
Header Col1 Header Col2Header Col3 Flag

So whenever, flag will come, you have to pass the Information in Line Item for Header information.

Hope you are clear with logic.

Praveer.

Former Member
0 Kudos

hi, i developed a driver program , both header data and item data are correct in separate internal table ,then in Smartform I passed loop at table for header data and created another loop in main window for item data and pass the where condition but it still show last record of item data

but you wrote in our last discussion, you passed flag column , can you explain me, what is use of this ? and how to pass this ?

thanks

sandeep

former_member185054
Active Participant
0 Kudos

hi,

merge that two table into a single table, hope you know how to do (initialization or insert program lines)

pass that internal table into that loop...

With regards,

sampath kumar.

0 Kudos

Hi ,

use under main window use table (header data ), in the main area of the table

need to create two table lines, first table line is to print the header data,

and second table line for item data, and use the second table line under the loop and maintain the primary key in conditions tab of the loop.

please find screen shot

0 Kudos

how to merge two internal tables in single one internal table ?

0 Kudos

I tried your way, but output is same , its showing last record

0 Kudos

The easiest way to merger internal table is to do that in your driver program..

Your smartform should work. Can you paste the screenshot of your Header and Item table Data tab. Hope you have checked the Internal table checkbox.

Raju

0 Kudos

thank you

how to merge to different structure of internal table in one table. because i am already fetched header and item data in separate internal table from driver program

can you explain this, how to merge two internal tables in SM ?

regards sandeep

Former Member
0 Kudos

hi,

you can use as karthik said or as below

VenkatRamesh_V
Active Contributor
0 Kudos

Hi,

Try  with passing  Item data internal table  in loop statement, sort itab using key fields,

Fetch the header data content using programming lines (Read statement) using AT NEW (Control Break Statments) Based on key fields.

Hope it helpful,

Regards,

Venkat.

Former Member
0 Kudos

Are you passing the entire item table to the smartform, or just one line?
Can you see the whole item data inside the smartform ?

0 Kudos

i want pass entire item table to the smartform but i can't proper data in output and showing last record of item data but it have 3 records..

0 Kudos

Hi Sandeep,

Why cant you use Merge table logic, which is explained by Raju and me..It is very simple approach to get the data in proper way.

Praveer.

0 Kudos

I merged two internal tables in one internal table in driver program and pass this internal table to SM  like itab to wa at table

but my output is coming this type....

PO no             Po type              date

item                quantity             amount

30006             BS                       22.11.2007            

1                     kg                         3770.5    

30006             BS                       22.11.2007           

2                     kg                         3770.5          

30006             BS                       22.11.2007           

3                     kg                         4770.5   

but i want output this type,      

PO no             Po type              date

item                quantity             amount

30006             BS                       22.11.2007              <---header data is coming properly

1                      kg                          3770.5                   !

2                      kg                          3770.5                   !--<----item data 1 or 2 not coming

3                       kg                         3770.5                     <---  item data 3 is coming

0 Kudos

You have maintained the data in wrong way in Final Internal table.

Check in Debug, the data maintenance logic should be like below.

Loop at Header_data.

     Insert Header Information in Final Table.

     Loop at Item_data where Header_data condition.

          Insert Item Data Information.

     End loop

Endloop.

Hope your are clear with above logic.

Praveer.

Former Member
0 Kudos

Hi,

Your Problem Will Be solve By This

Put The Two Loops,one For Header Data And Another For Main Data

And Remove Loop Of Table (Check Box Of Loop On Table).

Pass The Itabs And Wa for Loops For Main And Header Data As per Your Requirements

Data will come Properly.

Harish Yadav

0 Kudos

hi harish

I applied two loops same as said you .... but output is still same..

how to solve this problem ?

kabil_g
Active Participant
0 Kudos

Hi Sandeep,

In the driver Program   get all the values to header & Item Table.....using seperate internal tables

Pass the below

TABLES

       gt_main                    = gt_main

       gt_excise2                 = gt_excise2

Header .... Image

Item Image

Regards,

Kabil