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: 

Creation of SAP Query in SQ02 with Single Table With Condition

0 Kudos
181

Hi All,

I want to Create SAP Query in SQ02 using single Table MCHA.

ii) I dont want all entries of MCHA Table I mean , I have to apply some Condition on this Table.

i.e Suppose I am having actual data in MCHA table is like this for Material M1.

Plant Material Batch BatchCreationdate

P1 M1 B1 20.06.2007

P2 M1 B1 04.05.2009

P3 M1 B1 04.05.2009

But I want the Output of SAP Query is like this:

Material Batch BatchCreationdate

M1 B1 20.06.2007

That is irrespective of Plant if Material & Batch are equal ---> 1st record with Lowest date shoud get at the output.

Please help me How write the code on single table in the SAP Query.

Thanks,

Kiran Manyam

1 REPLY 1

Former Member
0 Kudos
60

Hi,

Your query should be like this:

Select MATNR CHARG HSDAT

from MCHA

into table t_mcha

where matnr = Materlal number from selection screen.

The structure of t_mcha should contain the fields that you select.

Then sort the table by date ascending

Sort t_mcha by HSDAT.

Hope this solves your problem.

Thanks,

Sowmya