Hi, I have a program that will be used in different countries. Each country have different selection criteria. How do I design my program such that I do not hard code the selection criteria?
Note: Selection criteria could be more than 1 fields or from more than 1 file.
Software/Hardware used:
ASKED:
July 28, 2009 6:48 AM
UPDATED:
August 6, 2009 9:03 PM
Hi Wilson,
Thanks for your reply.
Can you give example on how to go about it. My biggest problem is how to proceed after I have defined from the DBF.
For exampe, I need to select all records with category A,B,C,D. But I don’t want to hardcode A,B,C,D from my program because other countries may use different category code.
Then how do I define the selection from DBF if for example I have more than 1 selection criteria?
Please help.
Thanks.
As Wilson suggests, it’s down to using files to store the information specific to the countries. So you would have a country file, and you would store the categories for each country in a country categories file, which would be keyed on country code – so your program load the category codes associated with the specific country, nad (as Phil suggests) you store those categories in an array and use it to look up the valid category code from the incoming data. If the incoming DB record has a country code that is not the one you are looking for, reject it anyway. If it has a category code that is not in the list you loaded, reject it.
This is all quite usual programming in most databases.
Sloopy
Hi Everyone,
Thanks for sharing your inputs.
The suggestions given are for example 1 field out of (let say) 10 fields from 1 file. What if I have more than 1 fields to be selected? Or other selections from other files? Do I need to define the fields and the file from the BDF as well?
For Example:
File ABCD
Field 1 = Age
Field 2 = Type
Field 3 = Salary Range
etc.
File EFGH
Filed 1.2. = Officer Code
Field 2 = Group
etc.
I’m reading file 1 and select age 15,16,17,18 and type 1,2,3,4. Read File 2 and select officer code xyz, abc, fgh.
How to define in DBF? And how to process?
Thansk.
I’m finding this a bit mysterious.
Why would you have a program that is selecting a set of records from one file, and a set of records from another file which has no connection at all?
As for the general case in which you have, for example, radically different processing requirements for data from different companies – usually this is done by checking the company first, and then calling programs specific to that country’s requirements. Otherwise you end up with a huge program that is almost impossible to maintain.
You see, once the requirements get beyond a certain level of complexity, it’s a losing battle to keep ONE program to do so may different things. And then someone adds a new country, and the whole thing is just spaghetti….
Sloopy
JoBi, you seriously need to get some training or mentoring or complete your degree at IIT.
Yes. I don’t know where these people have been. You are spot on, you need a control file to contain the rules.
The rule name becomes the first field of the key, country code the second, the value third . for some fields you might have a value2 so you can enter a range, then for some fields you will need a text description..in-fact all of these fields are character.
So the AgeControl file
Key Country Value Description
AGE USA 19
AGE USA 20
AGE USA 21
AGE CAN 4
AGE CAN 8
OUTQ USA PRT05
OUTQ CAN PRT06
In the processing programs you can load these into arrays and do a lookup or you can chain into the control file or you can get the values from the file to do a dynamic sql.