85 pts.
 Avoid Hard Coding in AS/400 RPGLE
Hi,

I have a task to design a grouping rule engine that must be robust and flexible for future needs.

 I have a customer file with relationship code and I need to group the customers according to group types.  Each group type have different criteria.

For example:

1)  Group Type ABC  -  extract based on (1)  relationship codes (from FILE2) A1, A2, A3, (A4 and FILE2/X1 field > 10%).   (2)  For individual (from FILE2)  excluding A2,  include members B1, B2, B3  (3)  Stop extracting members for B1, B2, B3  i.e. just extract members for A1, A2, A3, A4

2)  Group Type DEF,  extract based on (1)  relationship codes B1, B2, B3 (2)  based on members extracted in (1)  extract the rest of the members by D1, D2, D3, (D4 and X1 field > 50%  or X1 field >=20% and < 50)

Any idea how to parameterized the above so that I can build a grouping rule engine without any hardcoding in my programs?  ALso,  if in the future they want to include new file and fields in the extraction how to cater?

Thanks so much in advance for those who will reply to may question.

 

 

 



Software/Hardware used:
AS400 RPGLE
ASKED: February 11, 2011  7:51 AM
UPDATED: February 15, 2011  3:18 PM

Answer Wiki:
OK, THis is what is sounds like what you wnat to do. You do not want to hard code anything, and also want to produce and online message. First you create the tables to store the data you want (either the way already described or some other way). Next once the files are populated you need to run some test SQL commands to select the data you want. Now, you need to build a DSPF where someone can enter the values for the records they need to extract. In you driver program over the DSPF (CL or RPG), you need to build and execute the sql statement on the fly. You can either just display the results or put them in a data base so you can then to do something else with. Processing time will not be much unless you have a huge file and do not have the correct indexes built over it. If you have the correct indexes, it will run very quickly.
Last Wiki Answer Submitted:  February 15, 2011  3:18 pm  by  CharlieBrowne   32,835 pts.
All Answer Wiki Contributors:  CharlieBrowne   32,835 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

This should be doable. Can you be a little more specific?
Is this for a single program, or multiple?
Is it Batch or Interactive?
The reason I ask, is I generally setup tables to control something like this, and it usually is a header file table and a detail file that.
A single record in the header file might contain:
Group Code ABC
Description Level A Customers…
Start Date mm/dd/yyyy
End Date mm/dd/yyy

The Detail file would be a one to many relationsjip with the Header File
Group Code ABC
Relation Code A1
Inc/Omit I

Group Code ABC
Relation Code A2
Inc/Omit I

Group Code ABC
Relation Code B1
Inc/Omit O

 32,835 pts.

 

Hi,
This is going to be an online message i.e. interactive.

Based on your recommendation of creating a header and a detail file, what possible command I can use to do the extraction without hardcoding the filename and the fields?
I was thinking of using a dynamic SQL but the processing might take time considering that it is going to be an online message.

Also, by using these 2 files, how do I setup a table if I have further selection for each relationship codes?

Thanks so much in advance.

 85 pts.

 

This is going to be an online message i.e. interactive.

Exactly what will be “an online message”? I’m not quite seeing how that ties back to these phrases:

“…group the customers according to group types…” and “…extract based on…” and “Stop extracting members…”

Can you clarify any more?

Tom

 107,995 pts.