Skip to Content
0
Former Member
Oct 31, 2007 at 01:58 PM

BAPI_PO_CREAT1

203 Views

Hi,

I am using BAPI to create Purchase Order. But it is showing error as

'Check item number 0 in table POSCHEDULEX '

Could u pls someone help me to get rid of this problem

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: POCOND TYPE TABLE OF BAPIMEPOCOND WITH HEADER LINE.

DATA: POCONDX TYPE TABLE OF BAPIMEPOCONDX WITH HEADER LINE.

DATA: POSCHEDULE TYPE TABLE OF BAPIMEPOSCHEDULE WITH HEADER LINE.

DATA: POSCHEDULEX TYPE TABLE OF BAPIMEPOSCHEDULX 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-doc_type = 'NB' .

pohead-vendor = '0020000011'.

pohead-creat_date = sy-datum .

pohead-purch_org = '1000'.

pohead-pur_group = '001'.

pohead-comp_code = '1074'.

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

poitem-plant = 'IN02'.

poitem-stge_loc = '1000'.

poitem-quantity = 123.

poitem-PO_UNIT = 'EA'.

POITEM-MATL_GROUP = '310400000'.

POITEM-ORDERPR_UN = 'EA'.

POITEM-ACCTASSCAT = 'K'.

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 .

poitem-PO_UNIT = c_x.

POITEM-MATL_GROUP = c_x.

POITEM-ORDERPR_UN = c_x.

POITEM-ACCTASSCAT = c_x.

  • poitemx-tax_code = c_x .

  • poitemx-item_cat = c_x .

  • poitemx-acctasscat = c_x .

append poitemx.

  • condition level data

POCOND-ITM_NUMBER = 1.

POCOND-COND_TYPE = 'ZP00'.

POCOND-COND_VALUE = '25'.

APPEND POCOND.

POCONDX-ITM_NUMBER = 1.

POCONDX-COND_TYPE = c_x.

POCONDX-COND_VALUE = c_x.

APPEND POCONDX.

  • schedule data

  • POSCHEDULE-PO_ITEM = 1.

    • POSCHEDULE-SCHED_LINE = '01'.

  • POSCHEDULE-DELIVERY_DATE = sy-datum.

  • APPEND POSCHEDULE.

  • *

    • POSCHEDULEX-PO_ITEMX = 1.

    • POSCHEDULEX-SCHED_LINEX = c_x.

  • POSCHEDULEX-DELIVERY_DATE = c_x.

  • APPEND POSCHEDULEX.

    • 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 = 1.

    append posched.

    poschedx-sched_line = 1.

    POSCHEDX-SCHED_LINEX = c_x.

    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

    POCOND = POCOND

    POCONDX = POCONDX.

    • POSCHEDULE = POSCHEDULE

    • POSCHEDULEX = POSCHEDULEX.

    IF ex_po_number IS INITIAL.

    call function 'BAPI_TRANSACTION_ROLLBACK'.

    ELSE.

    call function 'BAPI_TRANSACTION_COMMIT'

    EXPORTING

    wait = ''.

    ENDIF.