Focal Point
[CLOSED] Finding Passed Variable's Format

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/7397084196

August 19, 2019, 11:30 AM
John Coleman
[CLOSED] Finding Passed Variable's Format
I am passing a date formatted (MDYY) variable from an HTML page to a report. How can I test the report to see the format of the variable being passed? For simplicity sake I am using this code:

-DEFAULTH &DT = _FOC_NULL;
-SET &DT = IF &DT NE _FOC_NULL THEN &DT ELSE CLAIMS.FROM_DT;

TABLE FILE CLAIMS
PRINT
-* This NOPRINT is only here for the report to show properly. No calculatiosn are being done on it.
CLAIMS.FROM_DT NOPRINT
COMPUTE TM/MDYY = &DT;
END

It works if I just run it, but if I used the FROM_DT field in a combobox on the HTML page, and pass it to the report as &DT (via a Run Button) it doesn't work. I can't for the life of me figure out why it would work one way and not the other depending on where the variable is set.

This message has been edited. Last edited by: FP Mod Chuck,


John Coleman
WEBFocus 8.1.05
Windows 7
August 19, 2019, 11:35 AM
MartinY
What is &DT format passed by your HTML ? Are you using the Calendar control from HTML canvas, if so, which format have you selected ?

What is the defined format of CLAIMS.FROM_DT ?

It's possible that FROM_DT format is not a valid date format to reformat using /MDYY

Does FROM_DT is a date format in your file ?


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
August 19, 2019, 11:38 AM
John Coleman
quote:
CLAIMS.FROM_DT ?

The defined format of Claims.FROM_DT is MDYY

I am not using a calendar control. I am passing it from a combobox filled in dynamically by that field in the Master so &DT being passed should be the MDYY that the field is in the master, no?


John Coleman
WEBFocus 8.1.05
Windows 7
August 19, 2019, 11:53 AM
Tony A
In the properties of your combobox, make sure it is sent as a quoted value.

It is possible that the value being sent is an alphanumeric representation of your date (variables do not have a real format) such as 08/19/2019, which will not pass the compute that you have.

If you make your page send it as a quoted value, '08/19/2019', it should be dealt with correctly.

You could test this (or use the code!) like this -

-SET &DT = IF &DT NE _FOC_NULL THEN '''' || &DT || '''' ELSE DATE;


T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
August 19, 2019, 11:55 AM
MartinY
quote:
Originally posted by John Coleman:
quote:
CLAIMS.FROM_DT ?

The defined format of Claims.FROM_DT is MDYY

I am not using a calendar control. I am passing it from a combobox filled in dynamically by that field in the Master so &DT being passed should be the MDYY that the field is in the master, no?


Is it the USAGE or the ACTUAL that is MDYY ?

And once passed from a parameter, in a sense, it all become either a text or a number depending if it includes characters or not

If you add this at the top of your fex that receive the parameter, what do you see ?

-TYPE Received Dt : &DT
-EXIT


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
August 19, 2019, 12:02 PM
John Coleman
MartinY - When I run the -TYPE it get back

Received Dt : 01/01/2014

That leads me to assume it Alphanumeric, since it has "/" in it. That doesn't explain how if I just set it to the field via the IF...THEN... statement, it works.

I really want to see what the format is coming from the HTML, can I use the ?FF on something being passed into the report?

I'm trying to understand the conversion I am missing, so forgive me if I seem obstinate.

This message has been edited. Last edited by: John Coleman,


John Coleman
WEBFocus 8.1.05
Windows 7
August 19, 2019, 01:50 PM
MartinY
The date display depend on your configuration under Reporting Server / Workspace / LOCALE / LOCALE (Language, Numbers, Currency, Dates) /
- DATE_ORDER
- DATE_SEPARATOR

-DEFAULTH &DT = 08/01/2019;

DEFINE FILE CAR
TM/MDYY  = &DT.QUOTEDSTRING;
TM2/A10  = &DT.QUOTEDSTRING;
END
TABLE FILE CAR
PRINT TM
      TM2
BY COUNTRY
END 

As per above sample, with the configuration that I have, TM is displayed as 2019-08-01 and since it's a text field TM2 is displayed as 08/01/2019

This is an invalid command : -SET &DT = IF &DT NE _FOC_NULL THEN &DT ELSE CLAIMS.FROM_DT;
You cannot set a variable to a file field value but you can set a variable to a file field for display such as below

-DEFAULTH &DT = 08/01/2019
-*-DEFAULTH &DT = _FOC_NULL

-SET &FLD = IF &DT NE _FOC_NULL THEN CAR ELSE _FOC_NULL;

DEFINE FILE CAR
TM/MDYY  = &DT.QUOTEDSTRING;
TM2/A10  = &DT.QUOTEDSTRING;
END
TABLE FILE CAR
PRINT TM
      TM2
BY COUNTRY
BY &FLD
END 


Why is this "I really want to see what the format is coming from the HTML" so important ?


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
August 20, 2019, 04:27 AM
Tony A
quote:
This is an invalid command : -SET &DT = IF &DT NE _FOC_NULL THEN &DT ELSE CLAIMS.FROM_DT;

Not completely invalid - It works because of loose syntax rule or maybe by design?

If you really want to apply strict syntax, it could be made "syntax pure"(?!?!) by adding quotes around the assignment of the field. Add that to my suggestion above and this should do the trick -

-SET &DT = IF &DT NE _FOC_NULL THEN '''' || &DT || '''' ELSE 'CLAIMS.FROM_DT';


T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10