2011 Dec 05 4:10 PM
Hi,
it try to get the data from mara ordered by the select-option, is this possible.
Normally i use:
TABLES: MARA.
*
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
*
select * from mara where matnr in s_matnr.
write: / mara-matnr.
endselect.
Is there any FM, BAPI or any parameter for "ORDER BY" which i get use?
Thanks.
Regards, dieter
Hi,
it try to get the data from mara ordered by the select-option, is this possible.
Normally i use:
TABLES: MARA.
*
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
*
select * from mara where matnr in s_matnr.
write: / mara-matnr.
endselect.
Is there any FM, BAPI or any parameter for "ORDER BY" which i get use?
Thanks.
Regards, dieter
2011 Dec 06 3:51 AM
hi
change the select query like this:
select * from mara where matnr in s_matnr ORDER BY matnr.
If you are not using order by clause in select query by default it takes sorted values from table.
Regards,
Priyanka
2011 Dec 06 5:25 AM
Deiter,
your question is not very clear. what do you mean by order by select option?
2011 Dec 06 8:07 AM
Hi,
thanks for your answer.
What i mean is this:
In selection screen i insert this value: 3, 2, 4, 1.
the output is 1, 2, 3, 4, but i will get this: 3, 2, 4, 1 like my selection.
Is this possible?
Regards, Dieter
2011 Dec 06 8:13 AM
Not possible through select query - Read SAP help. Try to do it in the coding if required.
2011 Dec 06 9:13 AM
Hi ,
Use ascending /descing in query.
select * from mara where matnr in s_matnr ORDER BY matnr descending
OR
select * from mara where matnr in s_matnr ORDER BY matnr asceneding
As per requirement.
regards,
Praphull
Edited by: T Praphull on Dec 6, 2011 10:27 AM
2011 Dec 06 9:30 AM
hi
you can use asc or desc :-
select <field > from mara order by <field> asc/desc.
by default it is asc thats why u were gertting 1 2 3 4 like that.
hope this helps ..
regards ,
somesh
2011 Dec 06 9:43 AM
2011 Dec 06 2:42 PM
It would be pretty difficult to do even with coding.
What do you do if the user has entered patterns, or exclusions or NEs?
Rob
2011 Dec 06 3:12 PM
Just for the fun
TABLES: mara.
* data def
DATA: t1_mara TYPE TABLE OF mara WITH HEADER LINE,
t2_mara TYPE TABLE OF mara WITH HEADER LINE,
s2_matnr TYPE RANGE OF mara-matnr.
* selection screen
SELECT-OPTIONS so_matnr FOR mara-matnr.
START-OF-SELECTION.
* load wholde data in temp itab
SELECT * INTO TABLE t1_mara FROM mara
WHERE matnr IN so_matnr
ORDER BY matnr.
* now final itab
REFRESH t2_mara.
* for every Include select option, process its own records
LOOP AT so_matnr WHERE sign = 'I'.
REFRESH s2_matnr.
APPEND so_matnr TO s2_matnr.
LOOP AT t1_mara WHERE matnr IN s2_matnr.
APPEND t1_mara TO t2_mara.
DELETE t1_mara.
ENDLOOP.
ENDLOOP.
* If there is no "I" records,
IF t1_mara[] IS NOT INITIAL.
APPEND LINES OF t1_mara TO t2_mara.
ENDIF.
* free memory
REFRESH t1_mara. " FREE
* Proof of concept
LOOP AT t2_mara.
WRITE: / t2_mara-matnr.
ENDLOOP.Regards,
Raymond
2011 Dec 06 3:18 PM
And what do you do if there are overlapping ranges:
1-10
5-20
Rob
2011 Dec 06 3:20 PM
2011 Dec 06 3:29 PM
No, I mean that the requirements are contradictory. Do the entries 5-10 come after 1-4 because they are in the first select-options or after 1-10 because they are in the second.
Rob
2011 Dec 06 3:34 PM
- If you keep the delete, they come after 1-4 cause they are in the first range and will only appear once
- If you remove the delete they will come twice
The request should be completed for "duplicated selections", are they to be displayed once or as many times they were selected.
But honestly, no user ever dared to make such a request (am I too harsh?)
Regards,
Raymond
2011 Dec 06 3:45 PM
But honestly, no user ever dared to make such a request (am I too harsh?)
No, but the first thing a developer has to do after receiving new specs is to question them and make sure that the user understands exactly what they are asking for.
Only start coding after this is done.
Rob
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |