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

Reading internal table

former_member189596
Active Participant
0 Likes
715

Hi all,

i have two intenral table , itab and jtab.

i need to move data from jtab to local variable , but it should based on another internal table(jtab) record.

For example <b>itab has customer number , customer name

jtab customer number and customer value</b>.

i need to move based on customer name , customer value to local varible.

Thanks in advance,

Regards,

Bhaskar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
696

Hi Bhaskar,

LOOP AT itab.

READ TABLE jtab ..based on itab-customer name.

IF sy-subrc = 0

..move value to local variable.

Regards,

Atish

5 REPLIES 5
Read only

rainer_hbenthal
Active Contributor
0 Likes
696

loop at itab.

read table jtab with key number = itab-number.

if sy-subrc = 0.

write:/ itab-name, jtab-value.

endif.

endloop.

Read only

Former Member
0 Likes
697

Hi Bhaskar,

LOOP AT itab.

READ TABLE jtab ..based on itab-customer name.

IF sy-subrc = 0

..move value to local variable.

Regards,

Atish

Read only

0 Likes
696

Hi atish,

Thank u for reply.

my internal table does not have header line.

itab has fallowing values

customer internal number customer value

00001 y

00002 x

00003 s

00004 m

Jtab has fallowing values

Customer name customer internal number

z_001 00001

z_002 00002

z_003 00003

z_004 00004.

Now i have requiremnt to pass customer value to local variable based customer name . here customer names are constant values

i write fallowing code, can u advice me based on this for passing value.

LOOP AT itab into l_wa_itab.

READ table jtab into l_wa_jtab with key atinn = l_wa_itab-atinn.

CASE l_wa_jtab-atinn.

WHEN z_001.

MOVE itab-atwrt TO <b>l_v_val_class_01</b>.( local variable )

WHEN z_002.

MOVE itab_atwrt TO l_v_val_class_02.

WHEN z_003.

MOVE itab_atwrt TO l_v_val_class_03.

WHEN z_004.

MOVE itab-atwrt TO l_v_val_rs_exp_01.

WHEN z_011_exp_02.

MOVE itab-atwrt TO l_v_val_rs_exp_02.

WHEN z_0111_exp_03.

MOVE itab-atwrt TO l_v_val_rs_exp_03.

ENDCASE.

ENDLOOP.

Thanks in advance,

Regards,

Bhaskar

Read only

0 Likes
696

Hi Bhaskar,

Your code is correct only change one thing

READ table jtab into l_wa_jtab with key atinn = l_wa_itab-atinn.

IF sy-subrc = 0.

CASE l_wa_jtab-atinn.

WHEN z_001.

MOVE itab-atwrt TO l_v_val_class_01.( local variable )

WHEN z_002.

MOVE itab_atwrt TO l_v_val_class_02.

WHEN z_003.

MOVE itab_atwrt TO l_v_val_class_03.

WHEN z_004.

MOVE itab-atwrt TO l_v_val_rs_exp_01.

WHEN z_011_exp_02.

MOVE itab-atwrt TO l_v_val_rs_exp_02.

WHEN z_0111_exp_03.

MOVE itab-atwrt TO l_v_val_rs_exp_03.

ENDCASE.

ENDIF.

Regards,

Atish

Read only

Former Member
0 Likes
696

u can do it using inner join..but join degrades the performance .

better define a wrok area using both itab and jtab then move the value from work area to local variable.

thanx