Skip to Content
-1

Date Format Dynamically

May 27, 2017 at 10:49 AM

156

avatar image

Folks,

Any standard FM which identifies the Source field's date format and then converts it to the User specific Date format into the target field.

Source Field : Will have date but we are not sure in which format it will be.

1.Identify the date format in the Source field.( any SAP Standard FM for this ?)

2.Get the User Specific date format using SLS_MISC_GET_USER_DATE_FORMAT.

3.Convert the Source field date into User Specific date format using step2.

Steps 2 and 3, I was able to but looking for any Standard FM for step 1 or any standard FM which includes all the 3 steps.

Thanks,

K.Kiran.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Sandra Rossi May 27, 2017 at 03:16 PM
2

The official API described in the ABAP documentation is class CL_ABAP_DATFM.

Share
10 |10000 characters needed characters left characters exceeded
Raymond Giuseppi
May 29, 2017 at 06:21 AM
1

No FM or method will always be able to distinguish DDMMYYYY vs MMDDYYYY for days lower or equal to 12. Nevertheless you could try CL_ABAP_DATFM=>CONV_DATE_EXT_TO_INT, but better ask provider of the file...

Share
10 |10000 characters needed characters left characters exceeded
Kiran K May 29, 2017 at 11:07 AM
0

Thanks Sandra & Raymond.

I had checked CL_ABAP_DATFM but none of its methods will be able to get us the dateformat code with input as date ( possible values 1,2,3,4,5,6,7,8,9,A,B,C - refer to value range of XUDATFM ).

Not sure in which format the date will be in the source field but whatever the format it might be, I need to get the YYYYMMDD format in the target field.

Hence,I did like below.

1.Got the User specific date format code using CL_ABAP_DATFM=>GET_DATFM

2.Checking if XUDATFM is not 2.

3.If XUDATFM is not 2 then using CL_ABAP_DATFM=>CONV_DATE_EXT_TO_INT to convert the external date format into internal date format.

K.Kiran.

Share
10 |10000 characters needed characters left characters exceeded