Logo2
Two Subfiles
[Home] [Subfiles] [Two Subfiles]
SFLTWO0103
SFLTWO0202
SFLTWO0302

The DDS for the two-subfile program.
      ****************************************************************
      *   ___             _    _     __ __             _    _        *
      *  | . > ___  ___ _| |_ | |_  |  \  \ ___  _ _ _| |_ <_>._ _   *
      *  | . \/ . \/ . \ | |  | . | |     |<_> || '_> | |  | || ' |  *
      *  |___/\___/\___/ |_|  |_|_| |_|_|_|<___||_|   |_|  |_||_|_|  *
      *                                                              *
      *  A program to demo a two-subfile program.                    *
      *    Feature: radio buttons and checkboxes in the subfiles     *
      *   Name: SFLTWOD                                              *
      *                                                              *
      *   10/2012                                booth@martinvt.com  *
      ****************************************************************
                                            DSPSIZ(24 80 *DS3)
                                            CHGINPDFT(HI UL)
                                            ERRSFL
                                            CA03(03 'Exit')
                                            CA05(05 'Refresh')
                                            CA08(08 'Continue')
                                            MOUBTN(*ULD ENTER)
                R HEADER
                                        1 69DATE
                                            EDTCDE(Y)
                                        2 69TIME
      *                                 3 69SYSNAME
                                        3 69'SYSTEM X'
                                        4 69USER
                                        2  5'   __                            _-
                                            _    ___ _  __          '
                                        3  5'  / /_ _    __ ___    ___ __ __ / -
                                            /   / _/(_)/ /___  ___  '
                                        4  5' / __/| |/|/ // _ \  (_- / // // _-
                                             \ / _// // // -_)(_-   '
                                        5  5' \__/ |__,__/ \___/ /___/\_,_//_._-
                                            _//_/ /_//_/ \__//___/  '
                                        6  5'                                  -
                                                                    '
                R SFLA                      SFL
                  CTLFLD         1Y 0H      SFLCHCCTL
                  STATES        10A  O  2  1

                R FMT01                     SFLCTL(SFLA)
                                            TEXT('States subfile')
                                            OVERLAY
                                            WINDOW(9 5 8 27 *NOMSGLIN)
                                            WDWTITLE((*TEXT ' States '))
                                            SFLSNGCHC(*SLTIND)
                                            SFLPAG(0006)
                                            SFLSIZ(&NBRRECA)
                                            RTNCSRLOC(&REC &FLD)
        90                                  SFLDSP SFLDSPCTL
       N90                                  SFLCLR
        91                                  SFLEND(*SCRBAR *MORE)
                                            USRRSTDSP
                  TOPREC         4S 0H      SFLRCDNBR(*TOP)
                  TOPRECIN       5S 0H      SFLSCROLL
                  NBRRECA        5S 0P
                  REC           10A  H
                  FLD           10A  H

                R SFLB                      SFL
                  CTLFLD         1Y 0H      SFLCHCCTL
                  CITIES        20A  O  2  2

                R FMT02                     SFLCTL(SFLB)
                                            TEXT('Cities subfile')
                                            RTNCSRLOC(&REC &FLD)
                                            OVERLAY
        80                                  SFLDSP SFLDSPCTL
       N80                                  SFLCLR
        81                                  SFLEND(*SCRBAR *MORE)
                                            SFLSIZ(&NBRRECB)
                                            SFLPAG(0006)
                                            WINDOW(9 45 8 26 *NOMSGLIN)
                                            WDWTITLE((*TEXT &TITLE))
        33                                  WDWTITLE((*TEXT ' F8=Continue ') +
                                            *LEFT *BOTTOM)
                                            SFLMLTCHC(*SLTIND)
                                            USRRSTDSP
                  NBRRECB        5S 0P
                  REC           10A  H
                  FLD           10A  H
                  TITLE         12A  P

                R FMT03
                                            WINDOW(8 40 5 28 *NOMSGLIN)
                                            TEXT('Process SFL2 ')
                                            OVERLAY
                                            WDWBORDER((*COLOR RED))
                                        2  3'Processed Cities list.'
                                        4  3'Enter = continue.'
                R FOOTER
                                            OVERLAY
                                       23  3'F3=Exit   F5=Refresh'
                                            COLOR(TRQ)
                                       20 46'Select as many cities as you like.'
                                            COLOR(BLU)
                                       21 46'Use the space bar or mouse click'
                                            COLOR(BLU)
                                       22 46'to make your selections.'
                                            COLOR(BLU)                                  





This is the RPGIV for the two subfile program

      //***************************************************************
      //   ___             _    _     __ __             _    _        *
      //  | . > ___  ___ _| |_ | |_  |  \  \ ___  _ _ _| |_ <_>._ _   *
      //  | . \/ . \/ . \ | |  | . | |     |<_> || '_> | |  | || ' |  *
      //  |___/\___/\___/ |_|  |_|_| |_|_|_|<___||_|   |_|  |_||_|_|  *
      //                                                              *
      //  A program to demonstrate a two-subfile program.             *
      //   Name: SFLTWOR                                              *
      //                                                              *
      //  10/2012                                 booth@martinvt.com  *
      //***************************************************************
      // COMMENTS:                                                    *
      //    - This program uses MOUBTN() or the Enter key             *
      //      to select an item from the subfile.                     *
      //    - A feature of this program are the checkboxes            *
      //      on the subfile records.                                 *
      //                                                              *
      //--------------------------------------------------------------*
     H COPYRIGHT('Booth Martin, All rights reserved.')
     H option(*nodebugio) dftactgrp(*no) actgrp(*new)
     FSFLTWOD   cf   e             workstn
     F                                     SFILE(SFLA:RRNA)
     F                                     SFILE(SFLB:RRNB)
     FSFLTWOSP  if   e           k disk
     FSFLTWOCP  if   e           k disk

           // Working fields.
     D wNdx            s                   like(NBRRECA)
     D RRNA            s              4s 0
     D RRNB            s              4s 0
     D TopRec          s              4s 0
     D SavedStates     s                   Like(States)
      //  ..................................................
      /FREE
          exsr FillScreen;

       dow *inlr = *off;

           select;
           when *inkc;    // End of job
            *inlr = *on;

           when *inke;  // Refresh
             exsr FillScreen;

           when *inkh  // Continue
             and REC = 'SFLB';
             exsr DoSFL2Process;

           when REC = 'SFLA';
             exsr FillSubfileB;
             *in33 = *on;
             exfmt FMT02;
             *in33 = *off;

           when REC = 'SFLB';
             exfmt FMT01;

           other;
             exfmt FMT01;
           endsl;

       enddo;
           //  _________________________________________________________________
         begsr FillSubfileA;
         RRNA = 0;
         // Clear subfile & screen, prepare to re-fill or fill:
         *in90=*off;
         clear SFLA;
         write FMT01;
         *in90 = *on;

         setll *LoVal SFLTWOSP;
         read SFLTWOSP;
         dow not %eof(SFLTWOSP);
           RRNA = RRNA + 1;
           write SFLA;
           read SFLTWOSP;
         enddo;

           TopRec = 1;    // set States subfile at first record.
           NBRRECA = RRNA;

         if RRNA > 6;
           *IN91 = *on;
         endif;

       endsr;
         //  _________________________________________________________________
       begsr FillSubfileB;
         // fill SFLB
         RRNB = 0;

         *IN80=*off;
         clear SFLB;
         Title = ' Cities ';
         write FMT02;
         *in80 = *on;

          SavedStates = *blanks;
          STATES = SavedStates;
             for wNdx = 1 to NBRRECA;
              chain wNdx SFLA;
               if  CTLFLD = 1;
                   Title  = ' ' + STATES + ' ';
                   SavedStates = STATES;
                 leave;
               endif;
             endfor;

         if SavedStates = *blanks;
           CITIES = 'No State chosen';
             RRNB = 1;
             write SFLB;
         else;
           setll SavedStates SFLTWOCP;
           read(e) SFLTWOCP;
           if States <> SavedStates or
                 %eof(SFLTWOCP);
             cities = 'No cities listed';
             RRNB = RRNB + 1;
             write SFLB;
           else;
             dow Not %eof(SFLTWOCP) and
                   States = SavedStates;
                   CTLFLD = 0;
               RRNB = RRNB + 1;
               write SFLB;
               read SFLTWOCP;
             enddo;
           endif;
         endif;

         NBRRECB = RRNB;
         if RRNB > 6;
           *in81 = *on;
         endif;
       endsr;
         //  _____________________________________________________
       begsr FillScreen;
          exsr FillSubfileA;
          exsr FillSubfileB;
          write(e) Header;
          write(e) Footer;
          write(e) FMT02;
          exfmt  FMT01;
       endsr;
         //  _________________________________________________________________
       begsr DoSFL2Process;
             for wNdx = 1 to NBRRECB;
              chain wNdx SFLB;
               if  CTLFLD = 1;
         // whatever process you may desire with the Cities subfile list:
               endif;
             endfor;
             exfmt FMT03;
             exsr FillScreen;
       endsr;
         //  _________________________________________________________________ 

                        





The DDS for the two files used in this application
      ****************************************************************
      *   ___             _    _     __ __             _    _        *
      *  | . > ___  ___ _| |_ | |_  |  \  \ ___  _ _ _| |_ <_>._ _   *
      *  | . \/ . \/ . \ | |  | . | |     |<_> || '_> | |  | || ' |  *
      *  |___/\___/\___/ |_|  |_|_| |_|_|_|<___||_|   |_|  |_||_|_|  *
      *                                                              *
      *  A Physical file of Names of states                          *
      *                                                              *
      *   Name of states file: SFLTWOSP                              *
      *                                                              *
      *  10/2012                                 booth@martinvt.com  *
      ****************************************************************
                                            UNIQUE

                R RSFLTWOSP
                  STATES        10
                K STATES             



      ****************************************************************
      *   ___             _    _     __ __             _    _        *
      *  | . > ___  ___ _| |_ | |_  |  \  \ ___  _ _ _| |_ <_>._ _   *
      *  | . \/ . \/ . \ | |  | . | |     |<_> || '_> | |  | || ' |  *
      *  |___/\___/\___/ |_|  |_|_| |_|_|_|<___||_|   |_|  |_||_|_|  *
      *                                                              *
      *  A Physical file of Names of cities in states                *
      *                                                              *
      *   Name of cities file: SFLTWOCP                              *
      *                                                              *
      *  10/2012                                 booth@martinvt.com  *
      ****************************************************************
                R RSFLTWOCP
                  STATES        10
                  CITIES        20
                K STATES
                K CITIES  

[Home] [Code Samples] [SQL (simple)] [Subfiles] [Web & .json] [Contact Us] [Other]