‎2008 Aug 15 10:59 AM
Hi...
I want to Sort a table based on Display Variant Sort option??
Please Help????
‎2008 Aug 15 11:02 AM
Hi Try this...
FM..
K_KKB_OUTTAB_SORT
To Sort Data
CALL FUNCTION 'K_KKB_OUTTAB_SORT'
EXPORTING
IT_SORT = I_SORT
TABLES
T_OUTTAB = I_MAIL_FINAL
EXCEPTIONS
SORTFIELD_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
‎2008 Aug 15 11:02 AM
Hi Try this...
FM..
K_KKB_OUTTAB_SORT
To Sort Data
CALL FUNCTION 'K_KKB_OUTTAB_SORT'
EXPORTING
IT_SORT = I_SORT
TABLES
T_OUTTAB = I_MAIL_FINAL
EXCEPTIONS
SORTFIELD_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
‎2008 Aug 15 5:39 PM
‎2008 Aug 15 12:13 PM
Hi shashi,
in sy-slset SAP stores the name of the variant.
CASE sy-slset.
WHEN 'TEST01'. SORT gt_itab BY x y z.
WHEN 'TEST02'. SORT gt_itab BY y x z.
WHEN OTHERS. SORT gt_itab.
ENDCASE.
‎2008 Aug 15 12:48 PM
Thanks for your reply..
But user can create new variants too..
In that case How to get the fields which are used for sorting???
‎2008 Aug 15 1:04 PM
Hi Sashi,
I'm not sure understanding your needs. Maybe you have to read the SELECT-OPTIONS or using some radiobuttons / checkboxes to get the users preferences?
In other case, all known variants are stored in SAP-table VARIT, the specific field-descriptions and values you can retrieve by using function module 'RS_VARIANT_CONTENTS' (some informations are also in SAP-table VARID).
Hope it will help, otherwise try to explain what the user should do, please.