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

Modify Main Internal Table

Former Member
0 Likes
666

Hi Experts.

I am stuck in a dilemma here. What I am trying to do is this........

I have a MAIN internal table name gt_main with key ANLN1. I have another internal table with fields ANLN1, PERAF and NAFAZ. The second internal table has several entries for ANLN1.

PERAF = Month and NAFAZ = depreciation value. My main internal table has 12 NAFAZ fields named xx_anlp_nafaz.

I want to get these values appended to the main internal table based on PERAF AND NAFAZ. I am doing the following.........

FORM FILL_DATA.

DATA: lv_index TYPE sy-tabix.

LOOP AT GT_MAIN INTO gw_main.

lv_index = sy-tabix.

READ TABLE GT_ANLP INTO GW_ANLP

WITH KEY ANLN1 = GW_MAIN-ANLN1

BINARY SEARCH.

CASE GW_ANLP-PERAF.

WHEN '1'.

GW_MAIN-01_ANLP_PERAF = gw_anlp-NAFAZ.

WHEN '2'.

GW_MAIN-02_ANLP_PERAF = gw_anlp-NAFAZ.

WHEN '3'.

GW_MAIN-03_ANLP_PERAF = gw_anlp-NAFAZ.

WHEN '4'.

GW_MAIN-04_ANLP_PERAF = gw_anlp-NAFAZ.

WHEN '5'.

GW_MAIN-05_ANLP_PERAF = gw_anlp-NAFAZ.

WHEN '6'.

GW_MAIN-06_ANLP_PERAF = gw_anlp-NAFAZ.

WHEN '7'.

GW_MAIN-07_ANLP_PERAF = gw_anlp-NAFAZ.

WHEN '8'.

GW_MAIN-08_ANLP_PERAF = gw_anlp-NAFAZ.

WHEN '9'.

GW_MAIN-09_ANLP_PERAF = gw_anlp-NAFAZ.

WHEN '10'.

GW_MAIN-10_ANLP_PERAF = gw_anlp-NAFAZ.

WHEN '11'.

GW_MAIN-11_ANLP_PERAF = gw_anlp-NAFAZ.

WHEN '12'.

GW_MAIN-12_ANLP_PERAF = gw_anlp-NAFAZ.

WHEN OTHERS.

ENDCASE.

MODIFY GT_MAIN FROM gw_main INDEX lv_index.

CLEAR: gw_main, gw_anlp.

ENDLOOP.

ENDFORM.

_____________________________

However all this is doing is setting ONE of the TWELVE fields in the internal table. I need to somehow loop at the second internal table if anln1 keeps equalling gt_main-anln1.

Any ideas?

Points galore if answered.

1 ACCEPTED SOLUTION
Read only

JozsefSzikszai
Active Contributor
0 Likes
637

hi Dipesh,

LOOP AT gt_main INTO gw_main.

LOOP AT gt_anlp INTO gw_anlp WHERE anln1 EQ gw_main-anln1.

... here you have all 12 lines, one by one, you can insert your CASE here

ENDLOOP.

ENDLOOP.

hope this helps

ec

5 REPLIES 5
Read only

Former Member
0 Likes
637

Dipesh,

What do you have in the second internal table? What do mean by 'somehow loop at the second internal table if anln1 keeps equalling gt_main-anln1.'?

Regards,

Satish

Read only

Former Member
0 Likes
637

In my second internal table i have ANLN1, PERAF and NAFAZ. But for one ANLN1 entry in GT_MAIN i have several in GT_ANLP. However PERAF is different. I need to do a pass on the Main internal table and get all the values from GT_ANLP into one of the 12 fields (xx_anlp-nafaz) based on that CASE.

Read only

JozsefSzikszai
Active Contributor
0 Likes
638

hi Dipesh,

LOOP AT gt_main INTO gw_main.

LOOP AT gt_anlp INTO gw_anlp WHERE anln1 EQ gw_main-anln1.

... here you have all 12 lines, one by one, you can insert your CASE here

ENDLOOP.

ENDLOOP.

hope this helps

ec

Read only

Former Member
0 Likes
637

Hi Eric - thanks for that, but unfortunately that really messes up the data!

Read only

Former Member
0 Likes
637

Hi Eric - cheers actually that nearly answered my question. I did a few tweaks and it works! THANKS!!