‎2009 Apr 03 8:31 AM
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
‎2009 Apr 03 8:41 AM
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.
‎2009 Apr 03 8:41 AM
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.
‎2009 Apr 03 8:44 AM
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.
‎2009 Apr 13 4:06 PM
HI,
Thank you for your response!
I appreciate your suggestions!
Regards,
Kittu