Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
Wei
Product and Topic Expert
Product and Topic Expert
2,528

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

 

 
6 Comments
0 Kudos
Great, it's a very useful article. Thanks!
neil_xu
Advisor
Advisor
0 Kudos
Very Nice blog. Thanks.
Wei
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Readers of This Blog,

Sorry for the inconvenience but you have to do one more step for Step 3.3 in the procedure mentioned above. This is the additional step:

Change the date rule to the standard date type CONTEND in your custom date profile. 

  1. Go to your custom date profile (YCONT002)
  2. Find the standard date type CONTEND and double click it to see the details 
  3. Change the date rule assigned to the CONTEND from CONT001 to the new custom date rule (ZCONT007).
  4. Save the changes.

3.3.2.png

It's also fine that you do this step after you have done everything mentioned in the blog above.

If you have any questions regarding to this blog, feel free to add a comment.

BR,

Wei

 

HarunSLK
Associate
Associate
0 Kudos

Hi @Wei , I would like to have the contract start date set to FIRST OF NEXT MONTH for my Subscription item which is now enabled for solution orders to be set.

I saw you have created a new rule in your screenshots. Could you provide me this rule please?

HarunSLK_0-1717754470734.png

 

Wei
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi @HarunSLK,

Thanks for your comments.

You can use the basic steps above and apply the following XML for the new date rule to make contract start date at first of next month:

<?xml version="1.0"?>
<SAPTimeRule>
 <TimeRuleTree>
  <!-- Begin of Rule Tree -->
     <ruleline>
     <!-- Begin of new LINE -->
      <AssignTimeExp displaytype="AssignTime">
        <!-- Assign time -->
          <VarTimeExp displayType="VarTime"
                             name="RESULT"
                          position="B">
           <!-- Variable: Time -->
          </VarTimeExp>
           <!-- Round result of move to 1st of month -->
          <RoundTimeExp displaytype="RoundTimeExp"
                         timeunit="MONTH"
                          position="E">
            <MoveTimeExp displaytype="MoveTime" direction="+">
             <!-- Move -->
                           <ConstLocTimeExp displaytype="ConstLocTime"
                        date="now"
                        time="000000"
                        timeunit="DAY">
              <VarObjectExp displaytype="VarObject" name="SYSTEM"/>
          </ConstLocTimeExp>
              <ConstDuraExp displaytype="ConstDura"
                            duration="1" timeunit="DAY">
              <!-- Constant Duration -->
                 <VarObjectExp displaytype="VarObject"
                               name="SYSTEM"/>
                 <!-- Variable: Timeobject -->
              </ConstDuraExp>
            </MoveTimeExp>
           </RoundTimeExp>
       </AssignTimeExp>
     </ruleline>
 </TimeRuleTree>
</SAPTimeRule>

For subscription items of solution orders, copy the date profile SUBS_DAT_PRO (Date profile for subscription billing) to add your new date rule.

Good luck!

Best regards,

Wei

 

Sourabh9
Discoverer
0 Kudos

Hello Wei

thanks for this detailed explanation. Even I have a similar requirement, and I followed your steps to achieve it. 

However, this is small, catch. When I’m trying to place an order where my start date is the current system date. For example, let’s say today is 9th July 2024 00:00:00 and my contract validity period is 3 years which means my contract end date should be 8th July 2027 23:59:59

now what system is doing is It is accepting the start date as 9th July 2024 00:00:00 , however, the contract end date is getting set as 8th July 2024 23:59:59 Instead of 2027. This is causing an error and system is displaying as contract end date should be later than contract star date.

when I’m trying to edit this order and Select the dates manually in date profile section by not selecting the current date and time rather a past or a future Date. Let’s say 10th July 2024 , Then the end date is setting correctly as 9th July 2027 23:59:59. 
Now I don’t save it and again, select my current date I.e. 9th July 2024 00:00:00 then system is setting it correctly as 8th July 2027 at 23:59:59. 

After doing all this analysis, I realised that Date profile is actually working correctly where contract start date is either in past or in future considering the contract and date is in future like in this case three years validity period making it to 2027

However, if the contract start date is a current date and time like 9th July 00:00:00. In this case, It is not updating the contract end date Correctly in first go. But when we will tweak around with the dates like manually, flipping it to future or past, and then set it to present date , Then it works perfectly fine. 

Not sure what is causing this. But I will need your help in order to fix this. It would be great if you can take a look at this analogy. Please suggest how can we fix this?