Submitted by Kim Egekjaer on Thu, 08/27/2009 - 00:00
Forums

Many are using split definitions and split exit programs to solve a lot of different customer requirement. From time to time I get the question about what to do if the vital information used for the split is not found on all pages, but only page one of each document within the spooled file. The answer is to store the information in e.g. a data area and retrieve that for the pages where no information is found. Here is how:

This is an example with a split definition that splits by use of data that is not found on all pages in the spooled file.
In this case we pick out &entrytxt1 and &entrytxt2 from the demo spooled file:

&Entrytxt1 is taking spooled file text from line 3 positions 71-72. This contains a page number e.g. ' 1'.
(I use a preceeding blank to avoid a hit for page 11, 21 etc...).

&Entrytxt2 is taking text from line 11 position 13-42 (the contact name). But we only want to take this when it says ' 1' in Entrytxt1..

This is the program and the split and AFC definition is included in the export, that you can get it here.

Remember that the program must be owned by qsecofr. 

PGM          (&ENTRYTXT1  &ENTRYTXT2  &ENTRYTXT3  &ENTRYTXT4  +        

              &ENTRYTXT5  &OUTQ       &OUTQLIB    &WIDTH      +        

              &LENGTH     &LPI        &CPI        &OVRFLW     +        

              &FONT       &PAGRTT     &FORMTYPE   &SPLFNAME   +        

              &USRDTA     &HOLD       &SAVE       &COPIES     +        

              &RPLUNPRT   &RPLCHR     &ALIGN      &DRAWER     +        

              &RETURNTXT1 &RETURNTXT2 &RETURNTXT3 &RETURNTXT4 +        

              &RETURNTXT5 &RETURNTXT6 &RETURNTXT7 &RETURNTXT8 +        

              &RETURNTXT9 &RETURNTX10 &RETURNUDFD)                                                           


             DCL        &ENTRYTXT1    *CHAR      30             

             DCL        &ENTRYTXT2    *CHAR      30             

             DCL        &ENTRYTXT3    *CHAR      30             

             DCL        &ENTRYTXT4    *CHAR      30             

             DCL        &ENTRYTXT5    *CHAR      30             

             DCL        &OUTQ         *CHAR      10             

             DCL        &OUTQLIB      *CHAR      10             

             DCL        &WIDTH        *CHAR       6             

             DCL        &LENGTH       *CHAR       6             

             DCL        &LPI          *CHAR       6             

             DCL        &CPI          *CHAR       6             

             DCL        &OVRFLW       *CHAR       6             

             DCL        &FONT         *CHAR       6             

             DCL        &PAGRTT       *CHAR       6             

           DCL        &FORMTYPE     *CHAR      10    

          DCL        &SPLFNAME     *CHAR      10    

           DCL        &USRDTA       *CHAR      10    

           DCL        &HOLD         *CHAR       6    

          DCL        &SAVE         *CHAR       6    

          DCL        &COPIES       *CHAR       6    

          DCL        &RPLUNPRT     *CHAR       6    

          DCL        &RPLCHR       *CHAR       1    

          DCL        &ALIGN        *CHAR       6    

           DCL        &DRAWER       *CHAR       6    

          DCL        &RETURNTXT1   *CHAR      50    

           DCL        &RETURNTXT2   *CHAR      50    

           DCL        &RETURNTXT3   *CHAR      50    

           DCL        &RETURNTXT4   *CHAR      50    

           DCL        &RETURNTXT5   *CHAR      50    

           DCL        &RETURNTXT6   *CHAR      50    

             DCL        &RETURNTXT7   *CHAR      50              

      DCL        &RETURNTXT8   *CHAR      50              

       DCL        &RETURNTXT9   *CHAR      50              

       DCL        &RETURNTX10   *CHAR      50              

       DCL        &RETURNUDFD   *CHAR     255                                                   


/* FIRST PAGE IN SPOOLED FILE:*/                                 

             IF         COND(&ENTRYTXT1 *EQ ' 1') THEN(DO)       

             CHGVAR     VAR(&USRDTA) VALUE(&ENTRYTXT2)           

             CHGDTAARA  DTAARA(QTEMP/STORE_DATA) VALUE(&ENTRYTXT2)

             MONMSG     MSGID(CPF1015) EXEC(CRTDTAARA +          

                          DTAARA(QTEMP/STORE_DATA) TYPE(*CHAR) +  

                          LEN(30) VALUE(&ENTRYTXT2))             

             ENDDO                                               


 /* FOLLOWING PAGES IN SPOOLED FILE:*/    


         IF         COND(&ENTRYTXT1 *NE ' 1') THEN(DO)       

  /* RTVDTARA must retrieve into a field that is 30 char long... */

         RTVDTAARA  DTAARA(QTEMP/STORE_DATA) RTNVAR(&ENTRYTXT2)

         CHGVAR     VAR(&USRDTA) VALUE(&ENTRYTXT2)           

         ENDDO                                               


             ENDPGM                                      

The example works with the InterForm400 demo spooled file.