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

Three select statement data in to One Internal table

Former Member
0 Likes
1,096

HI All,

By using 3 select statement, data is displying by using work area (classical report). Now i want define three internal table for three select statements, and finally get the data in one final itab, and pass this to function module (ALV Report).

looking for response

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,068

can u be a bit more clear.

if ur requirement is that u have 3 intable and u want the data in one final table

then u can do this

loop at itab1 into wa1.

wa_final = wa1.

append wa_final to it_final.

endloop.

similarly for for the other 2 itab

8 REPLIES 8
Read only

Former Member
0 Likes
1,069

can u be a bit more clear.

if ur requirement is that u have 3 intable and u want the data in one final table

then u can do this

loop at itab1 into wa1.

wa_final = wa1.

append wa_final to it_final.

endloop.

similarly for for the other 2 itab

Read only

0 Likes
1,068

HI sushant,

In a classicall report, getting the data by using Select & Endselect statements (total 3 select stat). Now i want to displya the data in ALV formate. So, i want to get all data in to one final itab.

I am thinking to define 3 itabs for 3 select stats & one final itab. How to fetch all data into the final itab....

I hope provieded clear info..

Read only

0 Likes
1,068

hi,

first define 3 internal tables and get data into them.

now you can loop at one internal table and read the data from other internal tables and move that data into final internal table.

check this.


Form final_table.

loop at it_bsis.
 CLEAR IT_bkpf.
 READ TABLE IT_bkpf WITH KEY bukrs = IT_bsis-bukrs
                             belnr = it_bsis-belnr
                             gjahr = it_bsis-gjahr.


 IF SY-SUBRC = 0.

 it_final-xblnr = it_bkpf-xblnr.
 it_final-bukrs = it_bkpf-bukrs.
endif.
 CLEAR IT_bseg.
 READ TABLE IT_bseg WITH KEY bukrs = IT_bkpf-bukrs
                             belnr = it_bkpf-belnr
                             gjahr = it_bkpf-gjahr.
                             
 IF SY-SUBRC = 0.

 IT_FINAL-belnr = IT_bseg-belnr.
 it_final-prctr = it_bseg-prctr.
 IT_FINAL-gsber = IT_bseg-gsber.
endif.
 APPEND IT_FINAL.
 CLEAR IT_FINAL.
endloop.

endform.

Read only

Former Member
0 Likes
1,068

Just remove all write statements and Skip keyword.

and create internal tables as same as earlier work area were defined and collect all data in itab by using read statements.

this seems a very structured process while switching to ALV from classical

Read only

Former Member
0 Likes
1,068

hi,

to get the data of 3 internal tables(TABLEA,TABLEB,TABLEC) into 1 internal table(FINAL) can be done by:

=> append the data of all the 3 internal table into one.

loop at TABLEA.

append TABLEA to FINAL.

endloop.

loop at TABLEB.

append TABLEB to FINAL.

endloop.

loop at TABLEC.

append TABLEC to FINAL.

endloop.

=> if u want only some specific data from 3 internal tables into 1 internal table then,loop at one table and read every entry of other internal table on the basis of some comparision and filter out the data to a final table,like:

loop at TABLEA.

read table TABLEB with key fielda = TABLEA-fielda.

if sy-subrc = 0.

move TABLEA-fielda to FINAL-fielda.

move TABLEB-fieldb to FINAL-fieldb.

append FINAL.

endif.

endloop.

anf then throw this final table to function module "REUSE_ALV_GRID_DISPLAY" to show the final data in ALV format..

Read only

Former Member
0 Likes
1,068

hi,

just go through this simple example. no need of declaring 3 itabs.

data: begin of st1,
        a1 type c,
        a11 type i,
      end of st1.

data: begin of st2,
        a2 type i,
        a22 type c,
      end of st2.

data: begin of st3,
        a3 type i,
        a33 type i,
      end of st3.

data: begin of fin_struct.
          include structure st1.
          include structure st2.
          include structure st3.
data: end of fin_struct.

data: fin_itab like table of fin_struct with header line.

*1st structure  values
move 'a' to fin_itab-a1.
move 1 to fin_itab-a11.

*2nd structure values
move 11 to fin_itab-a2.
move 'b' to fin_itab-a22.

*3rd structure values
move 15 to fin_itab-a3.
move 12 to fin_itab-a33.

*appending 1st record.
append fin_itab.

*1st strcuct values
move 'b' to fin_itab-a1.
move 3 to fin_itab-a11.

*2nd structure values
move 22 to fin_itab-a2.
move 'c' to fin_itab-a22.

*3rd structure values
move 20 to fin_itab-a3.
move 30 to fin_itab-a33.

*appending 2nd record.
append fin_itab.


loop at fin_itab.
write:/ fin_itab-a1, fin_itab-a11, fin_itab-a2, fin_itab-a22, fin_itab-a3, fin_itab-a33.
endloop.

here structre1,2,3...

i used move statement.

here u write select statement.. into struct1,2,3....

using move u move all the values ...

finally append it to final itab...

rest of and all common for ALV...

Regards,

Shankar.

Read only

Former Member
0 Likes
1,068

HI sandya,

did u got it.....

Regards,

Shankar.

Read only

0 Likes
1,068

Hi Shakar,

yes i got it. ur answer helped me, not only this case but another case.

thnx