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

Move data.

Former Member
0 Likes
457

Hi all,

here i fetch data from two table one is kna1 and other is J_1IMOCUST and then i move this data in my internal structure. but when my ALV is generated this time kna1 table data display first and then after display second table data. So how can i get data in same field.

below my coding so please help me out.

select * from kna1 INTO TABLE it_kna1. " into TABLE it_kna1.

SELECT * FROM J_1IMOCUST "INTO TABLE it_J_1IMOCUST

INTO TABLE it_J_1IMOCUST

FOR ALL ENTRIES IN it_kna1

WHERE KUNNR = it_kna1-KUNNR.

  • loop at it_kna1.

  • SELECT SINGLE bezei from TVGRT

  • INTO itab-bezei

" FOR ALL ENTRIES IN it_kna1

  • where spras = it_kna1-spras.

  • endloop.

loop at it_kna1.

MOVE it_kna1-kunnr to itab1-kunnr.

move it_kna1-name1 to itab1-name1.

MOVE it_kna1-ort01 to itab1-ort01.

MOVE it_kna1-telf1 to itab1-telf1.

MOVE it_kna1-stras to itab1-stras.

APPEND itab1.

endloop .

  • clear itab1.

loop at it_J_1IMOCUST.

move it_J_1IMOCUST-J_1ICSTNO to itab1-J_1ICSTNO.

MOVE it_J_1IMOCUST-J_1ILSTNO to itab1-J_1ILSTNO.

MOVE it_J_1IMOCUST-J_1IPANNO to itab1-J_1IPANNO.

APPEND itab1.

  • PERFORM clear_table.

  • ENDLOOP.

ENDLOOP.

  • loop at itab.

  • MOVE itab-bezei to itab1-bezei.

  • APPEND itab1.

  • ENDLOOP.

perform clear_table.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
421

Hi Frn ,

beacuse you are appending the data comming from table every time ....so that it is comming comming in next line....

Please code like below .

Loop at it_kna1 .

MOVE it_kna1-kunnr to itab1-kunnr.

move it_kna1-name1 to itab1-name1.

MOVE it_kna1-ort01 to itab1-ort01.

MOVE it_kna1-telf1 to itab1-telf1.

MOVE it_kna1-stras to itab1-stras.

Read table it_J_1IMOCUST with key kunnr = it_kna1-kunnr .

if sy-subrc = 0 .

move it_J_1IMOCUST-J_1ICSTNO to itab1-J_1ICSTNO.

MOVE it_J_1IMOCUST-J_1ILSTNO to itab1-J_1ILSTNO.

MOVE it_J_1IMOCUST-J_1IPANNO to itab1-J_1IPANNO.

endif.

append itab1.

clear itab1.

endloop.

Thanks and regards..

Priyank

2 REPLIES 2
Read only

Former Member
0 Likes
421

hi,

this problem comes because you are appending the data into internal table <itab1> 1st from it_kna1 & than from the it_J_1IMOCUST.

you can use read statement between loop to read from different table....

Loop at it_kna1.

    MOVE it_kna1-<field1> to itab1-<field1>.
   .
   .
Read table it_J_1IMOCUST with key kunnr = it_kna1-kunnr .
IF sy-subrc = 0 .   
          MOVE  it_J_1IMOCUST -<field2> to itab1-<field2>.
         .
         .
ENDIF.

  MOVE it_kna1-<field3> to itab1-<field3>.
  append itab1.

Endloop.

regards

Gaurav

Read only

Former Member
0 Likes
422

Hi Frn ,

beacuse you are appending the data comming from table every time ....so that it is comming comming in next line....

Please code like below .

Loop at it_kna1 .

MOVE it_kna1-kunnr to itab1-kunnr.

move it_kna1-name1 to itab1-name1.

MOVE it_kna1-ort01 to itab1-ort01.

MOVE it_kna1-telf1 to itab1-telf1.

MOVE it_kna1-stras to itab1-stras.

Read table it_J_1IMOCUST with key kunnr = it_kna1-kunnr .

if sy-subrc = 0 .

move it_J_1IMOCUST-J_1ICSTNO to itab1-J_1ICSTNO.

MOVE it_J_1IMOCUST-J_1ILSTNO to itab1-J_1ILSTNO.

MOVE it_J_1IMOCUST-J_1IPANNO to itab1-J_1IPANNO.

endif.

append itab1.

clear itab1.

endloop.

Thanks and regards..

Priyank