2009 Sep 11 5:36 AM
Hi ,
I need to remove last 3 char from my varible which is char 30.
For example : WERKS = 1000 and .
I need to remove last 3 char (and) from the above varibale .Kindly guide this
Regards,
VC
Hi ,
I need to remove last 3 char from my varible which is char 30.
For example : WERKS = 1000 and .
I need to remove last 3 char (and) from the above varibale .Kindly guide this
Regards,
VC
2009 Sep 11 5:41 AM
Hi Veerachamy,
Jusy offset the value..
Example..
data:
w_char(30) type c,
wtmp(30) type c.
w_tmp = w_char+0(27).
write: w_tmp.it will remove the last three characters from the filed.
Regards
Kiran
2009 Sep 11 5:43 AM
Hi Kiran,
Thanks for your reply.
But my varible will not always char30 . it may be dynamic.how to do for this ?
Regards,
Vc
2009 Sep 11 5:52 AM
Hi veerachamy,
Just copy this code..it will work fine even if the field changes dynamically..
I took w_char as 30 char..u can give ur field name there...
data:
w_char(30) type c value 'asdfghjklpoiu',
w_tmp(30) type c,
w_tmp1 type i.
w_tmp1 = strlen( w_char ).
w_tmp1 = w_tmp1 - 3.
w_tmp = w_char+0(w_tmp1).
write: w_tmp.Hope it resolves the issue...
Regards
Kiran
2009 Sep 11 5:53 AM
Hi,
Then find string length of your variable like below.
DATA: dat(30) TYPE c,
dat1 type string,
len type i.
dat = '123456789012345678901234567890'.
len = strlen( dat ).
len = len - 3. " To remove last 3 characters
dat1 = dat(len).
2009 Sep 11 5:56 AM
shift the variable by 3 + (30 - length) places.
data : s1 type char30.
DATA : i1 type i.
s1 = 'asdasd12345'.
i1 = strlen( s1 ).
i1 = : 30 - i1, i1 + 3.
SHIFT s1 by i1 PLACES RIGHT.
WRITE s1.
2009 Sep 11 5:54 AM
hi
you can used this logic for it
data: V_CHAR(30) type c,
SWT_LENTH TYPE I,
wearks(12) value '10000'.
SWT_LENTH = STRLEN( wearks ). "get the lenth of ur variable
SWT_LENTH = SWT_LENTH - 3.
V_CHAR = wearks+0(SWT_LENTH).
write: V_CHAR.
regard
nawa
2009 Sep 11 5:56 AM
Hi
Using OFFSET Methodology,we can get that as follows:
w_char type char30,
wtmp type char27..
w_tmp = w_char+0(27).
w_tmp contains only 27 chars by not taking last 3.
Regards,
Sreeram
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |