× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: Simple Subfile question
  • From: "Rick Childers" <rcvernors@xxxxxxxxxxx>
  • Date: Wed, 04 Apr 2001 15:10:40 -0400




>From: Jim Langston <jimlangston@conexfreight.com>
>Reply-To: RPG400-L@midrange.com
>To: "RPG400-L@midrange.com" <RPG400-L@midrange.com>
>Subject: Simple Subfile question
>Date: Wed, 04 Apr 2001 10:33:32 -0700
>
>I don't work on subfiles too often, so this is really a simple question
>but...
>
>I am writing a new program and display file with a subfile.  I loaded the
>subfile with dummy records and all is well.  Now I am ready to read my
>real file, etc.. and I am displaying my screen for user input.  Now I'm
>getting a session or device error, and I'm sure it's being caused by the
>subfile being empty.
>
>How do I display my subfile with empty records?  Or do I have to check
>my SF_RecNum and only display it if it's not zero?
>
>   *** Clear Subfile ***
>  C                   Eval      *IN55 = *On
>  C                   Write     SubCtl
>  C                   Eval      *IN55 = *Off
>  C                   Eval      SF_RecNum = *Zero
>
>  C                   DoW       NOT (*IN03 OR *IN12)
>
>   *** Display Subfile and get input ***
>  C                   Write     Footer
>  C                   Write     Header
>  C                   Exfmt     SubCtl
>
>  C                   EndDo
>
>bombs out on the Exfmt SubCtl with
>Session or device error occurred in file MNTSTGDFM (C G D F).
>
>However:
>
>   *** Clear Subfile ***
>  C                   Eval      *IN55 = *On
>  C                   Write     SubCtl
>  C                   Eval      *IN55 = *Off
>  C                   Eval      SF_RecNum = *Zero
>
>   *** Load some dummy records ***
>  C                   Eval      DFType = '* Test1 *'
>  C                   Eval      DFUnit = 100
>  C                   Eval      DFSplt = 10
>  C                   Eval      DFCuFt = 100.101
>  C                   Eval      DFAmnt = 1000.01
>
>  C                   Eval      SF_RecNum = SF_RecNum + 1
>  C                   Write     SubFile
>
>  C                   DoW       NOT (*IN03 OR *IN12)
>
>   *** Display Subfile and get input ***
>  C                   Write     Footer
>  C                   Write     Header
>  C                   Exfmt     SubCtl
>
>  C                   EndDo
>
>works, but is obviously not what I want.
>
>Regards,
>
>Jim Langston

Jim,
You don't need to write blank subfile records to keep it from blowing up.

Try this....

* Load records to subfile
c                   do        6
c     pmacct        reade     chlcdlt1                               91
c                   if        *in91
* If no more records found, leave this do loop.
c                   leave
c                   else
* Else rec found, load it into the subfile.
c               load your data to your subfile fields here
C                   add       1             sflrrn
C                   write  subfile
C                   endif                                end-if in91
C                   enddo                                end-dou 91
    IF YOU "NEED" BLANK RECS IN YOUR SUBFILE (ONLY IF YOUR USERS NEED TO 
ENTER NEW RECORDS DIRECTLY INTO THE SUBFILE DISPLAY) YOU CAN ADD THEM HERE. 
(I know, I know. There are keywords to handle blank subfile records, but 
this is easier.)
C                   DO            2
c               initialize your subfile fields to blanks here
c                   add      1       sflrrn
c                   write   subfile
c                   ENDDO

* Check the results of the subfile load.
*  If no records were added to subfile, set SFLDSP indicator to off.
C                   if        sflrrn = *zeros
C                   eval      *in90 = *off
  *  Else, set SFLDSP indicator on, and set subfile RRN.
C                   else
C                   eval      *in90 = *on
c                   eval      sflpos = sflrrn
C                   endif
C                   endsr
The DDS looks like this.......
A          R CONTROL                   SFLCTL(SUBFILE)
A                                      SFLSIZ(0007)
A                                      SFLPAG(0006)
A                                      CA03(03 'End Program')
A N91                                  PAGEDOWN(96 'PAGEDOWN')
A                                      BLINK
A                                      OVERLAY
A  90                                  SFLDSP
A N93                                  SFLDSPCTL
A  93                                  SFLCLR
A  91                                  SFLEND(*MORE)
A            SFLPOS         4S 0H      SFLRCDNBR
You can also code error message text in the Control record so that when no 
sfl recs were loaded, a message line will appear like..
  A N90                        6  1  'No records to display.'
  A                                    DSPATR(RI)
  A                                    COLOR(RED)

The end result is.. When there are no recs to display, you tell the user 
instead of blowing up the program.
.......................................................
.   4/04/01           Header 1                        .
.  14:58:44    Display Phone Number Changes           .
.                                                     .
.  Acct#: 12121111                                    .
.                                                     .
. NO RECORDS TO DISPLAY                               .
. -Old Phone#-  -New Phone#-  -Date Changed-          .
.                                                     .
.                                                     .
.                                                     .
.                                                     .
.......................................................






>+---
>| This is the RPG/400 Mailing List!
>| To submit a new message, send your mail to RPG400-L@midrange.com.
>| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
>| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
>| Questions should be directed to the list owner/operator: 
>david@midrange.com
>+---

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.