Application Development 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: 

convert the date into user default date formate

former_member799868
Participant
0 Kudos
1,404

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

Former Member
0 Kudos
412

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

0 Kudos
412

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

Former Member
0 Kudos
412

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

former_member203501
Active Contributor
0 Kudos
412

hi use one of these .

CONVERT_DATE_TO_INTERNAL

PCA_CONVERT_DATE_INTERNAL

Former Member
0 Kudos
412

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.

Former Member
0 Kudos
412

Hi Adelly,

Use the FM CONVERT_DATE_TO_EXTERNAL.

With luck,

Pritam.

former_member329859
Participant
0 Kudos
412

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.

Former Member
0 Kudos
412

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