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

Problem with BAPI_CREATE_DOCUMENT2

Former Member
0 Likes
693

Dear Experts,

I am trying to create a document info record with file attachment using BAPI_DOCUMENT_CREATE2 for quality management module. I am getting an error in return table "Error uploading document /tmp/notification.pdf'. It doesn't specify what the actual error is. When i executed this function module with a file on local system(presentation server) its creating document info record and can see the attachment in actual transaction. but when i execute with a file in application server i have this error. i have all authorizations required to read the file from the application server.

Our file is a PDF file and is in application server and here's my code. I created one RFC function module and called this BAPI inside this RFC function module. The file is in our SAP application server /tmp of directory DIR_TEMP in AL11 transaction.

Please suggest me some solution. Thanks in advance..

Thanks

Rajesh.

3 REPLIES 3
Read only

Former Member
0 Likes
586
FUNCTION ZTEST_DMS.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(I_QMNUM) LIKE  VIQMEL-QMNUM
*"----------------------------------------------------------------------
*structures and tables for BAPI
  DATA: LS_DOC LIKE BAPI_DOC_DRAW2.
  DATA: LT_FILES LIKE BAPI_DOC_FILES2 OCCURS 0 WITH HEADER LINE.
  DATA: LT_DRAD LIKE BAPI_DOC_DRAD OCCURS 0 WITH HEADER LINE.
  DATA: LS_RETURN LIKE BAPIRET2.
  DATA: FILE_TYPE(3) TYPE C.

*key fields of new document
  DATA: LF_DOCTYPE    LIKE BAPI_DOC_DRAW-DOCUMENTTYPE,
        LF_DOCNUMBER  LIKE BAPI_DOC_DRAW-DOCUMENTNUMBER,
        LF_DOCPART    LIKE BAPI_DOC_DRAW-DOCUMENTTYPE,
        LF_DOCVERSION LIKE BAPI_DOC_DRAW-DOCUMENTVERSION.

  DATA: W_HOSTNAME TYPE BAPI_DOC_AUX-HOSTNAME.
  DATA: BEGIN OF KERNEL_VERSION OCCURS 0,
                  KEY TYPE CHAR21,
                  DATA TYPE CHAR69,
             END OF KERNEL_VERSION.

    CALL 'SAPCORE' ID 'ID' FIELD 'VERSION'
    ID 'TABLE' FIELD KERNEL_VERSION-*SYS*.
    READ TABLE KERNEL_VERSION INDEX 11.
    W_HOSTNAME = KERNEL_VERSION-DATA.

 FILE_TYPE = 'PDF'.

** Allocate document data
  LS_DOC-DOCUMENTTYPE    = 'SQN'.
  LS_DOC-DOCUMENTVERSION = '000'.
  LS_DOC-DOCUMENTPART    = '00'.
  LS_DOC-WSAPPLICATION1 = 'PDF'.

 CONCATENATE FILE_TYPE '- SQN -' I_QMNUM INTO LS_DOC-DESCRIPTION SEPARATED BY SPACE.
 LS_DOC-STATUSEXTERN   = 'AA'.

 MOVE: LS_DOC-DOCUMENTTYPE    TO LT_FILES-DOCUMENTTYPE,
             LS_DOC-DOCUMENTPART    TO LT_FILES-DOCUMENTPART,
             LS_DOC-DOCUMENTVERSION TO LT_FILES-DOCUMENTVERSION,
             LS_DOC-DESCRIPTION     TO LT_FILES-DESCRIPTION,
             '1'                    TO LT_FILES-ORIGINALTYPE,
             'SAP-SYSTEM'           TO LT_FILES-STORAGECATEGORY,
             LS_DOC-WSAPPLICATION1   TO LT_FILES-WSAPPLICATION,
            '/tmp/notification.pdf'           TO LT_FILES1-DOCFILE.
   TRANSLATE LT_FILES1-WSAPPLICATION TO UPPER CASE.
Read only

0 Likes
586
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
        EXPORTING
          DOCUMENTDATA    = LS_DOC
          HOSTNAME        = W_HOSTNAME
          PF_HTTP_DEST    = 'SAPHTTPA'
          PF_FTP_DEST     = 'SAPFTPA'
        IMPORTING
          DOCUMENTTYPE    = LF_DOCTYPE
          DOCUMENTNUMBER  = LF_DOCNUMBER
          DOCUMENTPART    = LF_DOCPART
          DOCUMENTVERSION = LF_DOCVERSION
          RETURN          = LS_RETURN
        TABLES
          OBJECTLINKS     = LT_DRAD
          DOCUMENTFILES   = LT_FILES.
      IF LS_RETURN-TYPE CA 'EA'.
        ROLLBACK WORK.
        MESSAGE ID '26' TYPE 'I' NUMBER '000'
                WITH LS_RETURN-MESSAGE.
      ELSE.
        COMMIT WORK.
        MESSAGE ID '26' TYPE 'I' NUMBER '000'
                WITH 'Attachement added'.
      ENDIF.
Read only

0 Likes
586

Experts,

Any help on this?

Thanks in advance

Rajesh.