cancel
Showing results for 
Search instead for 
Did you mean: 

RFC Error while checking and storing C:\...

Former Member
0 Kudos

Hi all,

I'm trying to attach photo to PM notification (tcode iw22). I use FM BAPI_DOCUMENT_CREATE2 to upload photo from local disc C.

Here is my code:

ls_drad-objecttype = 'PMQMEL'.
ls_drad-objectkey = I_MESSAGENUMBER.
APPEND ls_drad TO lt_drad.

ls_doc_data-documenttype = 'MS1'.
ls_doc_data-documentnumber = '*'.
ls_doc_data-description = 'Photo description'.


LOOP AT t_files ASSIGNING <fs_file>.

     ls_files-documenttype = 'MS1'.
     ls_files-storagecategory = 'DMS_C1_ST'.
     ls_files-docfile = <fs_file>-filepath.
     ls_files-wsapplication = <fs_file>-wsapplication.
     ls_files-description = <fs_file>-description.
     ls_files-SOURCEDATACARRIER = 'DEFAULT'.
     APPEND ls_files TO lt_files.
ENDLOOP.

   CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
       EXPORTING
         documentdata               = ls_doc_data
      IMPORTING
        documentnumber             = docnum
        return                     = ret
      TABLES
        objectlinks                = lt_drad
        documentfiles              = lt_files
               .

     IF sy-subrc EQ 0.
       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
     ENDIF.

It works fine when I execute this code, my photos succesfully attaching.

The problem appears when I try to execute my code by RFC. I got the following dump message:


CALL_FUNCTION_SEND_ERROR

Short text

    " " (I/O error)

What happened?

    "connection closed (no data)"

An error occurred when executing a Remote Function Call.

SY-MSGTY I

SY-MSGID 26

SY-MSGNO 253

SY-MSGV1 C:\Photos\photo1.jpg

It means "Error while checking and storing C:\Photos\photo1.jpg".

I guess this happens because the system can`t find the path C:\xxx while in RFC mode, but I`m not sure.

So my question is how to attach JPG files to PM notification by RFC?

Any help appreciated,

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

christoph_hopf
Advisor
Advisor
0 Kudos

Hi Anton,

please try to use the destinations SAPHTTP/SAPHTTPA or SAPFTP/SAPFTPA because sometimes this could help to avoid such problems. Further you can check the log files in transaction SLG1 after simulating the error message. The log file will provide further details why this error is raised.

Best regards,

Christoph

Former Member
0 Kudos

Hello Christoph,

thank you for your answer!

I added the HOSTNAME, PF_FTP_DEST and PF_HTTP_DEST parameters. It is still not working but in SLG1 I can see the following error:

STOR_CAT   DMS_C1_ST

PATH       C:\1\tempPhotos\

FRONTEND   X

ERRMSG     RFC server sapftp cannot be started - 1: The valid RFC handle 1 refers to an invalid memory   

V1         SCMS_DOC_CREATE_FILES

V2                                                        13

V3         DMS_PCD1

V4         602900516D38E81DE10000000AC5001F

%LOGNUMBER 00000000000001235894

If I try to set PF_FTP_DEST as SAPFTPA I get another error:

RFC server SAPFTPA cannot be started - 1: Connect to SAP gateway or RFC server failed

and after that:

STOR_CAT   DMS_C1_ST

PATH       C:\1\tempPhotos\

FRONTEND   X

ERRMSG     Error in opening file C:\1\tempPhotos\photo1.jpg for reading (No such file

ERRMSG     or directory)

I checked SM59 and found SAPFTP, SAPHTTP, SAPHTTPA (all connections succesfully tested), but no SAPFTPA at all.

I also checked OACT, there DMS_C1_ST is linked to H3 repository. In OAC0 I see that H3 repository storage type is "SAP system database" and not a content server.

So now I dont know what way to choose. Could you recommend me something?

Best wishes,

Anton.

jennifer_kramer2
Participant
0 Kudos

Hi Anton-

Not sure if this is the problem or not, but we would get that error if DNS wasn't working properly.  The workaround was to add the IP address and fully qualified SAP environment server name in the hosts.txt file.  (You can search your C: drive for "hosts.txt"). 

Hope it helps!

-J

Former Member
0 Kudos

The problem is solved.

To attach a file in background you should first upload it to application server. That is, the server can't find the path like "C:\myFiles\...". You should pass the path like "/path/to/file" instead. That path is realtive to appserver root.

To upload the file to appserver I use the following code:

TYPES: begin of ty_bindata,

               line type raw,

             end of ty_bindata.

DATA: t_bindata TYPE TABLE OF ty_bindata OCCURS 0.

field-symbols: <x> type any.

CONSTANTS: c_path_name TYPE localfile VALUE '/tmp/'.

" *******

" here the t_bindata is being filled by hex values

" ...

" *******

CONCATENATE c_path_name
                   lv_filename  " my file name
                   INTO w_file_name.

CONDENSE w_file_name  NO-GAPS.

OPEN DATASET w_file_name FOR OUTPUT
                                IN BINARY MODE
                                MESSAGE w_msg.
     IF sy-subrc <> 0.
       " message handling
     ENDIF.

     loop at t_bindata ASSIGNING <fs_bindata>.
       ASSIGN <fs_bindata>-line to <x> TYPE 'X'.
       TRANSFER <x> to w_file_name.
     endloop.

     CLOSE DATASET w_file_name.

After the file is uploaded you can attach it to everywhere you want:

      ls_files-documenttype = 'MS1'.
     ls_files-storagecategory = 'DMS_C1_ST'.
     ls_files-docfile = w_file_name.           " filename contains the path to file on the appserver
     ls_files-wsapplication = <fs_file>-wsapplication.
     ls_files-description = <fs_file>-description.
     ls_files-sourcedatacarrier = 'DEFAULT'.
     APPEND ls_files TO lt_files.

CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
     EXPORTING
       documentdata   = ls_doc_data
       pf_ftp_dest    = 'SAPFTPA'
       pf_http_dest   = 'SAPHTTPA'
     IMPORTING
       documentnumber = docnum
       return         = ret
     TABLES
       objectlinks    = lt_drad
       documentfiles  = lt_files.

Answers (0)