Easy fix though. Very nice style. This is a very good example. If you have this program with add and update? Thanks, Mic. Pages Home About. How to create a single page Subfile just using embedded SQL. Every RPGer knows about subfiles. I have done it easily using a scrollable cursor. Following are the codes.
Even you can download them from here. Display File. A HELP. A CA A 1 2USER. A 1 72DATE. A 2 72TIME. A 6 8'Customer'. A 7 12'Code'. A 6 18'Customer'. A 7 18'Name'. A 6 52'Customer'. A 7 52'Birthday'. I only have to use two indicators to condition them. Indicator 31 is used just to control the display of the subfile, if there are no records in the subfile I do not want to display it. Indicator 30 is used for all the display of the subfile control, and I want "More Amendment: Brian Rusch made suggestion in a comment below that makes good sense.
Lines 27 — I also display the "screen id", which is the program name with "-1" on the end. If the user has a problem with the program I tell them to give me the name of the screen and I know what program to work with. I never hard code this field. It is taken from the RPG program's data structure. This way if I copy or rename the program it will always show the current program's name. Lines 32 — I am providing a "Position to" field so that the user can position the start of the subfile to a record in the file, and then the program loads the subfile from that point.
And onto the RPG. For those of you using a release of IBM i that does not allow for free format definitions I have the fixed format equivalents at the bottom of this post here. I use what I call "open" subprocedures in place of subroutines. Lines 3 — 5: This is my program status data structure. I use this to get the program's name which I use for the screen name on the subfile control record format. Line 6: This is the definition for the display file that contains the subfile. The SFILE keyword is needed for each subfile, I need to give the name of the subfile record format and the name of the field that is used as a "numeric key" for the subfile.
Line 8 — This is the Indicator Communication Area data structure. What I like about these data structures is I can map an indicator from the display file to a meaningful name.
For example: indicator 3 from the display file will be known as Dsp. In other programs I have coded this as a hidden field in the subfile control, but I am keeping this example simple. Line This is not a definition line. It is where I create the screen name by appending "-1" onto the end of the program's name. This next section is the code I need to handle the subfile.
As I am using a "Load all" I do not have to code of the user pressing the Page Up or Down key the subfile does all that for me behind the scenes. Line Record format REC01 displays the function keys at the bottom of the screen. I WRITE it here so it overlays the previous screen displayed, this is especially useful if there are no records to display in the current subfile.
Line The EXFMT of the subfile control record means that the processing of the program remains "within" the subfile until Enter or one of the valid Function keys are pressed. No code necessary for Page Up or Down as the subfile handles that itself. Lines 22 — As Dsp. Exit is the equivalent of indicator 3 this code is only executed if F3 has been pressed.
Lines 24 — This is the code for when the F5 key has been pressed. All this code does is to reload the subfile from the start of the file. Active 7 years, 9 months ago. Viewed 1k times. Improve this question. Can you provide some more detail? Add a comment. Active Oldest Votes. The required logic is: Check the indicator of the rolldown key If that indicator is true, then clear your subfile Your file pointer must go 13 of whatever rows back.
Improve this answer. Sign up or log in Sign up using Google. Dcl-S wNoOptions Packed 4 : 0 ;. ExSr SrInitializeSubfile ;. ExSr SrLoadSubfile ;. ExSr SrDisplaySubfile ;. ExSr SrFinalRoutine ;. BegSr SrInitializeSubfile ;. BegSr SrLoadSubfile ;. EndIf ;. BegSr SrDisplaySubfile ;. Select ;. Leave ;. Other ;. ExSr SrValidateOptions ;.
0コメント