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

Merging three internal tables

Former Member
0 Likes
560

Hi

These all my three internal tables .

1)TYPES : BEGIN OF TY_EKKO,

EBELN TYPE EKKO-EBELN,

LIFNR TYPE EKKO-LIFNR,

BUKRS TYPE EKKO-BUKRS,

WAERS TYPE EKKO-WAERS,

END OF TY_EKKO.

DATA : INT_EKKO TYPE TABLE OF TY_EKKO,

WA_EKKO TYPE TY_EKKO.

2)TYPES : BEGIN OF TY_EKPO,

EBELN TYPE EKPO-EBELN,

EBELP TYPE EKPO-EBELP,

MATNR TYPE EKPO-MATNR,

NETPR TYPE EKPO-NETPR,

NETWR TYPE EKPO-NETWR,

END OF TY_EKPO.

DATA : INT_EKPO TYPE TABLE OF TY_EKPO,

WA_EKPO TYPE TY_EKPO.

3)TYPES : BEGIN OF TY_EKKN,

EBELN TYPE EKKN-EBELN,

EBELP TYPE EKKN-EBELP,

VBELN TYPE EKKN-VBELN,

VBELP TYPE EKKN-VBELP,

END OF TY_EKKN.

DATA : INT_EKKN TYPE TABLE OF TY_EKKN,

WA_EKKN TYPE TY_EKKN.

And i would like to get all the records in the internal table to this internal table.

TYPES : BEGIN OF TY_CLUB_EK,

EBELN TYPE EKKO-EBELN,

LIFNR TYPE EKKO-LIFNR,

BUKRS TYPE EKKO-BUKRS,

WAERS TYPE EKKO-WAERS,

EBELP TYPE EKPO-EBELP,

MATNR TYPE EKPO-MATNR,

NETPR TYPE EKPO-NETPR,

NETWR TYPE EKPO-NETWR,

VBELN TYPE EKKN-VBELN,

VBELP TYPE EKKN-VBELP,

END OF TY_CLUB_EK.

DATA : INT_CLUB_EK TYPE TABLE OF TY_CLUB_EK,

WA_CLUB_EK TYPE TY_CLUB_EK

Can any one suggest me some ways to do this??

Thanks and Regards

Arun Joseph

1 ACCEPTED SOLUTION
Read only

valter_oliveira
Active Contributor
0 Likes
506

Hello.

Why did you split and now merge? The best solution was to fill the target table in the moment you have filled the 3 source ones.

However I'll suggest a way to merge the three tables into one.


LOOP AT int_ekko INTO wa_ekko.
  CLEAR wa_club_ek.
  MOVE-CORRESPONDING wa_ekko TO wa_club_ek.
  LOOP AT int_ekpo INTO wa_ekpo WHERE ebeln = wa_ekko-ebeln.
    MOVE-CORRESPONDING wa_ekpo TO wa_club_ek.
    CLEAR wa_ekkn.
*   CLEAR EKKN fields of work area wa_club_ek.
    READ TABLE int_ekkn INTO wa_ekkn
       WITH KEY ebeln = wa_ekko-ebeln
                ebelp = wa_ekpo-ebelp.
    IF sy-subrc EQ 0.
      MOVE-CORRESPONDING wa_ekkn TO wa_club_ek.
    ENDIF.
    APPEND wa_club_ek TO int_club_ek.
  ENDLOOP.
ENDLOOP.

Of course you can replace MOVE-CORRESPONDING statement by field assignment (ex: wa_club_ek-ebeln = wa_ekko-ebeln ...) to increase performance ... this was just an example.

Best regards.

Valter Oliveira.

2 REPLIES 2
Read only

Former Member
0 Likes
506

Arun,

Please do according to coding which i have provided in your previous thread.

For example i am giving one line of code here also.

but its your duty to see on which table you will take outer loop.

i am taking INT_EKKO.

Loop at INT_EKKO into WA_EKKO.

WA_CLUB_EK-EBELN = WA_EKKO-EBELN.

Read INT_EKPO into WA_EKPO.

WA_CLUB_EK-MATNR = WA_EKKO-MATNR.

Read INT_EKKN into WA_EKKN.

WA_CLUB_EK-VBELN = WA_EKKN-VBELN.

Apeend WA_CLUB_EK into INT_CLUB_EK.

clear WA_CLUB_EK.

ENDLOOP.

Use this statement for all fields.

BR,

Alok

Read only

valter_oliveira
Active Contributor
0 Likes
507

Hello.

Why did you split and now merge? The best solution was to fill the target table in the moment you have filled the 3 source ones.

However I'll suggest a way to merge the three tables into one.


LOOP AT int_ekko INTO wa_ekko.
  CLEAR wa_club_ek.
  MOVE-CORRESPONDING wa_ekko TO wa_club_ek.
  LOOP AT int_ekpo INTO wa_ekpo WHERE ebeln = wa_ekko-ebeln.
    MOVE-CORRESPONDING wa_ekpo TO wa_club_ek.
    CLEAR wa_ekkn.
*   CLEAR EKKN fields of work area wa_club_ek.
    READ TABLE int_ekkn INTO wa_ekkn
       WITH KEY ebeln = wa_ekko-ebeln
                ebelp = wa_ekpo-ebelp.
    IF sy-subrc EQ 0.
      MOVE-CORRESPONDING wa_ekkn TO wa_club_ek.
    ENDIF.
    APPEND wa_club_ek TO int_club_ek.
  ENDLOOP.
ENDLOOP.

Of course you can replace MOVE-CORRESPONDING statement by field assignment (ex: wa_club_ek-ebeln = wa_ekko-ebeln ...) to increase performance ... this was just an example.

Best regards.

Valter Oliveira.