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

Query

Former Member
0 Likes
749

hi friends,

Could u please send me details how can we write this Query

Once the Batch is selected. Select the process order(AFPO-AUFNR) from the table AFPO where the batch number(CHARG) selected from MSEG equals the batch number(CHARG) from AFPO. Select the total amount(AFKO-GAMNG) where the procress order(AFKO-AUFNR) equals the procress order selected from AFPO.

Regards

srinu

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
708

Hi srinu,

try this code.

data:begin of itab1 occurs 0,

CHARG like MSEG-CHARG,

end of itab1.

data:begin of itab2 occurs 0,

aufnr like afpo-aufnr,

charg like afpo-charg,

end of itab2.

data:begin of itab3 occurs 0,

GAMNG like afko-gamng,

aufnr like afko-aufnr,

end of itab3.

select charg from mseg into table itab1.

select aufnr charg from afpo into table itab2

for all entries in itab1

where charg = itab1-charg.

select GAMNG aufnr from afko into table itab3

for all entries in itab2

where aufnr = itab2-aufnr.

Please reward me if it helps you.

Thanks,

Sowjanya

4 REPLIES 4
Read only

Former Member
0 Likes
708

SELECT AAUFNR, BCHARG, BMATNR, AGMANG

INTO ITAB

FROM AFKO AS A INNER JOIN AFPO AS B

ON AAUFNR = BAUFNR

WHERE B~CHARG = P_CHARG.

Regards

Anurag

Read only

Former Member
0 Likes
708

select *

from mseg

into table it_mseg

where

<your where condition>.

if not_it_mseg[] is initial.

select aufnr

charg

from afpo

into it_afpo

for all entries in it_mseg

where charg = it_mseg-charg.

if not it_afpo[] is initial.

select aufnr

gamng

from afko

into table it_afko

for all entries in it_afpo

where aufnr = it_afpo-aufnr.

endif.

endif.

Regards,

ravi

Read only

Former Member
0 Likes
708

Hello Srinu,

Firstly u have to select unique batch number from MSEG as same batch may be split. Once u have found the batch connect it to the table AFPO. For each unique record found in AFPO select header table AFKO and get collect the qty in field GAMNG.

Read only

Former Member
0 Likes
709

Hi srinu,

try this code.

data:begin of itab1 occurs 0,

CHARG like MSEG-CHARG,

end of itab1.

data:begin of itab2 occurs 0,

aufnr like afpo-aufnr,

charg like afpo-charg,

end of itab2.

data:begin of itab3 occurs 0,

GAMNG like afko-gamng,

aufnr like afko-aufnr,

end of itab3.

select charg from mseg into table itab1.

select aufnr charg from afpo into table itab2

for all entries in itab1

where charg = itab1-charg.

select GAMNG aufnr from afko into table itab3

for all entries in itab2

where aufnr = itab2-aufnr.

Please reward me if it helps you.

Thanks,

Sowjanya