## Data structure with array AS/400

220 pts.
Tags:
AS/400
AS/400 Arrays
Sorry, I do not know how to explain this. I was expecting this can be work but it can't. It seems like will getting decimal data error. Can someone help on this?
```Field of FLD0 to FLD9 is from a PF which is 15,2.
DS

FLD          DIM(10) LIKE(FLD0)

FLD0 FLD1 FLD2 FLD3 FLD4 FLD5 FLD6 FLD7

FLD8

FLD9

XFOOT   FLD     TOTAL```

Thanks. We'll let you know when a new response is added.

## Discuss This Question: 12 Replies

Thanks. We'll let you know when a new response is added.
• Whats the length of your Total field.

And, Are you declaring file fields in DS again for copying the data to arrays? Or, Handling that in a program.

Bit more details would help.
report
• Decimal Data Error: Initialize all subfields to zero.
report
• Length of TOTAL is 15,2.
FLD0 to FLD9 is a field from PF.I was thinking whether when i read the file, the array FLD(x) would have the value if i using ds.
I know It can be work if i do like
EVAL FLD(1) = FLD0 untill FLD(10) = FLD9.

report
• try this, and total should be bigger than fld0-9 to handle the summation if they were all 9999999999999.99
`d total           s             17p 2                   `
```d fields          ds
d fld0
d fld1
d fld2
d fld3
d fld4
d fld5
d fld6
d fld7
d fld8
d fld9
d fld                                 dim(10) like(fld0)
d                                     overlay(fields:1)
/free
total = %xfoot(fld);
//will sum them up.
/end-free          ```
report
• Hi BigKat, can i code like this? What does overlay mean? I did google it but seems not understand.
```d fields          ds
d fld                                dim(10) like(fld0)
d                                    overlay(fields:1)
d fld0
d fld1
d fld2
d fld3
d fld4
d fld5
d fld6
d fld7
d fld9```
report
• Hi, What if I do like this, i getting decimal data error because of field fld0wk. why?
```d fields          ds
d fld0wk                          like(fld1)
d fld1
d fld2
d fld3
d fld4
d fld5
d fld6
d fld7
d fld8
d fld9
d fld                                 dim(10) like(fld0)
d                                     overlay(fields:1) ```
report
• Did you take a Dump for the error and looked at it ? Probably its value in Hex is all X'40'. Inititalize !!
report
• Declare like this:
d fld        dim(10) like(fld0) inz

In case fld0 is a numeric field the inz keyword will automatically initialize all array elements to zero.
report
• Hi pdraebel, only the declared field fld0wk getting value in Hex. But why ?