cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_CONDITION_CONTRACT_CREATE Not able to create for multiple condition type

0 Kudos

we are trying to create a condition contract using 'BAPI_CONDITION_CONTRACT_CREATE' .We were able to create condition contract with one condition type COND_TYPE = 'RES1' ,but we are not able to create for multiple condition type (COND_TYPE = 'REA1').

While passing the second condition type as same as the first one with order key as same and count as '02' with COND_TYPE = 'REA1' .We are getting return error from BAPI.

CLEAR: HEADDATAIN.
HEADDATAIN-CONTRACT_TYPE = 'ZBBI'.
HEADDATAIN-CUSTOMER_OWNER = '0001200001'.
HEADDATAIN-SALESORG = '1110'.
HEADDATAIN-DISTR_CHAN = '90'.
HEADDATAIN-DIVISION = '00'.
HEADDATAIN-VALIDITY_DATE_FROM = '20191101'.
HEADDATAIN-VALIDITY_DATE_TO = '20191231'.

CLEAR: HEADDATAINX.
HEADDATAINX-CONTRACT_TYPE = 'X'.
HEADDATAINX-CUSTOMER_OWNER = 'X'.
HEADDATAINX-SALESORG = 'X'.
HEADDATAINX-DISTR_CHAN = 'X'.
HEADDATAINX-DIVISION = 'X'.
HEADDATAINX-VALIDITY_DATE_FROM = 'X'.
HEADDATAINX-VALIDITY_DATE_TO = 'X'.


CLEAR: IT_CONDITIONKEYDATAIN.
CLEAR: IT_CONDITIONKEYDATAINX.
CLEAR: IT_CONDITIONITEMDATAIN.
CLEAR: IT_CONDITIONITEMDATAINX.
CLEAR: L_ID.

ADD 1 TO L_ID.
CLEAR: WA_CONDITIONKEYDATAIN.
WA_CONDITIONKEYDATAIN-ORDER_KEY = L_ID.
*WA_CONDITIONKEYDATAIN-TABLE_NO = '163'.
WA_CONDITIONKEYDATAIN-TABLE_NO = '4AB'.
WA_CONDITIONKEYDATAIN-COND_TYPE = 'RES1'.
WA_CONDITIONKEYDATAIN-VALID_FROM = '20191101'.
WA_CONDITIONKEYDATAIN-VALID_TO = '20191231'.
*WA_CONDITIONKEYDATAIN-MATERIAL = 'EP4933-01-302'.
WA_CONDITIONKEYDATAIN-APPLICATIO = 'V'.
APPEND WA_CONDITIONKEYDATAIN TO IT_CONDITIONKEYDATAIN.

CLEAR: WA_CONDITIONKEYDATAINX.
WA_CONDITIONKEYDATAINX-ORDER_KEY = L_ID.
*WA_CONDITIONKEYDATAINX-MATERIAL = 'X'.
APPEND WA_CONDITIONKEYDATAINX TO IT_CONDITIONKEYDATAINX.

CLEAR: WA_CONDITIONITEMDATAIN.
WA_CONDITIONITEMDATAIN-ORDER_KEY = L_ID.
WA_CONDITIONITEMDATAIN-COND_COUNT = '01'.
WA_CONDITIONITEMDATAIN-CALC_TYPE = 'A'.
WA_CONDITIONITEMDATAIN-AMOUNT = 3.
WA_CONDITIONITEMDATAIN-CONDCURR = '%'.
APPEND WA_CONDITIONITEMDATAIN TO IT_CONDITIONITEMDATAIN.

CLEAR: WA_CONDITIONITEMDATAINX.
WA_CONDITIONITEMDATAINX-ORDER_KEY = L_ID.
WA_CONDITIONITEMDATAINX-COND_COUNT = '01'.
WA_CONDITIONITEMDATAINX-CALC_TYPE = 'X'.
WA_CONDITIONITEMDATAINX-AMOUNT = 'X'.
WA_CONDITIONITEMDATAINX-CONDCURR = 'X'.
APPEND WA_CONDITIONITEMDATAINX TO IT_CONDITIONITEMDATAINX.


CALL FUNCTION 'BAPI_CONDITION_CONTRACT_CREATE'
EXPORTING
HEADDATAIN = HEADDATAIN
HEADDATAINX = HEADDATAINX
* WITHDEFAULT =
* MIGRATIONTESTRUN =
IMPORTING
HEADDATAOUT = HEADDATAOUT
CONDITIONCONTRACTNUMBER = CONDITIONCONTRACTNUMBER
TABLES
* ITEMDATAIN =
* ITEMDATAINX =
CONDITIONKEYDATAIN = IT_CONDITIONKEYDATAIN
CONDITIONKEYDATAINX = IT_CONDITIONKEYDATAINX
CONDITIONITEMDATAIN = IT_CONDITIONITEMDATAIN
CONDITIONITEMDATAINX = IT_CONDITIONITEMDATAINX
* ITEMDATAOUT =
* CONDITIONKEYDATAOUT =
* CONDITIONITEMDATAOUT =
* EXTENSIONIN =
* EXTENSIONOUT =
* HEADTEXTIN =
* HEADTEXTOUT =
* ITEMTEXTIN =
* ITEMTEXTOUT =
RETURN = IT_RETURN
* SCALEDATAIN =
* SCALEDATAOUT =
* BVBDATAIN =
* BVBDATAINX =
* BVBDATAOUT =
* CALENDARDATAIN =
* CALENDARDATAINX =
* CALENDARDATAOUT =
.

Accepted Solutions (0)

Answers (1)

Answers (1)

VeselinaPeykova
Active Contributor
0 Kudos

You forgot to mention what error you see in RETURN. This is quite important information, in addition to listing what troubleshooting steps you have performed so far, like searching for notes, debugging, etc. and the outcome of this investigation.

I do not have suitable data in the sandbox to reproduce the case, but what I usually do in similar cases is:

1. Try passing the parameters via SE37 and look for errors. If you have an error in the program, but not in SE37 - look for problems with the parameters that you pass to the function module. It should be relatively easy to pinpoint this via debugging.

2. Try creating a contract with all required data via WCOCO and then use BAPI_CONDITION_CONTRACT_READ to see how this information is stored and retrieved. This could help you figure out if you are passing information correctly to BAPI_CONDITION_CONTRACT_CREATE.

3. Search for notes for the specific error that you encounter (if you have not done this already).

4. If you are on 1909 - I think that the same BAPI is used in LTMC, which means that you can take a look at the mappings and the templates to figure out how to populate specific fields (if the available documentation from transaction BAPI and the FM documentation are not sufficient.

5. If still no luck - you can always debug the code.

Please, in the future use the code button to insert code, this makes it easier to read.

CLEAR: HEADDATAIN.
HEADDATAIN-CONTRACT_TYPE = 'ZBBI'.
HEADDATAIN-CUSTOMER_OWNER = '0001200001'.
HEADDATAIN-SALESORG = '1110'.
HEADDATAIN-DISTR_CHAN = '90'.
HEADDATAIN-DIVISION = '00'.
HEADDATAIN-VALIDITY_DATE_FROM = '20191101'.
HEADDATAIN-VALIDITY_DATE_TO = '20191231'.

CLEAR: HEADDATAINX.
HEADDATAINX-CONTRACT_TYPE = 'X'.
HEADDATAINX-CUSTOMER_OWNER = 'X'.
HEADDATAINX-SALESORG = 'X'.
HEADDATAINX-DISTR_CHAN = 'X'.
HEADDATAINX-DIVISION = 'X'.
HEADDATAINX-VALIDITY_DATE_FROM = 'X'.
HEADDATAINX-VALIDITY_DATE_TO = 'X'.

CLEAR: IT_CONDITIONKEYDATAIN.
CLEAR: IT_CONDITIONKEYDATAINX.
CLEAR: IT_CONDITIONITEMDATAIN.
CLEAR: IT_CONDITIONITEMDATAINX.
CLEAR: L_ID.

ADD 1 TO L_ID.
CLEAR: WA_CONDITIONKEYDATAIN.
WA_CONDITIONKEYDATAIN-ORDER_KEY = L_ID.
*WA_CONDITIONKEYDATAIN-TABLE_NO = '163'.
WA_CONDITIONKEYDATAIN-TABLE_NO = '4AB'.
WA_CONDITIONKEYDATAIN-COND_TYPE = 'RES1'.
WA_CONDITIONKEYDATAIN-VALID_FROM = '20191101'.
WA_CONDITIONKEYDATAIN-VALID_TO = '20191231'.
*WA_CONDITIONKEYDATAIN-MATERIAL = 'EP4933-01-302'.
WA_CONDITIONKEYDATAIN-APPLICATIO = 'V'.
APPEND WA_CONDITIONKEYDATAIN TO IT_CONDITIONKEYDATAIN.

CLEAR: WA_CONDITIONKEYDATAINX.
WA_CONDITIONKEYDATAINX-ORDER_KEY = L_ID.
*WA_CONDITIONKEYDATAINX-MATERIAL = 'X'.
APPEND WA_CONDITIONKEYDATAINX TO IT_CONDITIONKEYDATAINX.

CLEAR: WA_CONDITIONITEMDATAIN.
WA_CONDITIONITEMDATAIN-ORDER_KEY = L_ID.
WA_CONDITIONITEMDATAIN-COND_COUNT = '01'.
WA_CONDITIONITEMDATAIN-CALC_TYPE = 'A'.
WA_CONDITIONITEMDATAIN-AMOUNT = 3.
WA_CONDITIONITEMDATAIN-CONDCURR = '%'.
APPEND WA_CONDITIONITEMDATAIN TO IT_CONDITIONITEMDATAIN.

CLEAR: WA_CONDITIONITEMDATAINX.
WA_CONDITIONITEMDATAINX-ORDER_KEY = L_ID.
WA_CONDITIONITEMDATAINX-COND_COUNT = '01'.
WA_CONDITIONITEMDATAINX-CALC_TYPE = 'X'.
WA_CONDITIONITEMDATAINX-AMOUNT = 'X'.
WA_CONDITIONITEMDATAINX-CONDCURR = 'X'.
APPEND WA_CONDITIONITEMDATAINX TO IT_CONDITIONITEMDATAINX.

CALL FUNCTION 'BAPI_CONDITION_CONTRACT_CREATE'
EXPORTING
HEADDATAIN = HEADDATAIN
HEADDATAINX = HEADDATAINX
* WITHDEFAULT =
* MIGRATIONTESTRUN =
IMPORTING
HEADDATAOUT = HEADDATAOUT
CONDITIONCONTRACTNUMBER = CONDITIONCONTRACTNUMBER
TABLES
* ITEMDATAIN =
* ITEMDATAINX =
CONDITIONKEYDATAIN = IT_CONDITIONKEYDATAIN
CONDITIONKEYDATAINX = IT_CONDITIONKEYDATAINX
CONDITIONITEMDATAIN = IT_CONDITIONITEMDATAIN
CONDITIONITEMDATAINX = IT_CONDITIONITEMDATAINX
* ITEMDATAOUT =
* CONDITIONKEYDATAOUT =
* CONDITIONITEMDATAOUT =
* EXTENSIONIN =
* EXTENSIONOUT =
* HEADTEXTIN =
* HEADTEXTOUT =
* ITEMTEXTIN =
* ITEMTEXTOUT =
RETURN = IT_RETURN
* SCALEDATAIN =
* SCALEDATAOUT =
* BVBDATAIN =
* BVBDATAINX =
* BVBDATAOUT =
* CALENDARDATAIN =
* CALENDARDATAINX =
* CALENDARDATAOUT =
.