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 CREATION

Former Member
0 Likes
525

Hi all,

Please suggest me how to create purchase order using BAPI

5 REPLIES 5
Read only

Former Member
0 Likes
483

Hi,

Use BAPI_PO_CREATE1 and pass the respective Import and Table parameters.

Regards,

Ram

Reward points if helpful...

Read only

Former Member
0 Likes
483

Hi Praveen

Please check this link: to check code provided by Rich earlier in the community.

Kind Regards

Eswar

Read only

0 Likes
483
Here is a sample FORM routine.


************************************************************************
*      Form  create_purchase_order
************************************************************************
form create_purchase_order.

  constants : c_x value 'X'.

  data: del_date type sy-datum.

  data: pohead  type bapimepoheader.
  data: poheadx type bapimepoheaderx.

  data: exp_head type bapimepoheader.

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

  data: posched  type table of bapimeposchedule with header line.
  data: poschedx type table of bapimeposchedulx with header line.

  data: ex_po_number type bapimepoheader-po_number.


* Header Level Data
 pohead-comp_code = '0010'.
  pohead-doc_type   = 'NB'     .
  pohead-creat_date = sy-datum   .

pohead-vendor = p_lifnr.
 pohead-purch_org = '0010'.
  pohead-pur_group = 'EMG'.

  pohead-langu      = sy-langu   .
  pohead-doc_date   = sy-datum.

  poheadx-comp_code  = c_x.
  poheadx-doc_type   = c_x.
  poheadx-creat_date = c_x.
  poheadx-vendor     = c_x.
  poheadx-langu      = c_x.
  poheadx-purch_org  = c_x.
  poheadx-pur_group  = c_x.
  poheadx-doc_date   = c_x.


* Item Level Data
  poitem-po_item  = 1.
  poitem-material = xresb-matnr.
  poitem-plant    = xresb-werks.
  poitem-stge_loc = xresb-lgort.
  poitem-quantity = p_bdmng.
  append poitem.

  poitemx-po_item    = 1.
  poitemx-po_itemx   = c_x.
  poitemx-material   = c_x.
  poitemx-plant      = c_x .
  poitemx-stge_loc   = c_x .
  poitemx-quantity   = c_x .
  poitemx-tax_code   = c_x .
  poitemx-item_cat   = c_x .
  poitemx-acctasscat = c_x .
  append poitemx.


* Schedule Line Level Data
  posched-po_item        = 1.
  posched-sched_line     = 1.
  posched-del_datcat_ext = 'D'.
  del_date = sy-datum + 1.
  write del_date to posched-delivery_date.
  posched-deliv_time     = '000001'.
  posched-quantity       = p_bdmng.
  append posched.

  poschedx-po_item        = 1.
  poschedx-sched_line     = 1.
  poschedx-po_itemx       = c_x.
  poschedx-sched_linex    = c_x.
  poschedx-del_datcat_ext = c_x.
  poschedx-delivery_date  = c_x.
  poschedx-quantity       = c_x.
  append poschedx.

  call function 'BAPI_PO_CREATE1'
       exporting
            poheader         = pohead
            poheaderx        = poheadx
            testrun          = ' '
       importing
            exppurchaseorder = ex_po_number
            expheader        = exp_head
       tables
            return           = return
            poitem           = poitem
            poitemx          = poitemx
            poschedule       = posched
            poschedulex      = poschedx.

  call function 'BAPI_TRANSACTION_COMMIT'
       exporting
            wait = 'X'.

  if not ex_po_number is initial.
    call function 'DEQUEUE_ALL'.
  else.
    call function 'DEQUEUE_ALL'.
    message i036.
  endif.

endform.
Read only

anversha_s
Active Contributor
0 Likes
483

Hi,

chks a sample code.

http://www.sapgenie.com/phpBB2/viewtopic.php?p=15525&sid=ea0812d14d0cbffb804e18d34040d521

/people/sap.user72/blog/2005/03/22/sample-code-to-create-purchase-order-using-bapi-in-r3

http://apolemia.blogspot.com/2005/06/create-purchase-order-with.html

rgds

Anver

<i>'if hlped pls mark points'</i>

Read only

shishupalreddy
Active Contributor
0 Likes
483

Hi

Use

BAPI_PO_CREATE

or

BAPI_CREATE_FROMDATA

as per your requirement

regards