Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

'File path is invalid'

Former Member
0 Likes
2,819

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,668

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.

9 REPLIES 9
Read only

Former Member
0 Likes
1,668

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>

Read only

abdul_hakim
Active Contributor
0 Likes
1,668

hi helen use

v_afile = '/usr/sap/comm/recv/in/MMSC07/PIR1.txt'.

Cheers,

Abdul Hakim

Mark all useful answers..

Read only

0 Likes
1,668

Use the method describe in this thread !!

Thanks

SK

Read only

Former Member
0 Likes
1,668

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

Read only

Former Member
0 Likes
1,669

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.

Read only

0 Likes
1,668

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

Read only

0 Likes
1,668

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

Read only

0 Likes
1,668

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

Read only

Former Member
0 Likes
1,668

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