08-01-2006 9:41 AM
1). I have value ...123.
sometimes values is like ..123.
How to count number of dots (.) in that variable.
2).One more thing is I am using
DATA :
lv_var1(6) TYPE c,
lv_var2(6) type c,
lv_var3(6) type c.
( because in my SAPSCRIPT data is coming thru structure itcsy ( itcsy-value which is character ), I am taking character )
and I am calculating
lv_var3 = lv_var2 - lv_var1.
in my subroutine pool program which is used for script.
It is working fine.
Please suggest me whether I am correct or not ?
08-01-2006 10:18 AM
Hello Sam,
I think as suggested by another user to use Split. Surely, it would do the needful only if you string starts with '1' but in case it is not than it would give incorrect results.
In case it can start with any other number you can use the below logic.
1. Get the strlen of the string l_var1.
2. translate l_var1 replacing '.' with '0'.
3. write the variable with no-zero.
4. condense
5. Get the strlen again for l_var1.
6. Difference between the first and second strlen output is the number of dots.
Surely, you can use the common do..enddo logic where you read in each character and check if it is a dot and count.
Regards
Anurag
08-01-2006 9:44 AM
hi Sam,
1. Use Split statement i.e, <b>split at '1'.</b> and collect the dots in a variable and then make use of strlen statment for knowing the number of dots ..
2. I feel that what ever you are doing is correct
Regards,
Santosh
08-01-2006 9:58 AM
Hi Sam,
1. Try the code:
<b> If var CS '123' .
count = SY-FDPOS .
Endif.</b>
2. You are correct. It will work fine.
Regards,
Pragya
08-01-2006 10:18 AM
Hello Sam,
I think as suggested by another user to use Split. Surely, it would do the needful only if you string starts with '1' but in case it is not than it would give incorrect results.
In case it can start with any other number you can use the below logic.
1. Get the strlen of the string l_var1.
2. translate l_var1 replacing '.' with '0'.
3. write the variable with no-zero.
4. condense
5. Get the strlen again for l_var1.
6. Difference between the first and second strlen output is the number of dots.
Surely, you can use the common do..enddo logic where you read in each character and check if it is a dot and count.
Regards
Anurag
08-01-2006 10:29 AM
translate l_var1 replacing '.' with '0'.
what is the exact syntax to o the above .
Could any body help me.
08-01-2006 10:30 AM
translate l_var1 replacing '.' with '0'.
what is the exact syntax to o the above .
Could any body help me.
08-01-2006 10:32 AM
DATA: letters(20) TYPE C VALUE 'abcabcabcXab',
change(15) TYPE C VALUE 'aXbaYBabZacZ'.
TRANSLATE letters USING change.
Here is the syntax
Anurag
08-01-2006 10:35 AM
Hi Sam,
Try this code:
<b>REPLACE
ALL OCCURRENCES OF '.'
IN l_var1 WITH '0'.</b>
Regards,
Pragya
08-01-2006 10:39 AM
...123
or
..256
How to put spaces instead of dots (.).
I want syntax.
your help will be appreciatd.
08-01-2006 10:42 AM
Translate dot to zero.
TRANSLATE l_var1 USING '.0'.
Translate dot to space.
TRANSLATE l_var1 USING '. '.
Regards
Anurag
08-01-2006 10:42 AM
Hi Sam,
Try this code:
<b>REPLACE
ALL OCCURRENCES OF '.'
IN var1 WITH ' '.</b>
Regards,
Pragya