Arrays in INDEPENDENT variables

Hello, how can I use arrays in INDEPENDENT variables.

01 +W-CAMPOARR (A40/1:4)
…
WRITE &W-CAMPOARR(1)

Index entry incorrectly specified for field.

Thank you,
Greetings

The ampersand (&) is used only to designate dynamic text. Normally you would code

DEFINE DATA INDEPENDENT
1 +W-CAMPOARR (A40/1:4)
END-DEFINE
WRITE '=' +W-CAMPOARR (1)
END

thanks.
but I need to use the value & and not the +

NAT0280 Index entry incorrectly specified for field.
WRITE &W-CAMPOARR (1)

currently:
01 +W-CAMPO1 (A40)
01 +W-CAMPO2 (A40)
01 +W-CAMPO3 (A40)
01 +W-CAMPO4 (A40)

but i require:
01 +W-CAMPOARR (A40/1:4)

actually works with WRITE & W-CAMPOARR but I only get the first position of the array

Greetings

Ralph is (of course) correct. You do not want & in your case. &W-CAMPOARR is not a valid variable.

DEFINE DATA INDEPENDENT                      
1 +W-CAMPOARR (A4/1:4) INIT <'a','b','c','d'>
END-DEFINE                                   
WRITE '=' +W-CAMPOARR (*)                    
WRITE '=' +W-CAMPOARR (1)                    
WRITE '=' +W-CAMPOARR (2)                    
WRITE '=' +W-CAMPOARR (3)                    
WRITE '=' +W-CAMPOARR (4)                    
END

Output:

 +W-CAMPOARR: a    b    c    d  
 +W-CAMPOARR: a                  
 +W-CAMPOARR: b                 
 +W-CAMPOARR: c                  
 +W-CAMPOARR: d                 

However, independent variables are tricky. If you have already defined them in your session, you cannot change them until you restart your session or using the RELEASE VARIABLES statement.

OP said

but I need to use the value & and not the +

If this is indeed true, then I would quote the Statements manual, Run statement, Dynamic Source:

A global variable with index must not be used within a program that is invoked via a RUN statement.

You are not allowed to change the +W-CAMPOx scalars to an array.

Thanks,
Greetings

thanks,
Greetings