Application Development 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: 

Moving WA data back to new itab

former_member210563
Participant
0 Kudos

Hi,

I have defined the types and tables like below:

TYPES: BEGIN OF t_valuetab,
recn TYPE cciht_wah-recn,
waplant TYPE cciht_wah-waplant,
waid TYPE cciht_wah-waid,
wanam TYPE cciht_wald-wanam,
END OF t_valuetab.

TYPES: BEGIN OF t_finaltab,
waplant TYPE cciht_wah-waplant,
waid TYPE cciht_wah-waid,
wanam TYPE cciht_wald-wanam,
END OF t_finaltab.

DATA: it_valuetab TYPE STANDARD TABLE OF t_valuetab INITIAL SIZE 0, "itab
wa_valuetab TYPE t_valuetab, "work area (header line)
it_finaltab TYPE TABLE OF t_finaltab,
wa_finaltab TYPE t_finaltab.

The coding for filling the itab looks like this:

SELECT recn waplant waid FROM cciht_wah
INTO TABLE it_valuetab
WHERE waplant = im_werks
AND watype = 'ST'
AND valfr <= im_keydate
AND valto >= im_keydate.

LOOP AT it_valuetab
INTO wa_valuetab.

IF sy-subrc = 0.
SELECT wanam
FROM cciht_wald
INTO wa_valuetab-wanam
FOR ALL ENTRIES IN it_valuetab
WHERE recnroot = it_valuetab-recn.
ENDSELECT.
ENDIF.

ENDLOOP.

QUESTION

My question is:

In order to get the name of a work area I needed the keyfield RECN. It updated OK in wa_valuetab. However, I need the fields for FM = POPUP_WITH_TABLE_DISPLAY. The field RECN is not to be shown in the selection and I therefore need fill a table with the records without RECN. How can I move the updated records from WA_VALUETAB "back" into an itab without the field RECN?

1 ACCEPTED SOLUTION

Jelena
Active Contributor
0 Kudos

Not sure how FM is involved here exactly but the whole LOOP part is just wrong. Please make sure to read the documentation on SELECT and FOR ALL ENTRIES.

Also I'm not familiar with these specific DB tables but an obvious solution would be to use SELECT... JOIN and avoid two different internal tables altogether.

If this is for some reason not feasible then, naturally, both internal tables need to include a unique ID (here it's RECN, I guess?). Based on the provided code fragment, you need only RECN and WANAM in the second table, the other stuff is already in the first table.

MOVE-CORRESPONDING cannot be used when one is a structure and the other is an internal table. Just look at them in the debugger.

4 REPLIES 4

horst_keller
Product and Topic Expert
Product and Topic Expert

MOVE-CORRESPONDING?

former_member210563
Participant
0 Kudos

WA_ is the updated records. If I use

MOVE-CORRESPONDING, I get a syntax error that tells me that WA_ and IT_ are not of the same type.

Jelena
Active Contributor
0 Kudos

Not sure how FM is involved here exactly but the whole LOOP part is just wrong. Please make sure to read the documentation on SELECT and FOR ALL ENTRIES.

Also I'm not familiar with these specific DB tables but an obvious solution would be to use SELECT... JOIN and avoid two different internal tables altogether.

If this is for some reason not feasible then, naturally, both internal tables need to include a unique ID (here it's RECN, I guess?). Based on the provided code fragment, you need only RECN and WANAM in the second table, the other stuff is already in the first table.

MOVE-CORRESPONDING cannot be used when one is a structure and the other is an internal table. Just look at them in the debugger.

former_member210563
Participant
0 Kudos

Thanks Jelena for enlightening me.

This is the solution below:

SELECT
cciht_wah~waplant
cciht_wah~waid
cciht_wald~wanam
INTO TABLE it_seltab
FROM cciht_wah
INNER JOIN cciht_wald
ON cciht_wah~recn = cciht_wald~recnroot
AND cciht_wald~langu = 'EN'
WHERE waplant = im_werks
AND watype = 'ST'
AND cciht_wah~valfr <= im_keydate
AND cciht_wah~valto >= im_keydate.

Case closed.