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

Select Statement problem?

Former Member
0 Likes
481

Hi friends i want to know wht is the difference between MBLNR IN V_MA_NOS and wht is MBLNR = MKPF-MBLNR AND WERKS = V_PLANT AND BWART IN V_MO_TY AND LIFNR IN V_VENDOR. I mean i want to know how the records are selected. My original two select statements are....

SELECT * FROM MKPF WHERE MBLNR IN V_MA_NOS AND BLDAT IN V_D_DATE.

SELECT * FROM MSEG WHERE MBLNR = MKPF-MBLNR AND WERKS = V_PLANT AND BWART IN V_MO_TY AND LIFNR IN V_VENDOR.

Thks

4 REPLIES 4
Read only

Former Member
0 Likes
459

hi Venkat,

The first select statement fetches the data from MKPF based on MBLNR and BLDAT for the given ranges/select-options V_MA_NOS & V_D_DATE

SELECT * FROM MKPF WHERE MBLNR IN V_MA_NOS AND BLDAT IN V_D_DATE.

llarly the second select statement fetches the data from MSEG based on WERKS, BWART & LIFNR for a given values in V_PLANT, V_MO_TY & V_VENDOR.

SELECT * FROM MSEG WHERE MBLNR = MKPF-MBLNR AND WERKS = V_PLANT AND BWART IN V_MO_TY AND LIFNR IN V_VENDOR.

Read only

Former Member
0 Likes
459

Hi ,

MBLNR = MKPF-MBLNR is used when you matches your condition with a single value i.e. parameter.

while BWART IN V_MO_TY is used when you want to match your condition to a range i.e. select-option

reward if helpful

Read only

Former Member
0 Likes
459

Hi,

if you use IN condition , it will fetch the data for the range( set of values in V_MA_NOS ).

if it is MBLNR = MKPF-MBLNR , records matching the MBLNR is selected. ie for one value of MBLNR there can be one or more records matching MBLNR in MSEG

Regards,

Madhu

Read only

kiran_k8
Active Contributor
0 Likes
459

Venkat,

V_MA_NOS might be select-options in the selection screen which will have a range of values or it can be a range declared in the program.

MBLNR IN V_MA_NOS will see to that the select query will consider only those MBLNRs which are declared in that range.

The same with BWART IN V_MO_TY AND LIFNR IN V_VENDOR. ie only the valuation types and vendors declared in that range will only be considered.

MBLNR = MKPF-MBLNR

Here all the MBLNRs in the table MKPF will be considered for further processing.

WERKS = V_PLANT

Here V_PLANT is a parameter declared in the selection screen,ie if you have entered XX as plant in the selection screen it will fetch only those records related to that plant only.

You can even initialize this V_PLANT in the program too.

K.Kiran.