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: 

ABAP select query

0 Kudos
612

Hi,

Is below select query is correct to fetch data from MSEG for MSEG-MATNR = 200000003,

After executing the select statement getting zero records, but for same value when I check at table level records exists.

SELECT *
FROM MSEG
INTO TABLE @DATA(IT_MSEG1)
where WERKS = 'US01'
AND BUDAT_MKPF GE @I_FKDATLOW
AND BUDAT_MKPF LE @I_FKDATHIGH
AND MATNR = '200000003'
AND BWART = '531'
4 REPLIES 4

Abhishek_10
Participant
563

user conversion exit alpha input to convert matnr from 200000003 to 200000003 preceded with zeroes similar to what you see in se11/se16n. And then you send that data in where condition of select.

GADKE
Explorer
0 Kudos
563

I would suggest to check the exact condition on the Table level. Using "BETWEEN" statement in the condition for the date could also be useful for getting the date for the Date range.

Sandra_Rossi
Active Contributor
563

So, you are recommending the OP to use

       AND BUDAT_MKPF BETWEEN @I_FKDATLOW AND @I_FKDATHIGH

instead of

       AND BUDAT_MKPF GE @I_FKDATLOW
       AND BUDAT_MKPF LE @I_FKDATHIGH

That's good, but that's not answering the question.

Sandra_Rossi
Active Contributor
0 Kudos
563

You say "when I check at table level records exists."

You need to understand the concept of Conversion Exit at the DDIC Domain (SE11) level = difference between external (display) and internal (database) value. See the conversion exit in the domain MATNR.

Solution is given by Abhishek ("alpha input to convert matnr from 200000003 ...").

See forum and ABAP documentation for more information about Conversion Exits.