Skip to Content
0
Former Member
May 08, 2010 at 12:49 PM

Errors in reading Fields Value while uploading data from CSV file

499 Views

Dear ABAP Guru

I am facing a problem in which the values of the fields gets truncated while reading the data from CSV File

as per below given details:

009,000000000019214,OMC1,TEST-BIN-1

009,000000000019215,OMC1,TEST-BIN-2

009,000000000019216,OMC1,TEST-BIN-3

  • ABAP PROGRAM ********

REPORT ZUPDATE_BIN.

  • Data declarations for later use

TABLES MARD.

PARAMETERS FILENAME(128) DEFAULT 'c:\testfile.csv'

LOWER CASE.

DATA: MSG_TEXT(50),ws_mandt(4),ws_matnr(18),ws_werks(4),ws_lgort(4),ws_bin(10).

Data : BEGIN OF idetail occurs 0, "This is a temp-table where SELECT data is to be stored

mandt type c, "Client char(3)

comma_1(1) type c, "Comma

matnr(18) type c, "Material char(18)

comma_2(1) type c, "Comma

werks(4) type c, "plant char(4)

comma_3(1) type c, "Comma

lgort(4) type c, "storage location char(4)

comma_4(1) type c, "Comma

bin(10) type c. "Storage bin char(10)

data : END OF idetail.

OPEN DATASET FILENAME FOR INPUT IN TEXT MODE ENCODING DEFAULT MESSAGE MSG_TEXT.

IF SY-SUBRC NE 0.

WRITE: 'File cannot be opened. Reason:', MSG_TEXT.

EXIT.

ENDIF.

DO.

READ DATASET FILENAME INTO idetail.

IF SY-SUBRC NE 0.

EXIT.

ENDIF.

APPEND idetail.

ENDDO.

CLOSE DATASET FILENAME.

LOOP AT IDETAIL.

WRITE: / IDETAIL.

write : / idetail-matnr , idetail-bin.

ENDLOOP.

RESULTS

009,000000000019214,OMC1,TEST-BIN-1

9,000000000019214, IN-1

009,000000000019215,OMC1,TEST-BIN-2

9,000000000019215, IN-2

Note : Please note that my fields values are being truncated

Edited by: Anil Bedi on May 9, 2010 10:14 AM