Application Development 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: 

Date Format Dynamically

kiran_k8
Active Contributor
0 Kudos

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.

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor

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

3 REPLIES 3

Sandra_Rossi
Active Contributor

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

raymond_giuseppi
Active Contributor

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...

kiran_k8
Active Contributor
0 Kudos

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.