Enter Statement in Find and IF NO RECORDS FOUND

HI, I get a compile error when I include this enter statement.
Can someone tell me what I am doing wrong? It does not like ‘ENTER’

FIND GP-VIEW WITH BUS-KEY=#BUS-KEY
IF NO RECORDS FOUND
ENTER
#GP-VIEW-FOUND:=‘N’
END-NOREC
PERFORM LOAD_SCREEN
END-FIND

There error I get is
NAT0044 Output element not defined, or indexes incorrect.

We are using Natural 4.2

Is the ENTER command still supported?
Thanks.
Michele

There has never been an ENTER statement, neither is there an ENTER command.

I don’t know an ENTER command, too.

What is the ENTER command supposed to do?

From the documentation:

If one or more statements are specified with the IF NO RECORDS FOUND clause, the statements will be executed immediately before the processing loop is entered. If no statements are to be executed before entering the loop, the keyword ENTER must be used.

Here is the structured syntax

IF NO [RECORDS] [FOUND]
{ ENTER }
{statement }
END-NOREC

In other words, ENTER is mutually disjoint from and statements. You cannot have ENTER and any statements in the NO RECORDS clause.

If you comment out #GP-VIEW-FOUND:=‘N’ , your program will compile.

Now, for the reason for this option.

If you do not have an IF NO RECORDS found clause, and there are no records, you will simply skip the loop.

Suppose I want to do the loop if there are NO RECORDS found. Further, assume you do not want to do anything special before doing the loop. If you try:

FIND
IF NO RECORDS FOUND
END-NOREC
::::
You will get a compiler error :

NAT0226 An empty statement block is not allowed.

So, the word ENTER, which is basically equivalent to the word IGNORE for a plain IF.

Ralph, Matthias, and others who didn’t believe there was an ENTER option. Neither did I. I was actually going to the documentation to see if I could use IGNORE (you can) when I “discovered” ENTER.

Why there are two words with identical functionality is a bit of a mystery, especially since IGNORE is used in so many places to permit a null construct.

Would be interesting to know when ENTER “entered” (couldn’t resist) the language. Perhaps in Report Mode, where the syntax was always a bit strange for NO RECORDS.

steve

Dear Ralph:

I found this information in the online help screen , and in your onilne documentation. What gives? It indicates that ENTER is a keyword in IF NO RECORDS FOUND clause.

What am I missing? Michele

15:18:47 ***** NATURAL HELP UTILITY ***** 2009-03-02
- FIND - Page 5


                           GENERAL SYNTAX (continued)                       

IF NO RECORDS FOUND-clause:

IF NO RECORDS FOUND

 ENTER                                                                      
 statement ..                                                               

END-NOREC

Note: Not available with FIND FIRST, FIND NUMBER, FIND UNIQUE options.


                                                                   More ... 

Enter-PF1—PF2—PF3—PF4—PF5—PF6—PF7—PF8—PF9—PF10–PF11–PF12—
Help Menu Exit - + Canc

and this in the Natural for Mainframes Documentation Version 4.2.4 on your web site at http://techcommunity.softwareag.com/ecosystem/documentation/natural/nat424mf/overview.htm

IF NO RECORDS FOUND Clause
Structured Mode Syntax
IF NO [RECORDS] [FOUND]

ENTER
statement

END-NOREC

Reporting Mode Syntax
IF NO [RECORDS] [FOUND]

ENTER
statement
DO statement DOEND

The IF NO RECORDS FOUND clause may be used to cause a processing loop initiated with a statement to be in the event that no records meet the selection criteria specified in the WITH clause and the WHERE clause.

If no records meet the specified WITH and WHERE criteria, the IF NO RECORDS FOUND clause causes the processing loop to be executed once with an “empty” record. If this is not desired, specify the statement ESCAPE BOTTOM within the IF NO RECORDS FOUND clause.

If one or more statements are specified with the IF NO RECORDS FOUND clause, the statements will be executed immediately before the processing loop is . If no statements are to be executed before the loop, the keyword must be used.

Note it says keyword above.

I apologize for the confusion, Michele. My previous posting was a bit misleading. I was a bit surprised to see the ENTER syntax as far back as the Natural 313 documentation. When coding an empty IF NO RECORDS clause, I have always used an IGNORE statement.

In my defence, ENTER is not a Natural statement, but a clause of IF NO RECORDS FOUND, which is itself a clause of the FIND statement.

When the Natural documentation shows a vertical list surrounded by braces, that indicates one of the entries must be chosen - the entries are mutually exclusive. For an IF NO RECORDS clause, you must code either a set of Natural statements, or the keyword ENTER. If you code one or more statements, the keyword ENTER is not allowed. As stated above, I use the IGNORE statement to produce the same effect as ENTER.

find emp with personnel-id = '1'
  if  no record
      ignore    /* force entry into the loop - same as ENTER
  end-norec
  display personnel-id
end-find
find emp with personnel-id = '1'
  if  no record
      write 'Personnel ID not found'
      escape bottom
  end-norec
  display personnel-id
end-find

There should be a change made to the documentation.

Ralph said:

"When coding an empty IF NO RECORDS clause, I have always used an IGNORE statement. "

Me too; and, I’ll bet, most Natural programmers also.

HOWEVER, the Natural documentation, while it does mention ENTER, does not mention IGNORE at all. This should be changed by a simple statement such as:

The word IGNORE may be substituted for ENTER throughout this discussion of IF NO RECORDS FOUND. And in the syntax presentation, IGNORE should be added in both structured and report mode boxes as an alternative to the other options.

steve

Dear Ralph, Dear Steve

Thank you gentlemen , being a 1 1/2 year Natural Programmer I believed the documentation. Now I will only believe you guys! Now I understand! I could get my code to compile if I commented out the ENTER statement.

So basically on the “IF NO RECORDS FOUND” clause unless you code an ESCAPE you will ALWAYS go into the FIND loop.

SO Enter means IGNORE…

Thank you Thank you THank you ! :smiley: