Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to skip last disgit in variable

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

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

9 REPLIES 9

Former Member
0 Kudos

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.

Former Member
0 Kudos

Hi

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

rainer_hbenthal
Active Contributor
0 Kudos

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

Former Member
0 Kudos

hi,

try this

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Sagar,

Try this way :

Data:
  VAR type i value 10.

VAR = VAR Div 10.

Write 😕 VAR.

Regards,

Swapna.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

0 Kudos

Just shift the variable 1 place right to achieve this.

Regards

Farzan