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: 

date format in flat file of bdc

Former Member
0 Kudos

Hi Folks,

In BDC I have a flat file which has to be uploaded from a flat file and 4 users are using each of one has their date format.

so inorder to get their required date format what i need to do .

3 REPLIES 3

Former Member
0 Kudos

Hi,

use the below logic in your code.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-031.

PARAMETERS: date1 RADIOBUTTON GROUP rad1 DEFAULT 'X', "SAP date format YYYYDDMM

date2 RADIOBUTTON GROUP rad1, "Date format like aprial31, 2006

date3 RADIOBUTTON GROUP rad1, "Date format like 31 apr,2006

date4 RADIOBUTTON GROUP rad1, "Date format like DD/MM/YYYY

date5 RADIOBUTTON GROUP rad1. "Date format like DD.MM.YYYY

SELECTION-SCREEN END OF BLOCK b2

FORM getmonth .

SELECT mnr

ktx

ltx

INTO TABLE T_month

FROM t247

WHERE spras = 'EN'.

IF sy-subrc NE '0'.

MESSAGE I "Message - Not able to get month values from the table T247

ENDIF.

ENDFORM.

DATA : temp_date(16) TYPE c,

temp1_date(60) TYPE c,

year(4) TYPE c,

daymonth(11) TYPE c,

daymonth1(11) TYPE c,

month(9) TYPE c,

day(2) TYPE c,

mon LIKE t247-ktx,

len TYPE i .

MOVE date TO temp1_date .

CONDENSE temp1_date NO-GAPS.

MOVE temp1_date TO temp_date .

IF date2 EQ 'X'. "The date format is like Aprial 31, 2007

CONDENSE temp_date NO-GAPS.

SPLIT date AT ',' INTO daymonth year.

IF STRLEN( year ) NE '4'.

error = 'X'.

WRITE : 'Invalid date format.'.

ELSE.

daymonth1 = daymonth.

CONDENSE daymonth1 NO-GAPS.

_len = STRLEN( _daymonth1 ).

l_len = 13 - len.

SHIFT daymonth1 RIGHT BY len PLACES.

CONDENSE daymonth1 NO-GAPS.

month = daymonth1.

CONDENSE month NO-GAPS.

SORT t_month BY monthltx.

READ TABLE t_month WITH KEY monthltx = month.

IF sy-subrc <> 0.

error = 'X'.

WRITE : 'Invalid date format.' .

ELSE.

len = STRLEN( month ).

CONDENSE daymonth NO-GAPS.

SHIFT daymonth LEFT BY len PLACES.

day = daymonth.

CONDENSE day NO-GAPS.

CONCATENATE year t_month-monthnumber day INTO o_date.

ENDIF.

ENDIF.

ELSEIF p_date3 EQ 'X'. "The date format is like 31 apr, 2007

CONDENSE temp_date NO-GAPS.

SPLIT i_date AT ',' INTO daymonth year.

IF STRLEN( year ) NE '4'.

error = 'X'.

WRITE : 'Invalid date format.'.

ELSE.

daymonth1 = daymonth.

CONDENSE daymonth1 NO-GAPS.

SHIFT daymonth1 LEFT BY 2 PLACES.

CONDENSE daymonth1 NO-GAPS.

month = daymonth1.

CONDENSE month NO-GAPS.

TRANSLATE month TO UPPER CASE.

SORT t_month BY monthstx.

MOVE month to mon.

READ TABLE t_month WITH KEY monthstx = mon.

IF sy-subrc <> 0.

error = 'X'.

WRITE : 'Invalid date format.' .

ELSE.

CONDENSE daymonth NO-GAPS.

day = daymonth+0(2).

CONDENSE day NO-GAPS.

CONCATENATE year t_month-monthnumber day INTO o_date.

ENDIF.

ENDIF.

ELSEIF p_date4 EQ 'X' OR p_date5 EQ 'X'. "Date format is like DD.MM.YYYY or DD/MM/YYYY

CONDENSE temp_date NO-GAPS.

IF STRLEN( temp_date ) EQ 10.

o_date0(4) = temp_date6(4).

o_date4(2) = temp_date3(2).

o_date6(2) = temp_date0(2).

ELSE.

error = 'X'.

WRITE : 'Invalid date format.' .

ENDIF.

ENDIF.

IF STRLEN( o_date ) NE '8'.

error = 'X'.

WRITE : 'Invalid date format.'.

ENDIf.

ENDFORM.

regards

Former Member
0 Kudos

Hi,

U can resolve it by using " WRITE.....TO....." statement.

As this will set the values w.r.t User Profile settings.

Revert back if any issues.

Reward with points if helpful.

Regards,

Naveen.

Former Member
0 Kudos

Hi

You before moving the field to table use conversion_exit_input.

this will convert accordingly the user settings

Regards

Shiva