Multiple field inside periodic group

Hello all!

I read in the Natural-Documentation (“View Definition”), it should be possible to use a variable for array-definition inside the define-data-clause. But it doesn’t work with multiple fields of periodic groups. I took the file “SAG-TOURS-G-REISE” as an example out of the ADABAS-Tutorial. (In reality, I got * a “real” file).
My questions:

  1. Why do a get a NAT0280 in the line I’ve marked in the source code?
  2. If I change the line containing the periodic group to “02 mitsegler (20)” the program is compile-able. But then I get a runtime error NAT1316. Why?
define data local
*
01 #index1       (N03) init <20>
01 #index2       (N03) init <20>
*
01 reise view of sag-tours-g-reise
  02 reise-id                 /* (N8)
  02 c*mitsegler
  02 mitsegler     (#index1)  /* periodic group
    03 anrede-name            /* (A30)
    03 c*sprachen
    03 sprachen    (#index2)  /* (A3)
*
01 #i     (N3)
01 #j     (N3)
01 #i_max (N3)
01 #j_max (N3)
*
end-define
*
read reise
  if reise.C*mitsegler > 0
    if reise.C*mitsegler > #index1
      write 'C*mitsegler > #index1' reise.reise-id
      #i_max := #index1
    else
      #i_max := reise.C*mitsegler
    end-if
    for #i = 1 to #i_max
      if reise.C*sprachen(#i) > #index2   /* here I get the NAT0280
        write 'C*sprachen(' #i ') > #index2' reise.reise-id
        #j_max := #index2
      else
        #j_max := reise.C*sprachen(#i)
      end-if
      for #j = 1 to #j_max
        display
          reise-id
          reise.C*mitsegler
          reise.C*sprachen(#i)
          #i
          #j
          reise.sprachen(#i,#j)    /* here I get the NAT1316
      end-for
    end-for
  end-if
end-read
*
end

Kind regards,

Matthias

Hi Matthias,
Changing from init to const in the definition of #index1 makes a tremendous difference !
Quite “natural” when you think of it :wink:

regards Finn

A quite simple solution. :oops:
But i still can’t understand that NAT1316…

Thanks

“Changing from init to const”
is also the answer to the nat1316 error !

In this case for #index2.

Which isn’t quite as “natural” to me though :wink:

Finn

Yes, I know. But I wonder why the index is running out of bounds just because another variable is constant or not.

But anyway: Thank for answering that quick!