2008 Mar 17 3:14 PM
Hi Gurus,
I hve to read the data from unix server which is in CSV file format and it has to convert in to TXT file format
how to achive this, asure reward
with regards,
Thiru
2008 Mar 17 3:32 PM
Hi Gurus,
I hve to read the data from unix server which is in CSV file format and it has to convert in to TXT file format
how to achive this, asure reward
with regards,
Thiru
2008 Mar 17 3:26 PM
You can use transactions CG3Y and CG3Z. Its very simple.
Refer sample code:
constants: c_split TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
c_path TYPE VALUE char100 '/local/data/interface/A28/DM/OUT'.
&----
*& Form f1001_browse_appl_file
&----
Pick up the file path for the file in the application server
&----
FORM f1001_browse_appl_file .
DATA: lcl_directory TYPE char128.
lcl_directory = p_direct.
CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
EXPORTING
directory = lcl_directory
filemask = c_mask
IMPORTING
serverfile = p_f2
EXCEPTIONS
canceled_by_user = 1
OTHERS = 2.
IF sy-subrc 0.
MESSAGE s000 WITH text-039.
EXIT.
ENDIF.
ENDFORM. " f1001_browse_appl_file
&----
*& Form f1004_app_file
&----
upload the file from the application server
&----
FORM f1004_app_file .
REFRESH: i_input.
OPEN DATASET p_f2 IN TEXT MODE ENCODING DEFAULT FOR INPUT.
IF sy-subrc EQ 0.
DO.
READ DATASET p_f2 INTO wa_input_rec.
IF sy-subrc 0.
MESSAGE s000 WITH text-030.
EXIT.
ENDIF.
*
o
+ Split The CSV record into Work Area
PERFORM f0025_record_split.
*
o
+ Populate internal table.
APPEND wa_input TO i_input.
CLEAR wa_input.
ENDDO.
ENDIF.
ENDFORM. " f1004_app_file
&----
*& Form f0025_record_split
&----
Move the assembly layer file into the work area
&----
FORM f0025_record_split .
CLEAR wa_input.
SPLIT wa_input_rec AT c_split INTO
wa_input-legacykey
wa_input-profile_role
wa_input-read_date.
ENDFORM. " f0025_record_split
DO your manipulation with the data records here.
Popualte data into final internal table and write it back to application server at the desired path.
&----
*& Form f0020_write_application
&----
Write error log to application Server
-
FORM f0020_write_application .
IF p_f1 IS NOT INITIAL.
CONCATENATE p_direct p_obj sy-datum text-037 INTO p_f2.
ELSEIF p_f2 IS NOT INITIAL.
REPLACE text-036 IN p_f2 WITH text-037.
ENDIF.
OPEN DATASET p_f2 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc 0.
EXIT.
ENDIF.
LOOP AT i_error INTO wa_error.
TRANSFER wa_error TO p_f2.
IF sy-subrc 0.
EXIT.
ENDIF.
CLEAR wa_error.
ENDLOOP.
CLOSE DATASET p_f2.
ENDFORM. " f0020_write_application
- Guru
2008 Mar 17 3:32 PM
2008 Mar 31 2:08 PM