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

Date Format IN BDC

Former Member
0 Likes
402

Hi,

In One Interview I was asked that How can You Handle Data Format when Writing BDC ?

Hi,

In One Interview I was asked that How can You Handle Data Format when Writing BDC ?

2 REPLIES 2
Read only

Former Member
0 Likes
355

Hi,

You have to concatenate '.' in the date to make it 2006.05.05. Once concatenated, then pass the value to the screen field in BDC.

Best regards,

Prashant

Read only

Former Member
0 Likes
355

Satya,

The date format depends on User settings. Its different for different login ID's.

It can be YYYY.MM.DD or MM.DD.YYYY or anything.

To handle the date format, you need to query on table USR01 and fetch DATFM field that stores date format.

Refer below piece of code

*/...Fetch the date format settings for the user

SELECT SINGLE datfm

INTO gv_date_format

FROM usr01

WHERE bname = sy-uname.

CASE gv_date_format.

WHEN 1. "DD.MM.YYYY

CONCATENATE fv_impdate+6(2) '.'

fv_impdate+4(2) '.'

fv_impdate+0(4) INTO fv_expdate.

WHEN 2. "MM/DD/YYYY

CONCATENATE fv_impdate+4(2) '/'

fv_impdate+6(2) '/'

fv_impdate+0(4) INTO fv_expdate.

WHEN 3. "MM-DD-YYYY

CONCATENATE fv_impdate+4(2) '-'

fv_impdate+6(2) '-'

fv_impdate+0(4) INTO fv_expdate.

WHEN 4. "YYYY.MM.DD

CONCATENATE fv_impdate+0(4) '.'

fv_impdate+4(2) '.'

fv_impdate+6(2) INTO fv_expdate.

WHEN 5. "YYYY/MM/DD

CONCATENATE fv_impdate+0(4) '/'

fv_impdate+4(2) '/'

fv_impdate+6(2) INTO fv_expdate.

WHEN 6. "YYYY-MM-DD

CONCATENATE fv_impdate+0(4) '-'

fv_impdate+4(2) '-'

fv_impdate+6(2) INTO fv_expdate.

ENDCASE.

This would convert the date into the format set for user.

Hope this is helpful.

Amogh