‎2022 Aug 04 2:14 PM
Hi there,
i am a fresher and i am new to abap! while coding i got into situation where
global structure holds n fields and
i want to add an extra field without touching the global structure.
i have tried this thing below but it is throwing an error no fields with that name.
TYPES: BEGIN OF lty_zruledate,
zpidrule TYPE z_s_pidrule(global),
date_popu TYPE sy-datum,
END OF lty_zruledate.
LOOP AT it_zpidrule INTO ls_zpidrule.
ls_zpidrule-werks = ls_zpidruledate-zpidrule-werks.
ls_zpidrule-gate_id = ls_zpidruledate-zpidrule-gate_id.
ls_zpidrule-stncd = ls_zpidruledate-zpidrule-stncd.
APPEND ls_zpidruledate TO lt_zpidruledate.
CLEAR:
ls_zpidrule,
ls_zpidruledate.
ENDLOOP.
thanks in advance
‎2022 Aug 04 3:28 PM
It's invalid syntax:
zpidrule TYPE z_s_pidrule(global),This is valid syntax:
zpidrule TYPE z_s_pidrule,
What are you trying to achieve with "(global)"?
‎2022 Aug 05 2:24 AM
DO YOU MEAN LIKE THIS?
TYPES: BEGIN OF LTY_DEMO.
TYPES: CHECKBOX TYPE C LENGTH 1. "add new component
INCLUDE STRUCTURE SFLIGHT. "Global structure
TYPES: END OF LTY_DEMO.
DATA: LT_DEMO TYPE TABLE OF LTY_DEMO,
LS_DEMO LIKE LINE OF LT_DEMO.
SELECT * FROM SFLIGHT INTO TABLE @DATA(LT_SFLIGHT) UP TO 10 ROWS.
LOOP AT LT_SFLIGHT INTO DATA(LS_SFILGHT).
LS_DEMO-CHECKBOX = 'X'.
LS_DEMO-CARRID = LS_SFILGHT-CARRID.
APPEND LS_DEMO TO LT_DEMO.
CLEAR: LS_DEMO, LS_SFILGHT.
ENDLOOP.
‎2022 Aug 05 8:40 AM
sandra.rossi Maybe he's trying to say "this is the global structure".
‎2022 Aug 05 10:01 AM
If Z_S_PIDRULE doesn't exist in SE11, and you defined Z_S_PIDRULE with DATA in your program, then syntax should be with LIKE:
zpidrule LIKE z_s_pidrule,
‎2022 Aug 05 10:06 AM
‎2022 Aug 05 11:28 AM
Your question is unclear. Lots of information are missing about the variables you are using, how they are typed. So I can only answer with different code:
TYPES: BEGIN OF lty_zruledate,
zpidrule TYPE z_s_pidrule,
date_popu TYPE sy-datum,
END OF lty_zruledate.
DATA ls_zpidruledate TYPE lty_zruledate.
DATA(werks) = ls_zpidruledate-zpidrule-werks.
DATA(gate_id) = ls_zpidruledate-zpidrule-gate_id.
DATA(stncd) = ls_zpidruledate-zpidrule-stncd.
DATA(date_popu) = ls_zpidruledate-date_popu.