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

Internal table selection

Former Member
0 Likes
416

Hi,

I have the following situation:

itab1: bukrs kostl gjahr monat amount1 amount2

itab2: bukrs kostl gjahr hsl01 hsl02.......hsl12

I need to get the amount2 of itab1 from itab2.

monat is the period in itab1 but in itab2 hsl01 is the amount for period 01.

This is the code that i have so far:

loop at itab1 into wa_itab2.

read table itab2 into wa_itab2 with key bukrs = wa_itab1-bukrs

kostl = wa_itab1-kostl

gjahr = wa_itab1-gjahr

concatenate 'wa_itab2-hsl' monat into l_amnt.

wa_itab1-amount2 = ?

endloop.

How do i get the value of l_amnt?

Thanks,

MJ

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
398

I think you are going to want to use a field symbol here.



data: HSL_Field(20) type c.
field-symbols: <fs>.

loop at itab1 into wa_itab1.    "<--- Change this to WA_ITAB1

read table itab2 into wa_itab2 with key bukrs = wa_itab1-bukrs
kostl = wa_itab1-kostl
gjahr = wa_itab1-gjahr

* Here we are assuming the MONAT has values like 01,02,03,04,....12
concatenate 'WA_ITAB2-HSL' wa_itab1-monat into hsl_field.  
condense hsl_field no-gaps.   

* Assign to the field symbol
assign (hsl_field) to <fs>.

wa_itab1-amount2 = <fs>.
modify itab1 from wa_itab1 index sy-tabix.

endloop.


Regards,

Rich Heilman

2 REPLIES 2
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
399

I think you are going to want to use a field symbol here.



data: HSL_Field(20) type c.
field-symbols: <fs>.

loop at itab1 into wa_itab1.    "<--- Change this to WA_ITAB1

read table itab2 into wa_itab2 with key bukrs = wa_itab1-bukrs
kostl = wa_itab1-kostl
gjahr = wa_itab1-gjahr

* Here we are assuming the MONAT has values like 01,02,03,04,....12
concatenate 'WA_ITAB2-HSL' wa_itab1-monat into hsl_field.  
condense hsl_field no-gaps.   

* Assign to the field symbol
assign (hsl_field) to <fs>.

wa_itab1-amount2 = <fs>.
modify itab1 from wa_itab1 index sy-tabix.

endloop.


Regards,

Rich Heilman

Read only

0 Likes
398

Thanks Rich!