# Trimming of Leading Zeros and Trailing Spaces

**URL:** <https://techcommunity.softwareag.com/t/trimming-of-leading-zeros-and-trailing-spaces/97936>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [August 3, 2011, 7:04pm UTC](https://techcommunity.softwareag.com/t/trimming-of-leading-zeros-and-trailing-spaces/97936 "2011-08-03T19:04:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aseem\_sharma](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@aseem\_sharma](https://techcommunity.softwareag.com/u/aseem_sharma)\
**Post date:** [August 3, 2011, 7:04pm UTC](https://techcommunity.softwareag.com/t/trimming-of-leading-zeros-and-trailing-spaces/97936/1 "2011-08-03T19:04:00Z")

</div>

I have a ADABAS file of which i have to take a backup extract in a flat file in a Variable extract format.So i read it in a waork file and add a delimiter in filler.Eg:  
1 #work  
2 #a (a50)  
2 #filler init\<‘|’\>  
2 #b (a50)

write work  
The record contains  
#a : standard text  
#b : record  
the output would be  
50 bytes | 50 bytes  
but the output should be like:  
standard text|record  
Also need to remove the leading zeros .Kindly help out for the same

---

<div class="post-metadata">

**Author:** ![Jerome\_LeBlanc](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/jerome_leblanc/32/111_2.png) [@Jerome\_LeBlanc](https://techcommunity.softwareag.com/u/Jerome_LeBlanc)\
**Post date:** [August 3, 2011, 7:26pm UTC](https://techcommunity.softwareag.com/t/trimming-of-leading-zeros-and-trailing-spaces/97936/2 "2011-08-03T19:26:40Z")

</div>

I would do something like this:

```auto

DEFINE DATA LOCAL                                         
1 #A (A) DYNAMIC                                          
1 FIELD1 (A50) INIT <'some text'>                      
1 FIELD2 (N7.2) INIT <123>                             
END-DEFINE                                                
COMPRESS NUMERIC FIELD1 FIELD2 INTO #A WITH DELIMITER '|' 
WRITE #A (AL=78)                                          
WRITE WORK FILE 1 VARIABLE #A
END                                                         
```

When done, #A contains “some text|123.4”

Two things to note:

1. COMPRESS NUMERIC preserves the decimal in the numeric field.
2. The VARIABLE option of WRITE WORK FILE allows you to write work file records with different lengths.

---

<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:00pm UTC](https://techcommunity.softwareag.com/t/trimming-of-leading-zeros-and-trailing-spaces/97936/3 "2021-04-02T15:00:41Z")

</div>


