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_CONTRACT_CREATE'

Former Member
0 Kudos
1,270

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.

4 REPLIES 4

Former Member
0 Kudos
195

Hi,

1.Also pass TESTRUN parameter as blank.

2.Check RETURN Values. If some error is there , it will not commit your work.

Reward if useful!

Former Member
0 Kudos
195

Hi,

Still im getting the error.The error is as follows.

No procurement defined for material 9000001

Former Member
0 Kudos
195

Hi,

Check your data is correct.

If something is missing, you have to take help of Functional consultant to solve customization issues.

This means your contract is not created becasue of this error , so no use of commit BAPI till you suffice all the required data.

Check BAPI details in SE37 -> Give BAPI name -> Display -> DOCUMETATION

Reward if useful!

Former Member
0 Kudos
195

Hi frds,

Im able to solve my problem.The material number should be of 18 characters length,and the currency field is necessary.

i_header-CURRENCY = 'EUR'.

i_item-MATERIAL = '000000000000600010'.

Regards,

Asmitha.