Skip to Content
-3

Moving WA data back to new itab

Jan 26 at 03:59 PM

92

avatar image

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?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Jelena Perfiljeva
Jan 26 at 09:34 PM
0

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.

Share
10 |10000 characters needed characters left characters exceeded
Horst Keller
Jan 26 at 04:39 PM
1

MOVE-CORRESPONDING?

Share
10 |10000 characters needed characters left characters exceeded
Peter C. Sandgaard Jan 26 at 05:57 PM
-3

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.

Share
10 |10000 characters needed characters left characters exceeded
Peter C. Sandgaard Jan 27 at 02:41 PM
0

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.

Share
10 |10000 characters needed characters left characters exceeded