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

Upload data on Application server in CSV format

Former Member
0 Likes
523

Hi.

I have data in the Final Internal table and I need to save it in Application server

in Comma Delimited(CSV) format.

Example:

10000364,007-46781,10051397,20081114

10000550,41270OP,10051238,2008,1111

This has to be saved in the location DR1/Interfaces/OTC

I know we have to use open, read/ transfer, close dataset...etc

But not sure how to do it...can anybody explain me with the sample code...My data is in T_final and i need to upload 4 fields in Application server.

Any suggestions will be apprecaited!

Thanks & Regards,

Kittu

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
463

data: gv_output(255) type c.

p_file = 'DR1/Interfaces/OTC'.

CONCATENATE p_file

'\'

'Name'

sy-datum

sy-uzeit

'.xls'

INTO p_file.

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE.

IF sy-subrc <> 0.

MESSAGE e999 WITH 'Couldnt Open file.'.

ENDIF.

CONCATENATE

'header1'

'header2'

'header3'

INTO gv_output

SEPARATED BY ','.

TRANSFER gv_output TO p_file.

LOOP AT gt_table INTO gs_table.

CLEAR gv_output.

CONCATENATE

gs_table-field1

gs_table-field2

INTO gv_output

SEPARATED BY '|'.

TRANSFER gv_output TO p_file.

IF sy-subrc <> 0.

MESSAGE e999 WITH 'Transfer Is Failed'.

ENDIF.

ENDLOOP.

CLOSE DATASET p_file.

3 REPLIES 3
Read only

Former Member
0 Likes
464

data: gv_output(255) type c.

p_file = 'DR1/Interfaces/OTC'.

CONCATENATE p_file

'\'

'Name'

sy-datum

sy-uzeit

'.xls'

INTO p_file.

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE.

IF sy-subrc <> 0.

MESSAGE e999 WITH 'Couldnt Open file.'.

ENDIF.

CONCATENATE

'header1'

'header2'

'header3'

INTO gv_output

SEPARATED BY ','.

TRANSFER gv_output TO p_file.

LOOP AT gt_table INTO gs_table.

CLEAR gv_output.

CONCATENATE

gs_table-field1

gs_table-field2

INTO gv_output

SEPARATED BY '|'.

TRANSFER gv_output TO p_file.

IF sy-subrc <> 0.

MESSAGE e999 WITH 'Transfer Is Failed'.

ENDIF.

ENDLOOP.

CLOSE DATASET p_file.

Read only

Former Member
0 Likes
463

hi,

PARAMETER p_app LIKE rlgrap-filename. "filename foe application server

OPEN DATASET p_app FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc NE 0.

MESSAGE e000 WITH 'Error in file creation named - ' p_app.

ENDIF.

LOOP AT i_final.

TRANSFER i_final TO p_app. "to transfer i_final into p_app

IF sy-subrc NE 0.

MESSAGE e000 WITH 'Error writing records to file' p_app.

ENDIF.

ENDLOOP.

CLOSE DATASET p_app.

CHECK sy-subrc EQ 0.

MESSAGE s000 WITH 'File created successfully at' p_app.

Read only

Former Member
0 Likes
463

HI,

Thank you for your response!

I appreciate your suggestions!

Regards,

Kittu