[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Tips to writing out extended subfile records conditionally

Posted on 2009-04-03
Medium Priority
Last Modified: 2013-11-25
I have written many subfile RPG programs.  I have a need for a program to one of the following:  (1) write out an extended sub file record (record 1,2,3 my be extended - taking up 2 lines each, record 4,5,6 may not be extended - taking up 1 line each.
(2) write out the sub file, then be able to overlay one of the subfile records with a different layout.  (While writing out the subfile, I will know that I need an extra line, so I will write a blank subfile record, then do I will go back and overwrite the subfile record.
(3) be able to write different record formats in the same subfile:

The subfile would look like the following:

Customer    Item          Date
ABC Cust   Wedge1   5/15/09
    Forcast of 30
CDE Cust   Wedge2    5/30/09
    Forecast of 50
FGH Cust   Wedge3   5/30/09
    Forecast of 25
AAA Cust  Wedge4   5/30/09
BVB Cust   Wedge5  5/30/09

Question by:ChuckMason
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 14

Expert Comment

ID: 24074908
there is no way to write different records in a subfile, If you are simply using the subfile for output this is what I have done in the past:
1. Create one field on the Subfile, character(79)
2. Using the RPGLE BIF's ie EDTCDE, build up the string as you wish to see it
3 Output the string along with a hidden record ID.

you can use diffeent data structures to hold the subfile formats.

Quick and easy to maintain.


Author Comment

ID: 24076796
Thanks for your input.  However the above will not work for me as each column has a different color and I need the individual fields to display the correct color.  The DDS manual references an "OVERLAY" option.  For the description, I gather that I can write a normal subfile out (While writing out I know that record 3 will have an subfile line, so I write an extra subfile line after record 3.  At the end, I write a record that "Overlays"  the subfile for this record.  Footers appear to be treated this way, but I cannot seem to get it to work.  Any examples would greatly be appriciated!!
LVL 14

Expert Comment

ID: 24076882
Hi the colours are quite easy to do, they are simply hex codes are teh start of a field
20 Normal Green
21 Reverse image Green, reverse image
22 High intensity White
23 High intensity, reverse image White, reverse image
24 Underscore Green, underscore
25 Underscore, reverse image Green, underscore, reverse image
26 Underscore, high intensity White, underscore
27 Nondisplay Nondisplay
28 Blink Red
29 Blink, reverse image Red, reverse image
2A Blink, high intensity Red, high intensity
2B Blink, high intensity, reverse image Red, high intensity, reverse image
2C Blink, underscore Red, underscore
2D Blink, underscore, reverse image Red, underscore, reverse image
2E Blink, underscore, high intensity Red, underscore, blink
2F Nondisplay Nondisplay
30 Column separator Turquoise, column separator
31 Reverse image, column separator Turquoise, column separator, reverse image
32 High intensity, column separator Yellow, column separator
33 High intensity, reverse image, column separator White, reverse image, column separator
34 Underscore, column separator Turquoise, underscore, column separator
35 Underscore, reverse image, column separator Turquoise, underscore, reverse image, column parator
36 Underscore, high intensity, column separator Yellow, underscore, column separator
37 Nondisplay Nondisplay
38 Blink, column separator
39 Blink, reverse image, column separator Pink, reverse image
3ABlink, high intensity, column separator Blue
3B Blink, high intensity, reverse image, column separator Blue, reverse image
3C Blink, underscore, column separator Pink, underscore
3D Blink, underscore, reverse image, column separator
Pink, underscore, reverse image
3E Blink, underscore, high intensity, column separator Blue, underscore
3F Nondisplay Nondisplay
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.


Author Comment

ID: 24077033
Wow!  I was not aware that this could be done.
The next problem is that some of the fields are input capable (Use can modify the data)
I have attached an example of the current screens/programs along with the "Future" screen.
The current screen does reuse some of the fields already.  I was hoping the "OVERLAY" option would work.  
I have tried the FOLD/UNFOLD which works ok, just the owner wants to see more data lines on the page.
If I cannot use the overlay option, I will modify the screen similar to what was done in the past (reuse predefined fields).
LVL 14

Expert Comment

ID: 24077348
It looks like the input fields occupy their own space on the sreen - if that is the case you can use indicators to:
a. Display the colour
b. Protect the field, if you use the ChgInpDft commnad to can remove the input underline so the screen looks like a continues output field.


Author Comment

ID: 24078223
This is what I have done in the past.  Just protected the input fields, changed the color on the display fields and put the data for the extra lines into existing datafields.
I may go back to the above approach.

Thanks again!
LVL 14

Expert Comment

ID: 24078517
I was thinking about other options; this is a bit more long winded bit gives you a massive amount of control.

Read the records into a multi occurance data structure, this would be the same process as populating your subfile.
Create x (x being the number of lines in the SFL F0401, f0402 etc..)  number of identical formats with the same field names, you need to code the RTNDTA keyword. and a different start line
Write  each of the formats dependtant on the ccurance of the MODS and what the record is.
The rtndta then allows you to read each of the formats as with the press of a single enter key


   Write Header
   Write F0401 ;
   Write F0402 ;
   Write F0403 ;
   Write F0404 ;
   Exfmt  F0413 ;

   Read F0401 ;
   Exsr Validation ;

   Read F0402 ;
   Exsr Validation ;


LVL 16

Expert Comment

by:theo kouwenhoven
ID: 24092311
Hi ChuckMason,

is it an option to make the screens extended with fold, so that initialy only 1 line is visible untill a Fkey is pressed?
or.... what about forgetting the subfile and makke 2 diferent 1 and 2 line screens with a variable startline?


Author Comment

ID: 24092417
Thanks.  I have a version of the program running with the fold/drop function key.  The problem is that the customer does not want 2 lines to show for every record.  He only wants 2 lines to show when there is data to be displayed on the second line.  Typically there are 20 records to be displayed on the screen.  2 of these records would have extra information to be displayed.
I have taken Dave's approach above and defined several of my output only fields as one field.  Then conditionally output a extra subfile record in the same format. (Using an indicator to turn off the unneeded fields on the second subfile record.

According to the DDS manual, what I want to do is possible (using OVERLAY and PUTOVR in the DDS), I just can't get it to work :(
Thanks again!
LVL 35

Accepted Solution

Gary Patterson earned 2000 total points
ID: 24094633
I think what you want to do is a variable-length subfile record.  With a variable-length subfile record, you can have one record take up one line, another take up two, and another take up three.  There are a couple of "gotchas":  

1) You must code a subfile-page-equals-subfile-size (Page-At-A-time) subfile to do this.  See page 4-19 of the Application Display Programming manual:  
2) You have to keep track of how many screen lines you are using.


I've never tried to do it in two passes before, though, that I can recall.  You may need to restructure your program to gather all the data and then build the subfile once you have all the data you need.  You can change the contents of a subfile record using relative access:  CHAIN by record number, alter the contents, and UPDATE.

I don't think OVERLAY and PUTOVR work quite the way you think the do:

OVERLAY just allows you to put a record format on screen without erasing the entire display first.  You see OVERLAY used on the second and subsequent record formats that you write to a screen, generally:

WRITE ERRCTL (no overlay - we want to erase the screen first, then display the error subfile)
WRITE FKEYS (overlay - we don't want to erase the error subfile)
EXFMT SFLCTLR (overlay - we don't want to erase the error subfile or function key record format)
OVERLAY doesn't have anything to do with overlaying individual records inside a subfile.

PUTOVR (plus OVRATR and OVRDTA) allows you to alter the attributes or contents of fields already on the display in order to reduce the amount of data that is sent when a screen doesn't need to be changed much.  It is there to allow you to save communications bandwidth.  It doesn't allow you to do anything that you can't do by sending the whole screen (or a whole record format).  For example, if you already have an entire screen displayed,and you just need to change the contents of one field, or change the attribute of one field, then you use PUTOVR at the record format level to tell the system that it does not need to send the entire record format every time, and you specify and condition OVRDTA or OVRATR at the field level to indicate that you are just going to update that particular field or attribute.

See page 3-18 of the Application Display Programming manual for details and examples.

- Gary Patterson


Author Closing Comment

ID: 31566426

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Geo-targeting is the practice of distributing content based on a person’s location, as best as you can determine it. Let’s look at some ways you could successfully use this tactic. The following tips and case studies could lead to meaningful results.
Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question