Product Information
How to Use Public API Service for Condition Records – Part 3
Contents
Background
Using public API service, you can create, read, update, and delete condition records for pricing. The service contains entities for condition record, validity of condition record, pricing scale, and condition supplement.
We provide users public API service for sales and purchase. This public API class is: CL_PRCG_CNDNRECORD_API_FACTORY.
This purchase part guide is continued from the guide of sales part:
Part 2: Sales — UPDATE & DELETE
1. For Purchasing
1. Basic Function
Public API for Purchasing provide 4 method to do CURD of condition records.
· GET_CONDITION_RECORD: This method is used to display condition record as you input the some search criterial. (GET_PRCG_VALIDITIES is a method with same function, we recommend users so not use this one)
· CREATE_CONDITION_RECORD: You can create condition records with validity and its supplement and scales or just create supplement and scales for existed condition records.
· UPDATE_CONDITION_RECORD: Update some changeable fields for condition records.
· DELETE_CONDITION_RECORD: Delete condition records or supplement or scales.
2. Examples of CURD
1. CREATE_CONDITION_RECORD
Importing Parameters:
Ø CT_CONDITION_RECORD
Ø CT_CONDITION_VALIDITY
Ø CT_CONDITION_SUPPLEMENT
Ø CT_CONDITION_SCALE
Create example: if you want to create a condition record with validity, do the following steps.
1. Prepare the basic input data
Condition Type: PPR0
Condition Table: A016
You can check the key fields of table A305, as below:
Ø EVRTN – Purchasing Document
Ø EVRTP – Purchasing Document Item
2. Input mandatory fields into importing parament.
· You can create a new condition record with its validity, supplement and scale.
CT_CONDITION_RECORD (required)
CT_CONDITION_VALIDITY (required)
CT_CONDITION_SUPPLEMENT (optional)
CT_CONDITION_SCALE (optional)
· You can also create a supplement or scale for existed condition record.
Validity, supplement and scale for one condition record will be connected by its condition record number. You can create multiple condition records in one time.
CT_CONDITION_RECORD
CONDITIONRECORD |
$$00000001 |
CONDITIONSEQUENTIALNUMBER |
01 |
CONDITIONTABLE |
016 |
CONDITIONAPPLICATION |
M |
CONDITIONTYPE |
PPR0 |
CONDITIONRATEVALUE |
666 |
CONDITIONRATEVALUEUNIT |
EUR |
CONDITIONQUANTITY |
1 |
CONDITIONQUANTITYUNIT |
CAR |
CT_CONDITION_VALIDITY
CONDITIONRECORD |
$$00000001 |
CONDITIONVALIDITYENDDATE |
Default (or input value) |
CONDITIONVALIDITYSTARTDATE |
Default (or input value) |
PURCHASINGDOCUMENT |
4500000112 |
PURCHASINGDOCUMENTITEM |
00001 |
CT_CONDITION_SUPPLEMENT
CONDITIONRECORD |
$$00000001 (or an existed number) |
CONDITIONTYPE |
PPR0 |
CONDITIONRATEVALUE |
821 |
CONDITIONRATEVALUEUNIT |
EUR |
CT_CONDITION_SCALE
CONDITIONRECORD |
$$00000001 (or an existed number) |
CONDITIONSEQUENTIALNUMBER |
01 |
CONDITIONSCALELINE |
0002 |
CONDITIONRATEVALUE |
600 |
CONDITIONRATEVALUEUNIT |
EUR |
CONDITIONSCALEQUANTITY |
100 |
CONDITIONSCALEQUANTITYUNIT |
CAR |
3. Execute after input parameters
Create Execute Successful: if you create successfully, you can receive messages, which filled in the following 2 parameters: (note: this create no commit, if you want to save data, need add commit code)
Ø ET_MESSAGE
Ø ET_CNDN_RECORD_MAPPING
Message format: (PRCG_CNDNRECORD_API (015)) Condition record 0000202633 (temp. No. $$00000001) is created and valid from 20190820 to 99991231.
2. GET_CONDITION_RECORD
Importing Parameters:
Ø IS_CNDNRECORD_CRITERIA_HEADER
Ø IT_CNDNRECORD_CRITERIA_ITEM
Ø IS_CNDNRECORD_QUERY_OPTION
Get example: if you want to search condition records, do the following steps:
1. Prepare search criteria you want to input.
IS_CNDNRECORD_CRITERIA_HEADER (optional)
CONDITIONVALIDITYSTARTDATE |
31.12.1999 |
CONDITIONVALIDITYENDDATE |
31.12.1999 |
DELTDCONDITIONRECORDISEXCLUDED |
X |
IT_CNDNRECORD_CRITERIA_ITEM (required)
CONDITIONTABLE |
|
SIGN |
OPTION |
LOW |
HIGH |
|
E.g. 1 |
I |
EQ |
016 |
|
||
CONDITIONRECORD |
|
SIGN |
OPTION |
LOW |
HIGH |
|
E.g. 1 |
I |
EQ |
0000202633 |
|
||
CONDITIONTYPE |
|
SIGN |
OPTION |
LOW |
HIGH |
|
E.g. 1 |
I |
EQ |
PPR0 |
|
||
CONDITIONFIELDSELECTIONOPTION |
|
PRCGCONDITIONFIELDRANGENAME |
PRCGCONDITIONFIELDRANGESIGN |
PRCGCONDITIONFIELDRANGEOPTION |
PRCGCONDITIONFIELDRANGELOW |
PRCGCONDITIONFIELDRANGEHIGH
|
E.g. 1 |
PURCHASINGDOCUMENT |
I |
EQ |
TG11 |
|
IS_CNDNRECORD_QUERY_OPTION (optional)
“QUERYOPTIONCOUNTISSET” and “QUERYOPTIONINLINECOUNTISSET” cannot be set at same time.
PRCGQUERYOPTIONTOP |
10 |
||
PRCGQUERYOPTIONSKIP |
1 |
||
PRCGQUERYOPTIONORDERBY |
|
SORTFIELD |
SORTSEQUENCE |
E.g. 1 |
PURCHASINGDOCUMENT |
DESC |
|
QUERYOPTIONCOUNTISSET |
|
||
QUERYOPTIONINLINECOUNTISSET |
X |
2. Fill the parameters
You can input search criterial as example, in this example:
I filled CONDITIONTABLE: I EQ 016
3. Execute successfully
If no error raise, you can check export parameters, find the detail information of condition records:
Continue to learn about public API for Purchasing
Part 4: Purchase — UPDATE & DELETE
Thanks for sharing..
Useful, thanks. Where is the material specified in the example? 666 EUR for which material? Also, a customer-specific price example would help.
It`s in CT_CONDITION_VALIDITY part with GFN Material. here is what you wanted: https://blogs.sap.com?p=645