‎2013 Apr 22 9:16 AM
Hello,
I am facing issues with converting system date to DD.MM.YYYY format with function module RSAWBN_DATE_FORMAT. For example, input date 20130422 is converted to 22.13.2013 which is an invalid date. This should have been 22.04.2013.
Has anyone come across this function module? I checked the code withing this FM and found that issue with below mentioned line of code.
l_month = i_sys_date+2(2).
This line should have been
l_month = i_sys_date+4(2).
The entire code of FM is as mentioned below. Can you please let me know if this is actually a bug in the FM code or do I need to use this FM in another way? Thanks a lot.
Regards,
Amol
function rsawbn_date_format.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(I_SYS_DATE) TYPE RSTXTLG
*" EXPORTING
*" REFERENCE(E_DATE) TYPE RSTXTLG
*"----------------------------------------------------------------------
data l_date(2) type c.
data l_month(2) type c.
data l_year(4) type c.
data l_date_format type char10.
tables usr01.
select single * from usr01 where bname = sy-uname.
case usr01-datfm. "#EC DATFM
when '1' or '2' or '3'.
l_date = i_sys_date+6(2).
l_month = i_sys_date+2(2).
l_year = i_sys_date+0(4).
* concatenate l_date '.' l_month '.' l_year into e_date.
when '4' or '5' or '6'.
l_date = i_sys_date+6(2).
l_month = i_sys_date+2(2).
l_year = i_sys_date+0(4).
* concatenate l_year '.' l_month '.' l_date into e_date.
endcase.
call function 'SLS_MISC_GET_USER_DATE_FORMAT'
importing
p_date_format = l_date_format
exceptions
error_reading_user_master = 1
error_reading_date_format_text = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
***Replacing the date format ...
replace all occurrences of 'DD' in l_date_format with l_date.
replace all occurrences of 'MM' in l_date_format with l_month.
replace all occurrences of 'YYYY' in l_date_format with l_year.
e_date = l_date_format.
endfunction.
‎2013 Apr 22 9:32 AM
Hi Amol,
As mentioned by you, there is a problem in the FM. If you need to convert the internal format to user format, you can simply write the value to a field defined in reference to a date field.
DATA: lv_date type char08,
lv_datum type sy-datum.
lv_date = sy-datum.
write lv_date to lv_datum.
write: lv_datum.
lv_datum will hold the date in the user format. You can also use the EDIT MASK or date format options in addition with the WRITE statement.
Cheers
~Niranjan
‎2013 Apr 22 10:11 AM
hi Amol,
I check same issue i am also facing.Instead of wasting time in debugging use below code as this is simple code and no performance issue also.
You can write code as
DATA: lv_date TYPE char10.
CONCATENATE sy-datum+6(2) sy-datum+4(2) sy-datum+0(4) INTO lv_date SEPARATED BY '.' .
replace sy-datum by your date field variable.
‎2013 Apr 22 11:08 AM
Hi,
Function module RSAWBN_DATE_FORMAT has status 'Not released' and if I run a where-used this function module (or any of the others in the same function group) are not called by standard.
As others have said, date manipulation is a simple ABAP task, better to write something yourself than use code you can't rely on.
Regards,
Nick