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: 

please correct this code

Former Member
0 Kudos

Hello Experts please solve this

select mblnr into table itab1

from mkpf

where budat in s_budat

and vgart = 'WE'.

select mblnr into table itab2

from mkpf

where budat in s_budat

and vgart = 'WO'.

I modified the above query as

select mblnr into table itab1

from mkpf

where budat in s_budat

and ( vgart = 'WE'or vgart = 'WO').

Now please tell me how to modify the below query because we have to select data only from itab1 entries.But in above we selected vgart = 'wo' into itab1.

select mblnr matnr bwart menge into table lt_menge

from mseg

for all entries in itab1.

where mblnr = lt_we-mblnr

and matnr = it_temp-matnr

and werks = p_werks

and bwart in ('501', '502').

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

if u have to select the values from itab where vgart = 'WE' only then you have to add the field vgart in the itab1.

select mblnr vgart into table itab1

from mkpf

where budat in s_budat

and vgart in ( 'WE' , 'WO' ).

select mblnr matnr bwart menge into table lt_menge

from mseg

for all entries in itab1

where mblnr = lt_we-mblnr

and matnr = it_temp-matnr

and werks = p_werks

and bwart in ('501', '502')

and vgart = 'WE'.

All the best !!

Regards

Aparna

Message was edited by:

Paluri Aparna

3 REPLIES 3

Former Member
0 Kudos

Change your code as below:

select mblnr 
into table itab1
from mkpf
where budat in s_budat
and vgart in ('WE', 'WO').

if not itab1 is initial.
select mblnr matnr bwart menge 
into table lt_menge
from mseg
for all entries in itab1
where mblnr = ltab1-mblnr
and matnr = it_temp-matnr
and werks = p_werks
and bwart in ('501', '502'). 
endif.

Former Member
0 Kudos

Hi,

if u have to select the values from itab where vgart = 'WE' only then you have to add the field vgart in the itab1.

select mblnr vgart into table itab1

from mkpf

where budat in s_budat

and vgart in ( 'WE' , 'WO' ).

select mblnr matnr bwart menge into table lt_menge

from mseg

for all entries in itab1

where mblnr = lt_we-mblnr

and matnr = it_temp-matnr

and werks = p_werks

and bwart in ('501', '502')

and vgart = 'WE'.

All the best !!

Regards

Aparna

Message was edited by:

Paluri Aparna

Former Member
0 Kudos

Hi Shiva,

Can try this:

Define another table say it_tab_we like itab1.

Now ur first query:

select mblnr into table itab1

from mkpf

where budat in s_budat

and vgart in ( 'WE', 'WO')..

if sy-subrc = 0.

  • Copy the content of itab1 into it_tab_we

it_tab_we[] = itab1[].

  • Now delete all the entries from it_tab_we which are not WE

Delete from it_tab_we where vgart <> 'WE'. "Check the syntax

  • Now use it_tab_we as the driver table and use for all entries on it to extract data * from MSEG - For better performance U can sort it_tab_we by mblnr

select mblnr matnr bwart menge into table lt_menge

from mseg

for all entries in it_tab_we

where mblnr = it_tab_we -mblnr

and matnr = it_temp-matnr

and werks = p_werks

and bwart in ('501', '502').

endif.

Please close the thraed if the problem is solved.