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: 

who can offer a sample code about bapi on po create

Former Member
0 Kudos

HI:

I want to creat batch POs using BAPI ,however,i never used BAPI before . now,i have a exel file where are the POs inlcluding headers and items .

who can offer the step <b>in detail </b> as well as some sample code.

TKS in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Check this link,

<u>http://www.sapgenie.com/abap/bapi/example.htm

http://www.sapgenie.com/abap/bapi/index.htm

http://www.sapgenie.com/abap/bapi/conventions.htm</u>;

Hope it helps u.

Thanks&Regards,

Ruthra.R

4 REPLIES 4

Former Member
0 Kudos

Hi,

Check this link,

<u>http://www.sapgenie.com/abap/bapi/example.htm

http://www.sapgenie.com/abap/bapi/index.htm

http://www.sapgenie.com/abap/bapi/conventions.htm</u>;

Hope it helps u.

Thanks&Regards,

Ruthra.R

0 Kudos

REPORT z_bapi_create .

TABLES : eban,ekko,ekpo,eket.

TYPE-POOLS :wod1t.

  • po header structure for the BAPI_PO_CREATE

DATA l_poheader LIKE bapimepoheader.

DATA l_poheaderx LIKE bapimepoheaderx.

DATA l_t_poitem LIKE bapimepoitem OCCURS 0 WITH HEADER LINE.

DATA l_t_poitemx LIKE bapimepoitemx OCCURS 0 WITH HEADER LINE.

DATA l_t_poschedule LIKE bapimeposchedule OCCURS 0 WITH HEADER LINE.

DATA l_t_poschedulex LIKE bapimeposchedulx OCCURS 0 WITH HEADER LINE.

DATA l_purchaseorder LIKE bapimepoheader-po_number.

DATA it_ekpo LIKE ekpo OCCURS 0 WITH HEADER LINE.

DATA l_t_return TYPE wod1t_t_return WITH HEADER LINE.

DATA l_error_found TYPE c.

CONSTANTS: c_no TYPE c VALUE ' '.

CONSTANTS: c_yes TYPE c VALUE 'X'.

DATA wrk_netprice(12) TYPE c.

DATA wrk_quan(12) TYPE c.

PARAMETERS : ebeln LIKE ekko-ebeln.

CLEAR eban.

SELECT SINGLE * FROM ekko

WHERE ebeln = ebeln.

IF sy-subrc = 0.

l_poheader-doc_type = 'NB'.

l_poheader-creat_date = sy-datlo.

l_poheader-vendor = ekko-lifnr.

l_poheader-purch_org = ekko-ekorg.

l_poheader-pur_group = ekko-ekgrp.

l_poheader-doc_date = ekko-bedat.

l_poheader-currency = 'INR'.

l_poheader-quotation = ekko-ebeln.

l_poheader-quot_date = ekko-aedat.

l_poheaderx-doc_type = 'X'.

l_poheaderx-creat_date = 'X'.

l_poheaderx-vendor = 'X'.

l_poheaderx-purch_org = 'X'.

l_poheaderx-pur_group = 'X'.

l_poheaderx-doc_date = 'X'.

l_poheaderx-currency = 'X'.

l_poheaderx-quotation = 'X'.

l_poheaderx-quot_date = 'X'.

ENDIF.

SELECT * FROM ekpo INTO TABLE it_ekpo

WHERE ebeln = ebeln.

LOOP AT it_ekpo.

CLEAR l_t_poitem.

l_t_poitem-po_item = it_ekpo-ebelp.

l_t_poitem-delete_ind = ' '.

l_t_poitem-material = it_ekpo-matnr.

l_t_poitem-plant = it_ekpo-werks.

l_t_poitem-stge_loc = '010'.

l_t_poitem-matl_group = it_ekpo-matkl.

l_t_poitem-info_rec = it_ekpo-infnr.

l_t_poitem-quantity = it_ekpo-ktmng.

l_t_poitem-po_unit = it_ekpo-meins.

l_t_poitem-price_unit = it_ekpo-peinh .

l_t_poitem-net_price = it_ekpo-netpr.

l_t_poitem-item_cat = it_ekpo-pstyp.

l_t_poitem-acctasscat = it_ekpo-knttp.

l_t_poitem-net_weight = it_ekpo-ntgew.

l_t_poitem-weightunit = it_ekpo-gewei.

l_t_poitem-gross_wt = it_ekpo-brgew.

l_t_poitem-volume = it_ekpo-volum.

l_t_poitem-volumeunit = it_ekpo-voleh.

l_t_poitem-rfq_no = it_ekpo-ebeln.

l_t_poitem-rfq_item = it_ekpo-ebelp.

l_t_poitem-ret_item = it_ekpo-retpo.

l_t_poitem-conf_ctrl = it_ekpo-bstae.

  • l_t_poitem-ref_doc = it_ekpo-ebeln.

  • l_t_poitem-ref_item = it_ekpo-ebelp.

APPEND l_t_poitem.

CLEAR l_t_poitemx.

l_t_poitemx-po_item = it_ekpo-ebelp.

l_t_poitemx-po_itemx = 'X'.

  • l_t_poitemx-short_text = 'X'.

l_t_poitemx-delete_ind = 'X'.

l_t_poitemx-material = 'X'.

l_t_poitemx-plant = 'X'.

l_t_poitemx-stge_loc = 'X'.

l_t_poitemx-matl_group = 'X'.

l_t_poitemx-info_rec = 'X'.

l_t_poitemx-quantity = 'X'.

l_t_poitemx-po_unit = 'X'.

l_t_poitemx-net_price = 'X'.

l_t_poitemx-price_unit = 'X'.

l_t_poitemx-item_cat = 'X'.

l_t_poitemx-acctasscat = 'X'.

l_t_poitemx-net_weight = 'X'.

l_t_poitemx-weightunit = 'X'.

l_t_poitemx-gross_wt = 'X'.

l_t_poitemx-volume = 'X'.

l_t_poitemx-volumeunit = 'X'.

l_t_poitemx-rfq_no = 'X'.

l_t_poitemx-rfq_item = 'X'.

l_t_poitemx-ret_item = 'X'.

l_t_poitemx-conf_ctrl = 'X'.

l_t_poitemx-ref_doc = 'X'.

l_t_poitemx-ref_item = 'X'.

APPEND l_t_poitemx.

  • CLEAR l_t_poschedule.

  • l_t_poschedule-po_item = it_ekpo-ebelp.

  • l_t_poschedule-sched_line = 1.

  • l_t_poschedule-del_datcat_ext = 'T'.

  • CLEAR eket.

  • SELECT SINGLE * FROM eket

  • WHERE ebeln = it_ekpo-ebeln

  • AND ebelp = it_ekpo-ebelp.

*

  • l_t_poschedule-delivery_date = '10.02.2004'.

  • l_t_poschedule-quantity = it_ekpo-menge.

  • l_t_poschedule-po_date = eket-bedat.

  • l_t_poschedule-preq_no = eket-ebeln.

  • l_t_poschedule-preq_item = eket-ebelp.

*

  • APPEND l_t_poschedule.

  • CLEAR l_t_poschedulex.

  • l_t_poschedulex-po_item = it_ekpo-ebelp.

  • l_t_poschedulex-po_itemx = 'X'.

  • l_t_poschedulex-sched_line = 1.

  • l_t_poschedulex-del_datcat_ext = 'X'.

  • l_t_poschedulex-sched_linex = 'X'.

  • l_t_poschedulex-delivery_date = 'X'.

  • l_t_poschedulex-quantity = 'X'.

  • l_t_poschedulex-po_date = 'X'.

  • l_t_poschedulex-preq_no = 'X'.

  • l_t_poschedulex-preq_item = 'X'.

*

*

  • APPEND l_t_poschedulex.

ENDLOOP.

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

poheader = l_poheader

poheaderx = l_poheaderx

  • POADDRVENDOR =

  • POADDRVENDORX =

IMPORTING

exppurchaseorder = l_purchaseorder

TABLES

return = l_t_return

poitem = l_t_poitem

poitemx = l_t_poitemx

  • POADDRDELIVERY =

  • POADDRDELIVERYX =

  • poschedule = l_t_poschedule

  • poschedulex = l_t_poschedulex

  • POACCOUNT =

  • POACCOUNTX =

  • POCOND =

  • POCONDX =

.

COMMIT WORK.

nishanthbhandar
Contributor
0 Kudos

The best way to know how to use the BAPI is to refer to standarad occurrences of the same.For BAPI_PO_CREATE the below programs will provide you an idea of how to use it :

LEHSWA_112U27

LMEWPU10

LQMLRF01

LWVMIU05

MMEWPF01

MMWE0F01

RBUS2012

Check these out.

Former Member
0 Kudos

Just an example for calling the fucntion module:

CALL FUNCTION 'BAPI_PO_CREATE1' DESTINATION c_none

EXPORTING

poheader = struct_poheader

poheaderx = struct_poheaderx

IMPORTING

exppurchaseorder = v_exppurchaseorder

TABLES

return = i_return

poitem = i_bapi_poitems

poitemx = i_bapi_poitemx

poschedule = i_bapi_poschedule

poschedulex = i_bapi_poschedulx

extensionin = i_extensionin

EXCEPTIONS

system_failure = 1 MESSAGE l_text

communication_failure = 2 MESSAGE l_text.

regards

Aveek