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

Condition record selection for MATNR

Former Member
0 Likes
1,751

Hi Experts,

I'm selecting the Condition Record Number(a505-knumh) for a Material Number like this.,(I want the record number whose validity date should be greater than today's date and whose begin date should be less than today's date.)

<b> select knumh from a505 into i_price-knumh

where kappl = 'V'

and kschl = 'ZR10'

and vkorg = '1000'

and pltyp = '01'

and matnr = itab-matnr

and datbi >= sy-datum

and datab <= sy-datum.</b>

But when I see the table a505, there are 3 records(knumh) for that material number (for eg: MATNR = 100813) like this:

-KAPPL|KSCHL |VKORG |PLTYP|MATNR|DATBI|DATAB |KNUMH|

-


V |ZR10|1000|01|100813 |11/30/1992|08/01/1989|0000037438|

V |ZR10|1000|01|100813 |04/07/1996|12/01/1992|0000037439|

V |ZR10|1000|01|100813 |12/31/2039|04/08/1996|0000042185|

-


My problem is: When i'm selecting the record like this, it should display the 3rd record as my value.

but it is showing up the wrong values.

plz tell me what is the wrong with the selection statement.

thnx,

Message was edited by: dev a

Message was edited by: dev a

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,273

it is pooled table

Hi Experts,

I'm selecting the Condition Record Number(a505-knumh) for a Material Number like this.,(I want the record number whose validity date should be greater than today's date and whose begin date should be less than today's date.)

<b> select knumh from a505 into i_price-knumh

where kappl = 'V'

and kschl = 'ZR10'

and vkorg = '1000'

and pltyp = '01'

and matnr = itab-matnr

and datbi >= sy-datum

and datab <= sy-datum.</b>

But when I see the table a505, there are 3 records(knumh) for that material number (for eg: MATNR = 100813) like this:

-KAPPL|KSCHL |VKORG |PLTYP|MATNR|DATBI|DATAB |KNUMH|

-


V |ZR10|1000|01|100813 |11/30/1992|08/01/1989|0000037438|

V |ZR10|1000|01|100813 |04/07/1996|12/01/1992|0000037439|

V |ZR10|1000|01|100813 |12/31/2039|04/08/1996|0000042185|

-


My problem is: When i'm selecting the record like this, it should display the 3rd record as my value.

but it is showing up the wrong values.

plz tell me what is the wrong with the selection statement.

thnx,

Message was edited by: dev a

Message was edited by: dev a

5 REPLIES 5
Read only

Former Member
0 Likes
1,273

Hi Dev,

Your selection statement is good.But i dont have a table a505,so am wondering how are you selecting data from that table.

Read only

Former Member
0 Likes
1,274

it is pooled table

Read only

Former Member
0 Likes
1,273

try to select with all the key fields in where condition

Read only

Former Member
0 Likes
1,273

This Select works fine for me.

Try once again. The fields in the table and the where

condition should be in the same order.

Or else.

Select all entries (without the date condition) into

an internal table.

Sort the Internal table by datbi descending.

and delete adjacent duplicates comparing ...

this will pick U the latest record.(U also want the

latest record , Since there are no Overlaps in the

records U'll have only one record for any given date )

Read only

Former Member
0 Likes
1,273

Hi Dev,

Are you looping internal table itab?

If you are then each loop the program will overwrite the internal table i_price with the new value. In other word,

you only get the last value from the select statment result.

Please try like the following example instead of looping internal table itab.

SELECT * FROM A306

INTO CORRESPONDING FIELDS OF TABLE T_HEADER_A306

FOR ALL ENTRIES IN ITAB_KSCHL

WHERE KSCHL EQ ITAB_KSCHL-KSCHL AND

KSCHL IN KSCHL AND

VKORG IN P_1 AND

VTWEG IN P_2 AND

PLTYP IN L_1 AND

WAERK IN H_1 AND

MATNR IN L_3 AND

KFRST IN L_2 AND

DATAB >= DATLOW AND

DATAB <= DATHIGH AND

KAPPL = 'V'.

Hope this will help.

Regards,

Ferry Lianto