Skip to Content

Issue : Mark Old Purcahse Requsiton as closed.

Solution : Marking a PR for closure is 10 seconds work, but if the PR is 10 years old and for the same PR material is deleted or vendor or PIR then the sytem will not allow you to close the PR.

We can use fucniton Module : BAPI_REQUISITION_DELETE.

Let me explain with a Example.

1. Consider a PR which was created long back.

NB STO.jpg

2. Go to Tcode SE37 Fucniton Builder and give BAPI_REQUISITION_DELETE.

Funciton Module.jpg

3. Execute function module and give required PR number.

Number.jpg

4. After entering PR number, doble click on Table “REQUISITON_ITEMS_TO_DELETE“,  and give line item number of PR and Mark “X” in column “C“.

Item Number.jpg

5. After entering values, come back and execute function module.

Execution.jpg

Result.jpg

6. Please check your PR , PR is marked as Closed.

Final.jpg

In this way we can close a PR.

This fucniton module can be used to convert one PR at time.

you can close multiple PR at a time. Please check with your ABAP team members they can create a program using this function module.

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Jürgen L

    I would be very very careful with this function module.

    It is an old function module which is only still there because SAP wants to be upward compatible. It has contrary to the standard BAPI design the commit within. Reference OSS note 394058 – BAPI_REQUISITION and COMMIT WORK

    And if you really want to use it then make sure you are current with the OSS notes, there are 31 with program fixes since this FM deleted more than it was supposed to do.

    (0) 
  2. Mehmet Ozgur Unal

    Hi all ,

    I benefited from this bapi to change a lot of PR items. Belowed program can be used by developers.

    The point of focus that there are two options : Delete indicator and closed. Please check BAPIEBAND structure.

    *&---------------------------------------------------------------------*
    *& Report  ZMM_R015
    *&
    *&---------------------------------------------------------------------*
    *& M.Ozgur Unal - 23.03.2016 - SP IT Department
    *&
    *& Satınalma taleplerinin toplu olarak tamamlandı ya da silinmesi
    *& işlemini yapmaktadır.
    *&---------------------------------------------------------------------*
    
    
    REPORT ZMM_R015.
    
    
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text1.
    PARAMETERS: p_uname LIKE sy-uname DEFAULT sy-uname.
    SELECTION-SCREEN END OF BLOCK b1 .
    
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text2.
    PARAMETERS : r1 RADIOBUTTON GROUP rad1, "tamamla
                 r2 RADIOBUTTON GROUP rad1. "sil
    SELECTION-SCREEN END OF BLOCK b2 .
    
    ************************************************************************
    *&   VERI TANIMLAMALARI
    *&
    ************************************************************************
    DATA: BEGIN OF hata OCCURS 0,
           type TYPE char1,
           code TYPE char5,
           ara1 TYPE char5,
           message TYPE char100,
          END OF hata.
    
    DATA: BEGIN OF result OCCURS 0,
           banfn TYPE banfn,
          END OF result.
    
    DATA: BEGIN OF itab OCCURS 0,
            banfn    TYPE banfn,
            bnfpo  TYPE bnfpo,
          END OF itab.
    
    DATA: BEGIN OF itab_ozet OCCURS 0,
            banfn    TYPE banfn,
          END OF itab_ozet.
    
    DATA: lv_satno   LIKE bapieban-preq_no,
          lt_items_d LIKE bapieband OCCURS 0 WITH HEADER LINE,
          lt_return  LIKE bapireturn OCCURS 0 WITH HEADER LINE.
    
    START-OF-SELECTION.
    
      PERFORM get_data.
    
    END-OF-SELECTION.
    
      CHECK NOT itab[] IS INITIAL.
    
      PERFORM stok.
    
      PERFORM rapor.
    
    ************************************************************************
    *&   FORM get_data                                                     *
    *&
    ************************************************************************
    FORM get_data.
    
      CALL FUNCTION 'UPLOAD'
       EXPORTING
    *   CODEPAGE                      = ' '
        filename                      = ' '
        filetype                      = 'DAT'
    *   ITEM                          = ' '
    *   FILEMASK_MASK                 = ' '
    *   FILEMASK_TEXT                 = ' '
    *   FILETYPE_NO_CHANGE            = ' '
    *   FILEMASK_ALL                  = ' '
    *   FILETYPE_NO_SHOW              = ' '
    *   LINE_EXIT                     = ' '
    *   USER_FORM                     = ' '
    *   USER_PROG                     = ' '
    *   SILENT                        = 'S'
    * IMPORTING
    *   FILESIZE                      =
    *   CANCEL                        =
    *   ACT_FILENAME                  =
    *   ACT_FILETYPE                  =
        TABLES
          data_tab                      = itab
     EXCEPTIONS
       conversion_error              = 1
       invalid_table_width           = 2
       invalid_type                  = 3
       no_batch                      = 4
       unknown_error                 = 5
       gui_refuse_filetransfer       = 6
       OTHERS                        = 7 .
      .
      IF sy-subrc <> 0.
    *    message e022(zmm).
    
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    
    ENDFORM.                    "get_data
    
    ************************************************************************
    *&   FORM stok                                                         *
    *&
    ************************************************************************
    FORM stok.
    
    *  break ounal.
    
    */itab'ı sıralayalım.
      SORT itab BY  banfn bnfpo.
    
    */RKPF 'yi doldurmak için Özet tabloyu dolduralım.
      LOOP AT itab.
        MOVE-CORRESPONDING itab TO itab_ozet.
        COLLECT itab_ozet.
      ENDLOOP.
    
    */Bapi datalarını dolduralım ve rezervasyon oluşturalım.
      LOOP AT itab_ozet.
    
        CLEAR: lv_satno,
           lt_return, lt_return[],
           lt_items_d, lt_items_d[].
    
    */header
        lv_satno = itab_ozet-banfn.
    
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = lv_satno
          IMPORTING
            output = lv_satno.
    
    */Kalem verilerini dolduralım.
        LOOP AT itab  WHERE banfn  = itab_ozet-banfn.
          CLEAR: lt_items_d.
          lt_items_d-preq_item  = itab-bnfpo.
          IF r1 = 'X'.
            lt_items_d-closed     = 'X'.
          ELSEIF r2 = 'X'.
            lt_items_d-delete_ind = 'X'.
          ENDIF.
          APPEND lt_items_d.
        ENDLOOP.
    
    */Eğer başlık ve kalem dolu ise bapiyi çağıralım.
        IF NOT lv_satno IS INITIAL.
          PERFORM bapi_purreq_delete.
        ENDIF.
      ENDLOOP.
    
    ENDFORM.                    "stok
    
    ************************************************************************
    *&   FORM bapi_purreq_delete                                           *
    *&
    ************************************************************************
    FORM bapi_purreq_delete .
    
      SET UPDATE TASK LOCAL.
    
    */Silme işlemine başlayalım..
      CLEAR: lt_return, lt_return[].
    
      SET UPDATE TASK LOCAL.
    
      CALL FUNCTION 'BAPI_REQUISITION_DELETE'
        EXPORTING
          number                      = lv_satno
        TABLES
          requisition_items_to_delete = lt_items_d
          return                      = lt_return.
    
    */Hata mesajı yok ise commit çalıştıralım..
      READ TABLE lt_return WITH KEY type = 'E'.
      IF sy-subrc NE 0."hata yoksa devam et
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait = 'X'.
        result-banfn = lv_satno.
        APPEND result.
    
    */hata mesajlarını toplayalım.
      ELSE.
        LOOP AT lt_return WHERE type = 'E'
                             OR type = 'I'.
          CLEAR hata.
          MOVE-CORRESPONDING lt_return TO hata.
          COLLECT hata.
        ENDLOOP.
      ENDIF.
    
    ENDFORM.                    " bapi_purreq_delete
    
    *&---------------------------------------------------------------------*
    *&      Form  rapor
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    FORM rapor.
      WRITE:/ 'SAT Tamamlama İŞLEM SONUCU:'.
      LOOP AT result.
        WRITE:/ result.
      ENDLOOP.
    
      WRITE:/ '..'.
      WRITE:/ 'İŞLEM HATALARI:'.
      LOOP AT hata.
        WRITE:/ hata.
      ENDLOOP.
    
    ENDFORM.                    " rapor
    

    Regards.

    M.Ozgur Unal

    (0) 

Leave a Reply