Page 1 of 2

Removing blank address lines from report

PostPosted: Wed Jun 08, 2011 1:19 am
by needhelp
How do you remove blank address lines and move the city state zip line up? There can be up to 4 address lines but I only want to print the address lines that have data. The data is coming in on 1 record. I was hoping to find a 'conditional' line command but can't find anything in the manual. Am I going to have to do this in COBOL?

Need this:
Jim Jones
123 Main st
PO Box 123


Anytown, US 12345

to remove blank lines and move up:
Jim Jones
123 Main st
PO Box 123
Anytown, US 12345

Re: Removing blank address lines from report

PostPosted: Wed Jun 08, 2011 2:04 am
by dick scherrer
Hello,

OMIT the blank lines. . . The others will automagically "move up".

Re: Removing blank address lines from report

PostPosted: Wed Jun 08, 2011 2:07 am
by BillyBoyo
There can be lots of ways. Also, sometimes, a general report-writer is not so good at a highly specfic task. What does your report specifcation look like?

Re: Removing blank address lines from report

PostPosted: Wed Jun 08, 2011 2:36 am
by dick scherrer
Oops . . Sorry, i was answering as though this was a SORT question. . . :oops:

Yes, it depends on how the report is produced/defined.

d

Re: Removing blank address lines from report

PostPosted: Wed Jun 08, 2011 3:06 am
by needhelp
When I run this, the blank lines show up, do I need to code this another way? If there is nothing in address-line2, 3 or 4 I don't want those lines to print, if there is something there, I want them to print.

JOB INPUT INFILE
IF EOF INFILE
STOP
END-IF
PRINT REPORT1
REPORT REPORT1 PAGESIZE 55 SKIP 1 PRINTER (REPORT1) LINESIZE 132
HEADING ( 'ADDRESS')
LINE 1 ADDRESS-LINE1
LINE 2 ADDRESS-LINE2
LINE 3 ADDRESS-LINE3
LINE 4 ADDRESS-LINE4
LINE 5 ADDRESS-CITY ADDRESS-STATE
LINE 6 ZIP10

Re: Removing blank address lines from report

PostPosted: Wed Jun 08, 2011 3:20 am
by dick scherrer
Hello,

One way to do this would be to define a set of ws variables (w1 - w5) in an array and move the "address line" to the "current line". Each time an address value is moved, increment the array subscript. Set the supbscript to 1 each tme a new record is read.

Re: Removing blank address lines from report

PostPosted: Wed Jun 08, 2011 4:37 am
by BillyBoyo
needhelp wrote:When I run this, the blank lines show up, do I need to code this another way? If there is nothing in address-line2, 3 or 4 I don't want those lines to print, if there is something there, I want them to print.

JOB INPUT INFILE
IF EOF INFILE
STOP
END-IF
PRINT REPORT1
REPORT REPORT1 PAGESIZE 55 SKIP 1 PRINTER (REPORT1) LINESIZE 132
HEADING ( 'ADDRESS')
LINE 1 ADDRESS-LINE1
LINE 2 ADDRESS-LINE2
LINE 3 ADDRESS-LINE3
LINE 4 ADDRESS-LINE4
LINE 5 ADDRESS-CITY ADDRESS-STATE
LINE 6 ZIP10


A table, as Dick has said, will clear your initial problem.

The next problem might be, well, that method leaves a load of blank lines in between addresses.

If you don't want that:
JOB INPUT INFILE +
   NAME PRODUCE-ADDRESS-REPORT-FROM-ALL-INPUT

    PRINT REPORT1

REPORT REPORT1 +
   PAGESIZE 55 +
   SKIP 1 +
   PRINTER REPORT1 +
   LINESIZE 132     

HEADING  'ADDRESS'

LINE 1  ADDRESS-LINE1             

AFTER-LINE. PROC

    IF ADDRESS-LINE2 NE " "
          DISPLAY +
                POS 1 +
                ADDRESS-LINE2
    END-IF
         
    IF ADDRESS-LINE3 NE " "
          DISPLAY +
                POS 1 +
                ADDRESS-LINE3
    END-IF

    IF ADDRESS-LINE4 NE " "
          DISPLAY +
                POS 1 +
                ADDRESS-LINE4
    END-IF
         
    IF ADDRESS-CITY NE " "
          DISPLAY +
                POS 1 +
                ADDRESS-CITY
                ADDRESS-STATE
    ELSE
          IF ADDRESS-STATE NE " "
              DISPLAY +
                    POS 1 +
                    ADDRESS-STATE
          END-IF
    END-IF

END-PROC


I removed your IF EOF, because that is handled automatically by the JOB statement, so yours would never be executed (it is necessary with JOB INPUT NULL and your own GETs).

I have also made it look a bit more pretty.

The problem this gives you is the end-of-page processing. Lucky for you, Easytrieve now supports access to the LINE-COUNT (number of lines printed).

There is more than one way to go about dealing with this, so it is time for you to have a go if you fancy it. Note, you might feel the need to replace my if's with Dick's solution in the after-line. proc. Feel free.

Re: Removing blank address lines from report

PostPosted: Wed Jun 08, 2011 7:01 am
by dick scherrer
Hello,

The next problem might be, well, that method leaves a load of blank lines in between addresses.

Yup, if the output is for mailing labels or something similar, the spacing might be needed. . .

Re: Removing blank address lines from report

PostPosted: Wed Jun 08, 2011 12:17 pm
by BillyBoyo
Indeed might be. Easytrieve has a special report type for LABELS. Your method plus that, big box ticked/checked in no time.

Re: Removing blank address lines from report

PostPosted: Wed Jun 08, 2011 6:33 pm
by needhelp
Thank you for the suggestions, I am fairly new to easytrieve and not sure how to change my COBOL thinking to easytrieve thinking. There is a bit more involved in the report but that was the basic problem I was having, the extra lines look bad. I will give these a try.