SAP ABAP FILES
From SapWiki
Contents
OPEN DATASET & TRANSFER
DATA: l_error TYPE string, lo_x TYPE REF TO cx_root, l_file TYPE string, l_nombre TYPE string, l_butxt TYPE t001-butxt, l_linea(8000). OPEN DATASET l_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. IF sy-subrc <> 0. MESSAGE i000(0k) WITH 'Error al crear archivo' l_file DISPLAY LIKE 'E'. RETURN. ENDIF. LOOP AT gt_csv_tab INTO ls_csv_tab. TRY. move ls_csv_tab to l_linea. TRANSFER l_linea TO l_file. CATCH cx_sy_codepage_converter_init cx_sy_conversion_codepage cx_sy_file_authority cx_sy_file_io cx_sy_file_open cx_sy_file_open_mode cx_sy_pipe_reopen cx_sy_too_many_files INTO lo_x. l_error = lo_x->get_text( ). MESSAGE i000(0k) WITH 'Error en transferencia de datos' l_error DISPLAY LIKE 'E'. CLOSE DATASET l_file. RETURN. ENDTRY. ENDLOOP. CLOSE DATASET l_file. IF sy-subrc = 0. MESSAGE i000(0k) WITH 'Archivo creado con éxito' p_file l_nombre DISPLAY LIKE 'S'. ELSE. MESSAGE i000(0k) WITH 'Error al crear archivo' l_file DISPLAY LIKE 'E'. ENDIF.