Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SHARING] Generic Text Logger

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SHARING] Generic Text Logger
 Login/Join
 
Master
posted
Sometimes you run into a situation where you might need a way to log to a CSV or dat file.. This is something that might help.

-SET &HEADERS = 'DTTM,ITEMNM,ITEMTXT';
-SET &AUDITDTTM = FPRINT(HGETC(8, 'HYYMD-s'), 'HYYMD-s', 'A23');

-*Reset the data, can be passed in.
-DEFAULTH &DELETEFILE = 0;

-*default values that will be passed in.
-DEFAULTH &ITEMNM = _FOC_NULL;
-DEFAULTH &ITEMTXT = _FOC_NULL;

-*validate data coming in.  If nothing, then ignore logging it.
-IF &ITEMNM EQ _FOC_NULL AND &ITEMTXT EQ _FOC_NULL THEN GOTO THEEND;

-*application name, full path and subdirectories (Reporting Server directory of full path to disk.) IS NOT OS DEPENDENT
-DEFAULTH &PATH = 'public';
-*filename without the extension to write log to
-DEFAULTH &FILENM = 'check_write_log_files';
-*file ext of the log file to write to
-DEFAULTH &FILEEXT = 'csv';

-*all data to write
-SET &WRITELINE = &AUDITDTTM || ',' || '"&ITEMNM.EVAL"' || ',';

-*Check make sure data was passed in.
-IF &ITEMTXT EQ _FOC_NULL THEN GOTO SKIPITEMTXT;
-TYPE 'ITEMTXT HAS DATA'
-SET &WRITELINE = &WRITELINE || '"&ITEMTXT.EVAL"';

-SKIPITEMTXT
-*check to make sure there is a slash on the end of the path
-IF SUBSTRING(&PATH, &PATH.LENGTH-1, 1) EQ '/' GOTO SKIPSLASHADD;
-SET &PATH = &PATH || '/';

-SKIPSLASHADD
-*add all the information together to get a full path and filename for logging
-SET &LOGFILENM = &PATH || &FILENM || '.' || &FILEEXT;
-TYPE LOGFILENM = &LOGFILENM

-*see if log file already exists
STATE &LOGFILENM
-RUN
-TYPE RETCODE1 = &RETCODE
-*if exists and delete flag is set to delete, errase the file else skip delete
-IF &RETCODE EQ 0 AND &DELETEFILE EQ 1 THEN GOTO ERASEFILE ELSE GOTO START;

-ERASEFILE
-TYPE Erasing File
-*delete the file, is not OS DEPENDENT
APP DELETEF '&PATH.EVAL' '&FILENM.EVAL' '&FILEEXT.EVAL'

-START
-TYPE Checking File State
-*check log state again
STATE &LOGFILENM
-RUN
-TYPE RETCODE2 = &RETCODE
-*if file exists, skip createfile
-IF &RETCODE EQ 0 THEN GOTO FILEEXISTS;

-CREATEFILE
-TYPE '-CREATEFILE'
-*create a file with only the header information
FILEDEF CLOGFILE DISK &LOGFILENM (APPEND
-RUN
-WRITE CLOGFILE &HEADERS
-WRITE CLOGFILE &WRITELINE
-RUN
-CLOSE CLOGFILE
-GOTO THEEND

-FILEEXISTS
-TYPE '-FILEEXISTS'

FILEDEF VLOGFILE DISK &LOGFILENM (APPEND
-RUN
-WRITE VLOGFILE &WRITELINE
-RUN
-CLOSE VLOGFILE

-THEEND



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Virtuoso
posted Hide Post
Thanks Gavin for the share!

To add to this thread, here's what we've developed for creating a log file that keeps track of what procedures were ran when and by who. This is nice when you want to pilot a portal for a specific user group and see who's using it and exactly what they are clicking on.

Our logging .fex:

-* To reference this file within a procedure you want to log having been ran, type the
-* following at the top of the procedure:
-*   "-MRNOEDIT -INCLUDE fexlog3" (without extension or semi-colon)

-DEFAULTH &LOG = 'ranfexlog.log';

-GOTO setname.&fexname.EXIST;
-setname.0
-SET &fexname = IF &FOCFOCEXEC CONTAINS 'ADHOCRQ' THEN 'ADHOCRQ' ELSE TRUNCATE(&FOCFOCEXEC);
-setname.1
-SET &fexname = TRUNCATE( &fexname );

-SET &HOUR = EDIT(&TOD, '99$$$$$$');
-SET &MIN = EDIT(&TOD, '$$$99$$$');
-SET &TIME = &HOUR | ':' | &MIN;

FILEDEF LOGFILE DISK \\server\share\&LOG (APPEND
-RUN

-SET &LOGGED = 'Day ran: ' | &DATEMDYY | ', Time of day: ' | &TIME | ', User that ran procedure: ' | &IBIMR_user | ', Procedure name: ' | &fexname;
-SET &OUT1 = PUTDDREC('LOGFILE', 7, &LOGGED, &LOGGED.LENGTH, 'I1');
-SET &OUT1 = CLSDDREC('I1');
-End


8.2.02M (production), 8.2.02M (test), Windows 10, all outputs.
 
Posts: 1113 | Location: USA | Registered: January 27, 2015Report This Post
Expert
posted Hide Post
Just gave this 5 stars.

Good One


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!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SHARING] Generic Text Logger

Copyright © 1996-2020 Information Builders