As several people have requested it, here is my code for producing
a 2-column report where the data goes down one side of the page and
then to the other column.  You MUST be able to figure out how many
lines of data fit on one page.  Header data must be only PAGE headers, 
because a report header would make less room for data on the 1st page.  

1.  First create a temporary table with the columns to be printed.
    Add an autonumber column.

    CREATE TEMP TABLE tmpMixedPick1 +
      (tmpLinecount INTEGER, +
      tmpLotNo TEXT (8), +
      tmpCount INTEGER)

    AUTONUM tmpLinecount IN tmpMixedPick1 USING 1 


2.  Insert all the data to be printed into this table making sure
    it goes in there in the order that it should be printed.  If
    you need blank rows between pieces of data, insert an 'empty'
    row where it needs to be.  It will get an autonumber so it will 
    appear in the correct order.

    In my situation, I had a cursor through the data to group items
    by similar types.  These get printed in lines following each other,
    with a "------" between groups.  This "------" gets loaded into
    the table in its proper place.

    (Actually my code gets even more complicated because they wanted
    a 'header' that would be copied from the bottom of one column
    and appear at the top of the second column if a group was split...)

    So my data might look like:
       tmpLinecount (autonumber)   tmpLotNo   tmpCount
       1                           Lot1       5
       2                           Lot1A      10
       3                           --------
       4                           Lot2       8


3.  Now create another temp table with the columns listed twice:
    CREATE TEMP TABLE tmpMixedPick +
      (tmpLinecount INTEGER, +
      tmpLotNo_1 TEXT (8), +
      tmpCount1 INTEGER, +
      tmpLotNo_2 TEXT (8), +
      tmpCount2 INTEGER  )

4.  Set variable for #rows per page:
      SET VAR vRowsPerPage = 21

5.  Here's the process.  The first column of data will always have (in
    my instance) rows 1-21 of data,  rows 43 - 63, etc.   So here is my
    cursor to INSERT the rows into the second temp table:

SET VAR vbegrow = 1
SET VAR vendrow = (.vbegrow + .vrowsperpage - 1)
SET VAR vitem1 TEXT = NULL, vitem2 INTEGER = NULL
  
WHILE 1 = 1 THEN
  SELECT tmpLotNo, tmpCount2 INTO vitem1 IND iv1, vitem2 IND iv1 +
    FROM tmpMixedpick1 +
    WHERE tmpLinecount = .vbegrow

  IF SQLCODE <> 0 THEN
    BREAK
  ENDIF  

  *( in here is where I have other code you don't need to see)

  INSERT INTO tmpMixedPick +
    (tmpLinecount, tmpLotNo_1, tmpCount1) +
    VALUES .vbegrow, .vitem1, .vitem2

  -- if you have gone thru a batch of the rows, need to increment to get to

  -- the next batch of rows
  IF vbegrow < .vendrow THEN
    SET VAR vbegrow = (.vbegrow + 1)
  ELSE
    SET VAR vbegrow = (.vbegrow + .vrowsperpage + 1)
    SET VAR vendrow = (.vbegrow + .vrowsperpage - 1)
  ENDIF    

ENDWHILE


6.  Now we have all the first column data, so let's do the 2nd column data.
    This will be rows for 22-42, 64-84, etc.  We will UPDATE the table
    this time.

SET VAR vbegrow = (.vrowsperpage + 1)
SET VAR vendrow = (.vbegrow + .vrowsperpage - 1)

WHILE 1 = 1 THEN
  -- You are looking for the row in tmpMixedPick1 where the linecount is
for
  --  that count of row# (such as row 22 being the first).  
  -- The row that you are UPDATING in the tmpMixedPick table will be the
row
  --  that is that row# minus the rows-per-page; IE you update tmpMixedPick
  --  row# 1 with data from tmpMixedPick1 row# 22
  
  SELECT tmpLotNo, tmpCount INTO vitem1 IND iv1, vitem2 IND iv2 +
    FROM tmpMixedpick1 +
    WHERE tmpLinecount = .vbegrow

  IF SQLCODE <> 0 THEN
    BREAK
  ENDIF  
    
  UPDATE tmpMixedPick SET +
    tmpLotNo_2    = .vitem1, +
    tmpCount2     = .vitem2 +
    WHERE tmpLinecount = (.vbegrow - .vrowsperpage)

  -- if you have gone thru a batch of the rows, need to increment to get to

  -- the next batch of rows
  IF vbegrow < .vendrow THEN
    SET VAR vbegrow = (.vbegrow + 1)
  ELSE
    SET VAR vbegrow = (.vbegrow + .vrowsperpage + 1)
    SET VAR vendrow = (.vbegrow + .vrowsperpage - 1)
  ENDIF     
   
ENDWHILE






HOPE YOU ALL GOT THAT AND THAT IT MIGHT HELP SOMEONE!  I'm kinda proud
that I figured that one out...

Karen





Reply via email to