cancel
Showing results for 
Search instead for 
Did you mean: 

Table Sort for Date Column in WD ABAP

Former Member
0 Kudos

Hi All,

We have a requirement in MSS Add-On Time Approval screen to enable sort option for all coulmns in table and which is dynamic table. We have done almost except sorting on date fields "From date" and "To date" as those are coming as string data type from backend.

Can you pl suggest how we can acheive the column type from string to date and values to date and sort those columns.

Regards,

Suresh

Accepted Solutions (0)

Answers (1)

Answers (1)

Abhinav_Sharma
Contributor
0 Kudos

Hi Suresh,

You should have used context attribute of type date for the From and To date. If your From date and To Date is bound to String type, then you can try to convert it to Date format using FM - CONVERT_DATE_TO_INTERNAL.

Regards

Abhinav

Former Member
0 Kudos

Hi Abhinav,

Thanks for the quick response. Can you pl provide the code to convert date value for context attribute.

Regards,

Suresh

Abhinav_Sharma
Contributor
0 Kudos

Hi Suresh,

First you have to read the context attribute in String format and save it in the local variable str_date (let say your date is 30.04.2013).


Then call the function module


DATA: str_date type string,
      dd_date type dats.

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
  EXPORTING
    date_external                  = str_date
*   ACCEPT_INITIAL_DATE            =
IMPORTING
   DATE_INTERNAL                  = dd_date
* EXCEPTIONS
*   DATE_EXTERNAL_IS_INVALID       = 1
*   OTHERS                         = 2
          .

the internal date dd_date will be 20130430 which you can use for comparision.


Hope this helps.


Regards
Abhinav