on 09-20-2007 11:52 AM
hi dear,
i have requirement like as follows:-->
i retrieve sort code from t012-bankl . get the values like this 208294.
i want a space every second character like this 20 82 94.
how can i solve it . please help me as soon as possible . please give me solution in details .
Thanks .
Puneet.
hi Tripat Pal Singh,
i have use your code, it's working fine as u have take 8 lenth of values.
but FYI this field is not a constant value , varies according to condition.
if i get this value 200294345453423 then output is not accept . so please make this code for generic terms . i think require the Do w_len times ......i don't know but please use generic code for it.
if user put whatever value then output comes space after every 2 character.
Please tripat ji , do it ASAP.
Thanks for supporting.
Puneet.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i got the bug in code, run this code and see
data: W_BANKL(30),
W_TEMP(2),
W_REPL(3),
COUNT TYPE I,STR_LEN TYPE I.
W_BANKL = '200294345453423'.
write:/ w_bankl.
COUNT = 1.
DO 10 TIMES.
STR_LEN = STRLEN( W_BANKL ) - 1.
IF COUNT GE STR_LEN.
EXIT.
ENDIF.
W_TEMP = W_BANKL+COUNT(2).
CONCATENATE W_TEMP0(1) W_TEMP1(1) INTO W_REPL SEPARATED BY SPACE.
REPLACE FIRST OCCURRENCE OF W_TEMP IN W_BANKL+count WITH W_REPL.
COUNT = COUNT + 3.
ENDDO.
WRITE:/ W_BANKL.
Reward points if useful, get back in case of query...
Cheers!!!
Hi Tripat Pal Singh,
Thank you very much for your quick and descent reply.
i am very happy with your solution , it's working better.
i am giving you full point for this.
well done !!! Kudos!!!
Excellent job.
Thanks .
Puneet.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Tripat Pal Singh,
thanks for support . but i have doubt why you take DO 10 TIMES., can you explain this .
this is hard code for this field. because this field is 15 char.if data comes 223322112323231
this is max. values we get.
then why you use DO 10 times ? reply me ASAP.
Thanks
puneet.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I had to hard code it coz u required the solution ASAP, anyways i hav removed the hard coding...
check the code below, BTW u shud try to debug the code and change it according to ur preference, at sdn u'll just find solution at superficial level...
enjoy Coding...
data: W_BANKL(30),
W_TEMP(2),
W_REPL(3),
COUNT TYPE I,STR_LEN TYPE I,
w_loop type i.
W_BANKL = '200294345453423'.
w_loop = strlen( w_bankl ).
w_loop = w_loop / 2.
write:/ w_bankl.
COUNT = 1.
DO w_loop TIMES.
STR_LEN = STRLEN( W_BANKL ) - 1.
IF COUNT GE STR_LEN.
EXIT.
ENDIF.
W_TEMP = W_BANKL+COUNT(2).
CONCATENATE W_TEMP0(1) W_TEMP1(1) INTO W_REPL SEPARATED BY SPACE.
REPLACE FIRST OCCURRENCE OF W_TEMP IN W_BANKL+count WITH W_REPL.
COUNT = COUNT + 3.
ENDDO.
WRITE:/ W_BANKL.
Reward points if useful, get back in case of query...
Cheers!!!
Hi,
You can use this code, then no matter how big is the number it will come as you want.
this is the perform for it,
data : v_length type i,
v_count type i,
v_part(20) type c,
v_string(20) type c,
v_newstring(50) type c.
v_string = 'ABCDEFGHIJKL'.
clear v_newstring.
v_length = strlen( v_string ).
v_count = 0.
while v_length >= 0.
if v_length = 2.
v_part = v_string+v_count(2).
concatenate v_newstring v_part into v_newstring separated by space.
exit.
elseif v_length <= 1.
v_part = v_string+v_count(1).
concatenate v_newstring v_part into v_newstring separated by space.
exit.
endif.
v_part = v_string+v_count(2).
v_count = v_count + 2.
v_length = v_length - 2.
concatenate v_newstring v_part into v_newstring separated by space.
endwhile.
<b>Reward if useful.</b>
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Run this code, it works as per ur requirement.
data: W_BANKL(30),
W_TEMP(2),
W_REPL(3),
COUNT TYPE I,STR_LEN TYPE I.
W_BANKL = '12345678'.
COUNT = 1.
DO 7 TIMES.
STR_LEN = STRLEN( W_BANKL ) - 1.
IF COUNT GE STR_LEN.
EXIT.
ENDIF.
W_TEMP = W_BANKL+COUNT(2).
CONCATENATE W_TEMP0(1) W_TEMP1(1) INTO W_REPL SEPARATED BY SPACE.
REPLACE FIRST OCCURRENCE OF W_TEMP IN W_BANKL WITH W_REPL.
COUNT = COUNT + 3.
ENDDO.
WRITE W_BANKL.
Reward points if useful, get back in case of query...
Cheers!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi dear ,
but i don't know the values means this is the 15char field , when i get the value which is may be 10 lenght or 14 len or 4 lenth , in that case how i use offset.
it's vary values.
like this is the internal table which is store this field value.
2233445566.
123456
23456789
22334455667788
then i want to store in another table those table value like this:-
22 33 44 55 66
12 34 56
23 45 67 89
22 33 44 55 66 77 88.
then what can i do?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can take each two characters of this field in 3 different variables and concatenate them again into a single field.
Eg.
Var1 = 20
Var2 = 82
Var3 = 94
then use command concatenate var1 var2 var3 into var4 separated by space.
<b>Reward if useful.</b>
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
take the values into the charecter string and caluculate the offset value
see the value where u want to put the space value where u want
and place in the internal table
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
DATA : p_BANKL(12) TYPE C.
CONCATENATE T112-BANKL0(2) ' ' T112-BANKL2(2) + ' ' + T112-BANKL+4(2) INTO P_BANKL.
REWARD IF USEFUL.
aMIT SINGLA
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
shift t012-bankl(2) by 2 places
or write t012-bankl(2) to text1.
write t012-bankl(2)+2 to text2.
write t012-bankl(2)+4 to text3.
CONCATENATE text1 ' ' text2 ' ' text3 into text4.
write text4
Regards
Nicole
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Puneet,
Use offset operation on your sort code.
DATA V_SCODE(8).
CONCATENATE TO12-BANKL0(2) TO12-BANKL2(2) TO12-BANKL+4(2) INTO V_SCODE SEPARATED BY SPACE.
Thanks,
Vinay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
110 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.