cancel
Showing results for 
Search instead for 
Did you mean: 

Determination of Dates - xml help

anais_jaussaud
Participant
0 Kudos


Dear all,

I am struggling with determining a duration in a date profile.

I have found some explanations on a wiki but I am not sure what I need to do is possible with standard.

I have declared 2 dates, let's say TODAY and BIRTHDAY . I would like to have the duration between those 2 dates, so that i can know how many days I have left until the day of the BIRTHDAY. The duration can be minus which means that the Birthday dates is in the past.

Let's say today is 29/08/2014

Birthday is 30/08/2014

I would like my duration to say : 1

If we are today : 01/09/2014 - I would like my duration to be -2

Would anyone be kind on sharing the possibility of xml code for this kind of rule?

I have found the explanation below but have no idea where to put the 'dates' to make the calculation.

Determine the duration between two times

<ruleline>          <AssignDuraExp>
              <VarDuraExp/>
              <DiffTimeExp timeunit="DAY">
                  <VarTimeExp position="T"/>
                  <VarTimeExp position="F"/>
                  <VarObjectExp/>
              </DiffTimeExp>
          </AssignDuraExp>
      </ruleline>

Best regards and thanks again.

Anaïs

Accepted Solutions (0)

Answers (2)

Answers (2)

anais_jaussaud
Participant
0 Kudos

Niraj,

Thanks (again ) for your help. Unfortunately, the restul is still the same, the 'duration' between the two dates is not calculated.

I have created the following date:

Without checking the Milestone checkbox.

Then I have created the Date rules as follow

with the rule given :

<?xml version="1.0"?>

<TimeRule>

<TimeRuleSource>

<ruleline>

  <AssignDuraExp>

     <VarDuraExp/>

        <DiffTimeExp timeunit="DAY">

           <VarTimeExp name="Z_TR_BRTHDA" position="T"/>

           <VarTimeExp name="TODAY" position="F"/>

           <VarObjectExp/>

         </DiffTimeExp>

    </AssignDuraExp>

  </ruleline>

  </TimeRuleSource>

</TimeRule>

In the date profile, I have matched the dates with date rule.

However, in the web_ui, for the date, i cannot see the 'duration' in the date Z_TR_BIRTHDA:

'Durée (for duration) is empty and not calculated.

However, with the link given, I am wondering if I should trigger the FM 'CRM_APPT_MAINTAIN_SINGLE_OW' if it cannot do it in a standard way.

In that case, what is the 'Duration' column (durée) in the view refering to?

Thanks a lot,

Regards,

Anaïs

Former Member
0 Kudos

Anais,

In that case, what is the 'Duration' column (durée) in the view refering to?

Date customization has 3 things - Duration, Date Type and Rules. See your first screen shot youpasted. Duration column that you see in Dates assignment block refers to Duration from customization. Try to crate a Duration type and assign it to your date profile. You will be able to see that Duration in Dates AB and that column will be editable for it.

Now what you need is difference between 2 dates expressed in days.

Assuming that the rule will work

1. You need to have 2 date types, seems you have only 1. Is TODAY a date type for you? Also you need to have Milestone clicked otherwise your date type itself has a start and end date.

2. Next is your Rule which you already created.

3. You can assign Rule to a date type and not a duration. This is the point I'm worried about. Also said in the other discussion. If you have a Rule whose result is in Days and not a date how will it help assigning that rule to a date? You cannot assign say 2 days to a date..right?

So I doubt this solution will work. Some other guys in the forum can have another idea on this. May be they have done something that I am unaware. 

Assuming that rule will not work

1. You need to have 2 date types, both of which have milestone checked.

2. No need to have any rule

3. Do either from below, both developments

   a) Either follow the other discussion, of having a custom event. This should be a FM registered against your event where you will have to read both dates and calculate the duration. To set the duration call FM - CRM_APPT_MAINTAIN_SINGLE_OW

   b) Use BAdi - CRM_APPOINTMENT_BADI. After you enter a date type its MERGE method is triggered. In each trigger check whether both date types are filled. If yes, calculate duration and call the same FM - CRM_APPT_MAINTAIN_SINGLE_OW to maintain duration. Remember that for duration, control will come again inside this BAdi. At this time you need not do anything.

In all probability you will need technical help from your ABAP team.

Niraj

Former Member
0 Kudos

Hi Anais,

I can let you know where you will put the date type names -

<ruleline>         

  <AssignDuraExp>

     <VarDuraExp/>

        <DiffTimeExp timeunit="DAY">

           <VarTimeExp name="BIRTHDATE" position="T"/>

           <VarTimeExp name="TODAY" position="F"/>

           <VarObjectExp/>

         </DiffTimeExp>

    </AssignDuraExp>

  </ruleline>


Try and see whether this works or not.


Just as an alternate, read below. You may have already looked at it.