Skip to Content
0
Former Member
Jul 23, 2007 at 09:17 AM

'BAPI_CONTRACT_CREATE'

386 Views

Hi frds,

im using BAPI_CONTRACT_CREATE to create outline agreement(me31k) transaction.Im using the commit fm also.Still the agreement is not getting created.The code is as follows.Is this data is necessary for OA creation or should i have to pass additional fields.

data : i_header type BAPIMEOUTHEADER occurs 0 with header line,

i_headerx type BAPIMEOUTHEADERX occurs 0 with header line,

i_return type BAPIRET2 occurs 0 with header line,

i_item type BAPIMEOUTITEM occurs 0 with header line,

i_itemx type BAPIMEOUTITEMX occurs 0 with header line.

data v_end like sy-datum.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

date = sy-datum

days = 7

months = 0

SIGNUM = '+'

years = 0

IMPORTING

CALC_DATE = v_end.

i_header-VENDOR = '0010000000'.

i_header-DOC_TYPE = 'MK'.

i_header-COMP_CODE = 'XY91'.

i_header-CREAT_DATE = sy-datum.

i_header-PURCH_ORG = 'X001'.

i_header-PUR_GROUP = '001'.

i_header-VPER_END = v_end.

append i_header.

i_headerx-VENDOR = 'X'.

i_headerx-DOC_TYPE = 'X'.

i_headerx-COMP_CODE = 'X'.

i_headerx-CREAT_DATE = 'X'.

i_headerx-PURCH_ORG = 'X'.

i_headerx-PUR_GROUP = 'X'.

i_headerx-VPER_END = 'X'.

append i_headerx.

i_item-ITEM_NO = '0010'.

i_item-MATERIAL = '9000001'.

*i_item-SHORT_TEXT = 'Test Material'.

i_item-TARGET_QTY = '05'.

i_item-PO_UNIT = 'EA'.

i_item-NET_PRICE = '1000'.

append i_item.

i_itemx-ITEM_NO = '0010'.

i_itemx-MATERIAL = 'X'.

i_itemx-TARGET_QTY = 'X'.

i_itemx-RELORD_QTY = 'X'.

i_itemx-PO_UNIT = 'X'.

i_itemx-NET_PRICE = 'X'.

append i_itemx.

CALL FUNCTION 'BAPI_CONTRACT_CREATE'

EXPORTING

HEADER = i_header

HEADERX = i_headerx

TABLES

RETURN = i_return

ITEM = i_item

ITEMX = i_itemx.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

loop at i_return.

write : i_return-TYPE , i_return-MESSAGE.

endloop.