How to Use Date Management to Configure Service Contract Dates
In this blog, we demonstrate how to use configuration activities to set up your desired service contract dates in the SAP S/4HANA Cloud system.
Date management in the application area Service of SAP S/4HANA Cloud is technically originated from that in the SAP Customer Relationship Management (CRM). You can use it to control displaying and changing of dates in service contracts.
When you create a service contract, the system by default creates it with a start date set at the current date (11/17/2022 00:00:00) and an end date at one year later (11/17/2023 00:00:00) to make a one-year service contract.
However, some customers requested a different end date (11/16/2023 23:59:59) according to their business requirement. A simple approach is to manually change the end date of the service contract. If you want the system to do it automatically, we show you how to achieve it in the following blog.
Note that you can see seconds in the time picker only as of 2302 release.
How to meet the requirement depends on how you interpret it. You can find various approaches to achieve the requirement based on different interpretations. Here, we found that the requirement (11/16/2023 23:59:59) can be achieved by minus one second from the default contract end date and time (11/17/2023 00:00:00). Therefore, our solution is based on that approach.
Step 1 Find Configuration Item Date Management
As a configuration expert, you open the Manage Your Solution App and select Configure Your Solution. Choose the application area Service and find the general settings for Date Management.
Step 2 Define Date Types, Duration Types and Date Rules
2.1 Define a new entry for duration: ZONE_S_DUR One Second
2.2 Define a new date type for the contract end date: ZCONTEND Contract End Date Minus One Second
You can do this by copying the existing date type CONTEND.
2.3 Define a new date rule: ZCONT007 One Second Minus Contract End Date
You can do this by copying the existing date rule CONT007.
2.4 Open XML Editor for Date Rules
Double click the new date rule and double click the version entry to open the XML editor for date rules.
2.5 Write XML date rule
When you first open the XML editor, it displays the XML date rule that you have copied from the date rule CONT007 as below:
To achieve our goal, we replace the XML date rule with the following XML expressions and save.
In this new XML date rule, we used three variables:
- RESULT – This variable holds the result after the evaluation of the date rule
- ZCONTEND – This is the new date type
- ZONE_S_DUR – This is the new duration
In the new XML date rule, we used two expressions:
- AssignTimeExp – We use this expression to assign a time variable from source to target. Here the target is the variable RESULT and the source is from the MoveTimeExp.
- MoveTimeExp – We use this expression to subtract a duration from a time point by defining the direction as “-“. Here the time point is new date type ZCONTEND and the duration is ZONE_S_DUR.
<?xml version="1.0"?> <TimeRule> <TimeRuleSource> <ruleline> <AssignTimeExp> <VarTimeExp name="RESULT" position='F'/> <MoveTimeExp direction="-"> <VarTimeExp name="ZCONTEND" position='F'/> <VarDuraExp name="ZONE_S_DUR"/> </MoveTimeExp> </AssignTimeExp> </ruleline> </TimeRuleSource> </TimeRule>
For more details about writing XML date rules, see this blog How to Create XML Date Rules for Service Contracts.
Step 3 Define Date Profile
Open the configuration step Define Date Profile and click on Configure.
3.1 Create a new date profile: YCONT002
You can do this by copying the existing date profile CONT002. When prompted with options, select “copy all”.
3.2 Add date rule ZCONT007 to the new date profile YCONT002
Select the date profile YCONT002 and go to the Date Rules from the Dialog Structure in the left. Add the new entry ZCONT007.
3.3 Add date type ZCONTEND and date rule CONT001 to date profile YCONT002
Choose date profile YCONT002 and go to the Date Types from the Dialog Structure in the left. Make the requested changes as below.
3.4 Add duration ZONE_S_DUR to date profile YCONT002
Go to Durations from the Dialog Structure in the left and double click the duration ZONE_S_DUR. Set default values here using reference object SYSTEM and duration 1 second.
Step 4 Assign Date Profile to Transaction Types
Open the configuration step Assign Date Profile to Transaction Types and click on Configure.
Assign date profile YCONT002 to transaction type SC1 (Service Contract).
Step 5 Assign Date Profile to Item Categories
Open the configuration step Assign Date Profile to Item Categories and click on Configure.
Assign date profile YCONT002 to item categories that you want the date profile to apply. Here we apply it to all three item categories (SCN1, SCN2, SCN3) of service contract.
Now, when you create a service contract or a service contract item, the system automatically sets its end date One Second less than the previous default settings. You get 23:59:59 for your contract end date!
In this blog, we show you how to configure date types, duration, XML date rules, and date profile step by step. Date management is a complex design to enable our customers to customize date relvant system behaviors according to your own business requirements. The example we choose is a real business case required by our customers. We hope you can understand the basic logic of it and will apply it in your own system if needed.
If you have any questions, please comment under this blog. We will get back to you soon with our answers. If you have any other questions about service contracts, you can find Q&A and post your questions in the community.