Skip to Content
Technical Articles

How to Use Public API Service for Condition Records

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.

In this blog, users can learn the basic function, importing parameters and calling examples for this public API.

1. For Sales

1. Basic Function

Public API for Sales 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. Example of CURD mandatory input

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 (maybe also supplement and scale), do the following steps.

1. Prepare the basic input data

Condition Type: PPR0

Condition Table: A305

You can check the key fields of table A305, as below

(you can check the mapping excel for global field name with its technical name in bottom of this guide):

Ø  VKORG – Sales Organization

Ø  VTWEG – Distribution Channel

Ø  KUNNR – Customer

Ø  MATNR – Material

2. Input mandatory fields into importing parameter

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.

Following example, please check the mandatory fields for importing parameters:

CT_CONDITION_RECORD

CONDITIONRECORD $$00000001
CONDITIONSEQUENTIALNUMBER 01
CONDITIONTABLE 305
CONDITIONAPPLICATION V
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)
SALESORGANIZATION 0001
DISTRIBUTIONCHANNEL 01
CUSTOMER 100020
MATERIAL TG11

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:

Ø  ET_MESSAGE

Ø  ET_CNDN_RECORD_MAPPING

For example, if you create a condition record with validity, no supplement and scale.

Message format: (PRCG_CNDNRECORD_API (015)) Condition record 0000202628 (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.10.1999
DELTDCONDITIONRECORDISEXCLUDED X

 

IT_CNDNRECORD_CRITERIA_ITEM (required, you need to input at least one entry)

CONDITIONTABLE SIGN OPTION LOW HIGH
E.g. 1 I EQ 305
CONDITIONRECORD SIGN OPTION LOW HIGH
E.g. 1 I EQ 0000202628
CONDITIONTYPE SIGN OPTION LOW HIGH
E.g. 1 I EQ PPR0
CONDITIONFIELDSELECTIONOPTION PRCGCONDITIONFIELDRANGENAME PRCGCONDITIONFIELDRANGESIGN PRCGCONDITIONFIELDRANGEOPTION PRCGCONDITIONFIELDRANGELOW

PRCGCONDITIONFIELDRANGEHIGH

 

E.g. 1 MATERIAL 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 MATERIAL DESC
QUERYOPTIONCOUNTISSET
QUERYOPTIONINLINECOUNTISSET X

2. Fill the parameters

You can input search criterial as example, in this example:

I filled CONDITIONTABLE:  I EQ 305

3. Execute successfully

If no error raise, you can check export parameters, find the detail information of condition records.

3. UPDATE_CONDITION_RECORD

Importing parameters:

Ø  CT_CONDITION_RECORD

Ø  CT_CONDITION_VALIDITY

Ø  CT_CONDITION_SUPPLEMENT

Ø  CT_CONDITION_SCALE

Update example: if you want to update the changeable fields for condition records, do the following steps.

1.  Prepare basic parameters

CT_CONDITION_RECORD

CONDITIONRECORD 0000202628
CONDITIONRATEVALUE 444
CONDITIONRATEVALUEUNIT EUR (same as original)

CT_CONDITION_VALIDITY

CONDITIONRECORD 0000202628
CONDITIONVALIDITYENDDATE 20.08.2019
CONDITIONVALIDITYSTARTDATE 20.08.2018

CT_CONDITION_SUPPLEMENT

CONDITIONRECORD 0000202628
CONDITIONSEQUENTIALNUMBER 03
CONDITIONRATEVALUE 666
CONDITIONRATEVALUEUNIT EUR (same as original)

CT_CONDITION_SCALE

CONDITIONRECORD 0000202628
CONDITIONSEQUENTIALNUMBER 03
CONDITIONRATEVALUE 666
CONDITIONRATEVALUEUNIT EUR (same as original)
CONDITIONSCALEQUANTITY 12
CONDITIONSCALEQUANTITYUNIT EA (same as original)

2. Execute successfully

If execute success, you can check he export parameters, and you will find that the value of reference fields is changed.

4. DELETE_CONDITION_RECORD

Importing parameters:

Ø  CT_CONDITION_RECORD

Ø  CT_CONDITION_SUPPLEMENT

Ø  CT_CONDITION_SCALE

Delete example: if you want to delete condition records, we provide you the Delete function to do so, the procedure as following.

1. Import parameters

CT_CONDITION_RECORD

CONDITIONRECORD 0000202628

CT_CONDITION_SUPPLEMENT

CONDITIONRECORD 0000202628
CONDITIONSEQUENTIALNUMBER 03

CT_CONDITION_SCALE

CONDITIONRECORD 0000202628
CONDITIONSEQUENTIALNUMBER 01
CONDITIONSCALELINE 0001

2. Execute

If execute success, the changing parameter will receive the deleted condition records information:

For example, delete one scale:

3. Example for Calling Sales API

If you want to call public API in your own project. Here is an example for the calling:

If you want to Call CREATE_CONDITION_RECORD (other CURD methods are called nearly the same steps) to create condition records.

You need firstly declare an object for sales API, for example mo_sls_api

The constructor of this object like this:

mo_sls_api type ref to IF_SLSPRCG_CNDNRECD_API

Then you can call the function, like the following:

(the importing parameters examples have been provided example before)

2. 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:

3 UPDATE_CONDITION_RECORD

Importing parameters:

Ø  CT_CONDITION_RECORD

Ø  CT_CONDITION_VALIDITY

Ø  CT_CONDITION_SUPPLEMENT

Ø  CT_CONDITION_SCALE

Update example: if you want to update the changeable fields for condition records, do the following steps.

1.       Prepare basic parameters

CT_CONDITION_RECORD

CONDITIONRECORD 0000202633
CONDITIONRATEVALUE 444
CONDITIONRATEVALUEUNIT EUR (this value cannot be changed)

CT_CONDITION_VALIDITY

CONDITIONRECORD 0000202633
CONDITIONVALIDITYENDDATE 20.08.2019
CONDITIONVALIDITYSTARTDATE 20.08.2018

CT_CONDITION_SUPPLEMENT

CONDITIONRECORD 0000202628
CONDITIONSEQUENTIALNUMBER 03
CONDITIONRATEVALUE 666
CONDITIONRATEVALUEUNIT EUR (same as original)

CT_CONDITION_SCALE

CONDITIONRECORD 0000202628
CONDITIONSEQUENTIALNUMBER 03
CONDITIONRATEVALUE 666
CONDITIONRATEVALUEUNIT EUR (same as original)
CONDITIONSCALEQUANTITY 12
CONDITIONSCALEQUANTITYUNIT EA (same as original)

2.  Execute successfully

If execute success, you can check he export parameters, and you will find that the value of reference fields is changed.

4. DELETE_CONDITION_RECORD

Importing parameters:

Ø  CT_CONDITION_RECORD

Ø  CT_CONDITION_SUPPLEMENT

Ø  CT_CONDITION_SCALE

Delete example: if you want to delete condition records, we provide you the Delete function to do so, the procedure as following.

1. Import parameters

CT_CONDITION_RECORD

CONDITIONRECORD 0000202633

 

CT_CONDITION_SUPPLEMENT

CONDITIONRECORD 0000202633
CONDITIONSEQUENTIALNUMBER 03

CT_CONDITION_SCALE

CONDITIONRECORD 0000202633
CONDITIONSEQUENTIALNUMBER 01
CONDITIONSCALELINE 0001

 

2. Execute

If execute success, the changing parameter will receive the deleted condition records information:

For example, delete one condition record:

3. Example for Calling Purchase API

If you want to call public API in your own project. Here is an example for the calling:

If you want to Call CREATE_CONDITION_RECORD (other CURD methods are called nearly the same steps) to create condition records.

You need firstly declare an object for purchasing API, for example mo_purg_api

The constructor of this object like this:

mo_purg_api type ref to IF_PURGPRCG_CNDNRECD_API

Then you can call the function, like the following:

(the importing parameters have been provided example before)

2. Mapping

In our Public API, importing parameters are all using global field name. However, when you do some more development based on our API, maybe you will use the technical name of these fields.

So, we provide you the mapping excel of it.

EXT_FIELDNAME: Using as global field name, it can be used in importing parameter.

INT_FIELDNAME: Technical name.

Conclusion

Now you finish the guide of using public API for purchasing and sales, which for teaching you to use CREATE, GET, UPDATE and DELETE.

Please try to begin your first test about this guide, and following you can get more guide for public API.

 

Be the first to leave a comment
You must be Logged on to comment or reply to a post.