FMs to convert date from User Format into SAP standard
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.