12-20-2006 5:02 AM
Hi guys
i have a structure(ABC) with name address and varaiable called as BP( with char 1)
but when i sort the structure
like sort ABC by name address BP
aaa 123 null
aaa 123 X
but i want the sort by
aaa 123 x
aaa 123 null
how can i write the sort statement
senthil
12-20-2006 5:03 AM
use the DESCENDING for sort
<b>sort ABC by name address ascending BP descending.</b>
Regards
- Gopi
Message was edited by:
Gopi Narendra
12-20-2006 5:03 AM
use the DESCENDING for sort
<b>sort ABC by name address ascending BP descending.</b>
Regards
- Gopi
Message was edited by:
Gopi Narendra
12-20-2006 5:05 AM
hi
i want the sort everthing name address by asc only the bp
is only i want it by desc ie with values it should cum first
senthil
12-20-2006 5:07 AM
12-20-2006 5:05 AM
hi,
try this
sort ABC by name address BP <b>DESCENDING</b>.
here name and address will be sorted in ASCENDING fashion
and bp will be in DESCENDING fashion.
12-20-2006 5:07 AM
SORT abc ASCENDING BY name address DESCENDING bp.
regards
shiba dutta
Message was edited by:
SHIBA DUTTA
12-20-2006 5:07 AM
12-20-2006 5:11 AM
USE THIS CODE AND REWARD POINTS IF HELPFULL -
data: begin of itab occurs 0,
name(20),
add(20),
bp(1),
end of itab.
itab-name = 'aaa'.
itab-add = '123'.
APPEND ITAB.
CLEAR ITAB.
itab-name = 'aaa'.
itab-add = '123'.
itab-bp = 'X'.
APPEND ITAB.
SORT ITAB ASCENDING BY name add DESCENDING bp.
LOOP AT ITAB.
WRITE:/ ITAB.
ENDLOOP.
Message was edited by:
Amit Tyagi
12-20-2006 5:25 AM
thanx for all u r replies
i want a sort like this
if the table contains values like
AAA 123 null
BBB 123 X
it should check if the BP is X then the sort should change it means
it should disaly the value liek this
BBB 123 X
AAA 123 null
senthil
12-20-2006 5:30 AM
considering ABC to be your internal table
sort ABC by BP descending.
Regards
- Gopi
12-20-2006 5:34 AM
TRY THIS CODE AND POINTS
data: begin of itab occurs 0,
name(20),
add(20),
bp(1),
end of itab.
DATA ITAB1 LIKE TABLE OF ITAB WITH HEADER LINE.
itab-name = 'aaa'.
itab-add = '123'.
APPEND ITAB.
CLEAR ITAB.
itab-name = 'bbb'.
itab-add = '123'.
itab-bp = 'X'.
APPEND ITAB.
ITAB1[] = ITAB[].
loop at itab1 .
IF ITAB-BP = 'X'.
SORT ITAB DESCENDING BY NAME ADD BP.
EXIT.
ELSE.
SORT ITAB ASCENDING BY name add DESCENDING bp.
EXIT.
ENDIF.
ENDLOOP.
LOOP AT ITAB.
WRITE:/ ITAB.
ENDLOOP.
Message was edited by:
Amit Tyagi
12-20-2006 5:36 AM
HI senthil,
try following code and let me know is this your requirement.
DATA : BEGIN OF itab OCCURS 0,
name(1) TYPE c,
add(1) TYPE c,
bp(1) TYPE c,
END OF itab.
DATA wa LIKE LINE OF itab.
CLEAR wa.
wa-name = 'A'.
wa-add = '1'.
wa-bp = 'V'.
APPEND wa TO itab.
CLEAR wa.
wa-name = 'B'.
wa-add = '2'.
wa-bp = 'X'.
APPEND wa TO itab.
SORT itab BY bp DESCENDING.
LOOP AT itab INTO wa.
WRITE 😕 wa-name,
wa-add,
wa-bp.
ENDLOOP.
regards
Ashutosh
Reward points if helpful
12-20-2006 5:37 AM
12-20-2006 5:38 AM
READ TABLE ITAB WITH KEY BP = 'X'.
IF SY-SUBRC = 0.
SORT sort ABC by BP DESCENDING.
ELSE.
sort ABC by name address BP.
ENDIF.
REGARDS
SHIBA DUTTA
12-20-2006 5:41 AM
hi,
try this.
select single * from table into itab where bp = 'X'.
*check whether bp filed hase value 'x'.
if sy-subrc = 0.
sort ABC by name address BP DESCENDING.
else
sort ABC by name address BP.
endif.
12-20-2006 8:26 AM
hi guys,
Thanx for u replies
but it is not working for me
any more ideas on this issue
senthil
12-20-2006 8:36 AM