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: 

How to create purchase order using BAPI

Former Member
0 Kudos
8,971

Dear Experts,

how to create purchase order using bapi, give me the FM used.

can u give me the link for its step by step screen shot.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
1,370

Hi,

BAPI_PO_CREAT & BAPI_PO_CREAT1.

Check the related document, it can help u to use.

Regards

Rajendra

6 REPLIES 6

Former Member
1,370

Use...

BAPI_PO_CREATE function module

Former Member
0 Kudos
1,370

Use FM BAPI_PO_CREATE1... refer its documentation and sample code on how to populate the structures.

Thanks,

SKJ

Former Member
0 Kudos
1,371

Hi,

BAPI_PO_CREAT & BAPI_PO_CREAT1.

Check the related document, it can help u to use.

Regards

Rajendra

Former Member
0 Kudos
1,370

Hi,

Take the help of the code and create a PO.

gs_poheader-ref_1 = delivery.

gs_poheader-creat_date = sy-datum.

gs_poheader-created_by = sy-uname.

gs_poheader-langu = sy-langu.

gs_poheader-doc_date = sy-datum.

CLEAR gs_poheaderx.

gs_poheaderx-doc_type = 'X'.

gs_poheaderx-purch_org = 'X'.

gs_poheaderx-vendor = 'X'.

gs_poheaderx-pur_group = 'X'.

gs_poheaderx-ref_1 = 'X'.

gs_poheaderx-creat_date = 'X'.

gs_poheaderx-created_by = 'X'.

gs_poheaderx-langu = 'X'.

gs_poheaderx-doc_date = 'X'.

IF gt_delitem[] IS NOT INITIAL.

LOOP AT gt_delitem INTO gs_delitem.

CLEAR: gs_poitem, gs_poitemx.

gs_poitem-po_item = gs_delitem-posnr.

gs_poitem-material = gs_delitem-matnr.

gs_poitem-plant = gv_plant.

gs_poitem-quantity = gs_delitem-lfimg.

gs_poitem-shipping = space.

gs_poitem-tax_code = gv_taxid.

gs_poitem-po_unit = gs_delitem-meins.

APPEND gs_poitem TO gt_poitem.

gs_poitemx-po_item = gs_delitem-posnr.

gs_poitemx-po_itemx = 'X'.

gs_poitemx-material = 'X'.

gs_poitemx-plant = 'X'.

gs_poitemx-quantity = 'X'.

gs_poitemx-shipping = 'X'.

gs_poitemx-tax_code = 'X'.

gs_poitemx-po_unit = 'X'.

APPEND gs_poitemx TO gt_poitemx.

CLEAR: gs_poschedule, gs_poschedulex.

gs_poschedule-po_item = gs_delitem-posnr.

gs_poschedule-delivery_date = lv_date.

APPEND gs_poschedule TO gt_poschedule.

gs_poschedulex-po_item = gs_delitem-posnr.

gs_poschedulex-po_itemx = 'X'.

gs_poschedulex-delivery_date = 'X'.

APPEND gs_poschedulex TO gt_poschedulex.

ENDLOOP.

ENDIF.

    • Create Purchase Order.

IF gs_poheader IS NOT INITIAL.

CLEAR: gv_ponum.

REFRESH gt_return.

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

poheader = gs_poheader

poheaderx = gs_poheaderx

testrun = testrun

IMPORTING

exppurchaseorder = gv_ponum

TABLES

return = gt_return

poitem = gt_poitem

poitemx = gt_poitemx

poschedule = gt_poschedule

poschedulex = gt_poschedulex.

    • Check for error messages

LOOP AT gt_return INTO gs_return WHERE type = 'E'

OR type = 'A'.

EXIT.

ENDLOOP.

IF sy-subrc <> 0 AND gv_ponum IS NOT INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

ENDIF.

    • Return the values to Calling Program

IF gv_ponum IS NOT INITIAL.

purchaseorder = gv_ponum.

IF gt_poitem IS NOT INITIAL.

LOOP AT gt_poitem INTO gs_poitem.

CLEAR gs_item.

MOVE-CORRESPONDING gs_poitem TO gs_item.

gs_item-po_number = gv_ponum.

APPEND gs_item TO po_items.

ENDLOOP.

ENDIF.

ENDIF.

ENDIF.

Please let me know if you need help.

Thanks,

Kartavya

Former Member
0 Kudos
1,370

Hi,

Go through this below link..

http://www.sap-img.com/abap/sample-abap-code-on-bapi-po-change.htm

Hope helpful

Raghunath.S

Former Member
0 Kudos
1,370

Thanks for your help.....

regards

Ravi chendra