[SOLVED] How to check if a column exists in a file before COMPUTE?
I have the following code:
TABLE FILE ACR_DATA
SUM
PER1 AS ''
PER2 AS ''
COMPUTE DIFF1/P32BS = PER2 - PER1; AS ''
PER3 AS ''
PER4 AS ''
COMPUTE DIFF2/P32BS = PER4 - PER3; AS ''
PER5 AS ''
PER6 AS ''
COMPUTE DIFF3/P32BS = PER6 - PER5; AS ''
BY SRTING NOPRINT
BY ORGANIZATION_LEVEL_3 NOPRINT
BY DEPARTMENT_CODE NOPRINT
BY SUBJECT NOPRINT
ON SUBJECT SUBHEAD
That is throwing this error:
0 ERROR AT OR NEAR LINE 383 IN PROCEDURE rom_proj_inst_plan
(FOC003) THE FIELDNAME IS NOT RECOGNIZED: PER4
BYPASSING TO END OF COMMAND
(FOC009) INCOMPLETE REQUEST STATEMENT
because I'm finding that PER4 and PER6 columns may not be in the file: ACR_DATA
Anyone have any creative ways to work-around and perform the COMPUTE only if the column exists?This message has been edited. Last edited by: globalwm,
8.0.02M, Oracle 11.2 (AIX), Windows 2008R2, HTML, PDF, Excel
February 24, 2014, 04:31 PM
j.gross
CHECK FILE ACR_DATA HOLD AS ACRFIELDS
TABLE FILE ACRFIELDS
PRINT FIELDNAME
IF FIELDNAME EQ PER$$
ON TABLE SAVE
END
-RUN
-SET &PER_COUNT = 0 + &RECORDS;
will capture the count (assuming none of the non-varying fieldnames starts with PER); take it from there.
February 24, 2014, 04:42 PM
Waz
There is also the SYSCOLUM table that will have this info as well
Waz...
Prod:
WebFOCUS 7.6.10/8.1.04
Upgrade:
WebFOCUS 8.2.07
OS:
Linux
Outputs:
HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!
February 24, 2014, 05:12 PM
globalwm
quote:
Originally posted by j.gross:
CHECK FILE ACR_DATA HOLD AS ACRFIELDS
TABLE FILE ACRFIELDS
PRINT FIELDNAME
IF FIELDNAME EQ PER$$
ON TABLE SAVE
END
-RUN
-SET &PER_COUNT = 0 + &RECORDS;
will capture the count (assuming none of the non-varying fieldnames starts with PER); take it from there.
Interesting - I can see the good files have:
NUMBER OF FIELDS= 15
while the bad (missing columns) have:
NUMBER OF FIELDS= 13
February 24, 2014, 05:31 PM
globalwm
quote:
Originally posted by Waz: There is also the SYSCOLUM table that will have this info as well