02-29-2008 5:30 AM
Hello,
I have the charactor as "00002A" OR "00001D".
Here I want to change 00002A to 21, means, A is 1, B is 2, C is 3 and so on..
Same 00001D sould become 14.
How to achieve this functionality?
Thanks,
Shreekant
02-29-2008 5:45 AM
Hi,
Assumptions :
1. Length should be same for all
2. LAst 2 chars only get the values.
DATA : v_string(10) VALUE '00002A' ,
v_cnt TYPE I,
v_cnt1 TYPE I,
v_cnt3 TYPE I,
v_data(2) ,
v_data1(5).
v_cnt = Strlen( v_string ).
v_cnt1 = v_cnt - 2.
v_data = v_string+v_cnt1(2).
v_data1 = v_data+1(1).
CASE v_data1.
WHEN 'A'.
v_cnt3 = 1.
CONCATENATE v_data1+0(1) v_cnt3 INTO v_data1.
WHEN 'B'.
v_cnt3 = 2.
CONCATENATE v_data1+0(1) v_cnt3 INTO v_data1.
ENDCASE.
Like you can calculate .But if data length is dynamic and if last letter is 'J' value will be 10 so adjust your program dynamically.
Reward if useful....
02-29-2008 5:36 AM
hi,
Search for the alphabet and replace it with the value.
u can use 'SEARCH' command for this.
SEARCH
Searches for a string.
Syntax
SEARCH <f>|<itab> FOR <g> [ABBREVIATED]
[STARTING AT <n1>]
[ENDING AT <n2>]
[AND MARK].
Searches the field <f> or the table <itab> for the string in field <g>. The result is placed in the system field SY-FDPOS. The additions allow you to hide intermediate characters, search from and to a particular position, and convert the found string into uppercase.
REPLACE
Replaces strings in fields with another string.
Syntax
REPLACE <str1> WITH <str2> INTO <c> [LENGTH <l>].
This statement searches the first occurrence of the first <l> characters of the search pattern <str1> in field <c> and replaces them with the string <str2>.
Hope this helps u,
Arunsri
02-29-2008 5:45 AM
Hi,
Assumptions :
1. Length should be same for all
2. LAst 2 chars only get the values.
DATA : v_string(10) VALUE '00002A' ,
v_cnt TYPE I,
v_cnt1 TYPE I,
v_cnt3 TYPE I,
v_data(2) ,
v_data1(5).
v_cnt = Strlen( v_string ).
v_cnt1 = v_cnt - 2.
v_data = v_string+v_cnt1(2).
v_data1 = v_data+1(1).
CASE v_data1.
WHEN 'A'.
v_cnt3 = 1.
CONCATENATE v_data1+0(1) v_cnt3 INTO v_data1.
WHEN 'B'.
v_cnt3 = 2.
CONCATENATE v_data1+0(1) v_cnt3 INTO v_data1.
ENDCASE.
Like you can calculate .But if data length is dynamic and if last letter is 'J' value will be 10 so adjust your program dynamically.
Reward if useful....
02-29-2008 6:10 AM
data: alpha type c length 26 value 'ABCDE...XYZ'.
store all alphabets in it form A to Z
data: var, var1 type c value '00002A'. "watever ur value is
data: moff type i.
find first occurence of var+5(1) in alpha match offset moff.
concatenate var+0(5) moff into var1.
var 1 will have the value dat u want..
This will do..
Reward !!!