‎2006 Nov 24 7:18 AM
how to handle files in application server by using opendata sets
‎2006 Nov 24 7:25 AM
Hi,
Hope this could be helpful..
FORM f_upload_appfile TABLES gi_lbox_chkrec USING p_afile.
*open the file to which data is to be sent
OPEN DATASET p_ifile FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
DO.
READ DATASET p_ifile INTO gw_lbox_chkrec.
IF sy-subrc = 0.
APPEND gw_lbox_chkrec TO gi_lbox_chkrec.
CLEAR: gw_lbox_chkrec.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET p_ifile.
IF sy-subrc <> 0.
MESSAGE i170(yfi) . " 'Error in closing the file'.
LEAVE LIST-PROCESSING.
ENDIF.
ELSE.
MESSAGE i169(yfi). "Error in opening the file'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " f_upload_appfile
-Mohan
‎2006 Nov 24 7:25 AM
Hi,
Hope this could be helpful..
FORM f_upload_appfile TABLES gi_lbox_chkrec USING p_afile.
*open the file to which data is to be sent
OPEN DATASET p_ifile FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
DO.
READ DATASET p_ifile INTO gw_lbox_chkrec.
IF sy-subrc = 0.
APPEND gw_lbox_chkrec TO gi_lbox_chkrec.
CLEAR: gw_lbox_chkrec.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET p_ifile.
IF sy-subrc <> 0.
MESSAGE i170(yfi) . " 'Error in closing the file'.
LEAVE LIST-PROCESSING.
ENDIF.
ELSE.
MESSAGE i169(yfi). "Error in opening the file'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " f_upload_appfile
-Mohan
‎2006 Nov 24 7:28 AM
Hi Raju,
what do u need exactly?
normally for keeping the files in the Application server you can use the following code..
REPORT ZMURALI_DS_UPLOAD.
CONSTANTS: C_FILE(20) VALUE '.\MURALI123.TXT'.
DATA: V_MSG(100).
DATA: BEGIN OF ITAB OCCURS 0,
MATNR(18),
WERKS(4),
LGORT(4),
END OF ITAB.
data :itab1 like itab occurs 0 with header line.
ITAB-MATNR = 'ABC123'.
ITAB-WERKS = '1000'.
ITAB-LGORT = '0001'.
APPEND ITAB.
CLEAR ITAB.
ITAB-MATNR = 'ABC456'.
ITAB-WERKS = '1001'.
ITAB-LGORT = '0002'.
APPEND ITAB.
CLEAR ITAB.
ITAB-MATNR = 'ABC789'.
ITAB-WERKS = '1002'.
ITAB-LGORT = '0003'.
APPEND ITAB.
CLEAR ITAB.
ITAB-MATNR = 'ABC101'.
ITAB-WERKS = '1003'.
ITAB-LGORT = '0004'.
APPEND ITAB.
CLEAR ITAB.
OPEN DATASET C_FILE FOR input
IN TEXT MODE
ENCODING DEFAULT
MESSAGE V_MSG.
IF SY-SUBRC NE 0.
WRITE:/'NO FILE'.
EXIT.
ENDIF.
do.
read dataset c_file into itab1.
if sy-subrc eq 0.
append itab1.
else.
exit.
endif.
enddo.
CLOSE DATASET C_FILE.
‎2006 Nov 24 7:29 AM
You can try this
DATA: v_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.
OPEN DATASET v_file FOR INPUT IN TEXT MODE.
IF sy-subrc NE 0.
MESSAGE 'Error opening file' TYPE 'E'.
ENDIF.
DO.
Reads each line of file individually
READ DATASET v_file INTO <WORK_AREA>.
Perform processing here
.....
ENDDO.
Regards
Kathirvel
‎2006 Nov 24 7:31 AM
hi
check the below link you will get good info
http://help.sap.com/saphelp_webas620/helpdata/en/fc/eb3d42358411d1829f0000e829fbfe/content.htm
Regards,
Naveen