06-30-2014 5:32 PM
Hi Experts, Data is selected from VBKPF table based on previous month posting date range.Here data not coming as primary key sorted, It is very urgent to know why its not coming as primary key sorted, i checked indexes but not found. SELECT * FROM vbkpf INTO TABLE it_vbkpf WHERE budat IN s_budat
06-30-2014 5:50 PM
This table not has the month as key and index. (In my SAP version)
The date available in the key is the year.
If you realy need to select this table using month, create a index (ask if possible to basis team and explain the reason). In your index you can use these fields:
BUKRS
GJAHR
BUDAT
07-01-2014 11:00 AM
Hi Teixeira, Data is required as sorting form of primery keys ( Mandt ausbk bukrs belnr gjahr), it will automaticaly come because we selected from data base table(VBKPF) but here not coming automatically, that is the problem.
07-01-2014 1:01 PM
Hi Prasad,
there's a way to get from selection the fields sorted regarding your specific requirement.
Declare a internal table using this:
DATA it_vbkpf TYPE SORTED TABLE OF vbkpf WITH UNIQUE KEY feld1 field2.
or
DATA it_vbkpf TYPE SORTED TABLE OF vbkpf WITH NON-UNIQUE KEY feld1 field2.
After this apply your selection into table it_vbkpf
07-01-2014 1:20 PM
Hi Teixeira,
Thanks for you reply,
I know that one, They want reason why data coming as with out sorting of primary key fields.
Normally if we select data from database it will come primary key based sorted data,
In my case why its not coming like that....
07-01-2014 1:26 PM
Hello Prasad,
If you pass primary key field as where clause then you will get sorted order which is exist in DB sequence order.
If you pass non primary key as where clause then you wont get the exact primary key order.
In his case you can sort the internal table.
Regards,
Vadamalai A.
07-01-2014 1:35 PM
Prasad,
i always use key or index to select table, but i made a test code using your example (only budat in where condition and internal table TYPE TABLE OF) and works fine for me, the key fields are sorted after selection.
tables vbkpf.
select-options s_budat for vbkpf-budat.
data ti_vbkpf type table of vbkpf.
select * from vbkpf into table ti_vbkpf where budat in s_budat.
Check the complete index fields values (sorted) and budat not:
Please, let me know if using this template you have the key fields sorted.
07-01-2014 2:05 PM
Hi Prasad,
My take is you are not guaranteed an ordered set of results.
Just add an "ORDER BY ..." to your select statement to assure order.
(See the SELECT help for details)
...Mike
07-01-2014 4:12 PM
the fact that this are key fields dont mean they are sorted, isnt it? It just means they are unique. I guess that the sorting of lines in the table VBKPF is exactly what you get in your internal table after your selection.
did you check this?
regards
Stefan Seeburger