01-28-2008 9:40 AM
Hi to all,
here i have three fields,
f1 length 18 char,
f2 length 4 char,
f3 length 4 char,
now i want to take last 4 char of f1 to f2 and the same i have to pass to f3.
how to do this?
regards,
swami
01-28-2008 9:44 AM
f2 = f1+14(4)
Alternatively you can use strlen() to get the length of the field and adjust accordingly
l_len = strlen(f1)
subtract 4 from l_len
f2 = f1+l_len(4)
01-28-2008 9:46 AM
f1 length 18 char,
f2 length 4 char,
f3 length 4 char,
f2 = f1 + 15(4).
move f2 to f3.
Pls reward pts if help.
01-28-2008 9:46 AM
DATA : l_var(12) VALUE 'SOMETEXT'. "this logic works on any length not only 18 chars
DATA : l_len TYPE i.
l_len = strlen( l_var ).
l_len = l_len - 4 .
"your case..
f2 = f3 = l_var+l_len(4).
01-28-2008 9:46 AM
Hi,
pls refer the below sample code.
data:
f1(18) type c value 'asjfkas',
f2(4) type c,
f3(4) type c,
l_len type i.
l_len = strlen( f1 ).
l_len = l_len - 4.
f2 = f1+l_len(4).
f3 = f2.
write:/ f2, f3.
Reward if useful.
Thanks,
Sreeram.
01-28-2008 9:46 AM
V1 = f1 + 15(4) ,
concatenate f2 V1 into f2,
concatenate f3 V1 into f3.
Reward if useful
01-28-2008 9:46 AM
01-28-2008 9:47 AM
Hi,
w_int = 18 - 4.
w_str = f1+w_int(4).
w_str1 =f2+w_int(4).
concatenate w_str w_str1 into f3.
Plzzz reward points if it helps.
01-28-2008 9:48 AM
Hi ,
do like this
f2 = f1+14(4).
f3 = f2.
+<postion> ( length )
reward and close if answered,
taher
01-28-2008 9:54 AM
Hi Swami,
You can use offset of f1, ie
f1 +14(4). then concatenate f1 and f2 and pass to f3.
I think it solves ur problem.
Regards,
DVNS.
01-28-2008 10:03 AM
Hi,
1. Take the maximum length of the field. Pass it to an integer variable. Lets say L1.
2. Subtract this variable by 4. Move this value to another variable. Lets say L2.
3. WRITE F1+L2(4) TO F3.
Sample Code.
REPORT zmaytest.
DATA : f1 TYPE string VALUE 'abcdefghijk',
f2(4) TYPE C,
f3(4) TYPE C.
DATA : l1 TYPE i,
l2 TYPE i.
START-OF-SELECTION.
l1 = STRLEN( f1 ).
l2 = l1 - 4.
WRITE f1+l2(4) TO f2.
WRITE f1+l2(4) TO f3.
WRITE: / 'F2', F2.
WRITE: / 'F3', F3.
Regards,
Mayank
01-28-2008 10:41 AM
Hi,
Use following statement,you will get result.Reward me
data a TYPE string VALUE 'abcdef'.
SHIFT a BY 4 PLACES RIGHT CIRCULAR .
WRITE a+(4).
L.Velu
01-28-2008 11:16 AM
Hi Dear,
U can write like this.
f1_last4char = f1+14(4).
move f1_last4char to f2.
move f2 to f3.
If it helps reward me points.
Regards
AshokChowdhary