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

internal table

Former Member
0 Likes
630

Moderator message: please use more meaningful subject in future

Hi Guyz,

i have two internal tables

1.gt_heager

2.gt_items

and i want to pass fields of this 2internal tables to 3rd one

ie, 3. gt_output

i declared like :

DATA:BEGIN OF gt_output OCCURS 0.

include structure gt_header.

INCLUDE STRUCTURE gt_items.

end of gt_output.

I knew its wrong coz im getting a bug..so could you please advise me right way to do it.

Thanks

Edited by: Matt on Nov 14, 2008 4:26 PM

4 REPLIES 4
Read only

Former Member
0 Likes
438

Hi,

Try like this.....


types : begin of typ_input,
            wa_string type string,
           end of typ_input.
           
types : begin of typ_input1,
            wa_string1 type string,
           end of typ_input1.    
           
data : gt_input type typ_input,
       gt_input1 type typ_input1.         
             
DATA: BEGIN OF gt_output OCCURS 0.
             include structure gt_input.
             INCLUDE STRUCTURE gt_input1.
DATA: end of gt_output.

Hope it will helps

Read only

Former Member
0 Likes
438

most likely you have same name for fields in both structures

Read only

uwe_schieferstein
Active Contributor
0 Likes
438

Hello

I would suggest to define appropriate types, e.g.:


TYPES: BEGIN OF ty_s_header.
  INCLUDE type <name of header type>.
TYPES: END OF ty_s_header.
TYPES: ty_t_header   TYPE STANDARD TABLE OF ty_s_header
                                 WITH DEFAULT KEY.

TYPES: BEGIN OF ty_s_item.
  INCLUDE type <name of item type>.
TYPES: END OF ty_s_item.
TYPES: ty_t_item   TYPE STANDARD TABLE OF ty_s_item
                                 WITH DEFAULT KEY.

TYPES: BEGIN OF ty_s_outtab.
  INCLUDE TYPE ty_s_header  AS header.
TYPES: items     TYPE ty_t_item  AS data.
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab   TYPE STANDARD TABLE OF ty_s_outtab
                                 WITH DEFAULT KEY.


DATA:
  gt_header   TYPE ty_t_header,
  gs_header  TYPE ty_s_header,
  gt_item       TYPE ty_t_item,
  gs_item      TYPE ty_s_item.

DATA:
  gt_outtab    TYPE ty_t_outtab,
  gs_outtab   TYPE ty_s_outtab.


  REFRESH: gt_outtab.
  LOOP AT gt_header INTO gs_outtab-header.
    REFRESH: gt_outtab-data.

    LOOP AT gt_item INTO gs_item
             WHERE ( key = gs_outtab-header-<header key...> ).

      APPEND gs_item TO gs_outtab-items.
    ENDLOOP.

    APPEND gs_outtab TO gt_outtab.
  ENDLOOP.

NOTE: Avoid header lines because they only will mess up your program.

Regards

Uwe

Read only

Former Member
0 Likes
438

u include the bold part

DATA:BEGIN OF gt_output OCCURS 0.

include structure gt_header.

INCLUDE STRUCTURE gt_items.

DATA : end of gt_output.