Create Mass Products by code in S/4HANA for Customer Management
This blog will briefly introduce the CRM Product model adaptation in S/4HANA and how to create mass products by ABAP program in the new world.
During my development in S/4HANA for Customer Management 1.0 I need to create a huge number of products in the system to test the performance of our adapted Product API.
You may find that product creation functionality is NOT available in new Accounts & Products UI any more.
The reason has been explained in my blog S/4HANA for Customer Management 1.0 introduction from technical point of view: the product concept is modeled differently in SAP CRM as the material model in S/4HANA, and then we have finished a so-called “Master Data Harmonization” to make CRM product related API to manipulate the S/4HANA model instead, which means:
1. the CRM product model related concept such as settype & relationship ( interlinkage ) is obsolete in S/4HANA. Just the same as one order model introduced in my blog CRM One Order Model Redesign in S/4HANA for Customer Management 1.0 – Part 1, the related table for CRM product model like COMM_PRODUCT, COMC_SETTYPE etc remains in the system but are NOT used by CRM application in S/4HANA any more. For custom development, you SHOULD never touch them as well.
2. Product create, update or archive IS NOT SUPPORTED in WebClient UI any more. You should perform such operation in S/4HANA Material application built by Fiori instead.
In SAP CRM once you click the hyperlink in Service Order line item, you will navigate to product overview page( in WebClient UI ).
3. It is NOT supported to create, update or delete CRM product in S/4HANA using BOL API any more. In the Genil implementation class of CRM Product, CL_CRM_PRODIL, the corresponding methods like CREATE_OBJECTS and MODIFY_OBJECTS are empty now. You should NEVER use API like CRM_PRODUCT_UI_MAINTAIN either, since it works on top of the CRM product model mentioned before which becomes obsolete in S/4HANA.
On the other hand you can still use BOL API to read or search products. The corresponding code have been redirected to new material model in S/4HANA. Such harmonization is done in package CRMS4_PRODUCT_API. A series of new CDS views are built on top of S/4HANA material model and stored in package CRMS4_PRODUCT_CDS.
In order to create product by ABAP code, you have to use S/4HANA material related API instead, and it’s the purpose of this blog.
I have written a report to enable the mass creation of products in S/4HANA.
Source code could be found from my github.
It’s easy to understand the purpose of each input field. The below setting will create 1000 products whose ID has prefix ANDROID plus the incremental integer from 1 to 1000, and description starts “Android phone S” plus integer as well.
The actual creation is achieved by function module BAPI_MATERIAL_SAVEREPLICA.
An example of created product looks like below in table MAKT:
Besides product type(HAWA by default in this report) and product description, the following properties are also created under the hood:
1. Sales organization ID and distribution channel ID fetched from table tvkov and tvko.
2. Tax classification related data from tstl and tskd
3. product industry from table T137 and product hierarchy from table T179. Entries are read from these two tables and assigned to each product randomly. The random logic is encapsulated in class cl_crms4_cust_home ( source code here ).
In next blogs I will continue to introduce mass creation for Business Partner and Service Document in S/4HANA for Customer Management.
Jerry’s other blogs on S/4HANA for Customer Management
- S/4HANA for Customer Management 1.0 introduction from technical point of view
- CRM One Order Model Redesign in S/4HANA for Customer Management 1.0 – Part 1
- CRM One Order Model Redesign in S/4HANA for Customer Management 1.0 – Part 2
- Create Mass Products by code in S/4HANA for Customer Management
- Create Mass Service document in S/4HANA for Customer Management
- One order extensibility in S4HANA for Customer Management
Unable to access the code in the github repository. Could you please fix the link? thanks for the brilliant content!
I have fixed the broken url. Thanks for using it.
Hi Jerry, any new about CM 2.0?
Me too looking for an update.