Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Shortest way to retrieve from KONM Table


Can anyone tell me how to write a query for, the shortest and quickest way to retrieve the data from KONM Table?

Sample Record in the KONM Table will be as given below.


007......... 1 .......... 50

007......... 11 ........ 45

007......... 55 .........40


When i give my input Quantity (KSTBM) as 4, i should get the price (KBETR) as 50. i.e., input quantity between 1 to 10 is 50. Input Quantity between 11 and 54 is 45. Anything Greater than 55 to next greater quantity is 40,...

Is there any function module available to retrieve the record?

Also best optimized logic, will be given a full mark.


Hello Vijay

I am assuming that you have value in KNUMH with you...

here's the idea in brief..

select the values.. sort by quantity descending.. then populate a range with LE option... the first entry in the interal table which meets the condition is the value u require..

Sort of Pseudo code:

ranges: r_kstbm for kstbm.

r_kstbm-sign = 'I'.

r_kstbm-option = 'LE'.

r_kstbm-low = p_kstbm. <your quantity value comes here>

select <your fields> from KONM into table i_konm where KNUMH eq p_knumh.

if sy-subrc = 0.

sort i_konm by kstbm descending.

loop at i_knom where kstbm in r_kstbm.

<The price required> = i_konm-kbetr.




Message was edited by:

Arun Nair

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question