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
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


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 17

Expert Comment

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 36

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

AngularJS web development a very simple procedure. So, to put it, in short, AngularJS’ stand out features are – Two-way data binding, MVC structure, directives, templates, dependency injections and testing.
Though there are a few manual ways to import PST files to Office 365 , third-party PST to Office 365 import tools are preferred over them due to various reasons.  Consequently, many tools or services are available for the same. Here, we pick the to…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
Watch the video to know the simple way to remove or recover or reset lost or forgotten passwords of Outlook PST file. With Kernel Outlook Password Recovery tool such operation is very easy to perform. It is a freeware with limitation to use with 500…

624 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