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: 

internal table

Former Member
0 Kudos

hi,

i want to pass a data from different internal table into single internal table like i had a data in ekko,ekpo,stxh...iam picking the data from this table into different internal tables...now i want to pass all the datas from different internal table into one internal table ..plz tel me how to do it...

8 REPLIES 8

GauthamV
Active Contributor
0 Kudos

hi,

check this sample code.

here t_outtab is final internal table which is defined with fields from diff tables.

LOOP AT t_ekko .

t_outtab-ebeln = t_ekko-ebeln .

t_outtab-bukrs = t_ekko-bukrs .

t_outtab-bsart = t_ekko-bsart .

t_outtab-aedat = t_ekko-aedat .

t_outtab-ekorg = t_ekko-ekorg .

t_outtab-ekgrp = t_ekko-ekgrp .

t_outtab-bedat = t_ekko-bedat .

t_outtab-kdatb = t_ekko-kdatb .

t_outtab-kdate = t_ekko-kdate .

t_outtab-lifnr = t_ekko-lifnr .

t_outtab-ernam = t_ekko-ernam .

t_outtab-waers = t_ekko-waers.

t_outtab-frgke = t_ekko-frgke .

t_outtab-frgsx = t_ekko-frgsx .

CLEAR t_ekpo.

READ TABLE t_ekpo WITH KEY ebeln = t_outtab-ebeln

BINARY SEARCH .

IF sy-subrc = 0 .

t_outtab-txz01 = t_ekpo-txz01 .

t_outtab-netwr = t_ekpo-netwr .

t_outtab-werks = t_ekpo-werks .

t_outtab-matkl = t_ekpo-matkl .

t_outtab-poqty = t_ekpo-menge .

t_outtab-netpr = t_ekpo-netpr .

ENDIF .

READ TABLE t_lfa1 WITH KEY lifnr = t_outtab-lifnr

BINARY SEARCH .

IF sy-subrc = 0.

t_outtab-name1 = t_lfa1-name1 .

ENDIF .

READ TABLE t_eket WITH KEY ebeln = t_ekpo-ebeln

ebelp = t_ekpo-ebelp

BINARY SEARCH.

IF sy-subrc = 0 .

READ TABLE it_tax WITH KEY

ebeln = t_ekko-ebeln.

  • ebelp = t_ekko-ebelp.

IF sy-subrc = 0.

  • IF NOT it_tax-mwskz IS INITIAL.

READ TABLE it_kwert WITH KEY

ebeln = it_tax-ebeln

kposn = it_tax-ebelp

knumv = it_tax-knumv

mwsk1 = it_tax-mwskz

BINARY SEARCH.

IF sy-subrc = 0.

t_outtab-kwert = it_kwert-kwert.

ENDIF.

ENDIF.

ENDIF .

READ TABLE t_ekbe WITH KEY ebeln = t_ekpo-ebeln

ebelp = t_ekpo-ebelp.

IF sy-subrc = 0 .

t_outtab-deliv = t_ekbe-wrbtr .

ENDIF .

READ TABLE it_ekkn WITH KEY ebeln = t_outtab-ebeln

BINARY SEARCH .

IF sy-subrc = 0 .

t_outtab-sakto = it_ekkn-sakto .

t_outtab-kostl = it_ekkn-kostl .

endif.

READ TABLE it_essr WITH KEY ebeln = t_outtab-ebeln

BINARY SEARCH .

READ TABLE it_esll WITH KEY packno = t_ekpo-packno

BINARY SEARCH .

IF sy-subrc = 0 .

READ TABLE it_esll1 WITH KEY packno = it_esll-sub_packno

BINARY SEARCH .

if sy-subrc = 0.

t_outtab-menge = it_esll1-menge .

t_outtab-ktext1 = it_esll1-ktext1 .

t_outtab-frmval1 = it_esll1-frmval1 .

t_outtab-frmval2 = it_esll1-frmval2 .

endif.

endif.

t_outtab-sdelv = t_outtab-netwr - t_outtab-deliv .

APPEND t_outtab .

CLEAR t_outtab .

CLEAR it_tax.

CLEAR it_kwert.

clear t_ekbe.

ENDLOOP .

Former Member
0 Kudos

Hi

use joins...

First know about what is inner join

The data that can be selected with a view depends primarily on whether the view implements an inner join or an outer join. With an inner join, you only get the records of the cross-product for which there is an entry in all tables used in the view. With an outer join, records are also selected for which there is no entry in some of the tables used in the view. The set of hits determined by an inner join can therefore be a subset of the hits determined with an outer join.

Example for Inner join:

SELECT AEBELN ALIFNR AKNUMV BEBELP BNETWR BNETPR BWERKS BMATNR

LNAME1 LNAME2

FROM EKKO AS A

INNER JOIN EKPO AS B ON AEBELN = BEBELN

INNER JOIN LFA1 AS L ON LLIFNR = ALIFNR

  • INNER JOIN EKKN AS C ON CEBELN = AEBELN

INTO CORRESPONDING FIELDS OF TABLE itab

WHERE B~BUKRS = 'company code' .

Left outer join

Usually, when defining InfoSets, the objects are linked via inner join operators. However, you can also use left outer joins. Inner join and left outer join are only different in the situation where one of the involved tables does not contain any suitable record which meets the join conditions.

With an inner join (table 1 inner join table 2), no record is included in the result set in this case. However, this means that the corresponding record from tables 1 is not considered in the results set.

With an left outer join (table 1 left outer join table2), exactly one record is included in the results set in this case´. In this record, the fields from table 1 contain the values of the record from table 1 and the fields from table 2 are all filled with the initial value.

Example of left outer join:

DATA: CUSTOMER TYPE SCUSTOM,

BOOKING TYPE SBOOK.

SELECT SCUSTOMNAME SCUSTOMPOSTCODE SCUSTOM~CITY

SBOOKFLDATE SBOOKCARRID SBOOKCONNID SBOOKBOOKID

INTO (CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,

BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,

BOOKING-BOOKID)

FROM SCUSTOM LEFT OUTER JOIN SBOOK

ON SCUSTOMID = SBOOKCUSTOMID AND

SBOOK~FLDATE = '20081015'

ORDER BY SCUSTOMNAME SBOOKFLDATE.

WRITE: / CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,

BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,

BOOKING-BOOKID.

ENDSELECT.

Former Member
0 Kudos

Hi,

Loop the header table, and Read the dependent table on key and push the relevant data to the FINAL internal table, as append at last.

So the Final table will be your resulted and wanted table.

Former Member
0 Kudos

hi,

1) open a new internal table with loop and endloop.

2) Read internal table whichever you want to do

3) append the data from the internal table to new internal table.

Regards

R.Rajendran

Former Member
0 Kudos

Hi,

Put some fields aommon in all internal table structure .

then loop at first internal table and put append the records at the final internal table .

After doing append loop at the final internal table and read the corresponding records from the second internal table using read statement with key addition of some common fields and then modify the final internal table by keeping the MODIFY statement inside the loop.

do the second step for each table and prepare the final intrnal table.

If any issues you can get back to me.

I hope this will help you.

Help children of U.N World Food Program by rewarding points and encourage others to answer your queries.

Former Member
0 Kudos

Hi,

1. First u create the new internal table with the required fields.

2. LOOP AT t_ekko and depending upon the condition LOOP AT next internal table and then Third internal table . Here u append the record to the new internal .

Former Member
0 Kudos

Hi Friend,

First you create your internal tablle with all the required fields.

Now write a select query all the three tables using INNER JOIN and move the data into your final table.

I cannot give you the code, because it is against the rules and you never expect so. Try it.

Hope this helps you.

Any queries, get back.

Regards,

Chandra Sekhar

Former Member
0 Kudos

check this simple example.....

read the table with keyfield...

tables:mara,marc.

data:begin of itab occurs 0,

matnr like mara-matnr,

end of itab.

data:begin of itab1 occurs 0,

matnr like marc-matnr,

werks like marc-werks,

end of itab1.

select matnr

from mara

into corresponding fields of table itab.

if itab is initial.

select matnr

werks

from marc

into table itab1

for all entries in itab

where matnr = itab-matnr.

loop at itab1.

read table itab with key matnr = itab-matnr.

write:/ itab1-matnr,itab1-werks.

endloop.

endif.