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     [SOLVED] COBOL Paragraphs

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] COBOL Paragraphs
 Login/Join
 
Member
posted
Hello.

I have been a COBOL programmer for years; so I am relatively new to Focus/WebFOCUS. Also,this is my first time posting to this site. Please bear with me.

My office uses Focus to create an extract from an IMS database. Because we have had instances of bad data adversely affecting another system, my supervisor wants me to write program to validate the data. If I could write it in COBOL, it would be done in nothing flat; however, he wants me to use Focus.

After trial and error, I came up with a method of validating each field separately within a set of "DEFINE" and "TABLE" statements. This means that I have to read the extract multiple times. For example: If each record contains five fields, and there are ten records in the file, then the file would be read fifty times.

There must be a more efficient way of doing this, a way to process all of the fields in a single pass without creating a gigantic and wieldly DEFINE. I am hoping that someone on this forum can help me.

Thank you.

This message has been edited. Last edited by: <Kathryn Henning>,


8.8.09 - z/Linux (WF, Report Caster, Report Library).
Iway FFS on MVS (HFS)
 
Posts: 12 | Location: Oklahoma City | Registered: April 02, 2013Report This Post
Virtuoso
posted Hide Post
This sounds all wrong to me. It is quite difficult to read a single record at a time with Focus. Maybe read a single field at a time, but even that sounds bad.

Is it possible to give more details of your approach?


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Member
posted Hide Post
In the DEFINE, I place all of the validations I require for a given field, then set an error indicator if any of the validations fail.

I know that the file is actually being read in the TABLE. Here, I only write out name and value of the field if error flag is turned on. Using my earlier example, I would have a DEFINE for the first field in the record followed by a TABLE that reads the file. Only that first field would be validated because that is all that is in the DEFINE.

After the TABLE, I would have another DEFINE. The code in this DEFINE would validate the second field in the file. This DEFINE would be followed by the TABLE that would print only field2 values that failed validation.

I repeat this pattern until all of the fields have been validated.


8.8.09 - z/Linux (WF, Report Caster, Report Library).
Iway FFS on MVS (HFS)
 
Posts: 12 | Location: Oklahoma City | Registered: April 02, 2013Report This Post
Silver Member
posted Hide Post
M
Here is something you can do. this is utilizing the CAR file as an example:. Just create all of the fields you want to validate within a single pass of the data and utilize a complex where statement to identify if the file and fields are ok or not:
DEFINE FILE CAR
FIELD1_VAL/A10 = IF COUNTRY EQ 'ENGLAND' THEN 'ERROR' ELSE ' ' ;
FIELD2_VAL/A10 = IF FIELD1_VAL EQ ' ' AND SALES EQ 0 THEN 'ERROR' ELSE ' ' ;
END
TABLE FILE CAR
WHERE FIELD1_VAL EQ 'ERROR' OR FIELD2_VAL EQ 'ERROR' ;
PRINT COUNTRY SALES FIELD1_VAL FIELD2_VAL
END


7.7.04
Win2K3, Unix
Oracle 10G,SQL2K,XFOCUS,ESRI,BID,MRE,SELF-SERVICCE
 
Posts: 36 | Location: Melville,NY | Registered: August 09, 2004Report This Post
Member
posted Hide Post
I thought of that. However, I didn't go that route for two reasons.

1. The validations are for format as well as content. For example, a legacy date field must be all numeric and the date must be valid. No February 29ths unless it's a leap year. As a result, one field could have beaucoup lines of validation code. As it is, each file record contains twenty to thirty fields.

2. Each field must generate its own line in an error report. For example, if three out of the five fields in a single record are invalid, then all three of those fields must have a separate line in the error report; preferably one after the other.

Mainly for these reasons, I split the program the way I did. Isn't there any way to do these validations without having a DEFINE so large that you can get lost in it?

For those not familiar with COBOL, I would do the following: 1. Read a record. 2. Process a separate paragraph for each field or field type. At the end of each paragraph, a message line would be written if the given field failed the audit. 3. Loop until all records have been read.


8.8.09 - z/Linux (WF, Report Caster, Report Library).
Iway FFS on MVS (HFS)
 
Posts: 12 | Location: Oklahoma City | Registered: April 02, 2013Report This Post
Virtuoso
posted Hide Post
Some ideas.....

Best solution: Fix the data in the source system and add some validations to it to prevent bad data from being collected.

Second best solution: Use the most productive resource available to do the job - which under the circumstances is you and COBOL.

Third best solution: Use WebFOCUS and write a program to read each source record exactly ONCE. For example:

DEFINE FILE XXX
 FIELD01_VALIDATION/I1 = IF (validation 1 fails) THEN 1 ELSE
                         IF (validation 2 fails) THEN 2 ELSE
                         IF (validation 3 fails) THEN 3 ELSE 0 ;
 FIELD02_VALIDATION/I1 = IF (validation 1 fails) THEN 1 ELSE
                         IF (validation 2 fails) THEN 2 ELSE
                         IF (validation 3 fails) THEN 3 ELSE 0 ;
                         IF (validation 4 fails) THEN 4 ELSE 0 ;
 .
 .
 .
 FIELD29_VALIDATION/I1 = IF (validation 1 fails) THEN 1 ELSE
                         IF (validation 2 fails) THEN 2 ELSE
                         IF (validation 3 fails) THEN 3 ELSE 0 ;
 FIELD30_VALIDATION/I1 = IF (validation 1 fails) THEN 1 ELSE
                         IF (validation 2 fails) THEN 2 ELSE 0 ;
 TOTAL_VALIDATION/I3   = FIELD01_VALIDATION + FIELD02_VALIDATION + .... + FIELD29_VALIDATION + FIELD30_VALIDATION ;
END
-*
TABLE FILE XXX
 PRINT <necesssary source fields>
       <DEFINE fields>
 WHERE (TOTAL_VALIDATION NE 0);
 ON TABLE HOLD AS INVALIDS
END


As much as possible, you should use IF/THEN/ELSE statements for your validations with the most important validations first. This avoids checking a field multiple times when failure of the first or second validation would suffice. For example, if a date field is blank, all other validations for that field should be skipped. IF/THEN/ELSE should accomplish this. If some fields require validations that are not mutually exlusive, then create more than one DEFINE for those fields.

Using the HOLD file, generate your report. Since the HOLD file should be relatively small, you can read and write from it as many times as necessary to generate the desired output. Each DEFINE field will contain a number indicating which validation failed. You could use a DECODE to spell out the errors in understandable language.


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Virtuoso
posted Hide Post
Last year I was at a Ibi seminar about data quality .
There was some company who offered software based on webfocus applications who did exactly what you need.
In fact you create a quality check for each field and hold that against the real database

So....ask your local Ibi rep..




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Virtuoso
posted Hide Post
M (shades of James bond?),

Here is a suggestion.
It uses DEFINE:
1. to identify each field
2. to verify each field
It then writes out to a file the fields, their names and the validations.
The file gets an alternate MASTER, using EX -LINES, from which are extracted all the singular validations, one per line.
  
-* File mward01.fex
-* 
-SET &MAXVALID=3;
DEFINE FILE CAR
FIELD1/A12='COUNTRY';
VALID1/A40=IF COUNTRY OMITS 'E' THEN 'No E in Country' ELSE IF COUNTRY OMITS 'O' THEN 'No O in Country' ELSE ' ';
FIELD2/A12='SALES';
VALID2/A40=IF SALES EQ 0 THEN 'No Sales for this record' ELSE IF SALES GT 30000 THEN 'Suspicious Sales value' ELSE ' ';
FIELD3/A12='MODEL';
VALID3/A40=IF MODEL CONTAINS '2000' THEN '2000 Obsolete' ELSE IF MODEL CONTAINS '7' OR '5'  THEN 'Return this Model' ELSE ' ';
END
TABLE FILE CAR
PRINT SALES
-REPEAT #VALID FOR &I FROM 1 TO &MAXVALID;
FIELD&I VALID&I
-#VALID
BY COUNTRY BY MODEL
ON TABLE SAVE AS MWARD 
END
-RUN
EX -LINES 9 EDAPUT MASTER,MWARD,C,MEM
FILENAME=MWARD, SUFFIX=FIX
SEGNAME=MWARD, SEGTYPE=S0
FIELDNAME=COUNTRY, FORMAT=A10, ACTUAL=A10, $
FIELDNAME=MODEL, FORMAT=A24, ACTUAL=A24, $
FIELDNAME=SALES, FORMAT=I6, ACTUAL=A6, $
SEGNAME=VALID, PARENT=MWARD, OCCURS=VARIABLE
FIELDNAME=FIELDN, FORMAT=A12, ACTUAL=A12, $
FIELDNAME=VALID, FORMAT=A40, ACTUAL=A40, $
-RUN
TABLE FILE MWARD
PRINT COUNTRY MODEL SALES FIELDN VALID 
WHERE VALID NE ' ';
END


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

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Virtuoso
posted Hide Post
I should like to add:
  
The EDAPUT command syntax is:

EX -LINES {n} EDAPUT {File Type},{App/}{File Name},{Create Type},{Create Location}


n                       : Number of lines including EDAPUT Line
File Type               : Type of File (e.g. MASTER, FOCEXEC, ACCESS, etc )
App/                    : Optionally Specify the APP directory
File Name               : Name of the File without the extension
Create Type             : Type of Create (CV=Create Variable, C=Create Fixed, A=Append to file)
Create Location         : File Location (FILE=Write to Current Location, MEM=Write to Memory only)


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

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Platinum Member
posted Hide Post
You have sent me to the way back machine. Although I have to admit I find myself forced to teach how to debug COBOL.
Look manual or “Using Functions” This list numerous functions you can use, there is even one to confirm something is packed (CHKPCK). There also is a manual on dates 1001 Ways to work with date sin WebFocus. The section on conversions will give you some ideas on validating dates.
It is possible within FOCUS to process an input record several times see https://techsupport.informatio...es/macgyver/toc.html
One last thought. When I was the level three support for about five thousand FOCUS users, one call was “How does this FOCEXEC work?” The define was one call to a COBOL program, which received through linkage a concatenation of fields, and returned a comma separated string of values which was parsed using GETTOK function.


Jim Morrow
Web Focus 7.6.10 under Windows 2003
MVS 7.3.3



 
Posts: 129 | Registered: June 01, 2005Report This Post
Expert
posted Hide Post
quote:
the way back machine


That brings back memories......


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
Master
posted Hide Post
quote:
the way back machine

Mr. Peabody is my hero.
 
Posts: 822 | Registered: April 23, 2003Report This Post
Expert
posted Hide Post
Danny-SRL's suggestion (posted April 27, 2013 02:36 PM) is a good idea...
Another thought: You could ON TABLE HOLD AS DATAFILE FORMAT ALPHA and do -READs on that in DM and works within DM to do it. OR, IB Has a Data Cleaner (Product name = ? / slips my mind at the moment)...
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Member
posted Hide Post
Thank you all for your responses. I now have quite a bit to think about and try out.


8.8.09 - z/Linux (WF, Report Caster, Report Library).
Iway FFS on MVS (HFS)
 
Posts: 12 | Location: Oklahoma City | Registered: April 02, 2013Report 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     [SOLVED] COBOL Paragraphs

Copyright © 1996-2020 Information Builders