# CSV-Workfile + X-Array = NAT6256. Why?

**URL:** <https://techcommunity.softwareag.com/t/csv-workfile-x-array-nat6256-why/172247>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Linux\
**Created:** [August 14, 2013, 5:06pm UTC](https://techcommunity.softwareag.com/t/csv-workfile-x-array-nat6256-why/172247 "2013-08-14T17:06:52Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [August 14, 2013, 5:06pm UTC](https://techcommunity.softwareag.com/t/csv-workfile-x-array-nat6256-why/172247/1 "2013-08-14T17:06:52Z")

</div>

Hello all!

Could you understand that type of error in this context? From my point of view it doesn’t make any sense…

```auto
define data local
1 #x-array(A10/1:*)
1 #i2 (I2)
end-define
define work file 1 '/tmp/x-array.txt' type 'CSV' /* type 'ASCII' works
expand array #x-array to (1:2)
#x-array(1) := 'LINE1'
#x-array(2) := 'LINE2'
for #i2 = 1 to *UBOUND(#x-array)
  write work file 1 variable #x-array(#i2) /* NAT6256 here
end-for
close work file 1
end
```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [August 14, 2013, 6:09pm UTC](https://techcommunity.softwareag.com/t/csv-workfile-x-array-nat6256-why/172247/2 "2013-08-14T18:09:10Z")

</div>

Matthias,

[the documentation](http://techcommunity.softwareag.com/ecosystem/documentation/natural/nat6314unx/sm/writewor.htm#Handling) says:

> [@](#):
>
> CSV: The maximum field/record length is 32766 bytes for dynamic and large variables. Dynamic variables are supported. X-arrays are not allowed and will result in an error message.

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [August 14, 2013, 11:45pm UTC](https://techcommunity.softwareag.com/t/csv-workfile-x-array-nat6256-why/172247/3 "2013-08-14T23:45:29Z")

</div>

Subject to the length constraint, you could COMPRESS what would have been the Xarray occurrences into a single dynamic variable with appropriate “delimiter”.

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [August 15, 2013, 8:12am UTC](https://techcommunity.softwareag.com/t/csv-workfile-x-array-nat6256-why/172247/4 "2013-08-15T08:12:01Z")

</div>

Thanks for answering.

> [@Wolfgang Winter](#):
>
> X-arrays are not allowed and will result in an error message.

The point is: I din’t write write work file 1 #x-arrayb[/b]. Why shouldn’t it be possible to use a single field out of an x-array?

But OK, let’s do a workaround.

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [August 15, 2013, 8:14am UTC](https://techcommunity.softwareag.com/t/csv-workfile-x-array-nat6256-why/172247/5 "2013-08-15T08:14:08Z")

</div>

> [@Steve Robinson](#):
>
> you could COMPRESS what would have been the Xarray occurrences into a single dynamic variable with appropriate “delimiter”.

I want to use the CSV-functionality. BTW: a CSV-COMPRESS would be nice…

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [August 15, 2013, 2:07pm UTC](https://techcommunity.softwareag.com/t/csv-workfile-x-array-nat6256-why/172247/6 "2013-08-15T14:07:25Z")

</div>

At least on the PC (haven’t tried mainframe yet) you can COMPRESS with individual members of an Xarray and, can COMPRESS #XARRAY (\*) where #Xarray is a dynamic array.

Of course, you still have the length restriction, and still cannot write a CSV work file record with an Xarray.

steve

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [August 15, 2013, 4:10pm UTC](https://techcommunity.softwareag.com/t/csv-workfile-x-array-nat6256-why/172247/7 "2013-08-15T16:10:01Z")

</div>

> [@Matthias](#):
>
> I want to use the CSV-functionality. BTW: a CSV-COMPRESS would be nice…

Already there, called [COMPRESS WITH DELIMITERS](http://techcommunity.softwareag.com/ecosystem/documentation/natural/nat6314unx/sm/compress.htm#delimiters)

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [August 16, 2013, 11:17am UTC](https://techcommunity.softwareag.com/t/csv-workfile-x-array-nat6256-why/172247/8 "2013-08-16T11:17:35Z")

</div>

> [@Wolfgang Winter](#):
>
> > [@Matthias](#):
> >
> > I want to use the CSV-functionality. BTW: a CSV-COMPRESS would be nice…
> 
> Already there, called [COMPRESS WITH DELIMITERS](http://techcommunity.softwareag.com/ecosystem/documentation/natural/nat6314unx/sm/compress.htm#delimiters)

No, it isn’t there. Try this to see the difference:

```auto
define data local
01 #struct
02 #field1 (A3) init <'1;1'>
02 #field2 (A3) init <' 2'>
02 #field3 (A3) init <'333'>
01 #a (A50)
end-define
define work file 1 '/tmp/test.csv' type 'CSV'
define work file 2 '/tmp/test.csv' type 'ASCII'
write work file 1 #struct
close work file 1
read work file 2 once #a
write 'CSV-WORKFILE............:' #a
compress #struct into #a with delimiters ';'
write 'COMPRESS WITH DELIMITERS:' #a
end
```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:29pm UTC](https://techcommunity.softwareag.com/t/csv-workfile-x-array-nat6256-why/172247/9 "2021-04-02T15:29:18Z")

</div>


