Hi All,
Thank you very much for responding me with your views and comments.
@ Athimoolam
Client want to create PR based on selected SO line items also, so it is required to have range of selected line item numbers.
@ Schek
Yes, you are right, sorting will resolve my issue, but I wanted to know why select query is fetching records in shuffled order. I already mentioned that the scenario is replicating in development and quality systems.
@ Matthew and Raj
Thank you for your comments as well.
At last after analyzing the table VBAP in production system for once specific sales order, I found two fields ERDAT and EADAT.
ERDAT is record creation date and EADAT is record change date.
If we have same dates in ERDAT and no dates in EADAT for all line items of a sales order, then select statement will not shuffle the records.
If we append line items on later dates to the existing sales order, then select statement will shuffle the records.
If we change the line items on later dates than it creation dates, then also select statement will shuffle the records
And this shuffling will be as per the ERDAT and EADAT dates.
This resolved my issue of understanding why select statement is shuffling line items.
and we all know that SORTING internal table BY POSNR, will again make the sequence of line items same as SO line items.
regards
Aslam