Inserting Records with MU-Fields

Is it possible to STORE a record with MU-Fields in a way that the occurence counter represents only the filled values?

The program

DEFINE DATA
LOCAL
1 E1 VIEW OF EMP
  2 NAME (A10)
  2 C*LANG
  2 LANG (A1/1:3)
END-DEFINE

READ ALL RECORDS IN E1
  DELETE
END-READ

E1.NAME    := 'Alpha'
E1.LANG(1) := 'A'
STORE RECORD IN E1

E1.NAME    := 'Beta'
E1.LANG(1) := 'B'
E1.LANG(2) := 'C'
STORE RECORD IN E1

READ ALL RECORDS IN E1
  WRITE NAME C*LANG
END-READ

END

results in

Alpha 3
Beta  3

which looks to me as if the occurence counter in the database is set to 3 for both records. I would like to see the ouput

Alpha 1
Beta  2

How can i achieve that? Thanks for any hint to a Natural-newbie.

Take a look at the Data Definition Module (DDM). Either double-click the view name or enter the command:

l v EMP      <-- this is the abbreviation for LIST VIEW EMP

What is the value in the Suppression column for field LANG? If the multiple occurring field (MU) is defined as null suppressed (N), then the count will reflect the number of non-null occurrences in the record. Any other specification will result in a count that matches your request, in this case, 3.

If you change the Suppression value to N, this will apply only to new and updated records. The old inflated count will be returned by Adabas until the records are updated.

Ralph’s response above is probably the one you want to go with; especially since you indicated you are a “newbie” when it comes to Natural.

However, Adabas has capabilities that pertain to MUs that are not available in Natural. To employ these capabilities, you would use USR1043 (found in library SYSEXT).

SYSEXT contains “utilities” for Natural, written and maintained/enhanced by Software AG. USR1043 allows a Natural program to issue “direct calls” to Adabas. If you do not have anyone in your shop who is familiar with direct calls, you almost certainly do not want to try doing this yourself.

I have posted an Issue of Inside Natural as an attachment to my category of the forum called “Natural General - Inside Natural”. It describes how to manipulate MUs using USR1043. In particular it describes the “old form” for updating MU fields (not available in Natural itself, but available through USR1043) as opposed to the “new form” which is the mechanism available in Natural.

steve
In Vol 15 No 1.pdf (172 KB)