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

Define Internal table

Former Member
0 Likes
1,470

Hi,

My requirement is like that i declare one internal table like:

TYPES: BEGIN OF wa_mathead,

matkl TYPE matkl, "Material Group

mvgr1 TYPE mvgr1, "Material Class

matnr TYPE matnr, "Material

end of wa_mathead.

now i want to declare another internal table say itab with some new fields and including wa_mathead structure.

how can i do that.

Amit.

1 ACCEPTED SOLUTION
Read only

matt
Active Contributor
0 Likes
809

INCLUDE STRUCTURE is not valid in all contexts and should be avoided.

Simply use the type you've defined in the definition of your table:

TYPES: BEGIN OF wa_mathead,
        matkl TYPE matkl, "Material Group
        mvgr1 TYPE mvgr1, "Material Class
        matnr TYPE matnr, "Material
      end of wa_mathead.

TYPES: BEGIN OF itab_rec_type,
         hdr TYPE wa_mathead, 
         f1  TYPE blah,
....

You'll have to acess the header data of a record of your itab as wa-hdr-matkl.

matt

6 REPLIES 6
Read only

Former Member
0 Likes
809

Hi Jony,

TYPES: BEGIN OF wa_mathead,
matkl TYPE matkl, "Material Group
mvgr1 TYPE mvgr1, "Material Class
matnr TYPE matnr, "Material
end of wa_mathead.

TYPES: BEGIN OF wa_mat1,
   additional fields,
   *INCLUDE TYPE wa_mathead.*
end of wa_mat1.

Regards,

Sunil

Read only

Former Member
0 Likes
809

HI

Its written as

data: begin of itab occurs 0.

include structure <name>.

field1,

field2,

-


end of itab.

Aditya

Read only

Former Member
0 Likes
809

Hi,

Refer this link

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/insert_i.htm

Please reward points if useful.

Edited by: nilanjana sinha on Apr 25, 2008 1:30 PM

Read only

Former Member
0 Likes
809

hi,

do this way ...



TYPES: BEGIN OF new_tab,
 matnr_new type matnr.
 include structure wa_mathead.
TYPES: end of new_tab. 

Read only

Former Member
0 Likes
809

Probably a little closer to this example.


DATA:
  BEGIN OF wk_0500_scr_rec.
        INCLUDE STRUCTURE zlmfoll.
DATA:
  cont_ty_2 LIKE zlmfoll-cont_ty,
  END OF wk_0500_scr_rec.

Read only

matt
Active Contributor
0 Likes
810

INCLUDE STRUCTURE is not valid in all contexts and should be avoided.

Simply use the type you've defined in the definition of your table:

TYPES: BEGIN OF wa_mathead,
        matkl TYPE matkl, "Material Group
        mvgr1 TYPE mvgr1, "Material Class
        matnr TYPE matnr, "Material
      end of wa_mathead.

TYPES: BEGIN OF itab_rec_type,
         hdr TYPE wa_mathead, 
         f1  TYPE blah,
....

You'll have to acess the header data of a record of your itab as wa-hdr-matkl.

matt