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: 

PO item deletion

Former Member
0 Kudos

Hello All,

I use BAPI_PO_CHANGE to delete a Item in PO.

And i do a Commit, it deletes PO item.

That is fine, after some checks i need to undelete/ Unblock the item which i have deleted earlier.

unfortunetly i cannot do the checks prior to deletion.

Inforeground i can use the unlock to undlete a deleted item, how do it do it with FM or BAPI.

Are theer any BAPI's or FM to do UNDELETE / UNBLOCK a deleted item?

Best Regards.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Can you not do what you did to delete the item, but in reverse? I mean, you probably set the DELETE_IND flag, right? Try setting it to SPACE.

Regards,

Rich Heilman

6 REPLIES 6

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Can you not do what you did to delete the item, but in reverse? I mean, you probably set the DELETE_IND flag, right? Try setting it to SPACE.

Regards,

Rich Heilman

0 Kudos

nope , it doesn't work

Aveek, I cannot roll back i do commit already , as i said earlier i will be able check the conditions only after i delete the PO item and commit it ( It has to send an IDOC to another system).

RICH IT WORKS ; I WAS N'T FILLING THE ITEMX:

I COUN'T ASSIGN POINTS SOME ERROR STOPS TO DO SO; WILL UPDATE WHEN THINGS ARE FINE.

Message was edited by: Mano Sri

0 Kudos

Hi,

Please refer to the note 456927. It deals with PO idocs but may not be appropriate for BAPI.

regards

Aveek

0 Kudos

Hi,

Another way is do a rollback:

  • Call BAPI to change

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = purchase_order

poheader = v_poheader

testrun = testrun

TABLES

return = return

poitem = i_poitem

poitemx = i_poitemx

poschedule = i_poschedule

poschedulex = i_poschedulex.

IF testrun = c_x.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'

IMPORTING

return = return.

ELSE.

  • Validation necessary if errors occurred

READ TABLE return WITH KEY type = c_success

id = '06'

number = '023'."Successfully changed

IF sy-subrc NE 0.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'

IMPORTING

return = return.

endif.

endif.

0 Kudos

This sample program is working good for me. It deletes the line and undeletes it.



report zrich_0002 .

data:     return type table of  bapiret2 with header line,
          poitem type table of   bapimepoitem with header line,
          poitemx type table of   bapimepoitemx with header line.

parameters: p_ebeln type bapimepoheader-po_number,
            p_dflag as checkbox.

poitem-po_item = '000001'.
poitem-delete_ind = p_dflag.
append poitem.

poitemx-po_item   = '000001'.
poitemx-delete_ind = 'X'.
append poitemx.

call function 'BAPI_PO_CHANGE'
  exporting
    purchaseorder                = p_ebeln
*   POHEADER                     =
*   POHEADERX                    =
*   POADDRVENDOR                 =
*   TESTRUN                      =
*   MEMORY_UNCOMPLETE            =
*   MEMORY_COMPLETE              =
* IMPORTING
*   EXPHEADER                    =
 tables
   return                       = return
   poitem                       = poitem
   poitemx                      = poitemx
*   POADDRDELIVERY               =
*   POSCHEDULE                   =
*   POSCHEDULEX                  =
*   POACCOUNT                    =
*   POACCOUNTPROFITSEGMENT       =
*   POACCOUNTX                   =
*   POCONDHEADER                 =
*   POCONDHEADERX                =
*   POCOND                       =
*   POCONDX                      =
*   POLIMITS                     =
*   POCONTRACTLIMITS             =
*   POSERVICES                   =
*   POSRVACCESSVALUES            =
*   POSERVICESTEXT               =
*   EXTENSIONIN                  =
*   EXTENSIONOUT                 =
*   POTEXTHEADER                 =
*   POTEXTITEM                   =
          .

commit work.

check sy-subrc = 0.

Regards,

Rich Heilman

Former Member
0 Kudos

Have a look at FM WB2_PO_ITEM_MAINTAIN.

Rob