‎2007 Oct 18 1:24 PM
Hi all
I get the Date in the format either in DD-MON-YYYY or DD.MM.YYYY. Even sometimes in other format.
I am using CONVERSION_EXIT_SDATE_INPUT to convert it to internal format.
since I have to find the Day from this date using DATE_COMPUTE_DAY.
Unforunately, sometimes the Program works well and sometime gets into trouble.
any help !
Thanks
‎2007 Oct 18 1:59 PM
Hi Remo,
<b>*Case 1: if your date is dd-mon-yyyy</b>
DATA v_date1(11) VALUE '18-OCT-2007'.
DATA v_actual_date TYPE sy-datum.
DATA v_day LIKE scal-indicator.
DATA: it_months LIKE t247 OCCURS 0 WITH HEADER LINE.
TRANSLATE v_date1+3(3) TO UPPER CASE.
CALL FUNCTION 'MONTH_NAMES_GET'
EXPORTING
language = sy-langu
TABLES
month_names = it_months
EXCEPTIONS
month_names_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.
READ TABLE it_months WITH KEY ktx = v_date1+3(3).
IF sy-subrc = 0.
CONCATENATE v_date17(4) it_months-mnr v_date10(2) INTO v_actual_date.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
date = v_actual_date
IMPORTING
day = v_day.
ENDIF.
write:/5 v_actual_date,
20 v_day.
*<b>Case 2: if your date is DD.MM.YYYY</b>
DATA v_date1(11) VALUE '18.10.2007'.
DATA v_actual_date TYPE sy-datum.
DATA v_day LIKE scal-indicator.
concatenate v_date16(4) v_date13(2) v_date1+0(2) into v_actual_date.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
date = v_actual_date
IMPORTING
day = v_day.
write:/5 v_actual_date,
20 v_day.
‎2007 Oct 18 1:34 PM
Hi Remo,
Can you tell me your exact requirement?
As far as my understanding,
you hav to convert dd-mon-yyyy to the ddmmyyyy format so that you can use that in the conversion_exit_sdate_input fm.
I'm not able to get the use of "DATE_COMPUTE_DAY": in this context.
Reward if Useful.
Regards,
Chitra
‎2007 Oct 18 1:37 PM
Hi,
May be problem arise on diffrent date format from diffrent user or system so for that first you have to write logic for conversion of date should be same as user specific setting then only u can use those function module.
eg
data : date(10) type c.
write sy-datum to date.
now use this date for your operation.
Regards
Gagan
‎2007 Oct 18 1:41 PM
Hi,
Check the following link:
http://sap-img.com/abap/fm-to-get-the-day-for-a-particular-date.htm
http://sap-img.com/abap/date-month-pop-related-function-modules.htm
Regards,
Bhaskar
‎2007 Oct 18 1:46 PM
I Wrote code for the Logic gap !
None of the FMs are directly usable !
Thanks you all !
Thanks
‎2007 Oct 18 1:59 PM
Hi Remo,
<b>*Case 1: if your date is dd-mon-yyyy</b>
DATA v_date1(11) VALUE '18-OCT-2007'.
DATA v_actual_date TYPE sy-datum.
DATA v_day LIKE scal-indicator.
DATA: it_months LIKE t247 OCCURS 0 WITH HEADER LINE.
TRANSLATE v_date1+3(3) TO UPPER CASE.
CALL FUNCTION 'MONTH_NAMES_GET'
EXPORTING
language = sy-langu
TABLES
month_names = it_months
EXCEPTIONS
month_names_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.
READ TABLE it_months WITH KEY ktx = v_date1+3(3).
IF sy-subrc = 0.
CONCATENATE v_date17(4) it_months-mnr v_date10(2) INTO v_actual_date.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
date = v_actual_date
IMPORTING
day = v_day.
ENDIF.
write:/5 v_actual_date,
20 v_day.
*<b>Case 2: if your date is DD.MM.YYYY</b>
DATA v_date1(11) VALUE '18.10.2007'.
DATA v_actual_date TYPE sy-datum.
DATA v_day LIKE scal-indicator.
concatenate v_date16(4) v_date13(2) v_date1+0(2) into v_actual_date.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
date = v_actual_date
IMPORTING
day = v_day.
write:/5 v_actual_date,
20 v_day.