2004 Sep 01 12:03 PM
Hi Friends,
I need a Function Module that would convert the incoming date from external sytem in format YYYYMMDD to the SAP system in DDMMYYYY. The External system data type for the date is Numberic. Please suggest any FM if you know.I found out many in SAP but didn't find for this requirement
Hi Friends,
I need a Function Module that would convert the incoming date from external sytem in format YYYYMMDD to the SAP system in DDMMYYYY. The External system data type for the date is Numberic. Please suggest any FM if you know.I found out many in SAP but didn't find for this requirement
2004 Sep 01 2:41 PM
If my external data format is fixed, I usually just program this myself like the following:
data: date1(8) type n. "Format YYYYMMDD
data: date2(8) type n. "Format DDMMYYYY
move date1+0(4) to date2+4(4).
move date1+4(2) to date2+2(2).
move date1+6(2) to date2+0(2).
call function 'DATE_CHECK_PLAUSIBILITY'
exporting
DATE = date2
exceptions
plausibility_check_failed = 1.
if sy-subrc ne 0.
"Do Something.
endif.
2004 Sep 01 3:29 PM
Hi Thomas,
I tried this patch of code in the LSMW, but it gave me a dump CALL_FUNCTION_CONFLICT_TYPE on the Function Module DATE_CHECK_PLAUSIBILITY. Please help.
2004 Sep 01 3:33 PM
2004 Sep 01 3:58 PM
Hi Thomas,
I am still getting some issue with the output for date. here's my code
data: date1(8) type c value '20051225'. "Format YYYYMMDD
data: date2 type sy-datum. "Format DDMMYYYY
data: f_date type datum.
data: l_year(4),
l_month(2),
l_day(2).
move date10(4) to date24(4).
move date14(2) to date22(2).
move date16(2) to date20(2).
l_year = date2+4(4).
l_month = date2+2(2).
l_day = date2+0(2).
concatenate l_day l_month l_year into f_date.
condense f_date.
write: f_date.
the expected should be 25122005 but I am getting the date output as 05.20.2512. I checked the UserProfile Own data of the system,it is set fine to DDMMYYYY.
2004 Sep 01 4:10 PM
Thanks Thomas ..I got the solution.The FM is CONVERSION_EXIT_PDATE_OUTPUT
2004 Sep 01 4:12 PM
Hello Mira,
In SAP, date is always stored in format YYYYMMDD. Depending on your format, it will be displayed on the screen or printer based on that format when you use WRITE statement to screen or text. You can't have a field in date format stored as DDMMYYYY.
2004 Sep 01 4:14 PM
Wait a minute. I am definetely missing something here. You want to convert from an external format YYYYMMDD to SAP's internal format? SAP's internal format is YYYYMMDD.
All you should have to do is move you external date directly to your internal date.
data: date1(8) type c value '20051225'. "Format YYYYMMDD
data: date2 type sy-datum. "Format (YYYYMMDD)
write: / date2.
When you write out date2 it will be in whatever format your user profile has.
If you want to force the date format independent of your user profile settings during the write statement:
write: / date2 DDMMYY.
Message was edited by: Thomas Jung
2004 Sep 01 2:42 PM
If the user default settings are DD.MM.YYYY, you can use the WRITE statement, e.g.
DATA: v_date1 TYPE dats,
v_date2(8) TYPE c.
v_date1 = sy-datum.
WRITE v_date1 TO v_date2.
v_date1 will be in format YYYYMMDD
v_date2 will be in format DDMMYYYY (according to user settings)
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |