How to Show if The S/4HANA Material is Batch or Serial Managed in SAP C4C?
Materials can be marked as Batch Managed or Serial Number managed in the Sap Erp system (ECC or S/4HANA). As a standard integration with SAP C4C for material replication from SAP ERP to SAP C4C the batch and serial number managed information is not transferred to SAP C4C as there is no standard field in SAP C4C Product to capture this information. There can be various used cases where this information may become important to represent in SAP C4C. For example, in a service ticket when the spare is entered for service confirmation, and that respective spare is serialized or batch managed then you may want the technician to mention the serial number or the batch number of the spare which he/she has consumed to fix the machine in the ticket. However it may not be possible for the SAP C4C to prompt the same as the information that the spare is serial or batch manages is not available in SAP C4C Product record of that spare.
In this blog we will see how the information regarding the material being batch or serial number managed can be published in the product record in SAP C4C from SAP ERP. In this example we are referring to the application environment where our SAP C4C (1705) is integrated with S/4HANA 1610 via SAP PI 7.4.
For publishing the serial or batch managed information for a material from SAP ERP to SAP C4C via PI following activities are required to be performed in the below sequence:
- Create custom fields in the SAP C4C Product screen for capturing this information. These fields have to be created with KUT and extended to the services.
- Download the material inbound wsdl file and import into PI ESR to ensure that the custom fields are available for mapping.
- The SAP ERP IDOC for the material replication to SAP C4C already contains the fields for the Serial Number Profile (Plant wise) and Batch Managed (at main material level MARA). The SAP ERP will populate these fields in the outgoing IDOC for the respective material if the material record is marked with the respective profiles. If not then the SAP ERP will not send these fields in the outgoing IDOC. These fields needs to be mapped in source and target structures in SAP PI service mapping.
- Test the mapping with test payload in SAP PI and activate the mapping in ESR.
- Replicate one material which is batched or serial managed from SAP ERP to SAP C4C and check if the information is published correctly.
We will now begin with these steps and observe how these needs to be performed in the respective systems:
Step 1: Creating the Serial Managed and Batch Managed fields with KUT in SAP C4C (1705)
Access the product screen in SAP C4C UI5 and go in the adapt mode and create the respective fields. Below are the screenshots for our example:
The below field is created with KUT as a list field with the values as “NO” or “YES” without any default. We have extended this field to the following:
- Form Templates: so the same is available in the form templates and can be bind with any specific field in the Adobe LiveCycle Designer while creating any custom form.
- Reporting: so the same is extended to the respective data sources and can be used for reporting.
- Enterprise Search: so the same can be enabled for the search the materials which are batch managed with the values.
- Extension Scenarios: so the same is available for extensions in the system with respect to the scenarios.
- Services: so the respective wsdl files are updated with the field and the field is available for mapping and update from the external applications via the inbound payload.
- ODATA Service: for, just in case.
The below screen shows the service which should be marked as selected which would help in replicating the value for this field in our example. From SAP ERP (S/4HANA on this case) to SAP C4C. It can be extended to all inbound services otherwise. Outbound is what you need to be careful about. Will cover the same in detail in another blog specially referring to some scenarios of Synchronous services for external pricing shortly.
Repeat the same steps for creating the field for Serial Number Manages. Below is the screenshot from our example:
Enable these fields in the Product screen at the overview screen. Please note that the Serial Number Profile is assigned at the plant level for each material in SAP ERP, hence if the material is extended to multiple plants then the serial number profile can be maintained at each plant vie for that material in material master in SAP ERP. Keeping this in mind the serial number managed field can also be put in the sales data tab in SAP C4C for the product, however in our scenario we only want the information that the material is serial number enabled in SAP ERP irrespective of what profile is maintained at each plant level in SAP ERP. Hence we have kept only two values for this field “YES” or “NO”. If it is enable for any plant for the material in SAP ERP that is good enough for us to publish the information on the product overview section in SAP C4C (in our example scenario). Below is the screenshot of where we have placed these fields in our SAP C4C system on product view:
Step 2: Download the material inbound wsdl file and import into SAP PI ESR to ensure that the custom fields are available for mapping.
Below are the steps for downloading the updated wsdl for material inbound in C4C:
- Go to the ‘Administrator’ work center and go to communication arrangements and edit the Communication Scenario ‘Material replication from External System/ERP’. In our example with S/4HANA, it is ‘Material Replication from SAP Business Suite’. This works well in SAP C4C UI5 but am more comfortable with SAP C$C silverlite UI
- Click on ‘Technical Data’ and then click on Edit Advance Settings’.
- Select ‘Inbound’ tab and select the ‘Material Replication from SAP Business Suite’ from the table and click on ‘Download WSDL’ button.
- Save the file in your local system with a relevant file name.
Open the file to check your fields. I use internet explorer to open the file and check the entries for our custom fields to ensure that the KUT extension of service is successful and the respective fields are available in the WSDL:
Import the WSDL file in SAP PI ESR. Will write a detail blog on how this activity can be performed in various ways. For our example we have already imported the file in SAP PI ESR, below are some of the screenshots of the ways which I performed this activity.
Open the service in PI ESR (ERP_COD_MATMAS_CFS ) where the target wsdl file needs to be uploaded:
In the operations mapping ERP_COD_MATMAS_CFS the source message is the SAP ERP IDOC MATMAS_CFS.MATMAS05 and the target structure is the SAP C4C service materialreplicationbulkin1 (MaterialMassReplicationRequest).
Double Click on the Mapping Program ERP_COD_MATMAS_CFS to open the field mapping view and double click on External Message MaterialMassReplicationRequest as highlighted in the screenshot below:
Below screen will appear. Study the screen carefully. Here go in the change mode and click on the import icon against the ‘File’ field where the current WSDL file details are displayed. Refer to the screenshot below.
Select your new WSDL file from the local after clicking on the import icon and click ‘Open’ button.
This will import the new WSDL file in the PI ESR. After the import is successful on the WSDL tab the new WSDL structure will display, here you can again search for your extended fields to confirm.
Save the change by clicking on the save button on the top and activate the change by clicking on the External Definition and Activate.
(Note: Do not worry, this change can be reverted in case anything goes wrong. To revert come to the same screen click on the External Definition > history. System will show the change history there select the previous version and open and make some dummy change in description then save and activate. The previous version will be restored.)
Once this external definition is active then close this screen and go back to the Message Mapping screen
Here your newly added WSDL will take impact. But our work is only half done yet. Click on the change mode in the message mapping screen:
Now we need to establish the source and target mapping for our newly added fields. Here we are going to Map the SAP ERP Batch Managed field of the material master with the SAP C4C Batch Managed field.
Name of the SAP ERP Batch Managed field is XCHPF this needs to be mapped with the BatchManaged field of SAP C4C. The logic which we are going to implement is that if there is any value sent by SAP ERP in the field XCHPF in the IDOC then PI should set the value for BatchManaged field to ‘YES” because all we want to publish to SAP C4C is that the product is batch managed.
For performing this mapping first search for XCHPF field in the source structure External Message MATMAS_CFS.MATMAS05, and search the BatchManaged field in External Message MaterialMassReplicationRequest, as shown in the screen below:
Step 3: The SAP ERP IDOC for the material replication to SAP C4C already contains the fields for the Serial Number Profile (Plant wise) and Batch Managed (at main material level MARA). The SAP ERP will populate these fields in the outgoing IDOC for the respective material if the material record is marked with the respective profiles. If not then the SAP ERP will not send these fields in the outgoing IDOC. These fields needs to be mapped in source and target structures in SAP PI service mapping.
Double click on BatchManaged field. This will bring the BatchManaged field in the mapping layout Do the same for the XCHPF field. Both fields will be in the same mapping layout. Now we can build the logic for our mapping. Refer to the screenshot below. If you have a SAP PI consultant along with you then it will be very helpful as he would be able to build the below logic very quickly.
The above mention logic is checking if XCHPF exists means generated on run-time in the source structure then pass the constant ‘YES’ to BatchManaged else pass the constant ‘NO’ to the BatchManaged field. Remember the SAP ERP IDOC will only contain any value for XCHPF if the material which is sent by the SAP ERP is marked as batch managed otherwise this field will not be sent in the IDOC to PI. Hence the above logic.
Same logic is applicable to Serial Number Managed product. The field for the Serial Number from SAP ERP is SERNP which contains the serial number profile ID assigned to the material in the plant view. This field needs to be mapped to the SerialNumberManaged field of SAP C4C in exactly same manner. In our scenario if a serial number profile is assigned to the material in any of the sales area plant view then SAP PI should update the SerialNumberManaged field of SAP C4C with value ‘YES’ else with ‘NO’. Below is how this is mapped for our example scenario:
The logic is same, if SERNP exists means generated on runtime in the source structure then pass the constant ‘YES’ to SerialNumberManaged else pass the constant ‘NO’ to the SerialNumberManaged field. Remember the SAP ERP IDOC will only contain any value for SERNP if the material which is sent by the SAP ERP is marked has serial number profile ID assigned otherwise this field will not be sent in the IDOC to SAP PI. Hence the above logic.
Now to check if the mapping is working fine, pick up the inbound IDOC payload for the material IDOC which is coming from SAP ERP and test the mapping with the same. Below is how this needs to be done
Step 4: Test the mapping with test payload in SAP PI and activate the mapping in ESR.
In SAP ERP run transaction BD10 and trigger a material replication to SAP C4C manually.
Open the message monitoring from SAP NetWeaver Process Integration link by clicking on the Configuration and Monitoring home:
Click on the Adapter Engine and then on Message Monitor
Run the query and click on the successful message. In our screenshot below there are 1900 successful message as be replicated so many materials to SAP C4C from SAP ERP (S/4HANA)
On the next screen Select the first message from the table and click on ‘Open Message’ button
Go to the Payload tab and copy or download the payload. I generally just copy the payload.
Go back to the message mapping screen of SAP PI and click on Test tab: Click on SRC icon and remove the content marked with yellow cross in the screenshot below and paste your copied payload and then click the execute button below
Then check the payload conversion. By clicking on the down arrow button.:
In my test above the material payload which I have used does not contain the batch or serial number profile and hence the logic executed successfully and passed the value as ‘NO’ to the respective Batch Managed or Serial Number Managed fields.
Below is another test result: Here the material sent by S/4HANA is serialized and the Serial Number Profile ID is Z001, hence the value exist for SERNP and hence our mapping logic has updated the SerialNumberManaged field to ‘YES’.
Save and activate the message mapping. Click on the save icon and then go to Message Mapping Link in the top Left and click on Activate.
Clear SLD Cash: Click on Environment and then click on Clear SLD Cash.
Step 5: Replicate one material which is batched or serial managed from SAP ERP to SAP C4C and check if the information is published correctly.
Now replicate a material from SAP ERP to SAP C4C and check the same in SAP C4C Product record the KUT fields will be updated correctly in the SAP C4C. Refer the screenshot below:
Hope the blog is helpful. Will be publishing more blogs shortly on various other custom integration mappings which are useful to know.