Application Development 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: 

Delivery Complete Indicator Check Box Tick

akjayaa
Explorer
0 Kudos

me23n.pngelikz.png

On PO screen at Item level, I want Delivery complete indicator checkbox to be tick for all open PO as i want to close all the PO's. Through ABAP Program?

In the screenshot elikz.png as I highlighted, I want all the PO to be released i.e. 'del. cmpl.' field to be marked as X automatically through ABAP program

Table Name : EKBE

Filed Name-ELIKZ

1 ACCEPTED SOLUTION

venkateswaran_k
Active Contributor

Hiakjayaa

Please refer to the sample program here. you can modify it as per your requirement.

LOOP AT it_po INTO wa_po. 
     k_tabix = sy-tabix.
     PERFORM bapi_po_change.
ENDLOOP.
FORM bapi_po_change .
  DATA: l_ponumber  LIKE bapimepoheader-po_number,
        i_po_items  TYPE TABLE OF bapimepoitem WITH HEADER LINE,
        i_po_itemsx TYPE TABLE OF bapimepoitemx WITH HEADER LINE,
        i_return    TYPE TABLE OF bapiret2 WITH HEADER LINE.
  CLEAR: i_po_items, i_po_items[],
         i_po_itemsx, i_po_itemsx[],
         i_return, i_return[].

  l_ponumber = wa_po-ebeln.
  i_po_items-po_item = wa_po-ebelp.
  i_po_items-deliv_compl = 'X'.
  i_po_items-no_more_gr = 'X'.
  i_po_itemsx-po_item = i_po_items-po_item.
  i_po_itemsx-po_itemx = 'X'.       "Item holds changes
  i_po_itemsx-no_more_gr = 'X'.
  i_po_items-conf_ctrl = '0001'.
  i_po_itemsx-conf_ctrl = 'X'.

  i_po_itemsx-deliv_compl = 'X'.     "Deletion field is changed
  APPEND: i_po_items, i_po_itemsx.

  CALL FUNCTION 'BAPI_PO_CHANGE'
    EXPORTING
      purchaseorder = l_ponumber
      testrun       = space
    TABLES
      poitem        = i_po_items
      poitemx       = i_po_itemsx
      return        = i_return.
READ TABLE i_return WITH KEY type = 'E'.
  IF sy-subrc NE 0.
    wa_output-message = 'Error in Update data'..  "i_return-message.
ELSE. wa_output-message = 'Updated..' . CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'. ENDIF. ENDFORM.

Regards,

Venkat

8 REPLIES 8

venkateswaran_k
Active Contributor

Hiakjayaa

Please refer to the sample program here. you can modify it as per your requirement.

LOOP AT it_po INTO wa_po. 
     k_tabix = sy-tabix.
     PERFORM bapi_po_change.
ENDLOOP.
FORM bapi_po_change .
  DATA: l_ponumber  LIKE bapimepoheader-po_number,
        i_po_items  TYPE TABLE OF bapimepoitem WITH HEADER LINE,
        i_po_itemsx TYPE TABLE OF bapimepoitemx WITH HEADER LINE,
        i_return    TYPE TABLE OF bapiret2 WITH HEADER LINE.
  CLEAR: i_po_items, i_po_items[],
         i_po_itemsx, i_po_itemsx[],
         i_return, i_return[].

  l_ponumber = wa_po-ebeln.
  i_po_items-po_item = wa_po-ebelp.
  i_po_items-deliv_compl = 'X'.
  i_po_items-no_more_gr = 'X'.
  i_po_itemsx-po_item = i_po_items-po_item.
  i_po_itemsx-po_itemx = 'X'.       "Item holds changes
  i_po_itemsx-no_more_gr = 'X'.
  i_po_items-conf_ctrl = '0001'.
  i_po_itemsx-conf_ctrl = 'X'.

  i_po_itemsx-deliv_compl = 'X'.     "Deletion field is changed
  APPEND: i_po_items, i_po_itemsx.

  CALL FUNCTION 'BAPI_PO_CHANGE'
    EXPORTING
      purchaseorder = l_ponumber
      testrun       = space
    TABLES
      poitem        = i_po_items
      poitemx       = i_po_itemsx
      return        = i_return.
READ TABLE i_return WITH KEY type = 'E'.
  IF sy-subrc NE 0.
    wa_output-message = 'Error in Update data'..  "i_return-message.
ELSE. wa_output-message = 'Updated..' . CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'. ENDIF. ENDFORM.

Regards,

Venkat

0 Kudos

po-del-ind.png

Dear Sir,

I have done as you mentioned in the above program. Now I am getting message as "Instance 3000000004 of object type Purchase Order could not be changed".

I have attached the screenshot of debugger with all the values and with return message.

Try the same PO with ME22N and try to update the delivery indicator. See what is the actual message and why it is not allowing.

based on that we can modify the BAPI.

0 Kudos

Hi Sir Good After Noon,

After adding wait = 'X' it is working fine....

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = 'X'.

Thank you so much sir..

Regards

Jayaprakash AK

Nitish2027
Participant

You can use the BAPI 'BAPI_PO_CHANGE' to update the delivery complete indicator.

Pass 'X' to no_more_gr field of the poitem structure of the BAPI.

I think the below sample code will help you get started with the development.

    DATA: lt_return  TYPE bapirettab,
          ls_poitem  TYPE bapimepoitem,
          lt_poitem  TYPE bapimepoitem_tp,
          ls_poitemx TYPE bapimepoitemx,
          lt_poitemx TYPE bapimepoitemx_tp.

    ls_poitem-po_item = p_ebelp. "Set Item Number
    ls_poitem-no_more_gr = 'X'.
    APPEND ls_poitem TO lt_poitem.

    ls_poitemx-po_item = p_ebelp. "Set Item Number
    ls_poitemx-no_more_gr = 'X'.
    APPEND ls_poitemx TO lt_poitemx.

    CALL FUNCTION 'BAPI_PO_CHANGE'
      EXPORTING
        purchaseorder = p_ebeln "Set Purchase Order number here.
      TABLES
        return        = lt_return[]
        poitem        = lt_poitem[]
        poitemx       = lt_poitemx[].

    IF sy-subrc = 0.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = 'X'.
    ENDIF.

Hi Nitish Good Afternoon,

I have modified this program based on my requirement now its working fine.

Thank you so much Nitish............

Regards

Jayaprakash AK

DominikTylczyn
Active Contributor

Hello akjayaa

You can of course write a custom report to close POs as indicated in the other answers. However as much simpler way is to use MEMASSPO transaction. It is a purchase order mass maintenance transaction. You can import data from external file or from the clipboard to the transaction - see SAP Help Importing Table Data

Best regards

Dominik Tylczynski

0 Kudos

Through MEMASSPO transaction, it is not allowing to close some PO's, so I want to close PO forcefully.

So, is there any code we can write to close PO.