# WRITE WORK FILE with Edit Mask

**URL:** <https://techcommunity.softwareag.com/t/write-work-file-with-edit-mask/60438>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Linux\
**Created:** [January 17, 2006, 8:57pm UTC](https://techcommunity.softwareag.com/t/write-work-file-with-edit-mask/60438 "2006-01-17T20:57:16Z")\
**Posts on this page:** 14\
**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:** [January 17, 2006, 8:57pm UTC](https://techcommunity.softwareag.com/t/write-work-file-with-edit-mask/60438/1 "2006-01-17T20:57:16Z")

</div>

Hello all!

It’s not a real problem for me…  
But sometimes I wonder why it’s impossible to combine a “write work file” with an edit mask.  
Or is there a way I don’t know about?

Regards,

Matthias

---

<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:** [January 25, 2006, 7:57pm UTC](https://techcommunity.softwareag.com/t/write-work-file-with-edit-mask/60438/2 "2006-01-25T19:57:41Z")

</div>

Why don’t take a Printfile?

Like this Natural on Host Code?

```auto

WRITE (01) NOTITLE NOHDR USING MAP 'MYMAP'
```

You only have to cut off the Newpages with an external Tool

---

<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:** [January 25, 2006, 8:56pm UTC](https://techcommunity.softwareag.com/t/write-work-file-with-edit-mask/60438/3 "2006-01-25T20:56:00Z")

</div>

You’ll get spaces inserted between the various fields in that case, if that doesn’t matter - fine 😉

---

<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:** [January 25, 2006, 9:24pm UTC](https://techcommunity.softwareag.com/t/write-work-file-with-edit-mask/60438/4 "2006-01-25T21:24:55Z")

</div>

Which other case could afford the use of a Map other than with Spaces? The Map-Editor doesn’t take fields without space between them, or?

---

<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:** [January 25, 2006, 9:25pm UTC](https://techcommunity.softwareag.com/t/write-work-file-with-edit-mask/60438/5 "2006-01-25T21:25:19Z")

</div>

> [@Sascha Wiegandt](#):
>
> Why don’t take a Printfile?

Here’s a part of my NATURAL-code:

```auto
define data local
01 #workfile_name (A50)
01 #workfile_delimiter (A1) const <';'>
*
* ...
*
end-define

define work file 1 #workfile_name type 'ASCII'
*
* and later in the code
*
if view.logical-field
  #a := 'Y'
else
  #a := 'N'
end-if
*
write work file 1
  view.Alpha-field
  #workfile_delimiter
  view.Numeric-field
  #workfile_delimiter
  #a
```

I guess it would get more complex if i would do it with a printfile…

---

<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:** [January 25, 2006, 9:32pm UTC](https://techcommunity.softwareag.com/t/write-work-file-with-edit-mask/60438/6 "2006-01-25T21:32:26Z")

</div>

> [@Wiegandt](#):
>
> The Map-Editor doesn’t take fields without space between them, or?

No, that’s due to the “attribute bytes”

---

<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:** [January 25, 2006, 9:40pm UTC](https://techcommunity.softwareag.com/t/write-work-file-with-edit-mask/60438/7 "2006-01-25T21:40:04Z")

</div>

> [@Matthias](#):
>
> > [@Sascha Wiegandt](#):
> >
> > Why don’t take a Printfile?
> 
> Here’s a part of my NATURAL-code:
> 
> ```auto
> define data local
> 01 #workfile_name (A50)
> 01 #workfile_delimiter (A1) const <';'>
> *
> * ...
> *
> end-define
> 
> define work file 1 #workfile_name type 'ASCII'
> *
> * and later in the code
> *
> if view.logical-field
> #a := 'Y'
> else
> #a := 'N'
> end-if
> *
> write work file 1
> view.Alpha-field
> #workfile_delimiter
> view.Numeric-field
> #workfile_delimiter
> #a
> ```
> 
> I guess it would get more complex if i would do it with a printfile…

Looks like you want to write a csv-File. Why don’t use:

```auto

compress view.Alpha-field view.Numeric-field with delimiter ';' into #av leaving no space 
```

On Open Systems Alpha lenght Variable is a good type for that. On Host (Nat 3.2.1) its not possible.

---

<div class="post-metadata">

**Author:** ![Ralph\_Zbrog](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ralph_zbrog/32/78_2.png) [@Ralph\_Zbrog](https://techcommunity.softwareag.com/u/Ralph_Zbrog)\
**Post date:** [January 26, 2006, 7:18am UTC](https://techcommunity.softwareag.com/t/write-work-file-with-edit-mask/60438/8 "2006-01-26T07:18:05Z")

</div>

I agree that an edit mask specification on a field in a WRITE WORK statement would be a nice enhancement.

But for your specific requirement, change the IF to a MOVE EDITED as in

MOVE EDITED view.logical-field (EM=‘N’/‘Y’) TO #A

You can get fancy and use something like (EM=‘False’/‘True’)

---

<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:** [January 26, 2006, 1:12pm UTC](https://techcommunity.softwareag.com/t/write-work-file-with-edit-mask/60438/9 "2006-01-26T13:12:25Z")

</div>

> [@](#):
>
> MOVE EDITED view.logical-field (EM=‘N’/‘Y’) TO #A

OK, my code was just a excerpt of a bigger program. Normally I’m doing much more inside my if-statements…

But I guess you agree, that the following code would be the best solution:

```auto
write work file 1
   view.date-field (EM=YYYY-MM-DD)
   #workfile_delimiter
   view.logical-field (EM='N'/'Y')
   #workfile_delimiter
```

---

<div class="post-metadata">

**Author:** ![Peter\_Pag](https://avatars.discourse-cdn.com/v4/letter/p/eb9ed0/32.png) [@Peter\_Pag](https://techcommunity.softwareag.com/u/Peter_Pag)\
**Post date:** [January 26, 2006, 1:13pm UTC](https://techcommunity.softwareag.com/t/write-work-file-with-edit-mask/60438/10 "2006-01-26T13:13:02Z")

</div>

> [@Wiegandt](#):
>
> ```auto
> 
> compress view.Alpha-field view.Numeric-field with delimiter ';' into #av leaving no space 
> ```

By the way, to create CSV you always should use COMPRESS NUMERIC, otherwise signs and decimal points get lost.

---

<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:** [January 26, 2006, 3:36pm UTC](https://techcommunity.softwareag.com/t/write-work-file-with-edit-mask/60438/11 "2006-01-26T15:36:09Z")

</div>

As i said - With Nat 3.2.1 i can’t use compress because of max. Alpha 253 or A1/1:32000. But thank you for this hint. If i get in Future Nat4.2 i would know it 🙂

But on 3.2 i normaly generate a subprogramm which uses the input parameter area and write it down in csv-structure with also changing types from logical and nummeric to text.

---

<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:** [January 26, 2006, 5:16pm UTC](https://techcommunity.softwareag.com/t/write-work-file-with-edit-mask/60438/12 "2006-01-26T17:16:48Z")

</div>

> [@Sascha Wiegandt](#):
>
> Why don’t use:
> 
> ```auto
> compress view.Alpha-field view.Numeric-field with delimiter ';' into #av leaving no space 
> ```

There are at least three reasons:

NAT0285 (when I run your code)  
NAT0100 (if I use a logical field inside compress)  
NAT0023 (if I use an Edit Mask inside compress)

---

<div class="post-metadata">

**Author:** ![Angel\_Mendoza\_O](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Angel\_Mendoza\_O](https://techcommunity.softwareag.com/u/Angel_Mendoza_O)\
**Post date:** [January 31, 2006, 11:26pm UTC](https://techcommunity.softwareag.com/t/write-work-file-with-edit-mask/60438/13 "2006-01-31T23:26:52Z")

</div>

Think

I’ve been a programmer for 15 years, and today I learned something new.

a new trick

```auto
MOVE EDITED view.logical-field (EM='N'/'Y') TO #A
```

---

<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, 2:40pm UTC](https://techcommunity.softwareag.com/t/write-work-file-with-edit-mask/60438/14 "2021-04-02T14:40:24Z")

</div>


