‎2006 Jul 31 10:00 AM
Hi all,
I am having data value like 31-JUL-06, i want to convert this to YYYYMMDD format. Is there any FM to achieve this.
Thanks & Regards,
Rajanidhi Rajasekeran.
‎2006 Jul 31 10:09 AM
‎2006 Jul 31 10:03 AM
Hi,
You can use edit mask to do the same, for ex,
DATA : LV_DATUM(10).
WRITE V_DAT TO LV_DATUM USING EDIT MASK '__.__.____'.
Hope this helps,
Rgds,
‎2006 Jul 31 10:04 AM
Hi rajanidhi,
1. we can use the FM
CONVERSION_EXIT_SDATE_INPUT
2. some minor logic will be reqruied,
bcos it accpets date in this format
31JUL2006
(and not 31-JUL-2006 with hiphen)
regards,
amit m.
‎2006 Jul 31 10:04 AM
This is nothing but the internal format of SAP, so you can use function CONVERT_DATE_TO_INTERNAL to do that.
Regards,
Ravi
Note : Please mark all the helpful answers
‎2006 Jul 31 10:09 AM
‎2006 Jul 31 10:10 AM
Hi rajanidhi,
Use this FM CONVERSION_EXIT_SDATE_INPUT.It will accept the date in the format 13JUL2005 and will give the date in the format 20051307.Use this FM and format the output as per your requirement.
Regards,
Mukesh Kumar
‎2006 Jul 31 10:11 AM
Hi Rajanidhi
Refer to the following FMs
<b>CONVERT_DATE_TO_INTERN_FORMAT </b> Converts a date to internal format
<b>CONVERT_DATE_TO_EXTERNAL </b> Conversion: Internal to external date (like screen conversion)
<b>CONVERT_DATE_TO_INTERNAL </b> Conversion: External to internal date (like screen conversion)
<b>CONVERT_DATE_INPUT </b> Conversion of a date from external to internal format
<b>CONVERT_DATE_WITH_THRESHOLD</b> Date conversion from external to internal format with time threshold
<b>CONVERT_DATE_BY_PERIOD_INPUT</b>
<b>CONVERT_DATE_BY_PERIOD_OUTPUT </b>
Regards
Inder
‎2006 Jul 31 11:03 AM
Hi,
Consider this code,
REPORT zztest_prd_1 .
DATA : temp TYPE sy-datum,
odate(8).
PARAMETERS : idate(11) TYPE c DEFAULT '31-JUL-06'.
START-OF-SELECTION.
TRANSLATE : idate TO UPPER CASE,
idate USING '- '.
CONDENSE idate NO-GAPS.
CONCATENATE idate+0(5) sy-datum+0(4) INTO idate.
BREAK-POINT.
CALL FUNCTION 'CONVERSION_EXIT_SDATE_INPUT'
EXPORTING
input = idate
IMPORTING
output = temp.
CONCATENATE temp+0(4) temp+6(2) temp+4(2) INTO odate.
WRITE : /10 idate,
/10 odate .
Regards,
AS
‎2006 Jul 31 11:08 AM
‎2006 Jul 31 11:10 AM
HI Rajanidhi,
Plz check this code once.
VALIDATE DATE
temp_date = in_date.
call function 'DATE_CHECK_PLAUSIBILITY'
exporting
date = temp_date
exceptions
plausibility_check_failed = 1
others = 2.
if sy-subrc <> 0.
raise invalid_date.
exit.
endif.
RETRIEVE USER PROFILE DATE SETTING
select single datfm
into user_setting
from usr01
where bname = sy-uname.
REFORMAT DATE ACCORDING TO USER PROFILE
case user_setting.
when '1'.
out_date(2) = in_date+6(2).
out_date2(2) = in_date4(2).
out_date+4(4) = in_date(4).
when '2' or '3'.
out_date(2) = in_date+4(2).
out_date2(2) = in_date6(2).
out_date+4(4) = in_date(4).
when '4' or '5' or '6'.
out_date = in_date.
endcase.
Regards,
Sudha.