Skip to Content
avatar image
Former Member

How to replace an original in DIS with BAPI?

Hi,

i want to replace an original file with an another file in a document.

My first try was to use the BAPI_DOCUMENT_CHANGE2 but whatever i do,

i can't replace the file.

Have i to delete the original and then append the another file or is there any other way?

Has anyone an idea?

Here is my sample-code to delete the originals.

REPORT  Z_TEST_DOC_CHANGE.

DATA : lv_doctype          TYPE bapi_doc_aux-doctype,

        lv_docnumber        TYPE  bapi_doc_aux-docnumber,

        lv_documentpart     TYPE  bapi_doc_aux-docpart,

        lv_documentversion  TYPE bapi_doc_aux-docversion,

        lwa_documentdata    TYPE bapi_doc_draw2,

        lwa_datax           TYPE bapi_doc_drawx2,

        lwa_return          TYPE bapiret2,

        lt_docfiles         TYPE STANDARD TABLE OF bapi_doc_files2,

        lwa_docfiles        TYPE bapi_doc_files2.

*For example sake Im assuming the following values below

lv_doctype = 'ZPR'.

lv_docnumber = '050001----ZF01-'.

lv_documentpart = '000'.

lv_documentversion = 'A'.

*Get Document Details for the above doc number

CALL FUNCTION 'BAPI_DOCUMENT_GETDETAIL2'

   EXPORTING

     documenttype        = lv_doctype

     documentnumber   = lv_docnumber

     documentpart        = lv_documentpart

     documentversion   = lv_documentversion

     getactivefiles         = 'X'

     getdocdescriptions = 'X'

     getdocfiles             = 'X'

   IMPORTING

     documentdata       = lwa_documentdata

     return                   = lwa_return

   TABLES

     documentfiles      = lt_docfiles.

*Indicate the fields which will be deleted namely the original file characteristics

lwa_datax-docfile1                = 'X'.  "Mark this as 'X' only if this has data in lwa_documentdata-docfile1

lwa_datax-datacarrier1            = 'X'.  "Mark this as 'X' only if this has data in lwa_documentdata-datacarrier1

lwa_datax-wsapplication1          = 'X'.  "Mark this as 'X' only if this has data in lwa_documentdata-wsapplication1

          "You get back all the files in the structure lt_docfiles.

LOOP AT lt_docfiles INTO lwa_docfiles.

   lwa_docfiles-deletevalue = 'X'.   "Do the following for all files you want to delete

   MODIFY lt_docfiles FROM lwa_docfiles INDEX sy-tabix TRANSPORTING deletevalue.

   CLEAR : lwa_docfiles.

ENDLOOP.

CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2'

   EXPORTING

     documenttype       = lv_doctype

     documentnumber  = lv_docnumber

     documentpart        = lv_documentpart

     documentversion   = lv_documentversion

     documentdata        = lwa_documentdata  "this is filled in above fm call no modification required

     documentdatax       = lwa_datax

   IMPORTING

     return                    = lwa_return

   TABLES

     documentfiles         = lt_docfiles.

IF lwa_return-type NE 'E'.

   CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

     EXPORTING

       wait = 'X'.

ENDIF.

.

Thanks in advance

Sebastian

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Jan 28, 2015 at 05:46 AM

    Hi,

    If your are using content server/KPRO then try below bapis

    CVAP_Doc_Getdetail

    CVAP_Doc_Change

    Also go thru below thread. This may solve your purpose:

    Regards

    Shishir

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Beat Fuchs

      I think you can create your own function module based on

      kpro_file_delete_main code @ SAPLCV110/LCV110F06/344

      Not sure if its big stretch or of any help

  • Nov 12, 2015 at 07:15 AM

    Hi Niketan

    I was successfull by using Bapis in the following order:

    - BAPI_DOCUMENT_GETDETAIL2

    - BAPI_DOCUMENT_CHECKOUTSET2

    - BAPI_DOCUMENT_CHANGE2

    Regards

    Beat

    Add comment
    10|10000 characters needed characters exceeded