on 2021 May 11 9:52 AM
Hi Experts,
I am a newbie here.
I am trying to find the difference between 2dates using FOX formulas, below is my code.
DATA VDATE TYPE ZVALUEDT.
DATA MDATE TYPE ZMATURITY.
DATA V_DATE TYPE D.
DATA M_DATE TYPE D.
DATA PER TYPE 0CALDAY.
FOREACH ZFD.
VDATE = ATRV( ZVALUEDT , ZFD).
MDATE = ATRV( ZMATURITY, ZFD).
V_DATE = VDATE.
M_DATE = MDATE.
PER = M_DATE - V_DATE .
{'/ERP/QUANTY',XXX,ZFD,MDATE,VDATE} = PER.
ENDFOR.
Not sure on the type of 'PER' variable here.. Is there any function to find the differences directly?
Thank you in advance.
Rajesh.
Request clarification before answering.
Hi Rajesh,
well, then you could define it in format D.
I am not sure what the value would be then and if this would then fit into your key figure...
regards
Cornelia
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rajesh,
the difference between two dates can only be a number.
That´s why you can not feed it into per when per is type 0calday.
you need to define the result type I or F
data per type F.
kind regards
Cornelia
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Cornelia,
I am getting below error after changing PER type to F.
Message no. RSPLFOX057
Types of operands must either be the same or compatible. Operands are compatible if they have the same data type. In addition, types I and F are compatible
Regards,
Rajesh.
Welcome Rajesh,
I think you should check for tutorials as it will help you better to understand the dynamic. I feel you are not explaining what is exactly your issue, you are specifically doing this operation M_DATE - V_DATE, if M_DATE (2020002) and V_DATE (2020001) you will obtain 0000001 and you are adding to {'/ERP/QUANTY',XXX,ZFD,MDATE,VDATE}. Do you have any error? Does code work?
My recomendation is that you can check this information in the menu of 'Operative' (selected one), 'Info' (Tutorials) and 'Verify HDB'.

Also, some easy way of checking, is printing messages with this kind of code:
MESSAGE I000(000) WITH 'TXT' MDATE VDATE PER.
You will see this text if you execute the function through the 'Sequence' it is involved in, with the option 'Execute step as trace'(picture), this option won't save the information in the cube and is a safe way to check the data you are generating.

Hope it helps and take your time for checking.
Kind regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lara,
Thank you for your reply.
I am getting below syntax error
Understand /ERP/QUANTITY is type F, and PER type is defined as 0CALDAY; hence above error.
In my example, M_DATE is 20205101 (1st May 2020) and V_DATE is 2020601 (1st Jun 2020).
When i do subtraction, not sure on which type or variable should i declare for PER.
Regards,
Rajesh.
I tried changing types, but no luck.
When i change PER type F, getting error.(Types if operands F and D do not agree)
PER = M_DATE - V_DATE .
Any suggestions would be a great help!
Message no. RSPLFOX057
Types of operands must either be the same or compatible. Operands are compatible if they have the same data type. In addition, types I and F are compatible.
Rajesh,
| User | Count |
|---|---|
| 9 | |
| 8 | |
| 7 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.