Override headers in different DISPLAYs

Product/components used and version/fix level:

Natural 9

Detailed explanation of the problem:

I’ve done a HISTOGRAM with a DISPLAY to overview a status field:

	HD1. HISTOGRAM FILE-1 IN-STATUS
	  DISPLAY IN-STATUS *NUMBER *COUNTER
	  END-HISTOGRAM
	  EJECT
Output ( previously I used WRITE TITLE and WRITE TRAILER ) :
	 1SISTEM: SYSTEM-1 GOAL: GENERAL OVERVIEW OS STATUSES  20240215 16:24:19.0
	 -------------------------------------------------------------------------------
	 IN-STATUS    NMBR        CNT
	 --------- ----------- -----------
	0E                  97           1
	 F                 299           2
	 J                   1           3
	 N                3369           4
	 X                   1           5
	                                               SERVICE: SERVICE-1  PAGE:      1
	 -------------------------------------------------------------------------------

Right after in the same program I did a FIND with another DISPLAY, to show some NOK fields according to business rules related to the status:

 	WRITE 'SAMPLE OF NOK RECORDS'
 	FD1. FIND(40) NOK-RECORDS WITH IN-STATUS NE 'F' AND IN-STATUS NE 'N' 
 	  IF NO RECORDS FOUND
 	    COMPRESS DEBUG-INFO 'ZERO PROBLEMS IN FD1.' INTO DEBUG-INFO
 	    END-NOREC
 	  DISPLAY *ISN IN-STATUS DT-REC-STORE *COUNTER
 	  END-FIND
Output:
	SAMPLE OF NOK RECORDS
	         79 E  20220222           1 
	         80 E  20220222           2 
	       2934 E  20230922           3 
	       2935 E  20230922           4 
	       2936 E  20230922           5 
	       2937 E  20230922           6 
	       2938 E  20230922           7
	       ...
	1SISTEM: SYSTEM-1 GOAL: GENERAL OVERVIEW OS STATUSES  20240215 16:24:19.0
	------------------------------------------------------------------------------ 
	IN-STATUS    NMBR        CNT      
	--------- ----------- ----------- 
	       2954 E  20230922          23 
	       2955 E  20230922          24 
	       2956 E  20230922          25 
	       2957 E  20230922          26 
	       2958 E  20230922          27 
	       2959 E  20230922          28 
	       2960 E  20230922          29 
	       2961 E  20230922          30

Finally I did a last DISPLAY to show execution details:

 	NEWPAGE
 	DISPLAY OPER-CONTROL(*) 4X EXEC-DATA(*)
Output:
	1SISTEM: SYSTEM-1 GOAL: GENERAL OVERVIEW OS STATUSES  20240215 16:24:19.0
	------------------------------------------------------------------------------- 
	IN-STATUS    NMBR        CNT      
	--------- ----------- ----------- 
	TOTAL RECORDS      3143      START: 16/02/24 11:14:23   
	    PROCESSED         0        END: 16/02/24 11:21:02   
	       STORED         0   DURATION: 00:06:39.6          
	    DISCARDED         0    ERROR? : NO
	BUSINESS ERRORS       0 
	NOT FOUND             0 
	                          OBJ EXEC: PROGRAM PGM-1
	                          ENVIRONM: DEV              
	                          VERS NAT: 09.01.02       

I tryied NEWPAGE and EJECT but the headers of the first DISPLAY keep on appearing.
I wish I could see the proper headers in each DISPLAY command.
Any tip of how to override or reset the pages so that each DISPLAY could have its proper headers?
Thanks in advance.

Error messages / full error message screenshot / log file:

No errors, just page adjustments. I’ve searched in Natural documentation but didn’t found explanation.

Question related to a free trial, or to a production (customer) instance?

Production instance

Here’s a doc link (for Unix since you didn’t specify an OS, but the code is the same)
Column Headers

The first DISPLAY statement (for a print unit) in any Natural program sets the headings for that program - not the first DISPLAY executed, but the first present in the code. To suppress headings and titles, use the NOHDR / NOTITLE clauses on any or all of the DISPLAY/WRITE/PRINT statements - use the AT TOP OF PAGE to create custom and modifiable headings or titles as needed.

If your DISPLAY statement with headers for the “main” part of your report is not the first DISPLAY in your program, try putting the main DISPLAY in a subroutine near the top of your code and PERFORM that from where it is needed.

See the examples with the EJECT statement to suppress the default heading/title behaviour.

Consider writing the reports to different print units (e.g. DISPLAY (1) or DISPLAY (2) ) as each unit will have its own column headings, so you can write the histogram report to DISPLAY (1) and the NOK report to DISPLAY (2).

When outputting your summary section, add NOHDR (and optionally NOTITLE) to your WRITE/PRINT statements to suppress the column headings that the DISPLAY statement provides. Use the NEWPAGE (rep) statement if you want to start a new page with the default titles for that print unit (rep) or EJECT (rep) to go to a new page without page titles. The first DISPLAY/WRITE/PRINT statement for a page (on the print unit) will determine if headings or titles are displayed on that page. So for your summary report, you might use

EJECT
DISPLAY NOHDR OPER-CONTROL(*) 4X EXEC-DATA(*)

For the second report, you might either use a WRITE (2) to write to a different print unit (outputs to CMPRT02) or set a flag variable before your NEWPAGE (#flag := 2) and check which header your AT TOP OF PAGE will produce based on the flag, combined with DISPLAY NOHDR [NOTITLE] *ISN IN-STATUS DT-REC-STORE *COUNTER.

Finally, if the 2 reports should have similar column alignments, make the a subroutine with the first DISPLAY the one with the most fields (in your example the second DISPLAY) and PERFORM it from the second loop. In the first loop use “WRITE NOHDR T*” notation to align the output with the columns in the subroutine’s DISPLAY. Then, if desired, use the AT TOP OF PAGE to produce headings for the different DISPLAYs (using the flag variable to tell the AT TOP which column headings it needs to produce) with WRITE NOHDR Tcol1 Tcol2…

1 Like

Here are the rules for Headers: