Focal Point
-INCLUDE RETURN CODE MESSAGES

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

July 29, 2008, 12:07 PM
Tomsweb
-INCLUDE RETURN CODE MESSAGES
I have created a driver fex that runs a stream of fexes for a monthly production run.

At this point, I have the following code:
-TYPE ___________________________________________________
-TYPE Starting Car1.fex: ( &BEG1 - &END1 ) FREQ = &FREQ
-RUN
-INCLUDE CAR1
-RUN
-TYPE Ending Car1 Fex: ( &BEG1 - &END1 ) FREQ = &FREQ
-TYPE ___________________________________________________
-RUN
-EXIT
-***********

However, if I remove the -RUN below the -INCLUDE car1.fex statement, I will see
this message when I click on view source:
___________________________________________________
Starting Car1.fex: ( 2008/07/01 - 2008/09/30 ) FREQ = Q
Ending Car1 Fex: ( 2008/07/01 - 2008/09/30 ) FREQ = Q
___________________________________________________
0 NUMBER OF RECORDS IN TABLE= 4 LINES= 4

Then if I put the -RUN back to follow the -INCLUDE CAR1 statement, I see this message:

Starting Car1.fex: ( 2008/07/01 - 2008/09/30 ) FREQ = Q
0 NUMBER OF RECORDS IN TABLE= 4 LINES= 4

Does anyone have any DM code that will effectively monitor that a called FEX is about to
start its run, and when it is complete, with the statistics - hopefully - displaying before a
message appears that it has completed?.

What about capturing a return code in the fex (at end) and passing that value back to
driver fex?

Thanks! Wink


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
July 29, 2008, 12:17 PM
GinnyJakes
Tom,

You need the -RUN to force the execution of the code in car1.fex before you can type out a message saying that the fex is complete.

If you don't have the -RUN, all the DM commands run first before FOCSTACK is executed.

If you want to test a return code, &LINES is as good as any.


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
July 29, 2008, 12:55 PM
Leah
quote:
Does anyone have any DM code that will effectively monitor that a called FEX is about to
start its run, and when it is complete, with the statistics - hopefully - displaying before a
message appears that it has completed?.

Where I worked previously, we allocated a file in a directory when the caster job ran and then did -WRITE commands to the file with various information. As Ginny indicates, for most control, the -RUN should be used. For our purposes we didn't use it often.


Leah
July 30, 2008, 04:23 AM
Danny-SRL
Tom,

Ginny gave you the "secret". When you run a WF procedure you have to be a bit schyzophrenic... or think "stereo".
Focexecs are read sequentially from line 1. If a line starts with a '-' it is executed immediately. If it doesn't, the line is written to the FOCSTACK. When either -RUN, -EXIT or last line is encountered, whatever has accumulated in the FOCSTACK is executed.
Hence, what you have observed.
As for testing "return codes" you have a choice:
&RECORDS (number of records extracted)
&LINES (number of lines generated)
&READS (number of records read from an external data source)
&BASEIO (number of I/O on a Focus db)
&FOCERRNUM (number of last error encountered - should be 0)

For efficiency, you can use &FOCCPU which shows the amount of CPU milliseconds. For example:
  
-* File ByTocXL.fex
-SET &START= &FOCCPU;
TABLE FILE CAR
SUM SALES
BY COUNTRY NOPRINT
BY CAR BY BODY
ON TABLE SET BYDISPLAY ON
ON TABLE HOLD FORMAT EXL2K BYTOC
END
-RUN
-SET &END= &FOCCPU;
-SET &USEDCPU=&END - &START;
-TYPE USED CPU = &USEDCPU



Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

July 30, 2008, 09:28 AM
Tomsweb
I tested your code exactly as provided with -RUN immediately after the Table Request.

-SET &ECHO=ALL;

-SET &START = &FOCCPU;
-TYPE START = &FOCCPU
-*
TABLE FILE CAR
SUM SALES
BY COUNTRY NOPRINT
BY CAR BY BODY
END
-RUN
-*
-SET &ENDZ = &FOCCPU;
-TYPE ENDZ = &FOCCPU
-SET &USEDCPU = (&ENDZ - &START);
-TYPE USED CPU = &USEDCPU

As the &ECHO display indicates, the &ENDZ and &USEDCPU are ignored:


< !--
-SET &START = 2453 ;
-TYPE START = 2453
START = 2453
-*
TABLE FILE CAR
SUM SALES
BY COUNTRY NOPRINT
BY CAR BY BODY
END
-RUN
0 NUMBER OF RECORDS IN TABLE= 13 LINES= 13

WebFOCUS Version 7.1.4 compiled and linked on Fri May 19 16:45:40 EDT 2006 (Gen branch714:284)
-->

In order to get the Used CPU value, I have to modify the code to this:
-*
TABLE FILE CAR
SUM SALES
BY COUNTRY NOPRINT
BY CAR BY BODY
END

-*
-SET &ENDZ = &FOCCPU;
-TYPE ENDZ = &FOCCPU
-SET &USEDCPU = (&ENDZ - &START);
-TYPE USED CPU = &USEDCPU
----------------------------------------------------------------------
and, I see this in the &ECHO display:

< !--
-SET &START = 2562 ;
-TYPE START = 2562
START = 2562
-*
TABLE FILE CAR
SUM SALES
BY COUNTRY NOPRINT
BY CAR BY BODY
END
-*
-SET &ENDZ = 2562 ;
-TYPE ENDZ = 2562
ENDZ = 2562
-SET &USEDCPU = (2562 - 2562 );
-TYPE USED CPU = 0
USED CPU = 0
0 NUMBER OF RECORDS IN TABLE= 13 LINES= 13

This is awkward because I see the CPU metrics before I see the
&LINES/&RECORDS info. It works, but is not the "ideal" that
some user(s) and developer(s) would prefer to live with.
----------------------------------------------------------------------
Lastly, If I place a -RUN after the TABLE Request, &ENDZ and
&USEDCPU coding, I get the same results.
-*
TABLE FILE CAR
SUM SALES
BY COUNTRY NOPRINT
BY CAR BY BODY
END

-*
-SET &ENDZ = &FOCCPU;
-TYPE ENDZ = &FOCCPU
-SET &USEDCPU = (&ENDZ - &START);
-TYPE USED CPU = &USEDCPU
-RUN
-*
and, I see this in the &ECHO display:
-*
TABLE FILE CAR
SUM SALES
BY COUNTRY NOPRINT
BY CAR BY BODY
END
-*
-SET &ENDZ = 718 ;
-TYPE ENDZ = 718
ENDZ = 718
-SET &USEDCPU = (718 - 718 );
-TYPE USED CPU = 0
USED CPU = 0
-RUN
0 NUMBER OF RECORDS IN TABLE= 13 LINES= 13

WebFOCUS Version 7.1.4 compiled and linked on Fri May 19 16:45:40 EDT 2006 (Gen branch714:284)
-->

I wonder if the particulars of Ver. 7.1.4 is part of the problem.

Thanks. Eeker


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
July 30, 2008, 09:54 AM
GinnyJakes
Depending on the robustness of the table request, it may not take enough cpu to get the variable to register. For instance, a report against the CAR file as you show in your post may only take milliseconds of cpu to execute. If the variable &FOCCPU is cpu in seconds, you'll never see anything.

I'd go with &RECORDS and &LINES and possibly the HHMMSS subroutine. Here is an example.

--SET &ECHO=ON;
-SET &BEGTIME=HHMMSS('A8');
-TYPE &BEGTIME
TABLE FILE CENTURYSALES
PRINT *
ON TABLE HOLD
END
-RUN
-SET &ENDTIME=HHMMSS('A8');
-TYPE &ENDTIME
-TYPE RECORDS READ &RECORDS
-TYPE LINES IN REPORT &LINES

gives you

 08.53.01
 TABLE FILE CENTURYSALES
 PRINT *
 ON TABLE HOLD
 END
 1
 0 NUMBER OF RECORDS IN TABLE=    32283  LINES=  32283
 0
 08.53.02
 RECORDS READ    32283
 LINES IN REPORT    32283



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
July 30, 2008, 10:06 AM
Danny-SRL
Tom,

Very strange. See the following:
  
 -SET &START= 11062   ;
 TABLE FILE CAR
 SUM SALES
 BY COUNTRY NOPRINT
 BY CAR BY BODY
 ON TABLE SET BYDISPLAY ON
 ON TABLE HOLD FORMAT EXL2K BYTOC
 END
 -RUN
 0 NUMBER OF RECORDS IN TABLE=       18  LINES=     13
 0 EXL2K FILE SAVED ...
 -SET &END= 11109   ;
 -SET &USEDCPU=11109    - 11062   ;
 -TYPE USED CPU = 47
 USED CPU = 47


Could you try my example as it is?


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF