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

Adding fields to the local structure including global structure,

0 Likes
4,226

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

6 REPLIES 6
Read only

Sandra_Rossi
Active Contributor
0 Likes
3,730

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)"?

Read only

former_member808116
Participant
0 Likes
3,730

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.
Read only

matt
Active Contributor
0 Likes
3,730

sandra.rossi Maybe he's trying to say "this is the global structure".

Read only

Sandra_Rossi
Active Contributor
0 Likes
3,730

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,
Read only

0 Likes
3,730

z_s_pidrule is a global structure which exists in se11.

Read only

Sandra_Rossi
Active Contributor
0 Likes
3,730

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.