Focal Point
[SOLVED] &LINES AND &RECORDS are not being reset for each CHECK FILE

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

September 21, 2015, 12:15 PM
GavinL
[SOLVED] &LINES AND &RECORDS are not being reset for each CHECK FILE
I've ran into an issue where we have multiple CHECK FILE to ensure a file exists in FOCCACHE before we read from them and &LINES and &RECORDS are coming back with the previous information, not the current one.

We have tried to -SET &LINES = _FOC_NULL; it errors. We have tried to -SET &LINES = 0; and even if the file exists, its still 0 when check file is executed.

Anyone run into this issue? How did you get around it?

You will noticed, I'm creating the first FOCCACHE file, but MYTABLE2 is never created, but it will return a results, saying there are 18 lines and records within it, from the CHECK FILE FOCCACHE/MYTABLE2

Here is the code I have:
SET ASNAMES = ON

TABLE FILE CAR
PRINT 
     CAR.ORIGIN.COUNTRY AS 'COUNTRY'
     CAR.COMP.CAR AS 'CAR'
     CAR.CARREC.MODEL AS 'MODEL'
     CAR.BODY.SALES AS 'SALES'
ON TABLE SET PAGE-NUM NOLEAD 
ON TABLE NOTOTAL
ON TABLE HOLD AS FOCCACHE/MYCAR FORMAT XFOCUS
END
-RUN

CHECK FILE FOCCACHE/MYCAR
-RUN
-TYPE LINES1 = &LINES;
-TYPE RECORDS1 = &RECORDS;
-IF &LINES EQ 0 THEN GOTO MISSINGDATA;

TABLE FILE FOCCACHE/MYCAR
PRINT *
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE HOLD AS SEARCHMYTABLE1 FORMAT INTERNAL
END
-RUN

-READFILE SEARCHMYTABLE1
-RUN

CHECK FILE FOCCACHE/MYTABLE2
-RUN
-TYPE LINES2 = &LINES;
-TYPE RECORDS2 = &RECORDS;
-IF &LINES EQ 0 THEN GOTO MISSINGDATA;

TABLE FILE FOCCACHE/MYTABLE2
PRINT *
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE HOLD AS SEARCHMYTABLE2 FORMAT INTERNAL
END
-RUN

-READFILE SEARCHMYTABLE2 
-RUN
-GOTO THEEND

-MISSINGDATA
-TYPE Missing Data here..

-THEEND
-TYPE Ended


Results:
 0 NUMBER OF RECORDS IN TABLE=       18  LINES=     18
 0 NUMBER OF ERRORS=     0
 NUMBER OF SEGMENTS=   1  ( REAL=    1  VIRTUAL=   0 )
 NUMBER OF FIELDS=     5  INDEXES=   0  FILES=     1
 TOTAL LENGTH OF ALL FIELDS=   61
 LINES1 =        5;
 RECORDS1 =        1;
 0 NUMBER OF RECORDS IN TABLE=       18  LINES=     18
 0 ERROR AT OR NEAR LINE     32  IN PROCEDURE ADHOCRQ FOCEXEC *
 (FOC205) THE DESCRIPTION CANNOT BE FOUND FOR FILE NAMED: FOCCACHE/MYTABLE2
 LINES2 =       18;
 RECORDS2 =       18;
 0 ERROR AT OR NEAR LINE     38  IN PROCEDURE ADHOCRQ FOCEXEC *
 (FOC205) THE DESCRIPTION CANNOT BE FOUND FOR FILE NAMED: FOCCACHE/MYTABLE2
 BYPASSING TO END OF COMMAND
 Ended

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



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
September 21, 2015, 01:22 PM
Dan Satchell
I agree, CHECK FILE on a non-existent file should set &LINES and &RECORDS to zero, but doesn't. A work-around is to use a TABLE request that returns zero records:

CHECK FILE CAR
-RUN
-TYPE &RECORDS
-TYPE &LINES
-*
TABLE FILE CAR
PRINT COUNTRY
WHERE COUNTRY EQ 'MEXICO';
END
-RUN
-TYPE &RECORDS
-TYPE &LINES
-*
CHECK FILE XYZ
-RUN
-TYPE &RECORDS
-TYPE &LINES



WebFOCUS 7.7.05
September 21, 2015, 01:46 PM
GavinL
Good find, but that's just redonkulous. I've already reached out to our rep about this, looks like I'll be opening a ticket.

Thanks..



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
September 21, 2015, 02:02 PM
Dan Satchell
You may be able to use the STATE command to check for the existence of a file. A return code of zero means the file exists. A return code of -1 means it doesn't.

DOS STATE FOCCACHE/MYCAR.FOC
-RUN
-TYPE &RETCODE



WebFOCUS 7.7.05
September 21, 2015, 02:10 PM
GavinL
Actually, I've made a discovery.. &RETCODE seems to be set for CHECK FILE. If the file exists, it's 0, if it doesn't I'm getting 8. I'm not sure what 8 means, but it seems to be consistent. Though HELP doesn't say anything about &RETCODE for CHECK FILE. My problem with using STATE was, our dev environment is Windows and our Prod environment is LINUX, so our FOCCACHE folder could be in different locations per environment. I didn't want to create a DB, just to store location of FOCCACHE and I can't do a STATE 'FOCCACHE/MYCAR.foc' as STATE thinks FOCCACHE is under the reporting server approot, which it isn't.

I'll play with &RETCODE for FILE CHECK a bit more to see if I see any flux.



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
September 21, 2015, 02:16 PM
Dan Satchell
&RETCODE=8 means "not in catalog".


WebFOCUS 7.7.05
September 21, 2015, 02:18 PM
GavinL
My IBI rep responded, that CHECK FILE isn't supposed to be used to validate file existence, it's only to validate the MASTER FILE, which I responded, if the validation fails, how does one know since HELP doesn't state it anywhere.

This seems to be working. Always 0 if the file exists and 8 if it doesn't exist. I think this might work.

-DEFAULT &RETCODE = _FOC_NULL;

SET ASNAMES = ON

TABLE FILE CAR
PRINT
     CAR.ORIGIN.COUNTRY AS 'COUNTRY'
     CAR.COMP.CAR AS 'CAR'
     CAR.CARREC.MODEL AS 'MODEL'
     CAR.BODY.SALES AS 'SALES'
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE HOLD AS FOCCACHE/MYCAR FORMAT XFOCUS
END
-RUN

CHECK FILE FOCCACHE/MYCAR
-RUN
-TYPE RETCODE = &RETCODE;
-IF &RETCODE NE 0 THEN GOTO MISSINGDATA;

TABLE FILE FOCCACHE/MYCAR
PRINT *
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE HOLD AS SEARCHMYTABLE1 FORMAT INTERNAL
END
-RUN
-TYPE RETCODE2 = &RETCODE;

CHECK FILE FOCCACHE/MYCAR
-RUN
-TYPE RETCODE3 = &RETCODE;

TABLE FILE FOCCACHE/MYCAR
PRINT *
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE HOLD AS SEARCHMYTABLE2 FORMAT INTERNAL
END
-TYPE RETCODE4 = &RETCODE;
-RUN

CHECK FILE FOCCACHE/MYTABLE2
-RUN
-TYPE RETCODE5 = &RETCODE;
-IF &RETCODE NE 0 THEN GOTO MISSINGDATA;

TABLE FILE FOCCACHE/MYTABLE2
PRINT *
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE HOLD AS SEARCHMYTABLE2 FORMAT INTERNAL
END
-RUN

-READFILE SEARCHMYTABLE1
-RUN

-READFILE SEARCHMYTABLE2
-RUN
-GOTO THEEND

-MISSINGDATA
-TYPE Missing Data here..

-THEEND
-TYPE Ended




- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
September 21, 2015, 02:20 PM
GavinL
quote:
&RETCODE=8 means "not in catalog".


Well that just makes too much sense. Smiler

Where did you find the list of text values?

Thanks..



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
September 21, 2015, 02:24 PM
GavinL
I found a PDF that wasn't on IBI's site:

https://www.marist.edu/it/admi...pdfs/ibioverview.pdf

&RETCODE Value Equivalent FOCUS Code/Message
0 (FOC488) Dataset is in catalog:
4 (FOC489) Dataset is in catalog, but not on volume
indicated:
8 (FOC490) Dataset is not in catalog



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
September 21, 2015, 02:43 PM
Francis Mariani
Gavin, this may not help you, but this is how I check for the existence of a file in FOCCACHE:

-* test if the previously created file is found in foccache
APP QUERY foccache HOLD
-RUN
-INCLUDE common/util_check_error.fex


TABLEF FILE FOCAPPQ
PRINT
FILENAME
WHERE FILENAME EQ 'hsearch_security_&P_RUN_ID...ftm'
ON TABLE SAVE
END
-RUN
-INCLUDE common/util_check_error.fex


-SET &P_FILE_EXIST = &LINES;

-* if the file is not found in foccache, create the file
-SET &P_FILE_STATUS = IF &P_FILE_EXIST GT 0 THEN 'file in foccache' ELSE '';

-IF &P_FILE_EXIST GT 0 GOTO CREATE_FILTERS;




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
September 21, 2015, 04:52 PM
susannah





In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
September 21, 2015, 04:59 PM
GavinL
Thanks Francis.. That will help also.



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
September 29, 2015, 02:34 PM
mpbMDE
quote:
-INCLUDE common/util_check_error.fex


Francis, what is in this fex?
can you supply the code?
Thanks!


WebFOCUS 8.1.05 Windows 7, all output