Avoid Hard Coding in AS/400 RPGLE

85 pts.
Tags:
AS400 RPGLE
Grouping
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

Thanks. We'll let you know when a new response is added.

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.

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • CharlieBrowne
    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
    39,815 pointsBadges:
    report
  • JoBi
    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 pointsBadges:
    report
  • TomLiotta
    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
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following