Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

convert the date into user default date formate

former_member799868
Participant
0 Likes
3,324

I am wrinting a bdc and i want to convert the date into user default date farmate ..please suggust the functiom module should i use...

I am wrinting a bdc and i want to convert the date into user default date farmate ..please suggust the functiom module should i use...

8 REPLIES 8
Read only

Former Member
0 Likes
2,332

Hi Kranthi,

Pls create a variable which is date type and write the statement as follows.

Write sy-datum to <variable>.

use this variable in the BDC code. It will work

Read only

0 Likes
2,332

Thanks, this was the simplest way possible.
I had a similar requirement and your comment got the job done. 🙂

Read only

Former Member
0 Likes
2,332

you can use

CONCATENATE sy-datum4(2) '/' sy-datum6(2) '/' sy-datum+0(4)

INTO lv_date.

or fm

DATA: lc_date_format TYPE char10 VALUE 'MM/DD/YYYY'.

CALL FUNCTION 'SLS_MISC_CONVERT_TO_DATE'

EXPORTING

p_date = lwa_final-bstdk

p_date_format = lc_date_format

IMPORTING

p_date_string = gwa_final1-bstdk

EXCEPTIONS

error_selecting_user_defaults = 1

OTHERS

Read only

former_member203501
Active Contributor
0 Likes
2,332

hi use one of these .

CONVERT_DATE_TO_INTERNAL

PCA_CONVERT_DATE_INTERNAL

Read only

Former Member
0 Likes
2,332

actually by using dats or d type you can get the user specific date itself.

but if u have different dates format that need to be converted to the user specific date then you can follow below procedure

1. retrieve the user format from usr01

SELECT SINGLE datfm

INTO w_datfm

FROM usr01

WHERE bname EQ sy-uname.

pass w_datfm to the below FM (4th import parameter)

2. create Z - FM and retrieve the user secific date

FUNCTION ZFXX_USER_SPECIFIC_DATE.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(IW_DAY) TYPE CHAR2

*" VALUE(IW_MONTH) TYPE CHAR2

*" VALUE(IW_YEAR) TYPE CHAR4

*" VALUE(IW_DATFM) TYPE USR01-DATFM

*" EXPORTING

*" VALUE(EW_USER_DATE) TYPE CHAR0008

*"----


*1 DD.MM.YYYY

*2 MM/DD/YYYY

*3 MM-DD-YYYY

*4 YYYY.MM.DD

*5 YYYY/MM/DD

*6 YYYY-MM-DD

CASE iw_datfm.

when '1'.

concatenate iw_day iw_month iw_year

into ew_user_date.

when '2'.

concatenate iw_month iw_day iw_year

into ew_user_date.

when '3'.

concatenate iw_month iw_day iw_year

into ew_user_date.

when '4'.

concatenate iw_year iw_month iw_day

into ew_user_date.

when '5'.

concatenate iw_year iw_month iw_day

into ew_user_date.

when '6'.

concatenate iw_year iw_month iw_day

into ew_user_date.

when others.

clear ew_user_date.

endcase.

ENDFUNCTION.

Read only

Former Member
0 Likes
2,332

Hi Adelly,

Use the FM CONVERT_DATE_TO_EXTERNAL.

With luck,

Pritam.

Read only

Former Member
0 Likes
2,332

Hi,

I dont think any function module require for date conversion in bdc,

you just take variable with character type and pass it to the field of bdc using internal table in which u takes ur data.

Read only

Former Member
0 Likes
2,332

Hi,

Use the following FM it will be helpful to you.

*To change date as per user settings

CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'

EXPORTING

input = loc_date

IMPORTING

output = loc_date.

Or use this Fm

CALL FUNCTION 'CONVERSION_EXIT_SDATE_INPUT'

EXPORTING

input = <fs_inrec>-to_date

IMPORTING

output = <fs_inrec>-end_date.

Regards,

Chaitanya