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

BAPI_PO_CHANGE

Former Member
0 Likes
836

Hi All,

I have been used the fun module 'BAPI_PO_CHANGE' for PO item Change.

But it is not updating the PO item.

have alook on this code...

CLEAR po_item_inx.

po_item_inx-po_item = order_info-item_no.

po_item_inx-po_itemx = 'X'.

po_item_inx-quantity = 'X'.

APPEND po_item_inx.

CLEAR po_item_in.

po_item_in-po_item = order_info-item_no.

po_item_in-quantity = temp_final_qty.

APPEND po_item_in.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = po_doc_no

testrun = test_run

TABLES

return = t_return

poitem = po_item_in

poitemx = po_item_inx.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'

IMPORTING

return = c_return.

Thanks

Ravi

Message was edited by:

ravikumar s

Hi All,

I have been used the fun module 'BAPI_PO_CHANGE' for PO item Change.

But it is not updating the PO item.

have alook on this code...

CLEAR po_item_inx.

po_item_inx-po_item = order_info-item_no.

po_item_inx-po_itemx = 'X'.

po_item_inx-quantity = 'X'.

APPEND po_item_inx.

CLEAR po_item_in.

po_item_in-po_item = order_info-item_no.

po_item_in-quantity = temp_final_qty.

APPEND po_item_in.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = po_doc_no

testrun = test_run

TABLES

return = t_return

poitem = po_item_in

poitemx = po_item_inx.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'

IMPORTING

return = c_return.

Thanks

Ravi

Message was edited by:

ravikumar s

3 REPLIES 3
Read only

Former Member
0 Likes
555

Can you post your code...??? It can help identifying the problem

Regards

Eswar

Read only

Former Member
0 Likes
555

Hi ,

Use BAPI_TRANSACTION_COMMIT after the PO change BAPI ,

When you dry run BAPI from SE37 it will not Change PO ,

  • Please mark useful answers

Read only

Former Member
0 Likes
555

Hi Ravikumar,

Make sure that your test_run variable doesn't have value 'X'. or just comment that line and try to execute.

Check this sample code.


REPORT ZTEST_BAPI_PO_CHANGE .
tables: ekpo.

data: tl_ekpo type standard table of ekpo,
      tl_fields type standard table of char21,
      tl_poitem type standard table of bapimepoitem,
      tl_poitemx type standard table of bapimepoitemx,
      tl_return TYPE standard table of bapiret2...


data: wal_ekpo type ekpo,
      wal_poitem type bapimepoitem,
      wal_poitemx type bapimepoitemx.

data: wl_ebeln type ekpo-ebeln,
      wl_eindt type eket-eindt.

data: wl_testrun type bapiflag-bapiflag value 'X',
      wl_maktx type makt-maktx.

field-symbols: <l_ekpo> type ekpo.

  parameters: p_ebeln type ekpo-ebeln.
  call function 'Z_GET_FIELDS_WORKAREA'
    exporting
      work_area       = wal_ekpo
    tables
      t_fields        = tl_fields
            .
wl_ebeln = p_ebeln.

call function 'CONVERSION_EXIT_ALPHA_INPUT'
  exporting
    input         = wl_ebeln
 IMPORTING
   OUTPUT        = wl_ebeln.
          .

  select (tl_fields)
          into table tl_ekpo
          from ekpo
          where ebeln = wl_ebeln.

  read table tl_ekpo assigning <l_ekpo> index 1.
  if sy-subrc ne 0.exit.endif.
  select single eindt
          into wl_eindt
          from eket
          where ebeln = <l_ekpo>-ebeln
          and ebelp = <l_ekpo>-ebelp.

  select single maktx
          into wl_maktx
          from makt
          where matnr = <l_ekpo>-matnr.

*  wal_poitem-po_item = <l_ekpo>-ebelp + 10.
*  wal_poitem- = wl_eindt
  wal_poitem-material = <l_ekpo>-MATNR.
  wal_poitem-short_text = wl_maktx.
*  wal_poitem-ematerial = <l_ekpo>-ematn.
  wal_poitem-QUANTITY = '1'.
  wal_poitem-PO_UNIT = <l_ekpo>-meins.
  wal_poitem-net_price = 6.
  wal_poitem-PRICE_UNIT = <l_ekpo>-PEINH.
  wal_poitem-ACCTASSCAT = <l_ekpo>-knttp.
  wal_poitem-ORDERPR_UN = <l_ekpo>-BPRME.
  wal_poitem-MATL_GROUP = <l_ekpo>-matkl.
  wal_poitem-plant = <l_ekpo>-werks.
  wal_poitem-stge_loc = <l_ekpo>-lgort.
  wal_poitem-TRACKINGNO = <l_ekpo>-bednr.
  wal_poitem-INFO_REC = <l_ekpo>-infnr.
  append wal_poitem to tl_poitem.

*    wal_poitemx-po_itemx = 'X'.
   wal_poitemx-material = 'X'.
*  wal_poitemx-ematerial = <l_ekpo>-ematn.
    wal_poitemx-quantity = 'X'.
    wal_poitemx-po_unit = 'X'.
    wal_poitemx-net_price = 'X'.
    wal_poitemx-price_unit = 'X'.
    wal_poitem-ACCTASSCAT = 'X'.
    wal_poitemx-short_text = 'X'.
    wal_poitemx-orderpr_un = 'X'.
    wal_poitemx-matl_group = 'X'.
    wal_poitemx-plant = 'X'.
    wal_poitemx-stge_loc = 'X'.
    wal_poitemx-trackingno = 'X'.
    wal_poitemx-info_rec = 'X'.
    append wal_poitemx to tl_poitemx.


 call function 'BAPI_PO_CHANGE'
   exporting
     purchaseorder                = <l_ekpo>-ebeln
*     TESTRUN                      = wl_testrun
   TABLES
     RETURN                       = tl_return
     POITEM                       = tl_poitem
     POITEMX                      = tl_poitemx
            .
    read table tl_return with key type = 'S' transporting no fields.
    if sy-subrc eq 0.
    call function 'BAPI_TRANSACTION_COMMIT'.
    endif.

Regards,

Raghav