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: 

Two Tables in a single structure

Former Member
0 Kudos

Hi,

How can i declare a structure that include all the fields of two table?? Please note that there some common fields in the two tables such as MANDT.

TYPES: BEGIN OF MY_STRUCT.

INCLUDE STRUCTURE TABLEA.

INCLUDE STRUCTURE TABLEB.

END OF MY_STRUCT.

Regards,

Kit

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Kit,

you may declare like this:


TYPES: BEGIN OF my_struct.
        INCLUDE STRUCTURE tablea AS a RENAMING WITH SUFFIX a1.
        INCLUDE STRUCTURE tableb AS b RENAMING WITH SUFFIX b1.
TYPES: END OF my_struct.

I hope this helps. Best regards,

Alvaro

3 REPLIES 3

Former Member
0 Kudos

Hi Kit,

you may declare like this:


TYPES: BEGIN OF my_struct.
        INCLUDE STRUCTURE tablea AS a RENAMING WITH SUFFIX a1.
        INCLUDE STRUCTURE tableb AS b RENAMING WITH SUFFIX b1.
TYPES: END OF my_struct.

I hope this helps. Best regards,

Alvaro

0 Kudos

Hi Alvaro,

Thx for your reply.

Do i need to use the alias a and b to access the structure variable??

Regards,

Kit

0 Kudos

Hi Kit,

if you declare (say) a variable with reference to this type:


DATA: l_mystruc TYPE my_struct.

...then you can access the individual fields by appending the suffix to the name of the field.

For example, if both tables have field MANDT, you may access L_MYSTRUC-MANDTA1 for the first table and L_MYSTRUC-MANDTB1 for the second table.

You may also access the whole structure of each table, by typing L_MYSTRUC-A or L_MYSTRUC-B.

I hope this helps. Best regards,

Alvaro