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: 

Bapi_po_create1

Former Member
0 Kudos

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.

PARAMETERS: p_matnr TYPE ekpo-matnr.

PARAMETERS: p_werks TYPE ekpo-werks.

PARAMETERS: p_lgort TYPE ekpo-lgort.

PARAMETERS: p_menge TYPE ekpo-menge.

PARAMETERS: p_lifnr TYPE ekko-lifnr.

PARAMETERS: p_ekorg TYPE ekko-ekorg.

PARAMETERS: p_ekgrp TYPE ekko-ekgrp.

PARAMETERS: p_bukrs TYPE ekko-bukrs.

parameters: p_KNTTP type ekpo-KNTTP.

parameters: p_pr type ekpo-banfn.

  • Header Level Data

pohead-comp_code = p_bukrs.

pohead-doc_type = 'NB'.

pohead-creat_date = sy-datum.

pohead-vendor = p_lifnr.

pohead-purch_org = p_ekorg.

pohead-pur_group = p_ekgrp.

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 = 00010.

poitem-material = p_matnr.

poitem-plant = p_werks.

poitem-stge_loc = p_lgort.

poitem-quantity = p_menge.

*poitem-ITEM_CAT = 'TAS'.

poitem-ACCTASSCAT = p_KNTTP.

poitem-PREQ_NO = p_pr.

poitem-preq_item = 00010.

APPEND poitem.

poitemx-po_item = 00010.

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 .

poitemx-preq_no = c_x.

poitemx-preq_item = c_x.

APPEND poitemx.

  • Schedule Line Level Data

posched-po_item = 00010.

posched-sched_line = 0100.

posched-del_datcat_ext = 'D'.

del_date = sy-datum + 1.

WRITE del_date TO posched-delivery_date.

posched-deliv_time = '000001'.

posched-quantity = p_menge.

posched-PREQ_NO = p_pr.

posched-preq_item = 0010.

APPEND posched.

poschedx-po_item = 00010.

poschedx-sched_line = 0100.

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.

poschedx-preq_no = c_x.

poschedx-preq_item = 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.

I used this program to create a purchase order with reference to purchase requisiton but im getting the Error>

1 E BAPI 001 No instance of object type PurchaseOrder has been created. External reference:

2 E MEPO 001 Purchase order item 00010 still contains faulty schedule lines

3 E 06 054 Doc. type/item cat. NB/S (requisition) <-> NB/ (purch. order)

4 E 8W 162 No schedule line exists for schedule line number 0010000030 00010 0000.

Could you please tell wats the error how to correct it?

I want to create purchase order with reference to purchase requisition number?

Thanks & Regards,

Azhar

1 REPLY 1

Former Member
0 Kudos

hi azhar,

Better u ask ur functional consultant , for these error.hope he will help u, these data can be verified by them, and if u want to check, u again check the test data.

regads

karthik