[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference iosg::all-in-1_v30

Title:*OLD* ALL-IN-1 (tm) Support Conference
Notice:Closed - See Note 4331.l to move to IOSG::ALL-IN-1
Moderator:IOSG::PYE
Created:Thu Jan 30 1992
Last Modified:Tue Jan 23 1996
Last Successful Update:Fri Jun 06 1997
Number of topics:4343
Total number of notes:18308

567.0. "Merge, Controlling page breaks in output" by ODIXIE::BIRCH () Fri Apr 24 1992 19:08

I am looking for a little advise on how to control the output of a merge.  
Using a selection list of keys and OA$MERGE_KEY I need to get four records per 
page of output.  I cant depend on all the outputs being the same size since 
some fields could be blank and therefore not output.  Here is the code:

FORM AUTO SELECT FOR TQLENTRY DO SEL_STYLE .PIF_NUM /STYLE=FILE/LIST="PIF.SEL"
MERGE TQLPRINTALL.WPL,OUT.WPL,PIF.SEL,PIFHEADER.WPL

TQLPRINTALL.WPL
---------------
<TQLENTRY1.%OPEN[oa$merge_key]>
<&TAB 1>ORIGINATOR:<&TAB 14><.ORIGINATOR:30><&TAB 55>PIF DATE: <.PIF_DATE:8>
<&TAB 2>PIF NO:<&TAB 14><$PIF_NUM:2>-<$PIF_NUM:4:2>-<$PIF_NUM:2:6><->
<&TAB 55>ASSIGNED:<&TAB 65><.ASSIGNED:3>
<&TAB 4>PROCESS:<&TAB 14><.PROCESS:62>
DESCRIPTION:<&TAB 14><.DESC1:66>
<.DESC2:79>
<.DESC3:79>
<.DESC4:79>
<.DESC5:79>

<&TAB 28>DEPARTMENT DIRECTOR<&TAB 65>DATE: <.DD_DATE:8>
ACCEPT: <.DD_ACC:1><&TAB 12>DECLINE: <.DD_DECL:1><&TAB 25><->
REFER TO DEPT. QMB: <.DD_REF:1><&TAB 50>FURTHER STUDY REQ'D: <.DD_STUDY:1>
REMARKS: <.DD_REMKS1:70>

<&TAB 30>DEPARTMENT QMB<&TAB 65>DATE: <.DQMB_DATE:8>
ACCEPT: <.DQMB_ACC:1><&TAB 12>DECLINE: <.DQMB_DECL:1><&TAB 25><->
REFER TO COMMAND QMB: <.DQMB_REF:1><&TAB 50>FURTHER STUDY REQ'D: <.DQMB_STUDY:1>
REMARKS: <.DQMB_REMKS1:70>

<&TAB 32>COMMAND QMB<&TAB 65>DATE: <.CQMB_DATE:8>
ACCEPT: <.CQMB_ACC:1><&TAB 12>DECLINE: <.CQMB_DECL:1><&TAB 25><->
REFER TO COMMAND QMB: <.CQMB_REF:1><&TAB 50>FURTHER STUDY REQ'D: <.CQMB_STUDY:1>
REMARKS: <.CQMB_REMKS1:70>

<&TAB 36>QPIC<&TAB 65>DATE: <.QP_DATE:8>
ACCEPT: <.QP_ACC:1><&TAB 12>DECLINE: <.QP_DECL:1><&TAB 50><->
FURTHER STUDY REQ'D: <.QP_STUDY:1>
REMARKS: <.QP_REMKS1:70>

COST SAVINGS:<&TAB 15><.SAVINGS:8><&TAB 33>IMPLEMENTED:<&TAB 46><.IMP:1><->
<&TAB 65>DATE: <.IMP_DATE:8>
<.%CLOSE>
-----------------------------------
The desired output is a header and four records on each page so a single record 
is not split across pages.  

Another question: Is there a way of suppressing the header on all but the 
first page?   Appending the out file to a header file would work but is there 
another way with a merge directive?

Thanks
 
T.RTitleUserPersonal
Name
DateLines
567.1Use a scriptSAC::JOYCEGreasing the baseball bat...Fri Apr 24 1992 19:2015
    
    personally for things like this I 've always tended to call a script
    from a simple blp (that does nothing else usually but it could put in
    the first/only header before calling the script). The script uses
    MERGE_LINE and GET OA$MERGE_LINE="...bla..." to build the output
    counting lines as it does. You probably have to have a bit of logic
    like "build a complete record and store the lines in # symbols, work
    out how many lines it takes, will it fit on the current page? if yes,
    output it line by line, if not MERGE_LINE "<&PAGE>" then output the
    record line by line. The script can read thru your selections using
    either NEXT_LIST or the TEXTFILE functions.
    
    Hope this helps.
    
    Andy
567.2Hints and HacksSAC::JOYCEGreasing the baseball bat...Fri Apr 24 1992 19:25157
    If this helps, here's part of a HINTs and HACKS guide I wrote a while
    back...
    
    
3.1.  Complex boilerplate processing

      Consider the following simple boilerplate...

      	      Details of POSTBOOK entry NO. <$POSTBOOK>

      	      Mail Type : <$POSTBOOK:1> (I=Incoming,O=Outgoing)

      	      Addressee	: <POSTBOOK_ENTRY.TO[$POSTBOOK]>
      	      		  <POSTBOOK_ENTRY.TADD1[$POSTBOOK]>
      	      		  <POSTBOOK_ENTRY.TADD2[$POSTBOOK]>

      	      Sender	: <POSTBOOK_ENTRY.SENDER[$POSTBOOK]>
      	      		  <POSTBOOK_ENTRY.SADD1[$POSTBOOK]>
      	      		  <POSTBOOK_ENTRY.SADD2[$POSTBOOK]>

      	      Subject	: <POSTBOOK_ENTRY.SUBJECT[$POSTBOOK]>

      For an INCOMING mail, no details are input for the Addressee's address, 
      so the resulting file will look something like...

      	      Details of POSTBOOK entry NO. I0123      

      	      Mail Type : I (I=Incoming,O=Outgoing)

      	      Addressee	: Mr Michael Murphy                
      	      		                                     
      	      		                                   

      	      Sender	: Mr Patrick O'Shaunessy             
      	      		  Blarney Stone Merchants          
      	      		  10 High Road, Cork, Ireland       

      	      Subject	: New shovels                         

      For an OUTGOING mail, no details are input for the Sender's address, so 
      the resulting file would look something like this...

      	      Details of POSTBOOK entry NO. O1001        

      	      Mail Type : O (I=Incoming,O=Outgoing)

      	      Addressee	: Mr Patrick O'Shaunessy         
      	      		  Blarney Stone Merchants          
      	      		  10 High Road, Cork, Ireland        

      	      Sender	: Mr Michael Murphy                 
      	      		                                   
      	      		                                    

      	      Subject	: Confirmation of delivery of new shovels

      In each case, we are outputting two blank lines that do not lend to the 
      aesthetic value of the document. Also, the "Mail Type" line is not 
      pleasing. We could either use a different boilerplate for each type of 
      mail (i.e. I and O) or we could still use one boilerplate but make it 
      more intelligent! It is the latter that will be discussed here...


      For both types of mail, the first line of text outputted will be the 
      same, so we code thisin the boilerplate as before. From then on, the 
      format of the outputted text is dependent on which kind of mail it is, so 
      we need to call a script. The final line outputted (the Subject) is the 
      same for both kinds of mail, and so we code this into the boilerplate. 
      Our boilerplate now looks like this...

      	      Details of POSTBOOK entry NO. <$POSTBOOK>

      	      <&OA DO POSTBOOK_MERGE>
      	      
      	      Subject	: <POSTBOOK_ENTRY.SUBJECT[$POSTBOOK]>

      The boilerplate is processed, line by line, by the MERGE function. Each 
      line (including the blanks) is written to the output file in turn, with 
      the symbol contents in place of the directives. When the "<&OA DO...>" 
      directive is processed, a script is called instead. From within this 
      script we can build more lines of text and by assigning them to a special 
      symbol, "OA$MERGE_LINE", can output them to the file we are creating. 
      When the script has completed, control returns to the MERGE function and 
      it continues to process the boilerplate line by line. For our example of 
      "Mr Murphy's Executive Shovel Emporium" the script, "POSTBOOK_MERGE.SCP", 
      would look something like this...

      !+
      ! POSTBOOK_MERGE.SCP
      !_
      .LABEL START
      !
      ! put out "Mail Type" line + blank line
      	      .IF $POSTBOOK:1 EQS "I" THEN GET #IN_OUT = "Incoming" -
      	      		ELSE GET #IN_OUT = "Outgoing"
      	      GET OA$MERGE_LINE="Mail Type : " #IN_OUT
      	      GET OA$MERGE_LINE=""
      !
      ! put out first line of Addressee (always)
      	      GET OA$MERGE_LINE="Addressee : " POSTBOOK_ENTRY.TO[$POSTBOOK]
      !
      ! do we need the TO address, if not skip it
      	      .IF $POSTBOOK:1 EQS "I" THEN .GOTO MERGE_SENDER
      !
      ! else put out the To address (2 lines) + blank line
      	      GET OA$MERGE_LINE="            " POSTBOOK_ENTRY.TADD1[$POSTBOOK]
      	      GET OA$MERGE_LINE="            " POSTBOOK_ENTRY.TADD2[$POSTBOOK]
      	      GET OA$MERGE_LINE=""

      .LABEL MERGE_SENDER
      !
      ! put out first line of Sender (always)
      	      GET OA$MERGE_LINE="Sender    : " POSTBOOK_ENTRY.SENDER[$POSTBOOK]
      !
      ! do we need the SENDER address, if not finish
      	      .IF $POSTBOOK:1 EQS "O" THEN .EXIT
      !
      ! else put out the To address (2 lines)
      	      GET OA$MERGE_LINE="            " POSTBOOK_ENTRY.SADD1[$POSTBOOK]
      	      GET OA$MERGE_LINE="            " POSTBOOK_ENTRY.SADD2[$POSTBOOK]
      	      .EXIT


      So, our resulting output for INCOMING mail will look like...

      	      Details of POSTBOOK entry NO. I0123      

      	      Mail Type : Incoming

      	      Addressee	: Mr Michael Murphy                
      	      		           
      	      Sender	: Mr Patrick O'Shaunessy             
      	      		  Blarney Stone Merchants          
      	      		  10 High Road, Cork, Ireland       

      	      Subject	: New shovels                         

      For an OUTGOING mail, the resulting output will look something like 
      this...

      	      Details of POSTBOOK entry NO. O1001        

      	      Mail Type : Outgoing

      	      Addressee	: Mr Patrick O'Shaunessy         
      	      		  Blarney Stone Merchants          
      	      		  10 High Road, Cork, Ireland        

      	      Sender	: Mr Michael Murphy                 
      	      		                                   
      	      Subject	: Confirmation of delivery of new shovels

      Clearly, this is a fairly trivial example but the same principle can be 
      applied when writing applications that require considerably more complex 
      processing; for example, controlling page breaks, widows and orphans, 
      different headings on each page etc.

567.3OA$PAGE_LENGTHUTRTSC::BOSMANWe're just sugar mice in the rainFri Apr 24 1992 19:465
    To answer your first question. Set OA$PAGE_LENGTH to 4 times the number
    of lines for one record plus the number of lines for the header. That
    will do it.
    
    Sjaak.