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 - PROBLEM

Former Member
0 Likes
1,420

Hi,

I am using BAPI_PO_CHANGE to change the dispatch country . But it is not changing. I have tried out everything, but still I am not able to change to dispatch country.After using BAPI_PO_CHANGE is it complusary to use BAPI_TRANSACTION_COMMIT?

**-Populate PO Header structure

x_poheader-po_number = v_succ_po. " PO no.

x_poheader-comp_code = it_head_item-bukrs. " Company code

x_poheader-doc_type = it_head_item-bsart. " Document type

  • x_poheader-creat_date = it_head_item-aedat. " Date created

  • x_poheader-created_by = it_head_item-ernam. " Created by

x_poheader-vendor = it_head_item-lifnr. " Vendor no.

x_poheader-incoterms1 = it_head_item-inco1. " Incoterms1

x_poheader-incoterms2 = it_head_item-inco2. " Incoterms2

x_poheader-pmnttrms = it_head_item-zterm. " Payment terms

x_poheader-currency = it_head_item-waers. " currency

x_poheader-currency_iso = it_head_item-waers. " currency iso

x_poheader-langu = sy-langu. " Language key

x_poheader-langu_iso = sy-langu. " Language key iso

x_poheader-purch_org = it_head_item-ekorg. " Purchasing org.

x_poheader-pur_group = it_head_item-ekgrp. " Purch. Group

x_poheader-doc_date = it_head_item-bedat. " Doc date

*-Populate PO Header 'X' structure

x_poheaderx-po_number = c_x.

x_poheaderx-comp_code = c_x.

x_poheaderx-doc_type = c_x.

  • x_poheaderx-creat_date = c_x.

  • x_poheaderx-created_by = c_x.

x_poheaderx-vendor = c_x.

x_poheaderx-langu = c_x.

x_poheaderx-langu_iso = c_x.

x_poheaderx-pmnttrms = c_x.

x_poheaderx-purch_org = c_x.

x_poheaderx-pur_group = c_x.

x_poheaderx-currency = c_x.

x_poheaderx-currency_iso = c_x.

x_poheaderx-doc_date = c_x.

x_poheaderx-incoterms1 = c_x.

x_poheaderx-incoterms2 = c_x.

*-Populate PO Item data

LOOP AT it_head_item WHERE ebeln = it_head_item-ebeln.

x_poitem-po_item = it_head_item-ebelp. " PO Item no.

x_poitem-net_price = it_head_item-netpr. " Net price

x_poitem-price_unit = it_head_item-peinh. " price per unit

x_poitem-tax_code = it_head_item-mwskz. " Tax Code

x_poitem-acctasscat = it_head_item-knttp. " Account ass cata

x_poitem-short_text = it_head_item-txz01. " Item description

x_poitem-material = it_head_item-matnr. " Material no.

x_poitem-plant = it_head_item-werks. " Plant

x_poitem-stge_loc = it_head_item-lgort. " Storage Loc

READ TABLE it_ekko_ekpo WITH KEY matnr = it_head_item-matnr

BINARY SEARCH.

IF sy-subrc = 0.

x_poitem-trackingno = it_head_item-ebeln. " Requ Tracking Number

x_poitemx-trackingno = c_x. " Requ Tracking Number

ENDIF.

  • x_poitem-matl_group = it_head_item-matkl. " Material group

  • x_poitem-quantity = it_head_item-menge. " Ordered qty.

  • x_poitem-po_unit = it_head_item-meins. " Order unit

  • x_poitem-po_unit_iso = it_head_item-meins. " Order unit

APPEND x_poitem TO it_poitem.

CLEAR x_poitem.

*-Populate PO Item 'X' structure

x_poitemx-po_item = it_head_item-ebelp. " PO Item no.

x_poitemx-po_itemx = c_x.

x_poitemx-short_text = c_x.

x_poitemx-material = c_x.

x_poitemx-plant = c_x.

x_poitemx-stge_loc = c_x.

  • x_poitemX-trackingno = c_x. " Requ Tracking Number

  • x_poitemx-matl_group = c_x.

  • x_poitemx-quantity = c_x.

  • x_poitemx-po_unit = c_x.

  • x_poitemx-po_unit_iso = c_x.

x_poitemx-net_price = c_x.

x_poitemx-price_unit = c_x.

x_poitemx-tax_code = c_x.

x_poitemx-acctasscat = c_x.

APPEND x_poitemx TO it_poitemx.

CLEAR x_poitemx.

*-- Populate PO Item Address Structure for Inbound Delivery

x_deliveryaddr-po_item = it_head_item-ebelp.

x_deliveryaddr-addr_no = it_head_item-adrnr.

APPEND x_deliveryaddr TO it_deliveryaddr.

CLEAR x_deliveryaddr.

<b>*-- Populate dispatch country details

x_poexpimpitem-po_item = it_head_item-ebelp.

READ TABLE it_lfa1 WITH KEY lifnr = it_ekko_ekpo-lifnr

BINARY SEARCH.

IF sy-subrc = 0 AND it_lfa1-land1 <> 'CN'.

x_poexpimpitem-shipping_country = it_lfa1-land1.

x_poexpimpitem-shipping_country_iso = it_lfa1-land1.

x_poexpimpitemx-shipping_country = c_x.

x_poexpimpitemx-shipping_country_iso = c_x.

ENDIF.

APPEND x_poexpimpitem TO it_poexpimpitem.

CLEAR x_poexpimpitem.

*-- Populate Foreign Trade Export/Import Item Data 'X' structure

x_poexpimpitemx-po_item = it_head_item-ebelp.

  • x_poexpimpitemX-shipping_country = c_x.

  • x_poexpimpitemX-shipping_country_iso = c_x.

APPEND x_poexpimpitemx TO it_poexpimpitemx.

CLEAR x_poexpimpitemx.</b>

ENDLOOP.

**---Function to modify PO line item

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = v_succ_po

poheader = x_poheader

poheaderx = x_poheaderx

TABLES

return = it_return

poitem = it_poitem

poitemx = it_poitemx

poaddrdelivery = it_deliveryaddr

<b> poexpimpitem = it_poexpimpitem

poexpimpitemx = it_poexpimpitemx.</b>

2 REPLIES 2
Read only

Former Member
0 Likes
619

Hi,

Yes..You have to give COMMIT WORK or call BAPI_TRANSACTION_COMMIT after the BAPI_PO_CHANGE call.

Thanks,

Naren

Read only

Former Member
0 Likes
619

Hi,

Yes you need to explicitly commit all BAPI transactions using:

BAPI_TRANSACTION_COMMIT.

This will commit the changes made by the BAPI FM.

Regards

Subbu