2007 Aug 23 12:37 PM
Hi Experts,
i have a variable like name1(40) type c.
So the value for name1 is: ravi.
So in the out put it will disply along with 36 spaces in the right side of data.
So iwant to delete the right side spaces if exists,
Can nay body tell me how can i do this?
regards
2007 Aug 23 12:40 PM
SHIFT NAME1 LEFT DELETING TRAILING SPACE.
2007 Aug 23 12:38 PM
U can use TRANSLATE Command.
DATA: T(10) VALUE 'A;C:E,G.',
TRANSLATE T USING '; : , . '.
CONDENSE T NO-GAPS.
WRITE : T.
Regards,
rewards point.
2007 Aug 23 12:39 PM
Use this piece of logic to remove all the special characters from the character value input by the user..
this program wil ensure that only A-Z,a-z and 0-9 wil come in the value..rest wil be deleted
reward if helpfull.
parameters: str(100) type c default ' #ABc D%12*3) ' lower case.
data: len1 type i.
data: ofst1 type i.
data len type i value '1'.
Constants c_abcde(26) type c value 'abcdefghijklmnopqrstuvwxyz'.
str = '#ABcD%123)'.
len1 = strlen( str ).
write:/ str.
do.
if ofst1 = len1.
exit.
endif.
if str+ofst1(1) CN sy-abcde
and str+ofst1(1) CN c_abcde
and str+ofst1(1) NE SPACE
and str+ofst1(1) CN '0123456789'.
replace section offset ofst1 length len of str
with SPACE.
ofst1 = ofst1 - 1.
endif.
ofst1 = ofst1 + 1.
if str+ofst1 eq SPACE.
exit.
endif.
enddo.
write:/ str.
CONDENSE str NO-GAPS.
SHIFT str LEFT DELETING LEADING SPACE.
write:/ str.
U can also use translate command if u r sure that which all special characters u want to remove..
so its better to use my above code instead of TRANSLATE command
regards,
rewards point.
2007 Aug 23 12:39 PM
just use simple logic :
data : v_data(10) type c '0123456789'.
data v_final(62) type c.
start-of-selection.
concatenate v_data sy-abcde into v_final.
now compare field with v_final
if v_final co field.
here use concatenate field for specila charcter with space.
use search command.
endif.
rewards point.
2007 Aug 23 12:39 PM
DATA : v_str type String,
V_len type i,
v_num type i.
start-of-selection.
v_str = 'ABCD123456'.
v_len = strlen( v_str ).
do .
v_num = v_num + 1.
if v_len eq v_num.
exit.
else.
if v_str+0(v_num) ca sy-abcde.
REPLACE v_str+0(v_num) WITH space INTO v_str.
v_num = v_num - 1 .
v_len = v_len - 1.
endif.
endif.
enddo.
By using this code and logic check the fields which are containing special chars
and replace them.
Note : in one variable take all possible special charectors and check the incoming variable with this special char variable if found replace.
regards,
rewards point.
2007 Aug 23 12:40 PM
2007 Aug 23 12:40 PM
Hi,
Use 'condense' statement.
Hope it solves ur problem...
Cheers,
Simha.
2007 Aug 23 12:44 PM
Hi
Try this code.
data name1 type name1.
name1 = 'anees'.
write: name1 right-justified.
Reward if helpfull.
Anees
9886358645
2007 Aug 23 12:48 PM
Hi
Try this code.
data name1 type name1.
name1 = 'anees'.
write: name1 right-justified.
Reward if helpfull.
Anees
9886358645
2007 Aug 23 12:56 PM
Try this code.
DATA: BEGIN OF sentence,
word1 TYPE c LENGTH 30 VALUE 'She',
word2 TYPE c LENGTH 30 VALUE 'feeds',
word3 TYPE c LENGTH 30 VALUE 'you',
word4 TYPE c LENGTH 30 VALUE 'tea',
word5 TYPE c LENGTH 30 VALUE 'and',
word6 TYPE c LENGTH 30 VALUE 'oranges',
END OF sentence,
text TYPE string.
text = sentence.
CONDENSE text.
write : text.
2007 Aug 23 1:31 PM
Hi,
Try This
DATA : name(40) TYPE c VALUE 'Dhwani',
s_name(5) TYPE c VALUE 'Shah'.
CONCATENATE text name INTO text.
CONDENSE text NO-GAPS.
CONCATENATE text s_name INTO text.
WRITE : text.
2007 Aug 23 1:33 PM
Hi,
sorry made some change...
DATA : name(40) TYPE c VALUE 'Dhwani',
s_name(5) TYPE c VALUE 'Shah',
<b> text TYPE string.</b>
CONCATENATE text name INTO text.
CONDENSE text NO-GAPS.
CONCATENATE text s_name INTO text.
WRITE : text.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |