redefine for arrays

I have something like this

01 #I-REC (A124)
01 REDEFINE #I-REC
02 I-F1 (N8)
02 I-F2 (N8)
.
.
.

01 #REC (A124/1:25)
01 REDEFINE #REC
02 #REC-GP (1:25)
03 #F1 (N8)
03 #F2 (N8)
.
.
.
.

I-REC record layout for a workfile. The thing is I’m moving records from the workfile(I-REC) to the #REC continuously.
Each time want to check if the #F1 ( #INDEX) EQ #F1(#INDEX-1)
I.E I want to check the previous record in the array with the current record and perform some processing.
The problem now is since the record is defined as (a124),how do I access the array as a group of 25 occurences.
When I use
IF #REC-GP.#F1(#INDEX) EQ #REC-GP.#F2(#INDEX - 1)
It throws me an error.

Is there any problem with my redefine ? Pls clarify.

Your fields beyond #REC-GP got two dimensions.

So please check, if you really need two dimensions.
If no, drop one dimension and everything should be OK.
If yes, you have to address #REC-GP.#F1 like this

IF #REC-GP.#F1(#INDEX, #index2) EQ #REC-GP.#F2(#INDEX - 1, #index2) 

I need only a single dimension. I need 25 occurences of (A124) structure .
And I need to compare the first occurence(first record) #F1 to the second occurence(second record) #F1.How do I accomplish it?

Then try the following definition:

01 #REC (A124/1:25) 
01 REDEFINE #REC 
02 #REC-GP  /* <-- no Array-definition here 
03 #F1 (N8)
03 #F2 (N8)

I’ve redefined as quoted .
But when I try to check
IF #REC(#INDEX).#F1 EQ #REC(#INDEX - 1).#F1

It says Invalid relational operator in a relational expression.

How about putting the index at the end of the field’s name?

IF #REC.#F1(#INDEX)  EQ #REC.#F1(#INDEX - 1)

am getting the error
Index entry incorrectly specified for field.
As #f1 is not defined as an array.
But when I change #F1 as an array of 25 occurences,the total necessity for a group of becomes meaningless.

Oh Sorry, what I initially told you about “two dimensions” was completely false. :oops::oops:

What you need is a REDEFINITION like that:

define data local
01 #REC-GP (1:25) 
   02 #REC (A124)
   02 REDEFINE #REC 
     03 #F1 (N8) 
     03 #F2 (N8)
*
01 #index (I4)
end-define
#index := 2
#REC-GP.#F1(#index) := 1
#REC-GP.#F1(#index - 1) := 1
IF #REC-GP.#F1(#index)  EQ #REC-GP.#F1(#index - 1)
  write #REC-GP.#F1(#index) 'EQ' #REC-GP.#F1(#index - 1)
end-if
end

The reason is:
With a array beyond the redefine, you’ll split the A-Field into an array.

Sorry again for confusing you :oops: . I should read the posts more carefully…