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 fields from third internal table to first internal table

Former Member
0 Likes
1,199

i am moving fields from third internal table to first itab by using move corresponding itab3 to itab1.

i am geting the values but only the last row of itab3 for particular partner1 .

since itab3 is having more than one row for particular partner1.

all 3 itabs have different structure.

itab1 have more than 10 fields including partner2, name .

,itab2 has partner1 and partner2, itab3 has partner2 and name.

and i want to move itab3-partner 2 and itab-3 name to itab1

itab-partner = itab2-partner1

itab2-partner2 = itab-partner3

i am doing this way.

loop at itab1.

loop at itab2 where partner1 = itab1-partner1.

loop at itab3 where partner2 = itab2-partner2.

move corresponding itab3 to itab1.

modify itab.

endloop.

endloop.

endloop.

pls reply , thanks in advance

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,138

HI Ekta

DATA: FIELD1(10) VALUE '1234567890', 
      OFF1 TYPE I VALUE 1, 
      LEN1 TYPE I VALUE 2, 
      FIELD2(8) VALUE 'abcdefgh', 
      OFF2 TYPE I VALUE 3, 
      LEN2 TYPE I VALUE 4. 
MOVE FIELD1+OFF1(LEN1) TO FIELD2+OFF2(LEN2). 

TYPES: BEGIN OF ROW1_3, 
         CO1 TYPE I, 
         CO2 TYPE I, 
         CO3 TYPE I, 
       END   OF ROW1_3. 
TYPES: BEGIN OF ROW2_4, 
         CO2 TYPE I, 
         CO3 TYPE I, 
         CO4 TYPE I, 
       END   OF ROW2_4. 
TYPES: BEGIN OF MATRIX1, 
         R1 TYPE ROW1_3, 
         R2 TYPE ROW1_3, 
         R3 TYPE ROW1_3, 
       END OF   MATRIX1. 
TYPES: BEGIN OF MATRIX2, 
         R2 TYPE ROW2_4, 
         R3 TYPE ROW2_4, 
         R4 TYPE ROW2_4, 
       END OF   MATRIX2. 
DATA: ROW TYPE ROW1_3, 
      M1  TYPE MATRIX1, 
      M2  TYPE MATRIX2. 

ROW-CO1 = 1. ROW-CO2 = 2. ROW-CO3 = 3. 
MOVE: ROW TO M1-R1, ROW TO M1-R2, ROW TO M1-R3. 
MOVE-CORRESPONDING  M1 TO M2. 

If move statement is not working properly try like this

modify  ITAB3 transporting KBETR

Reward all helpfull answers

Regards

Pavan

11 REPLIES 11
Read only

Former Member
0 Likes
1,138

hi,

Use move instead of move-corresponding.

Read only

Former Member
0 Likes
1,139

HI Ekta

DATA: FIELD1(10) VALUE '1234567890', 
      OFF1 TYPE I VALUE 1, 
      LEN1 TYPE I VALUE 2, 
      FIELD2(8) VALUE 'abcdefgh', 
      OFF2 TYPE I VALUE 3, 
      LEN2 TYPE I VALUE 4. 
MOVE FIELD1+OFF1(LEN1) TO FIELD2+OFF2(LEN2). 

TYPES: BEGIN OF ROW1_3, 
         CO1 TYPE I, 
         CO2 TYPE I, 
         CO3 TYPE I, 
       END   OF ROW1_3. 
TYPES: BEGIN OF ROW2_4, 
         CO2 TYPE I, 
         CO3 TYPE I, 
         CO4 TYPE I, 
       END   OF ROW2_4. 
TYPES: BEGIN OF MATRIX1, 
         R1 TYPE ROW1_3, 
         R2 TYPE ROW1_3, 
         R3 TYPE ROW1_3, 
       END OF   MATRIX1. 
TYPES: BEGIN OF MATRIX2, 
         R2 TYPE ROW2_4, 
         R3 TYPE ROW2_4, 
         R4 TYPE ROW2_4, 
       END OF   MATRIX2. 
DATA: ROW TYPE ROW1_3, 
      M1  TYPE MATRIX1, 
      M2  TYPE MATRIX2. 

ROW-CO1 = 1. ROW-CO2 = 2. ROW-CO3 = 3. 
MOVE: ROW TO M1-R1, ROW TO M1-R2, ROW TO M1-R3. 
MOVE-CORRESPONDING  M1 TO M2. 

If move statement is not working properly try like this

modify  ITAB3 transporting KBETR

Reward all helpfull answers

Regards

Pavan

Read only

Former Member
0 Likes
1,138

HI

TRY THIS.

LOOP AT ITAB3.

MOVE CORRESPONDING ITAB3 TO ITAB1.

MODIFY ITAB1.

ENDOOP.

PUT ALL OTHER CONDITIONS.

REWARD IF USEFUL/

Read only

0 Likes
1,138

hi

i am doing the same way but getting only one row from itab3 to itab1 for particular partner1

instead itab3 is having more than that

like for partner1 '304540' partner2 is '405454' 'abhishek'

'700069' 'satish'

but in itab1 only last row '700069' 'satish' is moving.

Read only

0 Likes
1,138

Hi Ekta,

may be ITAb2 is not having the more than one entry.

Regards,

Atish

Read only

0 Likes
1,138

hi atish

i debugged the report and found that within 3rd loop itab 3 is getting all

the rows

so there is no quetion of itab2 is empty.

i think some appending problem

thanks

Read only

0 Likes
1,138

Hi Ekta,

You are modifying ITAB1 based on the fields from ITAB3...Now your logic of MODIFYing the ITAB1 itself is wrong.

As lets say loop starts and the ITAB3 has three entries related to ITAB1 so it will LOOP at ITAB3 ..3 times but always MODIFY the last entry from ITAB3 to ITAB1 as ITAB1 is only in the same loop.

If you want ITAB1 should contain all those entries then you may use COLLECT..but still the logic you written is not good and not correct.

Try to change.

Reward points if useful.

Regards,

Atish

Read only

Former Member
0 Likes
1,138

hi... u can use 'MOVE-CORRESPONDING'

plz reward if useful

Read only

Former Member
0 Likes
1,138

here is the example :

PARAMETERS p_name TYPE scarr-carrname DEFAULT '*'. 

DATA: scarr_tab TYPE SORTED TABLE OF scarr 
                WITH UNIQUE KEY carrname, 
      spfli_tab TYPE SORTED TABLE OF spfli 
                WITH NON-UNIQUE KEY carrid. 

FIELD-SYMBOLS LIKE LINE OF scarr_tab. 
DATA spfli_line LIKE LINE OF spfli_tab. 

SELECT * 
       FROM scarr 
       INTO TABLE scarr_tab. 

SELECT * 
       FROM spfli 
       INTO TABLE spfli_tab. 

LOOP AT scarr_tab ASSIGNING 
                  WHERE carrname CP p_name. 
  LOOP AT spfli_tab INTO spfli_line 
                    WHERE carrid = -carrid. 
    WRITE: / spfli_line-carrid, 
             spfli_line-connid. 
  ENDLOOP. 
ENDLOOP.

reward points if it is usefull ....

Girish

Read only

former_member188827
Active Contributor
0 Likes
1,138

use

itab3[] = itab1[].

Read only

Former Member
0 Likes
1,138

Hi,

Ur logic of modifying is wrong, if I have understood ur requirements correctly for all the partner values in ITAB1 partner u want all the values of ITAB3 for all the partners . for that this logic won't work.

what u must do is define a table having similar structure as itab1 and inside the third loop append the entries to that table.

Thanks and Regards,

Saurabh Chhatre