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

Urgent-Date Format

Former Member
0 Likes
855

Hi All,

how to convert the system date into the Format defined in the User Profile?

Help will be highly appreciated:)

Hi All,

how to convert the system date into the Format defined in the User Profile?

Help will be highly appreciated:)

6 REPLIES 6
Read only

Former Member
0 Likes
817

hi ,

you can use the following FM

FUNCTION Z_SETDATE_TO_USER_PROFILE.

*"----


""Local interface:

*" IMPORTING

*" VALUE(IN_DATE) LIKE SY-DATUM

*" EXPORTING

*" VALUE(OUT_DATE) LIKE KLAHD-CREAT_DATX

*" EXCEPTIONS

*" INVALID_INPUT_DATE_FORMAT

*"----


TABLES: USR01.

DATA: DATE_FORMAT LIKE USR01-DATFM,

MONTH(2) TYPE C,

DAY(2) TYPE C,

YEAR(4) TYPE C.

  • VALIDATE THE INPUT DATE

CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'

EXPORTING

DATE = IN_DATE

EXCEPTIONS

PLAUSIBILITY_CHECK_FAILED = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

  • ERROR MESSAGE

ENDIF.

  • GET THE DATE INTO IT'S MONTH, DAY AND YEAR COMPONENTS

MONTH = IN_DATE+4(2).

DAY = IN_DATE+6(2).

YEAR = IN_DATE(4).

  • IN THE USER PROFILE TABLE DETERMINE THE DATE FORMAT

SELECT SINGLE DATFM

INTO DATE_FORMAT

FROM USR01

WHERE BNAME = SY-UNAME.

  • ACCORDING TO THE USER PROFILE FORMAT THE INPUT DATE

CASE DATE_FORMAT.

WHEN '1'.

CONCATENATE DAY '.' MONTH '.' YEAR INTO OUT_DATE.

WHEN '2'.

CONCATENATE MONTH '/' DAY '/' YEAR INTO OUT_DATE.

WHEN '3'.

CONCATENATE MONTH '-' DAY '-' YEAR INTO OUT_DATE.

WHEN '4'.

CONCATENATE YEAR '.' MONTH '.' DAY INTO OUT_DATE.

WHEN '5'.

CONCATENATE YEAR '/' MONTH '/' DAY INTO OUT_DATE.

ENDCASE.

ENDFUNCTION.

Read only

kiran_k8
Active Contributor
0 Likes
817

pavtihra,

l_dat = sy-datum.

CONCATENATE SY-DATUM6(2) '.' SY-DATUM4(2) '.' SY-DATUM+0(4) INTO L_DAT.

K.Kiran.

Read only

Former Member
0 Likes
817

write date to char type field.....it will automatically convert it....

data : a like sy-datum,

b(10) type c.

a = sy-datum.

move a to b.

write 😕 b.

now b will be format set by user.....in settings..

Regards

Vasu

Read only

former_member386202
Active Contributor
0 Likes
817

Hi,

Use FM " CY_CONVERT_DATE ".

Reward Point if helpfull.......

Regards,

Prashant

Read only

former_member194152
Contributor
0 Likes
817

hi,

you can use write to statement for that purpose.for example.

data : date(10) type c.

write sy-datum to date.

write : / sy-datum,

/ date.

just run this logic and see.

Rewards if helpful.

Regards

Gagan

Read only

Former Member
0 Likes
817

Hi,

Use the statement 'Write .... to......'