Focal Point
[SOLVED] Write run-time &Variables to a file

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

December 06, 2007, 07:14 AM
mark66
[SOLVED] Write run-time &Variables to a file
Hi all,

I would like to save all my run-time &variables, starting '&V_' to a file. So something similar to what I would get if I issued the following command:

-? &V

I have been reading the following thread where Ginny shows how to output column names to variables. I have tried to modify this code to write my &variables but without any luck.

I also tried the following in hope it would write out the variables, but alas that would have been too easy!

FILEDEF MARK_TEST DISK /home/iadmindev/ibi/apps/mark/test.fex
-RUN

-WRITE MARK_TEST -? &V


Any thoughts?

This message has been edited. Last edited by: Kerry,


WebFocus 765. iSeries v5r4
December 06, 2007, 08:18 AM
RichH
Are you getting any errors?
Is that syntax correct for the 400?
I think it should look more like...
FILEDEF MARK_TEST DISK library/mark(test)


WebFOCUS 8202 Win 2012
Test - WebFOCUS 8203 on Win 2012
December 06, 2007, 08:51 AM
mark66
Hi Rich,

This runs fine but will just write '-? &V' to the file within the IFS directory on the 400.

All our system database files are in the normal format library/file.


I can easily manually record all the variables, but I want the code to write all '&V_*' &variables without having to specify each one.


WebFocus 765. iSeries v5r4
December 06, 2007, 09:03 AM
GinnyJakes
Mark,

I'm glad you liked my previous post. However, I don't think you can -WRITE the output of a command to a specific file the way you tried.

The output of -? is going to the 'terminal' so I think what you would need to do, shades of old mainframe days, would be to filedef the terminal. Not sure what the ddname is these days. You could try TRMOUT.

So it would be something like this:

FILEDEF TRMOUT DISK whereever_you_want_to_put_it
-? &V

Sound reasonable?


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
December 06, 2007, 09:12 AM
GamP
Mark,

I've been trying something on my environment (which is NOT as400, but windows).
I think however that is should be possible to modify the code so that it also runs on as400.
My code is as follows:
SET TRACEOFF = ALL
SET TRACEON = ALL
SET TRACESTAMP=OFF
SET TRACEUSER=C:\TEMP\MARK.TRC
-RUN
-? &
SET TRACEOFF = ALL
-RUN
FILEDEF MASTER DISK TRACE.MAS
FILEDEF TRACE DISK C:\TEMP\MARK.TRC
-RUN
-WRITE MASTER FILENAME=TRACE, SUFFIX=FIX
-WRITE MASTER SEGNAME=TRACE
-WRITE MASTER FIELDNAME=LINE, FORMAT=A200, ACTUAL=A200, $
-RUN
DEFINE FILE TRACE
RESULT/A155 = SUBSTR(200,LINE,45,200,155,RESULT);
AMPER/A1 = EDIT(RESULT,'9');
END
TABLE FILE TRACE
PRINT RESULT
IF LINE CONTAINS 'ngput'
IF AMPER EQ '&'
END

On Windows this gives me a report with just the amper variables currently active.
Hope this helps..... and that you can convert it to and use it on the as400.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
December 06, 2007, 10:07 AM
Francis Mariani
GamP, that is very creative! I really like this solution.

For a cross-platform version, I would use the TEMPPATH function to determine where to save the trace file, so with a little tweak for the TRACEUSER setting, this has been tested on UNIX and Windows and works on both.

-SET &ECHO=ALL;

-SET &TEMPDIR = TEMPPATH(60,'A60');
-SET &TRACEFILE = &TEMPDIR || 'trace.trc';

SET TRACEOFF = ALL
SET TRACEON = ALL
SET TRACESTAMP=OFF
SET TRACEUSER=&TRACEFILE
-RUN
-? &
SET TRACEOFF = ALL
-RUN
FILEDEF MASTER DISK trace.mas
FILEDEF TRACE DISK trace.trc
-RUN
-WRITE MASTER FILENAME=TRACE, SUFFIX=FIX
-WRITE MASTER SEGNAME=TRACE
-WRITE MASTER FIELDNAME=LINE, FORMAT=A200, ACTUAL=A200, $
-RUN
DEFINE FILE TRACE
RESULT/A155 = SUBSTR(200,LINE,45,200,155,RESULT);
AMPER/A1 = EDIT(RESULT,'9');
END
TABLE FILE TRACE
PRINT RESULT
IF LINE CONTAINS 'ngput'
IF AMPER EQ '&'
END

Thanks very much GamP.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
December 06, 2007, 10:11 AM
GamP
You're welcome. Always trying to be of help.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
December 06, 2007, 10:15 AM
Francis Mariani
Post 111 for you GamP - a milestone Smiler


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
December 06, 2007, 10:23 AM
GinnyJakes
Good job, GamP. My suggestion didn't work a lick.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
December 06, 2007, 11:26 AM
FrankDutch
Very creative GamP...
I will recomend you for a job at Information Builders helpdesk




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

December 06, 2007, 11:35 AM
mark66
Hi all - as always a great effort from everyone!

GamP your solution with Francis's small mod works just right for us, thank you very much! Smiler



Also , if I may sneak in one last query with you all:

Every so often my Developer Studio decides to not allow me to edit a file when I right-click on it. Instead of getting the usual options "Open, Edit, Run, Print, Copy" etc, all I can do is "Run, Copy, Properties". I usually have to restart Dev Studio to get all the options back, but then sometimes it breaks again within minutes - todays has been particularly bad! Our other Developer doesn't have any problems, any ideas what am I doing wrong?! I guess somehow I am loosing my access rights?


WebFocus 765. iSeries v5r4
December 06, 2007, 11:52 AM
smiths
Mark,

Also note that if you want to check if an amper variable exists, you can use the EXISTS function, as in:

-SET &CASTER=IF &DSTSCHEDID.EXISTS EQ 1 THEN 'Y' ELSE 'N';


You may want to put your latest question in a new thread, so that it doesn't get lost.

GamP, very interesting code. Francis, thanks for Unixifying it.

Sean


------------------------------------------------------------------------
PROD: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
TEST: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
December 06, 2007, 12:10 PM
GinnyJakes
Mark,

I'm assuming that your reporting server is running under OPSYS security as ours is. And are you talking about Data Servers or which area of Dev. Studio. We are all Data Servers and sometimes have that issue. Our users store their operating system credentials in Show Environments. It appears that the cookie disappears or gets corrupted on occasion.

I have a little focexec that I have them run that tells them who is logged on.

-* File check_logon.fex
-*************************************************************
-SET &USERID=GETUSER('A8');
-TYPE THE USERID FROM GETUSER IS &USERID  


Unfortunately, sometimes the right id shows. It is a head-scratcher.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
December 06, 2007, 07:01 PM
susannah
gamps idea is really cool...
if you want a rather pedestrian way, you can take your initial idea and just tweak it a bit
say you have 10 &variables in your fex and you know what they are called...which you should, right?
FILEDEF MARK_TEST DISK /home/iadmindev/ibi/apps/mark/test.fex
-RUN

-WRITE MARK_TEST NOCLOSE &var1
-WRITE MARK_TEST NOCLOSE &var2
-WRITE MARK_TEST NOCLOSE &var3
-WRITE MARK_TEST NOCLOSE &var4
... etc
-CLOSE MARK_TEST
(I'm not sure the CLOSE is right, i use it and it works, but i think i made it up .. that's the thing with Focus, its a language so sometimes you make stuff up and it works!)
The NOCLOSE is important , it keeps from overwriting the same line.. kinda like a FILEDEF..(APPEND
I do this at run time for every one of my fexes..
-WRITE MYFILE &USERID &FEXNAME &DATE &TOD &ARANDOMNUMBER
and then all their &var values
and then MODIFY big log file..(hence the random number)
Big Brother is watching...




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
December 07, 2007, 06:04 AM
mark66
quote:
Originally posted by GinnyJakes:
Mark,

I'm assuming that your reporting server is running under OPSYS security as ours is. And are you talking about Data Servers or which area of Dev. Studio. We are all Data Servers and sometimes have that issue. Our users store their operating system credentials in Show Environments. It appears that the cookie disappears or gets corrupted on occasion.

I have a little focexec that I have them run that tells them who is logged on.

-* File check_logon.fex
-*************************************************************
-SET &USERID=GETUSER('A8');
-TYPE THE USERID FROM GETUSER IS &USERID  


Unfortunately, sometimes the right id shows. It is a head-scratcher.


Thanks Ginny, I was refering to the Data Servers. I will have to speak to our Techie and see if can shed some light on it and will check my logon user value when it next happens.


quote:
Originally posted by smiths:
Mark,

Also note that if you want to check if an amper variable exists, you can use the EXISTS function, as in:

-SET &CASTER=IF &DSTSCHEDID.EXISTS EQ 1 THEN 'Y' ELSE 'N';




quote:
Originally posted by susannah:
gamps idea is really cool...
if you want a rather pedestrian way, you can take your initial idea and just tweak it a bit
say you have 10 &variables in your fex and you know what they are called...which you should, right?
…..

Thanks Sean / Susannah,

The great thing about this script is that I don’t want/have to specify each and every run-time variable, it will just dump them out for me. This is necessary as many reports will be making use of it, all with different &variables.

To give more of an insight into its use:

All our reports end with a call to a Log scipt. This updates a log file, with details such as Report_ID, User, Report, Date, Start Time, End Time, Runtime, Rows Returned etc.

I have now coded an option to run this new script ‘ report dump’, if the report is one we want to monitor, or if the number of rows returned exceed a cetain value, or even if a report runs for too long.

This will allow us to be more effective in trying to improve the reports running on the system. Instead of having to email a user and say ‘Your report ran for 15 minutes, what did you enter?’, we can now just find the report dump which is saved under a the Report_ID.

Using a looping method (which is new to me in WebFocus) seen in Ginny’s other thread, I have been able to modify the dump script to divide the &variables into sections, each with headings. Therefore my dump now looks more like:


-* ------------------------------------------------------------------------------------------------------------------
-* Report Dump For ‘Mark Test Report’
-* ------------------------------------------------------------------------------------------------------------------

-* ------------------------------------------------------------------------------------------------------------------
-* LOG VARIABLES:
-* ------------------------------------------------------------------------------------------------------------------

&LOG_USER = ERF
&PROC = _mark_test_report
&RUNDATE = 20071207
&TERRITORY = UK
&LOG_SERVER =
&REP_ID = erf_20071207_111103
&STARTED = 11.11.03
&ENDED = 11.11.04
&RUNTIME = 1
&RETURNED = 102

-* ------------------------------------------------------------------------------------------------------------------
-* GLOBAL VARIABLES:
-* ------------------------------------------------------------------------------------------------------------------

&G_COP = ABC
&G_FORMAT = EXL2K
&G_RCS_INCL = A
&G_SYSTEM = DEVELOPMENT
&G_USER = erf

-* ------------------------------------------------------------------------------------------------------------------
-* PROGRAM VARIABLES:
-* ------------------------------------------------------------------------------------------------------------------

&V_DATE_FROM = 01/11/2007
&V_DATE_TO = 30/11/2007
&V_DRILL_YN =
&V_ENV = D
&V_INCLUDE = N
&V_MONTH =
&V_USER_FROM = ERF
&V_USER_TO = ERF

-* ------------------------------------------------------------------------------------------------------------------
-* USER DEFINED COLUMNS:
-* ------------------------------------------------------------------------------------------------------------------

&C1 = ‘ORDER_NO’
&C2 = ‘ORDER_LINE’
&C3 = ‘PRODUCT_NO’
&C4 = ‘QTY’

-* ------------------------------------------------------------------------------------------------------------------
-* OTHER VARIABLES:
-* ------------------------------------------------------------------------------------------------------------------

&H_IDENTIFIER = 20071207102140
&U_ENV = D
&U_TERRITORY = UK



I am really pleased with it, so thanks again for all your help!


WebFocus 765. iSeries v5r4
November 27, 2008, 01:48 PM
Roy D
This is a fantastic technique - thank you!

But I have a problem: the "-? &" in it is echoed into the html page and is viewable via "view source". Is there any way of stopping this? I have been searching site.wfs config but I really can't find anything.

Many thanks
Roy


8.0.0.6, Ubuntu 12.04, All
November 27, 2008, 09:01 PM
Waz
GamP , submit this in the Tips & Techniques Comp, its a winner.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

November 28, 2008, 03:27 PM
susannah
i second Waz's motion...
its a winner, Gamp.
as is Francesco's tweak.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
November 29, 2008, 03:31 AM
Roy D
quote:
But I have a problem: the "-? &" in it is echoed into the html page and is viewable via "view source". Is there any way of stopping this? I have been searching site.wfs config but I really can't find anything.


Any ideas anyone?


8.0.0.6, Ubuntu 12.04, All
November 29, 2008, 01:58 PM
susannah
but see, that's the whole point of turning on the trace...you're trapping the console...if it doesn't appear on the console...it can't be trapped in the trace output.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
November 30, 2008, 12:07 AM
Roy D
Thanks susannah but I'm not troubled by actually having the "-? &" command but rather that its result is returned in the html page. When it comes to composing the final page that is returned to the browser there must be a way of stopping the html comment from being included at the end of the displayable part of the page. (i.e. why does console output *need* to be returned to the user?)


8.0.0.6, Ubuntu 12.04, All
November 30, 2008, 10:11 AM
Tom Flynn
Roy,

quote:

But I have a problem: the "-? &" in it is echoed into the html page and is viewable via "view source". Is there any way of stopping this? I have been searching site.wfs config but I really can't find anything.


I'm sure you have:
-SET &ECHO=OFF;
so, the source code is not displayed.

Then turn off the right-click option for the HTML page.

Disable Right-Click - Toolbar


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
November 30, 2008, 10:38 AM
susannah
oh the user is seeing it? i thought it was just under ViewSource that it was being revealed.
how odd.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
November 30, 2008, 09:40 PM
Waz
GamP's technique can also get the results from APP SHOWPATH, I think that was an issue in another post here?

Roy D, if the users are seeing the & output, what are you returning ?

Is it an HTML page or a report.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

December 01, 2008, 01:26 AM
Roy D
Thanks for all the responses! Just to clarify I have included an edited html page below. It is on "view source" that the amper-variables become visible when you use this technique. My reasoning is that at the final composition of the page .. a function I believe is performed by the WebFOCUS Client .. the {!-- comment --} section is appended to the displayable report ('}' replaces left and right angle bracket). A want to prevent this part being displayed since some amper-variables contain more sensitive data that I don't want savy users having access to. I would have hoped that some configuration setting for the WF Client could altogether stop it from appending the html comment to the end of the page but I don't know what setting that is or whether it in fact exists. There is something in that line on TechSupport as a Technique: How to prevent "View Source" from revealing && variables? However this is not quite there

http://techsupport.informationbuilders.com/sps/10512001.html


How to prevent "View Source" from revealing && variables? Many of these
variables contain sensitive information that should not be displayed to someone
in the view source of html reports.



Solution:




In the /ibi/client53/wfc/etc/default.wfs file, the _ibi_get_ampers variable is
used to issue a '-? &&' command, whenever IBIF_persistentamp is set to "YES":
<if> IBIF_persistentamp.upper EQ "YES"
_ibi_get_ampers=-TYPE <AMPERS>\n-? &&&&\n-TYPE </AMPERS>
<else>

_ibi_get_ampers=\n
<endif>

To prevent this, _ibi_get_ampers can be set to nothing whether
IBIF_persistentamp is set to "YES" or "NO". Example:
<if> IBIF_persistentamp.upper EQ "YES"
<! _ibi_get_ampers=-TYPE <AMPERS>\n-? &&&&\n-TYPE </AMPERS> >
_ibi_get_ampers=\n
<else>

_ibi_get_ampers=\n
<endif>

This will comment out the line contained between <! and >. Then _ibi_get_ampers
is set to nothing whether IBIF_persistentamp is set to "YES" or "NO".

Before modifying the default.wfs file, please make a backup copy first. Then
after modifying the file and saving the changes, you will need to stop the
IIS Admin service and then start the World Wide Web Publishing service for the
changes to take effect.



My example page:




WebFOCUS Report


















PAGE 1

MODEL

COUNTRY

2000 4 DOOR BERLINA

ITALY




{!--
INSERT 0 1
HEADER_ID 17837
INSERT 0 1
CURRENTLY DEFINED & VARIABLES:
&&TSIBPATH = /opt/ibi/srv76/wfs/edatemp/ts000001/
&ACCEPTS = 0
&APPROOT = /opt/ibi/apps
&AUTOINDEX = NO
&BASEIO = 0
&CALLINGFEX = jnkaro24
&CHNGD = 0
&DATE = 12/01/08
.
.
.
&submit = Submit

WebFOCUS Version 7.6.2 compiled and linked on Tue Jun 26 21:27:18 EDT 2007 (Gen branch762:130)
--}



8.0.0.6, Ubuntu 12.04, All
December 01, 2008, 11:36 AM
GamP
RoyD,
The output will always be echoed in the html comment section. It is just the result of a command, and thus it will be included in the result set. I have not been able to find a way to not show the output.
I can only think of one way to do this, and that is to have it executed in the manner of how the html painter executes a fex to populate a drop-down box. The result of that process is never shown in the comments of the resulting html. Maybe you can do some research into that area?

BTW, Frances' tweak is not really needed. If you just specify a filename without a path in front of it, it will automatically be placed in the temporary directory.

Susannah/Waz: I'll think about submitting.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
December 01, 2008, 02:48 PM
susannah
that's brilliant
thank you so much for such good research and posting back to all of us.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
December 01, 2008, 11:27 PM
Roy D
Many thanks GamP. At this stage it probably isn't do-able, then. I might post it on TechSupport with IBI and see.

I don't use the Painters but I think they might be using an Ajax approach in which case any comments would be discarded (I tried it on some of my own stuff and that is what happened)

All the best
Roy


8.0.0.6, Ubuntu 12.04, All