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: 

CSV file

Former Member
0 Kudos

Hi,

iam uploding data from flatfile to internaltable.my flatfile is csv file and amount field also contains comma how can i handle? please provide solution.

Regards,

Suresh

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Here you change the amount filed value as it dont contain any commas. below code will work. if you still having probs then so like this. move the amount filed value to any character value and then remove those commas and then upload.

try like this...

TYPE-POOLS: truxs.

TYPES:

BEGIN OF ty_Line,

vbeln LIKE vbap-vbeln,

posnr LIKE vbap-posnr,

END OF ty_Line.

ty_Lines TYPE STANDARD TABLE of ty_Line WITH DEFAULT KEY.

DATA: itab TYPE ty_Lines.

DATA: itab1 TYPE truxs_t_text_data.

SELECT

vbeln

posnr

UP TO 10 ROWS

FROM vbap

INTO TABLE itab.

CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'

EXPORTING

i_field_seperator = ';'

TABLES

i_tab_sap_data = itab

CHANGING

i_tab_converted_data = itab1

EXCEPTIONS

conversion_failed = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'C:\TEMP\test.txt'

TABLES

data_tab = itab1

EXCEPTIONS

OTHERS = 1.

 

1 REPLY 1

Former Member
0 Kudos

Here you change the amount filed value as it dont contain any commas. below code will work. if you still having probs then so like this. move the amount filed value to any character value and then remove those commas and then upload.

try like this...

TYPE-POOLS: truxs.

TYPES:

BEGIN OF ty_Line,

vbeln LIKE vbap-vbeln,

posnr LIKE vbap-posnr,

END OF ty_Line.

ty_Lines TYPE STANDARD TABLE of ty_Line WITH DEFAULT KEY.

DATA: itab TYPE ty_Lines.

DATA: itab1 TYPE truxs_t_text_data.

SELECT

vbeln

posnr

UP TO 10 ROWS

FROM vbap

INTO TABLE itab.

CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'

EXPORTING

i_field_seperator = ';'

TABLES

i_tab_sap_data = itab

CHANGING

i_tab_converted_data = itab1

EXCEPTIONS

conversion_failed = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'C:\TEMP\test.txt'

TABLES

data_tab = itab1

EXCEPTIONS

OTHERS = 1.