[CLOSED] Logging procedure (FEX) calls to a database
Each time a user runs a report, I want to log that action into a table. I am not happy with the way I have it working at the moment.
I have an Access database with the tables DUAL (with one row) and tblReportLog This is the fex I call for logging:
-* File Log_Report.fex -DEFAULTS &sReport='UNDEFINED'; -DEFAULTS &sSystem='UNDEFINED'; DEFINE FILE DUAL INSERTDATE/HYYMDS = HGETC(10, 'HYYMDS'); USER/A8 = GETUSER(USER); REPORT/A50V='&sReport'; SYSTEM/A20V='&sSystem'; END TABLE FILE DUAL PRINT INSERTDATE USER REPORT SYSTEM BY X NOPRINT ON TABLE HOLD AS LOGGING END -RUN MODIFY FILE TBLREPORTLOG FIXFORM FROM LOGGING MATCH INSERTDATE USER REPORT SYSTEM ON MATCH UPDATE * ON NOMATCH INCLUDE DATA ON LOGGING END
From the report procedures, I call this procedure like this:
EX PassportReporting/Log_Report sSystem='&sSystem',sReport='WorksMgt_LabourHours_ByDate'
Things that I'd like to fix:
1. I am achieving the insert using the long winded MODIFY command and an Access table called DUAL. The table is needed so I can get one row into a hold table. I am hoping someone can tell me a better row of doing this. Even replacing the Access table with a Focus table would be a step forward, however I dont know how to get data into a Focus table in the first place.
2. I am passing the procedure name from the calling procedure. I am hoping there is a way that the procedure can know its own filename, so that I dont have to explicitly identify the procedure. something like GETFILENAME().
Thanks in advance.This message has been edited. Last edited by: Kerry,
Robert Billing Programmer Loy Yang Power Victoria, Australia.
February 01, 2006, 05:49 PM
susannah
Robert, i do this with a focus file. to start, each of my fexes has at its top an &var set called fexname -SET &FEXNAME = 'salesrep'; (This is handy because i use it in my report footers, dump it to the agent dir so if something crashes,i know what fex was running, etc) then i use the time of day and then, very important, a random variable ( i don't track the username..could, but dont) My random variable separates two simultaneous hits to the same fex . To make a focus db out of thin air, one way is to type up the master file description as you would want it to be, and then use CREATE FILE filename, one time only, before your first MODIFY -SET &FXCOMP = SUBSTR(8,&COMPANY | ' ',1,8,8,'A8'); // another variable i use -SET &FXNAME = SUBSTR(8,&FEXNAME | ' ',1,8,8,'A8'); -SET &FXNAME = UPCASE(8,&FXNAME,'A8'); -SET &FDFEX = 'FEX' | &FXNAME || '.FTM'; -SET &RAND = RDUNIF(D8.6) * 10000; -SET &RANDOM = SUBSTR(8,&RAND | '0000000',1,8,8,'A8'); -RUN USE D:\IBI\APPS\FEXUSAGF.FOC END -* getting warning on match include includes duplicate segments; don't care -* CREATE FILE FEXUSAGEF // only on your first execution MODIFY FILE FEXUSAGF FIXFORM DATE/8 X1 FEXNAME/A8 X1 TIME/8 X1 RANDOM/A8 X1 COMPANY MATCH DATE ON MATCH CONTINUE ON NOMATCH INCLUDE MATCH FEXNAME ON MATCH CONTINUE ON NOMATCH INCLUDE MATCH TIME ON MATCH CONTINUE ON NOMATCH INCLUDE MATCH RANDOM ON MATCH REJECT ON NOMATCH INCLUDE DATA &YYMD &FXNAME &TOD &RANDOM &FXCOMP END -RUN USE CLEAR * END -eoj.fexusage -RUN When i email a report by caster, i switch off the include of this usagetracking fex. There is a variable for the fexname &FOCFOCEXEC but i've never gotten it to retun anything but 'adhoc'...i just don't know how to make it usable. Someone will come along and tell us, tho.This message has been edited. Last edited by: susannah,
In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
The following sits in a standard -INCLUDE fex: -SET &STARTTIME = &TOD; -SET &STOPTIME = HHMMSS('A8'); MODIFY FILE USELOG MATCH * KEYS SEG 01 ON NOMATCH INCLUDE ON MATCH CONTINUE MATCH * KEYS SEG 02 ON NOMATCH INCLUDE DATA UDATE = '&YYMD', USERID = '&SET_USER', IPADDRESS = '&SET_IP', UTIME = '&STARTTIME', FEXNAME = '&RAPP', STOPTIME = '&STOPTIME',$ END
IBI also sells a product called Resource Analyzer which will do all this and much more for you. The thing to watch out for doing a MODIFY is to make sure you are licensed to do this. Also, you may currupt your tracking database if it is not under the sync machine and more than one person trys to add a record to it.
Thanks!
Mickey
FOCUS/WebFOCUS 1990 - 2011
February 06, 2006, 10:56 AM
susannah
oooo. very interesting . thanks stockholm!
In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
February 09, 2006, 08:47 AM
jbmuir
This is how we do it:
We modify the site.wfs so that it remembers the "IBIF_ex" value, and then redirects all requests to a "security" (call it SECURITY) fex that performs the logging and does security stuff. The last thing the SECURITY fex does is to -INCLUDE the original fex that the requestor wants run.
This way of doing things avoids having -INCLUDE code in each fex, and is therefore less error prone and more secure.
WF 7.1.6 moving to WF 7.7, Solaris 10, HTML,PDF,XL
February 09, 2006, 06:23 PM
susannah
jb, would you be kind enough to show us the line in your site.wfs?
In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
February 09, 2006, 09:46 PM
TexasStingray
jb
if you want a site fex to execute prior to the uses focexec look at setting the _site_profile in the site.wfs somthing like this
_site_profile = -INCLUDE SECURITY
Scott
February 10, 2006, 10:19 AM
jbmuir
Here is a simple stripped down example of code that could be placed in a site.wfs:
MYFOCEXEC=&IBIF_ex
IBIF_ex=SECURITY
MYFOCEXEC(pass)
The requestors fex is assigned to MYFOCEXEC, and IBIF_ex is assigned the name of the SECURITY fex. Then MYFOCEXEC is passed into fex SECURITY as it is run. You do your logging and other security stuff inside the SECURITY fex, and finally the last lines of your SECURITY fex are something like:
which causes the requestors fex to run. We use this in "self-serve" mode. Haven't done this with "Diabolical Studio". There were problems using this with DS :-(.
WF 7.1.6 moving to WF 7.7, Solaris 10, HTML,PDF,XL
February 10, 2006, 10:22 AM
jbmuir
The bulletin board trashed my last reply.
MYFOCEXEC(pass)
is incorrect. Should read:
.set. MYFOCEXEC(pass)
substitute angle brackets for periods (.)
WF 7.1.6 moving to WF 7.7, Solaris 10, HTML,PDF,XL
February 10, 2006, 10:24 AM
jbmuir
quote:
Originally posted by TexasStingray: jb
if you want a site fex to execute prior to the uses focexec look at setting the _site_profile in the site.wfs somthing like this
_site_profile = -INCLUDE SECURITY
Interesting. Thank you.
WF 7.1.6 moving to WF 7.7, Solaris 10, HTML,PDF,XL
February 14, 2006, 09:38 PM
Robert Billing
I cannot get the &IBIF_ex parameter value. I have tried making these changes to the site.wfs file in the srv71\wfs\etc directory.
1. RAPP=&IBIF_ex
2. RAPP=&IBIF_ex RAPP(pass)
3. RAPP=&IBIF_ex {SET}RAPP(pass)
4. {SET}IBIF_ex(pass)
5. {sendvar} RAPP=&IBIF_ex {endsendvar}
note: I used angle bracket, but they dont seem to post here, so I changed them to curly brackets.
None of these gave me a value for &RAPP or &IBIF_ex when referenced in my report header. I am running via developer studio.
However.. I did find out I could just reference &FOCFOCEXEC in my report which gave me the foc name, plus a leading underscore.
If anyone can help with getting site.wfs to do *anything*, I would be grateful.
note, I call the foc from html using a form with the action "/ibi_apps/WFServlet". I have a field with the name IBIF_ex with the value set to the procedure name. I also have some other custom fields that I am able to easily refer to in my reports by sticking an ampersand in front of their name. This makes it even more frustrating that IBIF_ex comes through blank (although webFocus runs the right report, of course).This message has been edited. Last edited by: Robert Billing,
Robert Billing Programmer Loy Yang Power Victoria, Australia.
February 15, 2006, 08:50 AM
mgrackin
You may also use &FOCFEXNAME which is the name of the FOCEXEC without the leading underscore.
the following works fine for us.
<SENDVAR> THEFEX=&IBIF_ex <ENDSENDVAR>
Thanks!
Mickey
FOCUS/WebFOCUS 1990 - 2011
February 15, 2006, 10:18 AM
jbmuir
The value for the IBIF_ex parameter does not get passed through on our site.
As silly as this seems, try placing a space between the {set} and the variable name. The "language" used in the site.wfs is scantly documented, and as you are discovering - in need of improvement.
WF 7.1.6 moving to WF 7.7, Solaris 10, HTML,PDF,XL
February 28, 2006, 04:27 PM
Robert Billing
I have it working.
I am developing in a stand alone environment with Dev Studio (711).
I edited the site.wfs in C:\ibi\DevStudio71\srv71\wfs\etc. There is no 'client' in a stand alone Dev Studio install.
I added the following line (using angle brackets where curly ones are shown): {SET} IBIF_ex (pass)
I have found that clicking the 'memory cache' button in the Admin Console (/ibi_html/wfconsole.htm) after making a change to the site.wfs helps in refreshing the settings.
hope this helps someone else.
Robert Billing Programmer Loy Yang Power Victoria, Australia.
July 17, 2006, 05:07 PM
.eric
Would someone be able to post the code to their master file because the one I created doesn't seem to be working properly. Instead of creating a new row it appends to an existing row.
dev: WF 7.6.5 w/IIS + Tomcat
prod: WF 7.6.5 w/IIS + Tomcat
July 18, 2006, 04:59 AM
Pete
Hi
the way we went about it is :
1. we altered the cgivars file so we could use the fex full name description
We use an sql passthrough the insert our lines into a log table
ex.
SQL SQLORA BEGIN SESSION SQL SQLORA INSERT INTO MIS_LOG (USR,REPNAME,AUTH) VALUES (upper('&&UNAME'),upper('&MR_FULL_FEXNAME'),upper('&&AUTH_LVL')); END
this routine is in a seperate fex so that we just have to include in a the fexes we want to log
P.
D: WF 7.6.2 P. : WF 7.6.2 on W2003 ------------------------------------------------------------------ I see myself as an intelligent, sensitive human, with the soul of a clown which forces me to blow it at the most important moments.
-Jim Morrison-
May 05, 2009, 11:23 AM
AMARNATH_EL
Hi,
We are desperate in implementing this functionality.
Can you please send the step by step process to acheive this?
Thanks, Amarnath
WebFOCUS 7.6.7 Unix Excel/Html
May 05, 2009, 01:24 PM
TexasStingray
this topic is is 3 years old. please open a new post and specify exactly what you want