How to eliminate blank lines in a DISPLAY statement group header

How do I eliminate the blank lines in a DISPLAY statement when using a group header? For example:


DEFINE DATA LOCAL
1 #DATA (A10/1:2) INIT <'ABC12','DEF34'>
1 #GROUP (HD='GRP')
  2 #SUB-FIELD1 (A1) (HD='SF1')
  2 #SUB-FIELD2 (A1) (HD='SF2')
  2 #SUB-FIELD3 (A1) (HD='SF3')
1 #FIELD1 (A1) (HD='//F1')
1 #FIELD2 (A1) (HD='//F2')
1 #X (I4)
END-DEFINE
FOR #X = 1 TO 2
  MOVE SUBSTR(#DATA(#X),1,1) TO #GROUP.#SUB-FIELD1
  MOVE SUBSTR(#DATA(#X),2,1) TO #GROUP.#SUB-FIELD2
  MOVE SUBSTR(#DATA(#X),3,1) TO #GROUP.#SUB-FIELD3
  MOVE SUBSTR(#DATA(#X),4,1) TO #FIELD1
  MOVE SUBSTR(#DATA(#X),5,1) TO #FIELD2
  DISPLAY NOTITLE (GC=-) #GROUP #FIELD1 #FIELD2
END-FOR
END

Produces the following output:

----GRP----

SF1 SF2 SF3 F1 F2
--- --- --- -- --

A   B   C   1  2
D   E   F   3  4

1) How do I get rid of the blank line after ----GRP----?
2) Is there a way to get rid of the blank line that appears before the first row of data? (I think this blank line appears regardless of whether or not a group header is being used)
Also, is there a way to use a fixed-width font when posting questions in this forum? The HTML

 tag doesn’t seem to work.

Don’t like to give bad news, especially on your first posting, but,

  1. Not possible
  2. No
  3. No

The first two may have been suggested on SAG’s Brainstorm site. If so, vote for them.

This text precedes the code snippet.


   DEFINE SUBROUTINE PREFORMATTED
        PRINT "Use 'Code' button to start and end preformatted (code) text"
   END-SUBROUTINE

This text follows code snippet.

Short answers, NO.
Long answers, yes, if you don’t mind coding the headers yourself. See code and output below

DEFINE DATA LOCAL  

1 #DATA (A10/1:2) INIT <‘ABC12’,‘DEF34’>
1 #GROUP (HD=‘GRP’)
2 #SUB-FIELD1 (A1) (HD=‘SF1’)
2 #SUB-FIELD2 (A1) (HD=‘SF2’)
2 #SUB-FIELD3 (A1) (HD=‘SF3’)
1 #FIELD1 (A1) (HD=‘//F1’)
1 #FIELD2 (A1) (HD=‘//F2’)
1 #X (I4)
END-DEFINE
*
write title left justified ’ grp’ / ‘sf1 sf2 sf3 f1 f2’
FOR #X = 1 TO 2
MOVE SUBSTR(#DATA(#X),1,1) TO #GROUP.#SUB-FIELD1
MOVE SUBSTR(#DATA(#X),2,1) TO #GROUP.#SUB-FIELD2
MOVE SUBSTR(#DATA(#X),3,1) TO #GROUP.#SUB-FIELD3
MOVE SUBSTR(#DATA(#X),4,1) TO #FIELD1
MOVE SUBSTR(#DATA(#X),5,1) TO #FIELD2
DISPLAY NOTITLE nohdr
/* (GC=-)
#GROUP #FIELD1 #FIELD2
END-FOR
END

   grp

sf1 sf2 sf3 f1 f2
A B C 1 2
D E F 3 4

Actually, the answer to your 2nd question is “Yes” …
A2. You can turn off the Underline Character. DISPLAY (UC=OFF) will “get rid of the blank line which appears before the first row of data”.
NB. But it will also “get rid of” the underlines below the column headers.
So the output will look like this:
----GRP----

SF1 SF2 SF3 F1 F2
A B C 1 2
D E F 3 4

Just a quick note on Steve’s excellent solution:

  1. the (HD=…) declarations are still required, even though the WRITE TITLE is now defining the “column header” texts
  2. the “column header widths” must be the same in the (HD=…) and the WRITE TITLE texts. otherwise your data rows may not line up nicely under the column headers.
    .
    For example, if you comment out the (HD=…) definitions in Steve’s program then the DISPLAY’s column widths will default back to the length of the field names.