RPG – Roll your own level breaks

1380 pts.
Tags:
AS/400
RPG
SQLRPGLE
Has anyone every heard of 'Roll your own Level Breaks' in RPG? Can you enlighten me on how it works? I have to mimic a program that does this already with a different set of data. Here is a basic overview of the application. A selection screen allows you to select a date range, region, territory, salesman, customer, product class, product, PDF or Excel output, print or email. Each 'flag' selected on the first screen takes you to another, i.e. Regional selections, Territory selections and so forth. As these selections are taking place, the results are being recorded in files. Then a job will submit to batch and build a master work file using the selections and pulling data from all over the place to en dup with a detail level file of all of the selections. Next, the reporting process reads through the file, bounces(chains) for the selections, sorting, and setting internal fields to mimic level breaks, totals. This thing is using arrays, SQL to select the records from the detail file, a ton of fields(looks like output fields for each level. I have never seen a program like this and its logic just hasn't clicked with me yet. Any thing you can tell me would be helpful. Thanks.

Software/Hardware used:
AS400, rpg, sqlrpgle

Answer Wiki

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

Discuss This Question: 8  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
  • philpl1jb
    stevensinstructionzone.com/BINF1310/07Chapter.ppt  This is a good review of control break processing it is not RPG specific but then the code you will be writing would be significantly the same in any language.    "Roll-your-own" is suppose is writing all the details like this powerpoint provides rather than using the old RPG II/III level controls. Phil
    49,930 pointsBadges:
    report
  • TomLiotta
    The 'roll your own' level-break idea is essentially the way RPG has been coded since 1978 with RPG III. The older way of using 'The Cycle' should be very uncommon in any new program now. It might be used in new programming for simpler requests, but should generally be discouraged.   The biggest reason to learn 'cycle' programming is that there are many old programs that you might need to understand and modify. If old RPG II programming is involved, the 'cycle' level-break function is the primary method of handling breaks between groups of records.   A second reason to learn it is that the 'cycle' is built into every RPG program even if you don't use it. It can affect the behavior of a program when the coding is slightly incorrect. (The 'cycle' code can be left out of ILE RPG modules if *NOMAIN is coded as a H-spec option.)   Otherwise, you shouldn't see any new programs that use anything other than 'roll your own' level breaks. It is nothing more than comparing sort fields from the current record against the sort fields that you saved from the previous record and calling your sub-total routine when the values change. (A "sub-total" routine is just the logic you write for handling when there is any break in the grouping values. It doesn't always have to generate 'sub-total' values.)   Tom
    125,585 pointsBadges:
    report
  • NickHutcheson1
    Thanks guys.  I have used primary read level break processing 25 + years ago.  This program is controlling the reads and breaks, as Tom said, by checking fields.  I am getting into it, changing for my files/fields/breaks.  Not liking it though.  I just hate programs bigger than my desk.
    1,380 pointsBadges:
    report
  • TomLiotta
    Not liking it though.  I just hate programs bigger than my desk.   A program written for full-procedural files should not be significantly large than one with primary and secondary files. It should also be clearer to general programmers, as well as to younger programmers who have less experience with 'Cycle' programming.   However...   There is no doubt that cramming all of that into a single module would be a mess, as it would if it was 'cycle' code. Unfortunately, it's not clear if we can do much other than sympathize.   In that light, yes, I've seen similar programs. I've never found a better solution than painful cleanup and restructuring. I usually start by moving code sections that seem tightly related into a series of subroutines. I can usually impose a kind of order that makes some visual sense that way.   That usually includes moving D-specs, too. If enough can be grouped so that any isolation is visible that matches subroutines, then breaking pieces off into separate procedures can really start to break the whole into more manageable smaller parts.   But I'm not sure I see a good way to give real help, unless moral support works. It takes ugly, detailed work.   Tom
    125,585 pointsBadges:
    report
  • Yorkshireman
    When you say 'mimic' an exisiting pgm - can this extend into 'design a new program? For instance - you could split the functions of data collection into a separate program - prompt for the selections and record everything into files for validating, re-use of last selection by userid and so on. Once you have a sane input file, it may be easier to construct some SQL / RPG that extracts data and compares to the requirement.  Build in some debugging diagnostics by emitting joblog messages under control of, say a 'testing' parameter or dataarea existence.  try and structure the code into discrete areas as Tom suggests so that each section can be independantly verified by reaching a sort of 'commit/completed' point. Sell the extra time needed on the basis if its being cheaper to enhance and maintain in the future.     
    5,580 pointsBadges:
    report
  • TomLiotta
    Sell the extra time needed on the basis if its being cheaper to enhance and maintain in the future.   That suggests a thread by itself: "Can anyone describe a successful attempt to sell extra time investment on the basis of future time savings?"   I'm sure (almost) that someone's done it.   Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    It takes less time to do it right the first time.
    49,930 pointsBadges:
    report
  • philpl1jb
    "All right everyone, line up alphabetically according to your height."  Casey Stengel
    49,930 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