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 tables

Former Member
0 Likes
719

hi,

i have 4 internal tables.i want total data put to 5th internal table?how?

7 REPLIES 7
Read only

Former Member
0 Likes
693

hi,

u have to merge data by common fields.

Do u want to make 5 th table by checking some field?

Means want to put data according to some field?

Try like this,

DATA:BEGIN OF TAB1 OCCURS 0,

EBELN LIKE EKPO-EBELN,

MATNR LIKE EKPO-MATNR,

MBLNR LIKE MSEG-MBLNR,

WERKS LIKE EKPO-WERKS,

MAKTX LIKE MAKT-MAKTX,

BUDAT LIKE MKPF-BUDAT,

MENGE LIKE EKPO-MENGE,

NETPR LIKE EKPO-NETPR,

MTART LIKE EKPO-MTART,

END OF TAB1.

DATA:BEGIN OF TAB3 OCCURS 0,

MENGE1 LIKE EKPO-NETPR,

EBELN LIKE EKPO-EBELN,

MATNR LIKE EKPO-MATNR,

END OF TAB3.

DATA:BEGIN OF TAB4 OCCURS 0,

EBELN LIKE EKPO-EBELN,

MATNR LIKE EKPO-MATNR,

MBLNR LIKE MSEG-MBLNR,

WERKS LIKE EKPO-WERKS,

MAKTX LIKE MAKT-MAKTX,

BUDAT LIKE MKPF-BUDAT,

MENGE LIKE EKPO-MENGE,

NETPR LIKE EKPO-NETPR,

MTART LIKE EKPO-MTART,

END OF TAB4.

LOOP AT TAB1.

TAB4-MATNR = TAB1-MATNR.

TAB4-MAKTX = TAB1-MAKTX.

TAB4-EBELN = TAB1-EBELN.

TAB4-MBLNR = TAB1-MBLNR.

TAB4-BUDAT = TAB1-BUDAT.

TAB4-WERKS = TAB1-WERKS.

TAB4-MENGE = TAB1-MENGE.

TAB4-MTART = TAB1-MTART.

LOOP AT TAB3.

IF TAB1-EBELN = TAB3-EBELN.

TAB4-NETPR = TAB3-MENGE1.

ENDIF.

ENDLOOP.

APPEND TAB4.

ENDLOOP.

Hope it will b useful.

Otherwise u can simply use move-corresponding, if u dont want to compare fields.

null

Read only

Former Member
0 Likes
693

Hi,

use

move-corresponding itab1 to itab2.

<b><REMOVED BY MODERATOR></b>

Regards,

Bindu.

Message was edited by:

Alvaro Tejada Galindo

Read only

Former Member
0 Likes
693

if the four internal tables have the same structure,

then use like

itab5 = itab1itab2itab3+itab4.

<b><REMOVED BY MODERATOR></b>

Message was edited by:

Alvaro Tejada Galindo

Read only

Former Member
0 Likes
693

Hi,

First find out which is the biggest table and common field for all internal table.

Then move the biggest table fields to one work area.

Get the other table fields corresponding to the biggest table work area with the use of comman field.

You can easily merge all 4 r 5 internal table with respect to common field.

Thanks,

Sakthi.

Read only

Former Member
0 Likes
693

Hello,

U have to create 5th internal table with all the fields that u have in other internal tables.

Then u can use

MOVE-CORRESPONDING keyword for moving data from 1 itab to other.

like this

MOVE-CORRESPONDING itab1 TO itab5

MOVE-CORRESPONDING itab2 TO itab5

MOVE-CORRESPONDING itab3 TO itab5

MOVE-CORRESPONDING itab4 TO itab5

<b><REMOVED BY MODERATOR></b>

Regards,

LIJO

Message was edited by:

Alvaro Tejada Galindo

Read only

Former Member
0 Likes
693

Hi,

Refer to the following code:

SELECT MBLNR MJAHR BUDAT1 ETIME FROM ZGEXIT INTO TABLE ITAB WHERE

MBLNR = IMBLNR AND MJAHR = IMJAHR.

IF SY-SUBRC = 0.

SELECT MBLNR MJAHR WERKS LGORT FROM MSEG

INTO CORRESPONDING FIELDS OF table ITAB1

for all entries in ITAB

WHERE MBLNR = ITAB-MBLNR AND MJAHR = ITAB-MJAHR.

SELECT MBLNR MJAHR BUDAT OIB_BLTIME FROM MKPF INTO CORRESPONDING

FIELDS OF table ITAB2 for all entries in itab

WHERE MBLNR = ITAB-MBLNR

AND MJAHR = ITAB-MJAHR.

ENDIF.

ENDIF.

sort itab1 by mblnr mjahr.

sort itab2 by mblnr mjahr.

Loop at itab.

read table itab1 with key mblnr = itab-mblnr

mjahr = itab-mjahr binary search.

if sy-subrc = 0.

move-corresponding itab1 to itab.

endif.

read table itab2 with key mblnr = itab-mblnr

mjahr = itab-mjahr binary search.

if sy-subrc = 0.

move-corresponding itab2 to itab.

endif.

modify itab transporting WERKS LGORT BUDAT OIB_BLTIME.

clear: itab, itab1, itab2.

Endloop.

Hope this helps.

<b><REMOVED BY MODERATOR></b>

Regards,

Sipra

Message was edited by:

Alvaro Tejada Galindo

Read only

sivaprasad_ml
Participant
0 Likes
693

make a loop for all tables individually and append the datas into 5th table.

regards

Siva