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

retrieving data into internal table

Former Member
0 Likes
826

Hi,

I am struck at a point where i have to retrieve data from 4 database table to a single internal table with some conditions. can anyone please help me in resolving this issue. your help will be highly appreciated.

some details are: tables used are-linv,mch1,makt,ausp.

data: begin of t_outtab,--


final internal table.---output to be displayed

lgnum LIKE linv-lgnum,

ivnum LIKE linv-ivnum,

werks LIKE linv-werks,

lgtyp LIKE linv-lgtyp,

matnr LIKE linv-matnr,

bestq LIKE linv-bestq,

charg LIKE linv-charg,

maktx LIKE makt-maktx,

vfdat LIKE mch1-vfdat,

atwrt LIKE ausp-atwrt,

END OF t_outtab.

input parameters:-- linv-lgnum and linv-ivnum.

conditions:1. Where MAKT-MATNR = LINV-MATNR and MAKT-SPRAS = ‘logon language user’

2. Where MCH1-CHARG = LINV-CHARG AND MCH1-MATNR = LINV-MATNR)

3. SELECT AUSP-ATWRT Where AUSP-OBJEK = MCH1- CUOBJ_BM and MCH1-CHARG = LINV-CHARG AND MCH1-MATNR = LINV-MATNR

Regards

Victor

8 REPLIES 8
Read only

Former Member
0 Likes
786

Hi,

Try using Join statement..but do take care of performance in that case.

Read only

Former Member
0 Likes
786

Hi,

What is your problem..

The way you wrote the issues seems not much useful for replying your question..

Be more clear ..

One thing I can say is..

First you have to collect data into four different internal tables and the depending on the key you can finally put them into one internal table..You can use For all entries when retrieving data ..

Using inner join may effect the performance..

reward points if useful

Regards

nazeer

null

Read only

0 Likes
786

hi,

i have to use all the conditions to retrive the data in the outtab table using lgnum and ivnum as parameters given by the user.

can u please help me in resolving this issue.

regards

Victor

Read only

Former Member
0 Likes
786

Hi

Use Inner join statement if only one select query has to be written.

But try to split into two itab & then use them, otherwise it will affect performance

Thanks

Sandeep

Reward if helpful

Read only

0 Likes
786

Hi,

thankyou a lot in trying to resolve my issue. can u please write the code for retrieving data in outtab using all the conditions.

thanks & regards

Victor

Read only

Former Member
0 Likes
786

Hi,

select linv~lgnum

linv~ivnum

linv~werks

linv~lgtyp

linv~matnr

linv~bestq

linv~charg

makt~maktx

mch1~vfdat

ausp~atwrt

from linv as linv inner join makt as makt

inner join mch1 as mch1 inner join ausp as ausp

into table t_outtab

where MAKTMATNR = LINVMATNR

and MAKT-SPRAS eq sy-uname

and MCH1CHARG = LINVCHARG

AND MCH1MATNR = LINVMATNR

and AUSPOBJEK = MCH1CUOBJ_BM and MCH1CHARG = LINVCHARG AND MCH1MATNR = LINVMATNR.

regards,

kiran kumar k

Read only

Former Member
0 Likes
786

Hi Victor,

data: begin of t_outtab,--


final internal table.---output to be displayed

lgnum LIKE linv-lgnum,

ivnum LIKE linv-ivnum,

werks LIKE linv-werks,

lgtyp LIKE linv-lgtyp,

matnr LIKE linv-matnr,

bestq LIKE linv-bestq,

charg LIKE linv-charg,

maktx LIKE makt-maktx,

vfdat LIKE mch1-vfdat,

atwrt LIKE ausp-atwrt,

END OF t_outtab.

<b>SELECT</b>

linv~lgnum,

linv~ivnum,

linv~werks,

linv~lgtyp,

linv~matnr,

linv~bestq,

linv~charg,

makt~maktx,

mch1~vfdat,

ausp~atwrt,

<b>FROM ( ( ( LINV JOIN MAKT ) ON</b>

MAKTMATNR = LINVMATNR

<b> INNER JOIN MCH1 ) ON</b>

MCH1CHARG = LINVCHARG AND

MCH1MATNR = LINVMATNR

<b> INNER JOIN AUSP ) ON</b>

AUSPOBJEK = MCH1 CUOBJ_BM

MCH1CHARG = LINVCHARG

MCH1MATNR = LINVMATNR

<b>where MAKT-SPRAS = ‘logon language user’.</b>

Read only

Former Member
0 Likes
786

select <data fields> into it_linv from LINV where LGNUM = linv-lgnum and IVNUM = linv-ivnum.

select <data fields> into it_mch1 from mch1 as a inner join makt as b on aMATNR = bMATNR for all entries of it_linv where amatnr = it_linv-matnr and acharg = it_linv-charg and b~langu = sy-langu.

select <data fields> into it_ausp from ausp for all entries of it_mch1 where AUSP-OBJEK = it_mch1- CUOBJ_BM.

now loop it_linv and use read statement for it_mch1, it_ausp and move data to final table..

Reward and close duplicate threads.