# Doing a right trim for a string

**URL:** <https://techcommunity.softwareag.com/t/doing-a-right-trim-for-a-string/79591>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes, Natural-on-Windows-Unix\
**Created:** [November 25, 2008, 10:23am UTC](https://techcommunity.softwareag.com/t/doing-a-right-trim-for-a-string/79591 "2008-11-25T10:23:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sriramp](https://avatars.discourse-cdn.com/v4/letter/s/bc79bd/32.png) [@sriramp](https://techcommunity.softwareag.com/u/sriramp)\
**Post date:** [November 25, 2008, 10:23am UTC](https://techcommunity.softwareag.com/t/doing-a-right-trim-for-a-string/79591/1 "2008-11-25T10:23:42Z")

</div>

Hi,  
I need to perform a right justification on a string. For eg,

#STR = "ROBERT SCHAZZ "

I want the content of #STR to be just “ROBERT SCHAZZ”

Is there any specific keyword in Natural to remove the extra spaces from the end?

Thanks in Advance  
Sam

---

<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:** [November 25, 2008, 4:03pm UTC](https://techcommunity.softwareag.com/t/doing-a-right-trim-for-a-string/79591/2 "2008-11-25T16:03:52Z")

</div>

> [@isami777](#):
>
> Is there any specific keyword in Natural to remove the extra spaces from the end?

On Natural for Windows, there is a System funktion called \*TRIM.

For Example:

```auto
DEFINE DATA LOCAL
1 #a (A) DYNAMIC init <"ROBERT SCHAZZ ">
end-define
display *LENGTH(#a)
#a := *TRIM(#a)
display *LENGTH(#a)
end
```

---

<div class="post-metadata">

**Author:** ![Finn\_the\_Dane1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/finn_the_dane1/32/132_2.png) [@Finn\_the\_Dane1](https://techcommunity.softwareag.com/u/Finn_the_Dane1)\
**Post date:** [November 25, 2008, 6:33pm UTC](https://techcommunity.softwareag.com/t/doing-a-right-trim-for-a-string/79591/3 "2008-11-25T18:33:44Z")

</div>

What about a simple  
COMPRESS #A INTO #A  
This should work also on NAT MF versions without the trim()  
Finn

---

<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:** [November 26, 2008, 12:03am UTC](https://techcommunity.softwareag.com/t/doing-a-right-trim-for-a-string/79591/4 "2008-11-26T00:03:58Z")

</div>

With a DYNAMIC variable a simple MOVE ‘ROBERT SHAZZ’ TO #STR will suffice.

On a mainframe, without a DYNAMIC variable, you would have to explain your desired output a bit more. Suppose #STR is defined as A20. Do you want ROBERT SHAZZ followed by binary zeroes?

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:** [April 2, 2021, 2:51pm UTC](https://techcommunity.softwareag.com/t/doing-a-right-trim-for-a-string/79591/5 "2021-04-02T14:51:12Z")

</div>


