‎2006 Jun 08 8:39 PM
Hi,
I have a file name in the server:
/usr/sap/comm/recv/in/MMSC07/PIR1.txt
CALL FUNCTION 'RZL_READ_DIR_LOCAL'
EXPORTING
name = v_afile
TABLES
file_tbl = gt_files
EXCEPTIONS
argument_error = 1
not_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE e101 WITH v_afile.
ENDIF.
v_afile =/usr/sap/comm/recv/in/MMSC07/PIR1.txt
sy-subrc ='2' as result
-
in function: 'RZL_READ_DIR_LOCAL'
FULL_NAME = NAME. =/usr/sap/comm/recv/in/MMSC07/PIR1.txt
CALL 'ALERTS' ID 'ADMODE' FIELD AD_RZL
ID 'OPCODE' FIELD RZL_OP_RD_DIR
ID 'FILE_NAME' FIELD FULL_NAME
ID 'DIR_TBL' FIELD LINE_TBL-SYS.
CASE SY-SUBRC.
WHEN 0. LOOP AT LINE_TBL.
FILE_TBL-SIZE = LINE_TBL(10).
FILE_TBL-NAME = LINE_TBL+12.
APPEND FILE_TBL.
ENDLOOP.
WHEN OTHERS. RAISE NOT_FOUND.
ENDCASE.
I got '1' for SY_SUBRC.
The message is <b>'File path is invalid'</b>.
I double check the path and the file is there.
Here is my questions:
1. is 'RZL_READ_DIR_LOCAL' SAP deliveried function?
2. What the CALL 'ALERTS' do?
why I got '1' as result?
where I can see the source code?
3. How to let the ABAP pgm locate my file and do the process?
Thanks,
Helen
‎2006 Jun 08 8:54 PM
Hi Helen,
I hope u better try this way...
data: v_afile like SALFILE-LONGNAME .
v_afile = '/usr/sap/comm/recv/in/MMSC07/PIR1.txt'.
and then pass v_afile to FM 'RZL_READ_DIR_LOCAL'
Regards,
Kiran.
‎2006 Jun 08 8:43 PM
hi Helen
Put that file name in this way i.e, within a colon..
<b>v_afile = '/usr/sap/comm/recv/in/MMSC07/PIR1.txt'.</b>
Regards,
Santosh
<b>REWARD IF IT HELPS</b>
‎2006 Jun 08 8:46 PM
hi helen use
v_afile = '/usr/sap/comm/recv/in/MMSC07/PIR1.txt'.
Cheers,
Abdul Hakim
Mark all useful answers..
‎2006 Jun 08 8:47 PM
‎2006 Jun 08 8:52 PM
This is a standard SAP FM.
Try cutting and pasting the name of the file (from wherever you check that it exists) into the variable v_afile. Check that it's the same when the FM is entered.
Rob
‎2006 Jun 08 8:54 PM
Hi Helen,
I hope u better try this way...
data: v_afile like SALFILE-LONGNAME .
v_afile = '/usr/sap/comm/recv/in/MMSC07/PIR1.txt'.
and then pass v_afile to FM 'RZL_READ_DIR_LOCAL'
Regards,
Kiran.
‎2006 Jun 08 8:59 PM
I don't think that this function module is designed to read your file, only the directory. So if you where to do something like this.
report zrich_0001 .
data: ifile type table of salfldir with header line.
parameters: p_file type salfile-longname
default '/usr/sap/comm/recv/in/MMSC07/'.
call function 'RZL_READ_DIR_LOCAL'
exporting
name = p_file
tables
file_tbl = ifile
exceptions
argument_error = 1
not_found = 2
others = 3.
loop at ifile.
write:/ ifile.
endloop.
Then this program would show your PIR.txt file in the output list.
If you want to read the file itself, please use OPEN DATASET.
Regards,
Rich Heilman
‎2006 Jun 08 9:00 PM
Here is the sample application for OPEN DATASET.
report zrich_0001.
Parameters: d1 type localfile default '/usr/sap/TST/SYS/Data1.txt'.
data: begin of itab occurs 0,
rec(1000) type c,
end of itab.
data: wa(1000) type c.
start-of-selection.
open dataset d1 for input in text mode.
if sy-subrc = 0.
do.
read dataset d1 into wa.
if sy-subrc <> 0.
exit.
endif.
itab-rec = wa.
append itab.
enddo.
endif.
close dataset d1.
Regards,
Rich Heilman
‎2006 Jun 08 9:15 PM
Here is a good sample puttin the two together, the program will give a list of the file in the directory and then allow you to write the file contents to the list display by clicking on the filename.
report zrich_0001 .
data: begin of itab occurs 0,
rec(1000) type c,
end of itab.
data: wa(1000) type c.
data: p_file type localfile.
data: ifile type table of salfldir with header line.
parameters: p_path type salfile-longname
default '/usr/sap/comm/recv/in/MMSC07/'.
call function 'RZL_READ_DIR_LOCAL'
exporting
name = p_path
tables
file_tbl = ifile
exceptions
argument_error = 1
not_found = 2
others = 3.
loop at ifile.
format hotspot on.
write:/ ifile-name.
hide ifile-name.
format hotspot off.
endloop.
at line-selection.
concatenate p_path ifile-name into p_file.
clear itab. refresh itab.
open dataset p_file for input in text mode.
if sy-subrc = 0.
do.
read dataset p_file into wa.
if sy-subrc <> 0.
exit.
endif.
itab-rec = wa.
append itab.
enddo.
endif.
close dataset p_file.
loop at itab.
write:/ itab.
endloop.
Regards,
Rich Heilman
‎2006 Jun 08 9:21 PM
HI,
Write the file name in the single codes.
<b>v_afile = '/usr/sap/comm/recv/in/MMSC07/PIR1.txt'.</b>
1) RZL_READ_DIR_LOCAL --> Get list of files within specific directory(Application Server)
2) If you want to Locate the file .. then use the DATASET functionmodules
OPEN_DATASET <Dataset name> <Text mode>
CLOSE_DATASET.
Thanks
Sudheer