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 CSV file

Former Member
0 Likes
1,410

Hello,

I am working on loading program which downloads the application server CSV file to internal table.

In the CSV file there is a field date in the format (22/05/2008). When I move this to my internal table field date, it is truncating to '22/05/20'. How to solve this issue.

Can I load into internal table with the same format?

Please help me.

Thanks,

Shreekant

1 ACCEPTED SOLUTION
Read only

faisalatsap
Active Contributor
0 Likes
1,228

Hi, Rangrej

As all Suggested assign first this date to char type filed length 10 and using following way you can assign this to type date.

Test Sample Code Bellow.

TYPES: BEGIN OF ty_test,
  cdate(10),
  date LIKE sy-datum,
  END OF ty_test.

DATA: it_test TYPE STANDARD TABLE OF ty_test WITH HEADER LINE.

it_test-cdate = '22/05/2008'. APPEND it_test.
it_test-cdate = '23/05/2008'. APPEND it_test.
it_test-cdate = '24/05/2008'. APPEND it_test.
it_test-cdate = '25/05/2008'. APPEND it_test.
it_test-cdate = '26/05/2008'. APPEND it_test.

LOOP AT it_test.
  it_test-date+0(4) = it_test-cdate+6(4).
  it_test-date+4(2) = it_test-cdate+3(2).
  it_test-date+6(2) = it_test-cdate+0(2).
  MODIFY it_test INDEX sy-tabix.
ENDLOOP.

Best Regards,

Faisal

6 REPLIES 6
Read only

Former Member
0 Likes
1,228

Hi,

Try to get it to into char field of length 10.Date field has 8 length so it is truncating.

Regards,

Nithya

Read only

GauthamV
Active Contributor
0 Likes
1,228

I guess you have declares it with sy-datum.

Declare like this, this if you want ' / ' in between also.

Data : date(10) type c.

Read only

former_member222860
Active Contributor
0 Likes
1,228

Hi,

Pl. check the declaration of the date field in your itab, say if it is dd/mm/yy

thanks\

Mahesh

Read only

Former Member
0 Likes
1,228

Hi,

u might have declared the variable type as date/sy-datum, instaed declare it as char with length 10.

After the data is moved into ur variable , then u can move it date field using " WRITE....To...' or offsets.

regards,

Naveen

Read only

Former Member
0 Likes
1,228

Hi,

Please check below code.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = v_filename_string

filetype = 'ASC'

has_field_separator = 'X'

dat_mode = 'I'

TABLES

data_tab = it_input

Read only

faisalatsap
Active Contributor
0 Likes
1,229

Hi, Rangrej

As all Suggested assign first this date to char type filed length 10 and using following way you can assign this to type date.

Test Sample Code Bellow.

TYPES: BEGIN OF ty_test,
  cdate(10),
  date LIKE sy-datum,
  END OF ty_test.

DATA: it_test TYPE STANDARD TABLE OF ty_test WITH HEADER LINE.

it_test-cdate = '22/05/2008'. APPEND it_test.
it_test-cdate = '23/05/2008'. APPEND it_test.
it_test-cdate = '24/05/2008'. APPEND it_test.
it_test-cdate = '25/05/2008'. APPEND it_test.
it_test-cdate = '26/05/2008'. APPEND it_test.

LOOP AT it_test.
  it_test-date+0(4) = it_test-cdate+6(4).
  it_test-date+4(2) = it_test-cdate+3(2).
  it_test-date+6(2) = it_test-cdate+0(2).
  MODIFY it_test INDEX sy-tabix.
ENDLOOP.

Best Regards,

Faisal