Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Date Formating

Former Member
0 Likes
676

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
642

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.

5 REPLIES 5
Read only

Former Member
0 Likes
642

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

Read only

former_member194152
Contributor
0 Likes
642

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

Read only

Former Member
Read only

Former Member
0 Likes
642

I Wrote code for the Logic gap !

None of the FMs are directly usable !

Thanks you all !

Thanks

Read only

Former Member
0 Likes
643

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.