Former Member

# How to skip last disgit in variable

Hi All there,

I want to skip last digit in one of varibale how to do that?

e.g. var = 10

I want to take var = 1

Regards

Sagar

10|10000 characters needed characters exceeded

Former Member
Sep 23, 2008 at 05:39 AM

Hi

you can use command SHIFT.. in your case you can SHIFT your vairable to LEFT by 1 position.

10|10000 characters needed characters exceeded
• Former Member
Sep 23, 2008 at 05:37 AM

Suppose length of your variable is N .Then create another variable V2 and follow the below statement.

V2 = V1+0(N-1).

It'll work.

10|10000 characters needed characters exceeded
• Sep 23, 2008 at 05:39 AM

If its a numeric variable without decimals, you can just divide it by 10.

10|10000 characters needed characters exceeded
• Former Member
Sep 23, 2008 at 05:41 AM

hii

use following code

```data:
var(3) type c value 'def',
ofset(3) type c,
sub type i,
var1 type i.

var1 = strlen( var ).
sub = var1 - 1.
ofset = var+0(sub).
write var1.
write ofset.```

regards

twinkal

10|10000 characters needed characters exceeded
• Former Member
Sep 23, 2008 at 05:53 AM

Hi,

plz write the code this way , it will surely work.

```data: var1 type string.

var1 = '10'.

shift var1 right deleting trailing '0' .
write: var1.```

thanx.

10|10000 characters needed characters exceeded
• Former Member
Sep 23, 2008 at 05:40 AM

hi,

try this

var = var+1(length of your field).

10|10000 characters needed characters exceeded
• Former Member
Sep 23, 2008 at 05:42 AM

Hi Sagar,

Try this way :

```Data:
VAR type i value 10.

VAR = VAR Div 10.

Write :/ VAR.```

Regards,

Swapna.

10|10000 characters needed characters exceeded
• Former Member
Sep 23, 2008 at 06:13 AM

Hi,

All the above mentioned codes will require data type conversion. However heres a direct approach.

1. divide by 10

2. Use the arithmatic function trunc to get the integer value.

Hope this helps,

Kind Regards,

Rajat