Trouble on referencing *ISN from a STORE

Product/components used and version/fix level:

Natural 09.01.02

Detailed explanation of the problem:

Hello, I appreciate getting some clarifying for this situation:

NAT0285: Field reference error; reference invalid or missing.

This error blocks the “update” in Natural One… or not… I´m not sure. I clicked on “continue” and the console shows:

Stowing subprogram '...'...failed
error: NAT0285 Field reference error; reference invalid or missing.
Updating private member of private-mode library '...'...done

The error occurs in GT1.
It seems that this *ISN is not noticed but I´m not sure…
I tried to put another END TRANSACTION right after ST1. but got the same error.
1) I understand for the moment that *ISN is not null because of ST1. Is this correct?
According to the Natural guide provided by my company:

        The Natural system variable *ISN contains the Adabas ISN assigned to the new record as a result of the STORE statement execution. 
        A subsequent reference to *ISN must include the statement number of the related STORE statement. 
  1. But what is this “statement number of the related STORE”?
    Is it the line number?
    If not, how do I reference it?
DEFINE DATA LOCAL
    1 BUSINESS-FIELDS VIEW OF FILE1
        2 BUSINESS-FLD1
        2 BUSINESS-FLD2
        2 BUSINESS-FLD3
    1 CONTROL-FIELDS VIEW OF FILE1
        2 IN-STATUS  /* i wish this could be filled by default with the store but it seems impossible
END-DEFINE
...
/* business data filled
...
ST1. STORE BUSINESS-FIELDS 
GT1. GET CONTROL-FIELDS *ISN /* the same error occurs with *ISN(ST1.)
MOVE 'I' TO IN-STATUS /* as we don't have a default fill we must do like this, right?
UPDATE(GT1.)
END TRANSACTION

I’m not sure if there is a reason you separated the IN-STATUS field to a separate view or not, but they seem to be on the same file, so can you not just do it as part of the STORE?

1 Like

this seems to be comparable to what you showed, but it compiles correctly…

define data
local
1 BUSINESS-FIELDS VIEW OF NCCONTRACT
  2 CONTRACT-ID (P6.0)
  2 PRICE (P10.3)
  2 DID-CONDITIONS (A8)
1 CONTROL-FIELDS VIEW OF NCCONTRACT
  2 DATE-RESERVATION (N8.0)
/*) imported data fields from Data Definition Module NCCONTRACT
end-define
CONTRACT-ID := 123
PRICE := 345.67
DID-CONDITIONS := 'OFF'
*
ST1. STORE BUSINESS-FIELDS
GT1. GET CONTROL-FIELDS *ISN (ST1.)
DATE-RESERVATION := *DATN
UPDATE (GT1.)
END TRANSACTION
END

Am I missing something? does this reflect the same situation you are trying to describe?

1 Like

Thank you!
Yes, this seems the same situation…
One difference here is that my view doesn’t have fields formatting. I could try this.
( When defining a view its fields doesn’t assume the file’s fields format and size? )

For interest sake can you try changing the MOVE to:

MOVE 'I' TO ``CONTROL-FIELDS.IN-STATUS

Eugene (Gene) Miklovich

ADABAS/NATURAL Systems Support and DBA

Cell: 916-202-7047

Normal Hours: 8am-4pm E.T.

Please call or text if assistance needed outside these hours.

1 Like

In this case my business fields are recieved by parameters,
and the control fields are managed internally.
Before the STORE I want to prevent duplicate records, with READ or even GET using the same business view , regardless the control fields.

Yes, you can let the format/size default to the DDM values. NaturalONE’s edit function to insert fields from a view always includes the format/size (I’ve asked for an option to omit that).

define data
local
1 BUSINESS-FIELDS VIEW OF NCCONTRACT
  2 CONTRACT-ID 
  2 PRICE 
  2 DID-CONDITIONS 
1 CONTROL-FIELDS VIEW OF NCCONTRACT
  2 DATE-RESERVATION
/*) imported data fields from Data Definition Module NCCONTRACT
end-define
contract-id := 123
price := 345.67
DID-CONDITIONS := 'OFF'
*
ST1. STORE BUSINESS-FIELDS
GT1. GET CONTROL-FIELDS *ISN (ST1.)
DATE-RESERVATION := *DATN
UPDATE (GT1.)
END TRANSACTION
END

Same example as before with out the format/size in the local view.
Perhaps you could include a screenshot of the edit area where the error is highlighted - preferably including both the data area and the offending code? This is not a runtime error (NAT0285) - it is a compile time error. Somewhere the Natural parser is not understanding the variables you are supplying.

1 Like

Man, I can’t explain but today it worked fine.
I wonder if NaturalOne’s compiler got a new clean session or something like this.
I didn’t put format/lenght in the view fields,
I put

ST1. ...
GT1. ... *ISN (ST1.) 
MOVE 'I' to IN-STATUS 
UPDATE (GT1.) 
END TRANSACTION

And now I proceed with the work, with new doubts…

Now do what Douglas suggested in his first reply.

MOVE ‘I’ TO BUSINESS-FIELDS.IN-STATUS
STORE BUSINESS-FIELDS
END TRANSACTION

Every good Natural programmer knows to avoid unnecessary Adabas calls. Your GET and UPDATE are unnecessary Adabas commands.

1 Like

Related to this I did another post in the forum. Could you please take a look?
Thanks for all.

Instead of using two views could we define one view with grouped fields?
If yes, could you give an example?

I tried to group but I got this error:

According to the documentation I use, this should work. But anyway…

Error message NAT0166 is telling you exactly what is wrong. All entries within a view must exist in the referenced DDM. If group name BUSINESS-FIELDS does not exist in EXP-FILE, then you can’t use it in EXP-VIEW.

In the following example, BUSINESS-FIELDS and OTHER-FIELDS must be defined as groups in the EXP-FILE DDM.

1 EXP-VIEW VIEW EXP-FILE
  2 BUSINESS-FIELDS
    3 CONTRACT-ID
  2 OTHER-FIELDS
    3 IN-STATUS
1 Like

I appreciate the reply and agree that the error message is pretty straightforward, but as an ordinary programmer I think the documentation lacks some detail and examples.
I checked here and here and it’s not clear that, in this case, grouping must be done in the DDM. Maybe one single phrase could help, something like “using groups in the view require its definition in the DDM”

I saw this example that does STORE and GET related to Trigger/Stored Procedures.
The example is SAMPINT1 . I appreciate some tips about this:

https://documentation.softwareag.com/adabas/ada854mfr/triggers/apx.htm#IPIunaacpd

The first “here” link you posted clearly states:

“The view-definition option is used to define a data view as derived from a data definition module (DDM)”

The syntax diagram also points out that only “ddm-field” or “redefinition” are allowed in a view definition.

Not sure what might be unclear here.

1 Like

As far as I knew, redefinition and grouping were different things.
Now I learned that a group is a kind of redefinition, and related to views, it only works in a view if it was defined in the DDM and not in the program.
But I’m learning thanks to this discussion and not the documentation solely.
So I thank you again for your attention.
I wish I could reach the proper “guru perspective” to realize the obviouness in that so simple phrase.
From my “ordinary perspective” one purpose of the documentation is to help the most of people, considering at least different experience levels.
Wether here in this forum, or in the documentation, or even in a source code, it’s all about using language that we hope can be comprehensible for someone else.

The SAMPINT1 code is working with multi-valued fields. If the MU fields are null-suppressed, then what is sent on the STORE/UPDATE may differ from what Adabas will store if there are embedded empty (blank) elements (e.g. “key1”,“”,“key2” will store just 2 occurrences, not 3), so the GET will return the actual MU array that was stored after null suppression is applied. This is rarely necessary - if you can do all your data manipulations before the STORE and avoid the GET/UPDATE steps, you will avoid the 2 extra database calls and improve performance (and clarity of your code).

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.