05-16-2009 6:37 AM
Hi,
I have a requirement in my code where I need to keep trailing spaces after the value.
Say, the value is ABC with 2 spaces before ABC and 4 spaces after ABC.
' ABC '
I want to remove the spaces before ABC but want the spaces that exist after ABC.
Thanks,
Sim
05-16-2009 7:06 AM
Hi,
You can use SHIFT statement.
data: v_var type char6 value ' ABC '
SHIFT v_var LEFT DELETING LEADING space.
write:/ v_var.
Output will be ABC .
Regards,
Nikhil
05-16-2009 6:57 AM
05-16-2009 7:00 AM
Hi,
Refer [Link|http://help.sap.com/saphelp_nw2004s/helpdata/en/79/c554d9b3dc11d5993800508b6b8b11/content.htm] on how to use CL_ABAP_CHAR_UTILITIES=>CR_LF (CRLF Carrige Return + Line Feed). You have to write CRLF at the end of your string to retain the trailing spaces.
Regards
Shital
05-16-2009 7:02 AM
Hi SIm,
Check this example for leading spaces --
SHIFT c BY n PLACES.
This command Shifts the contents of c by n places to the left. This statement has the same semantics as repeating the simple SHIFT statement n times.
Example
DATA: ALPHA1(10) TYPE C VALUE 'ABCDEFGHIJ',
ALPHA2 TYPE STRING,
FIVE TYPE I VALUE 5.
ALPHA2 = ALPHA1.
SHIFT ALPHA1 BY FIVE PLACES.
SHIFT ALPHA2 RIGHT BY 2 PLACES.
ALPHA1 now has the contents 'FGHIJ____ ' and ALPHA2 the contents '__ABCDEFGHIJ'.
To delete the spaces before
SHIFT c LEFT DELETING LEADING space.
Regards,
Pankaj
Edited by: Pankaj Singh on May 16, 2009 11:32 AM
05-16-2009 7:06 AM
Hi,
You can use SHIFT statement.
data: v_var type char6 value ' ABC '
SHIFT v_var LEFT DELETING LEADING space.
write:/ v_var.
Output will be ABC .
Regards,
Nikhil
05-16-2009 7:40 AM
How do I remove both leading and training spaces from a statement. SHIFT LEFT is working fine....but SHIFT w_sameena LEFT DELETING LEADING '*' does not seem to work in my code.
The field value is ***ABCCDE*FGHI**JKL****
and I want the o/p as ABC*CDE*FGHI***JKL
Regards,
Sameena