Skip to Content
Date Conversion from User to Internal Format  Often we need to upload the data from local machines and then load it into SAP and then problems arise such as:  1. How to convert date format from DD/MM/YY etc. to SAP YYYYMMDD ? 2. Is the date input valid? For example: does the year 2004 contain 29.Feb.2004 or not.     The solutions are the FM mentioned below.    1.     KCD_EXCEL_DATE_CONVERT  This FM has two input parameters of date in the user format and user date format. Date format is 3 character code to specify the position of month date and year in the value passed. Valid values are ‘TMJ’, ‘MTJ’ and ‘JMT’ where ‘J’ stands for year, ‘T’ stands for ‘Date and ‘M’ stands for month.   The limitation –  You cannot have date where month is mentioned as its name like 22-NOV-06.  2.     CONVERSION_EXIT_SDATE_INPUT  This FM has only one input parameter of date in the user format and converts it to SAP internal format using the ‘USER’ or ‘LOCALE’ settings. Advantage of this FM is that you need not pass the date format of the user, and disadvantage is that if the date is invalid it throws a success message ‘Specify a valid date’.    The Advantage – It just converts the passed date using the passed format without validity check and without throwing any message and the disadvantage is that separators in date value are must. It is handy where the passed date format is always fixed irrespective of the ‘USER’ or ‘LOCALE’ settings.   Date Plausibility  1.      DATE_CHECK_PLAUSIBILITY The FM accepts date value in SAP internal format and returns if the date is valid or not. Leap year rules are also adhered to.
To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Ryan Quackenboss
    I suspect I am not the only one to have seen many different ways to accomplish this particular task. From splitting the date at a deliminator and concatenating it back into a system date in the correct order to flurry of nested if statements determining the correct code to execute. 

    While one technique may be more efficient than others, if developers knew and used the SAP delivered function modules or classes rather than re-invent the wheel, I am all for it.

    Thanks for the information.

    Quack

    (0) 

Leave a Reply