‎2007 May 17 4:44 PM
If I have numeric values and alpha values and want to sort them according to numeric and alphabetcial order, should I define the field as NUMC or CHAR?
‎2007 May 17 4:45 PM
Hi,
You have to define it as char..As NUMC will not accept alpha values..
Thanks,
Naren
‎2007 May 17 4:45 PM
Hi,
You have to define it as char..As NUMC will not accept alpha values..
Thanks,
Naren
‎2007 May 17 4:46 PM
Hi,
1. If the field contains Alphabets,
then we cannot take NUMC,
(Bcos NUMC can contain only digits, in char format)
2. Hence, we have to take CHAR.
regards,
amit m.
‎2007 May 17 4:47 PM
‎2007 May 17 4:48 PM
‎2007 May 17 4:56 PM
Hi All,
I have the following scenario with these values:
10
12
2
4
6
8
A
B
C
D
When I use the field as CHAR, the sort becomes
10
12
2
4
6
8
A
B
C
I would want the result to be
2
4
6
8
10
12
A
B
C
What would you recommend on how to approach this. It seems that some ABAP logic is required to to this?
Thanks
null
null
‎2007 May 17 4:53 PM
Hi,
You may need to define two seperate fields. One is NUMC and the other one is CHAR.
DATA: BEGIN OF I_INPUT OCCURS 0,
FIELD1(10) TYPE N,
FIELD2(10) TYPE C,
MATNR TYPE MARA-MATNR.
DATA: END OF I_INPUT.
...
SORT T_INPUT BY FIELD1 FIELD2 ASCENDING.
Regards,
Ferry Lianto
‎2007 May 17 4:58 PM
Hi,
My problem is that I would have to use just one field for these values. I am not sure about your suggestions. Would you clarify
Thanks
‎2007 May 17 4:58 PM
Hi,
If you are in AFS..
you will have a function module that can be used to sort according to the size..
I don't remember the function module name..
GO to SE37..Give JSORTSIZE*
Thanks,
Naren
‎2007 May 17 5:05 PM
Hi,
Please try this ...
DATA: BEGIN OF ITAB OCCURS 0,
SORT(1) TYPE C,
FIELD1(5) TYPE C,.
DATA: END OF ITAB1.
LOOP AT ITAB.
IF ITAB-FIELD1 CO SY-ABCDE.
ITAB-SORT = 'B'.
ELSE.
ITAB-SORT = 'A'.
ENDIF.
MODIFY ITAB.
ENDLOOP.
SORT ITAB BY SORT FIELD1 ASCENDING.
LOOP AT ITAB.
WRITE: / ITAB-FIELD1.
ENDLOOP.
Regards,
Ferry Lianto
‎2007 May 17 5:30 PM
Hi,
Please try this ... it works for me.
DATA: BEGIN OF ITAB OCCURS 0,
SORT(1) TYPE C,
SEQ(5) TYPE N,
FIELD1(5) TYPE C.
DATA: END OF ITAB1.
LOOP AT ITAB.
IF ITAB-FIELD1(1) CA SY-ABCDE.
ITAB-SORT = 'B'.
ITAB-SEQ = '99999'.
ELSE.
ITAB-SORT = 'A'.
ITAB-SEQ = ITAB-FIELD1.
ENDIF.
MODIFY ITAB.
ENDLOOP.
SORT ITAB BY SORT SEQ ASCENDING.
LOOP AT ITAB.
WRITE: / ITAB-FIELD1.
ENDLOOP.
Regards,
Ferry Lianto
Message was edited by:
Ferry Lianto