‎2007 Dec 17 12:58 PM
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.
‎2007 Dec 17 1:18 PM
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
‎2007 Dec 17 1:03 PM
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
‎2007 Dec 17 1:13 PM
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.
‎2007 Dec 17 1:18 PM
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
‎2007 Dec 17 1:24 PM
Hi Eric - thanks for that, but unfortunately that really messes up the data!
‎2007 Dec 17 1:30 PM
Hi Eric - cheers actually that nearly answered my question. I did a few tweaks and it works! THANKS!!