Introduction
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.
Reasons
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.
Goal: Set a Different Service Contract End Date
Procedure
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.
Manage Your Solution App
Configure Your Solution
Configuration Item: Date Management
Step 2 Define Date Types, Duration Types and Date Rules
Configuration: Define Date Types, Duration Types and Date Rules
2.1 Define a new entry for duration: ZONE_S_DUR One Second
Step 2.1 Define a New Duration
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.
Step 2.2 Define a New Date Type
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.
Step 2.3 Define a New Date Rule
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.
Step 2.4 Open 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:
Step 2.5 XML Date Rule of CONT007
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.
Step 3 Define Date Profile
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".
Step 3.1 New Date Profile
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.
Step 3.2 Add Date Rule to Date Profile
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.
Step 3.3 Add Date Type and Rule
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 3.4 Add Duration and Set Default Values
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 4 Assign Date Profile to Transaction Type
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.
Step 5 Assign Date Profile to Item Categories
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!
Conclusion
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.
Further Reading
How to Create XML Date Rules for Service Contracts