Application Development and Automation 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: 
Read only

How to skip last disgit in variable

Former Member
0 Likes
1,299

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
Read only

Former Member
0 Likes
1,260

Hi

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

Hi

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

9 REPLIES 9
Read only

Former Member
0 Likes
1,260

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.

Read only

Former Member
0 Likes
1,261

Hi

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

Read only

rainer_hbenthal
Active Contributor
0 Likes
1,260

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

Read only

Former Member
0 Likes
1,260

hi,

try this

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

Read only

Former Member
0 Likes
1,260

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

Read only

Former Member
0 Likes
1,260

Hi Sagar,

Try this way :

Data:
  VAR type i value 10.

VAR = VAR Div 10.

Write :/ VAR.

Regards,

Swapna.

Read only

Former Member
0 Likes
1,260

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.

Read only

Former Member
0 Likes
1,260

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

Read only

0 Likes
1,260

Just shift the variable 1 place right to achieve this.

Regards

Farzan