Criteria Evaluation Routine Specifications



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Criteria Evaluation Routine Specifications

Postby shanshar » Tue Nov 15, 2011 6:04 pm

Criteria Evaluation Routine Specifications

A data extraction tool is being designed for a loan processing system. One of the key functionalities of the tool allows a user to define an extraction criteria based on any combination of fields, selected from a predefined list of fields. You need to write code that will evaluate the extraction criteria and determine if an account satisfies the criteria or not.



INPUTS and OUTPUTS

Input criteria file

Each row of the file will contain a unique criterion. The file will be 500 bytes long. The program will have to read each row of the file and evaluate the row in the data file and write the output (a true or a false) to the output file.

Data file

The file will contain a row for each field. The file is a 133 bytes FB file. The format of a row will be as follows:

<field name><space><value>

All the fields are numeric and have the following PIC clause PIC 9(04). The field names can vary in length.

Output file

The output file will contain a “TRUE” or a “FALSE” for each row of the input criteria file.



PROCESS

The tool will evaluate a data present in the data file against one or many criteria present in the criteria file. If the data present in the data file satisfies a criterion, then a row corresponding to the criterion is entered in the output file with a “TRUE”. If the data present in the file does not satisfies a criterion, then a row corresponding to the criterion is entered in the output file with a “FALSE”.




CRITERIA

Format

The following is the format of the criteria in the criteria file:

<field name><space><comparative operator><space><data value><space><Logical operator><space>

The data value will not have preceding zeroes. This structure repeats as much time as the 500 bytes of the criteria file would permit.



Comparative Operators

The following are the operators to compare a field to a given value:

· EQ - Equal

· NE - Not Equal

· GE - Greater than equal

· GT - Greater than

· LT - Less than

· GE - Greater than equal

· LE - Less than equal

This operator is 2 bytes long.

Logical Operators

The following are the operators that connect multiple comparisons and they appear in the order of precedence

· OR+ - An OR which has high precedence than an AND.

· AND - Typical AND

· OR - Typical OR

This operator is 3 bytes long.

An example

Consider the following data file content

ABC 0002

TYY 0003

OPP 0000



The following equation evaluates to a False.

ABC EQ 1 AND TYY LT 5 OR+ OPP LT 1



And the following equation evaluates to a True

ABC EQ 1 AND TYY LT 5 OR OPP LT 1




Please let me know about the logic of coding part...
shanshar
 
Posts: 4
Joined: Tue Nov 15, 2011 5:57 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Criteria Evaluation Routine Specifications

 

Re: Criteria Evaluation Routine Specifications

Postby BillyBoyo » Tue Nov 15, 2011 6:11 pm

The logic of the coding part is the stuff that you have to write to make your program behave like the specification.

No-one is going to provide the logic for you. If you sit down and have a think about it, mess around with a bit of pseudo-code, you might start to get somewhere. If you have questions about something you then don't understand, feel free to continue the thread.

I'd suggest you consider each logical part of the speicification seperately and deal with things one-at-a-time.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Criteria Evaluation Routine Specifications

Postby enrico-sorichetti » Tue Nov 15, 2011 6:18 pm

You need to write code that will evaluate the extraction criteria and determine if an account satisfies the criteria or not.

the application for which is written is completely irrelevant for the logic involved

You need to do it... not us.

and.... honestly don' t You feel that You are expecting too much for the people willing to answer with good advice
what You ask for is not something to which we can reply quickly , but it something that will take quite a bit of time and lots of experience
to understand the requirement and analyze to provide a good advice

anyway the best approach is to write a parser and a scanner for the evaluation of a logical expression
even the format of the criteria is quite primitive ...
the OR+ is just a sheer stupidity, much smarter to provide for Parenthesized parser to take care of the proper operator priorities
it can be easily written in c with the aid of yacc/bison for the parsing
in pl/I rexx with hand written parsers, not too difficult, if You know how to do it
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2644
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Criteria Evaluation Routine Specifications

Postby BillyBoyo » Tue Nov 15, 2011 6:29 pm

Yes, I can't remember ever seeing anything like OR+. Everyone knows of parentheses/brackets. The OR+ gives no hint of what it is even about.

Yes, it could be done in Cobol. It could be an "interesting" exercise for the end of a course, cetainly testing for someone who doesn't know where to start.

Presumably it is a Cobol course? To get some code going, do all the file handling, get that out of the way and seperate from the rest. Then think about how to store the criteria. Then how to match the criteria to the input records.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Criteria Evaluation Routine Specifications

Postby NicC » Tue Nov 15, 2011 7:00 pm

2 things:-
1 - if it is a course question then should it not be in the homework section?
2 - files (datasets) have records - not rows. Rows are found in DB2 tables.

Actually - just 1 thing as this board does not have a homework section but if ever a board should have one it is this one for beginners and students.
Last edited by NicC on Tue Nov 15, 2011 7:02 pm, edited 1 time in total.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: Criteria Evaluation Routine Specifications

Postby enrico-sorichetti » Tue Nov 15, 2011 7:01 pm

ABC 0002
TYY 0003
OPP 0000

...

And the following equation evaluates to a True
ABC EQ 1 AND TYY LT 5 OR OPP LT 1


even the terminology is wrong ... those are not equations those are expressions...

and what You are trying to build is a simple programming language ...

abc = 2
tyy = 3
opp = 0
<if>  ( abc eq 1 and tyy lt 5 or opp lt 1 )  <then>
    <display> "TRUE"
<else>
    <display> "FALSE"

You are starting on a long and windy road
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2644
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Criteria Evaluation Routine Specifications

Postby BillyBoyo » Tue Nov 15, 2011 9:20 pm

It's one of those "if we allow the users to do all the coding themselves, we can save on tiresome maintenance costs" examples.

Fortunately it is only a learning thing. If someone wants this for real, be very wary.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Criteria Evaluation Routine Specifications

Postby shanshar » Tue Nov 15, 2011 9:34 pm

Hi All,

Thanks for ur quick response..

I am using unstring here for each criteria in the input file and storing in WS variables.

If its comparative operator than in ws1, logical operato rthan in ws2 and if its else than in ws-data value. For each data-value it will search in table for its proper value and than will calculate the result accordingly for input criteria nad than write in output file. Am planning the perform the same step for 500 times.


But the problem is how to code the calculation part here....also let me know if you have any other way..

My intention is not to ask the full code but the logic to implement this....

Please help me in this..
shanshar
 
Posts: 4
Joined: Tue Nov 15, 2011 5:57 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Criteria Evaluation Routine Specifications

Postby enrico-sorichetti » Tue Nov 15, 2011 9:47 pm

But the problem is how to code the calculation part here....


did You read my previous reply .... I already explained a few things...
You will never be able to do in a simple way because the <names> of the variables are not fixed
it would be wiser to review the whole requirement

also let me know if you have any other way..


expecting people to spend time on such a requirement is expecting too much..
I answered because I have a bit of experience in parsing and and compiler construction techniques and use these techniques is the only way out
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2644
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Criteria Evaluation Routine Specifications

Postby dick scherrer » Tue Nov 15, 2011 11:44 pm

Hello,

But the problem is how to code the calculation part here....
Which calculation(s)? Showing a few examples may help clarify.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post