‎2006 Mar 21 10:00 PM
hi folks,
I have small confusion with the use of SHIFT.
when do you use 'LEFT DELETING LEADING' and 'RIGHT DELETING TRAILING'
because I have a character variable
z1 = Operation# and I need to get rid of the '#'. I have declared z1 as char type.
I need to get it clarified once for all.
Thanks
Vinu.
‎2006 Mar 21 10:04 PM
Hi Vinu,
The best explanation is given in F1 help with example..
Shifts the contents of c to the left or right for as long as the string begins or ends with a character contained in c1.
If c does not begin or end with a character from c1, it remains unchanged.
Example
DATA: ALPHABET(15) VALUE ' ABCDEFGHIJ',
M1(4) VALUE 'ABCD',
M2(6) VALUE 'BJJCA '.
SHIFT ALPHABET LEFT DELETING LEADING M1.
The field ALPHABET remains unchanged.
SHIFT ALPHABET LEFT DELETING LEADING SPACE.
The field ALPHABET now has the following contents:
'ABCDEFGHIJ '.
SHIFT ALPHABET RIGHT DELETING TRAILING M2.
ALPHABET now has the following contents:
' ABCDEFGHI'.
‎2006 Mar 21 10:08 PM
Hi Vinu,
When you use SHIFT (LEFT/RIFGT) pl note that the left or right of the field is then padded with blanks. If you do not want the blanks, you are better off moving the field contents using offsets.
Regards,
Suresh Datti
‎2006 Mar 21 10:07 PM
myvariable = 'xxx123'.
SHIFT myvariable LEFT DELETING LEADING 'x'.
WRITE:/ myvariable.The output in this case will be '123'.
myvariable = '123xxx'.
SHIFT myvariable RIGHT DELETING TRAILING 'x'.
WRITE:/ myvariable.The output in this case will be
' 123'.
‎2006 Mar 21 10:09 PM
Is that really a '#' or is it some special character like tab that got uploaded from a file? When you upload a file that has special characters, you will see '#' in the contents, but when you try to remove it using any of the string operations you will not be able to do it.
‎2006 Mar 21 10:25 PM
Thanks but the syntax is not working in the program when I am trying to remove the trailing '#' sign.
ZAUS02 = itab_in-aus02 ( the value is Operation#)
and aus02 is CHAR(10) declared in the itab.
SHIFT ZAUS02 RIGHT DELETING TRAILING '#'.
After that I have to compare the value in ZAUS02 USING if CONDITION.
IF ZAUS02 = 'Operation'
.
..
I hope you got the point here.
Thanks
Vinu.
‎2006 Mar 21 10:29 PM
You would have to shift it back to the left removing leading spaces. Try using replace instead.
Rob
‎2006 Mar 21 10:39 PM
Infact I tried that but it did not work, so I came to this, It's so simple but what am I missing here?
Vinu
‎2006 Mar 21 10:41 PM
Did you se the code I posted? You can just cut and paste it to see if it does what you want.
Rob
‎2006 Mar 21 10:45 PM
Srinivas, you are right, it comes from the external file in the .csv format, hecne I am not able to remove it.
But in a similar case in a different program I was able to remove the leading '##' signs using 'left DELETING leading' syntax for the value getting from the flat file.
why not here?
Thanks
Vinu
‎2006 Mar 21 10:58 PM
‎2006 Mar 21 11:02 PM
Then try:
DATA : code TYPE x VALUE '09'.
REPLACE code WITH '' INTO z1.
Rob
‎2006 Mar 21 11:07 PM
Folks, I got the issue.
Please help with the logic.
For the field 'ZAUS02' i AM READING THE VALUE from flat file the length of the field is CHAR10.
when the value is less than 10 it reads the value as with a trailing '#' like in 'Operation#'
Only in such case I need to get rid of the '#' sign and when the value of the field is equal to the size 10 no '#' sign is displayed.
then i go it works fine to check the IF condition..
Foe example:
ZAUS02 = Functional
it is fine
if ZAUS02 = 'Functional'
.
.
elseif ZAUS02 = 'Operation' (for this ZAUS02 needs to get rid of the # sign)
.
.
This is what I am trying to achieve here.
Thanks
Vinu
.
that's fine
‎2006 Mar 21 11:12 PM
Assuming the # is really a tab, the (second) code I posted should work. It did when i tested it. If it's not a tab, you'll have to find out the hex value of it.
Rob
‎2006 Mar 21 11:22 PM
I am sorry Rob, I did not understand the 'code' can you elaborate on it ?
Thanks.
Vinu
‎2006 Mar 21 11:28 PM
The variable CODE is a one byte hex field with the value X'09' (which I believe is the value of a tab). If you replace any instances of X'09' with a blank or null, it should get rid of it.
Do a F1 on DATA->Simple field definition->Addition 1 (type). It's discussed there.
Rob
Does this help:
DATA : tab TYPE x VALUE '09'.
REPLACE tab WITH '' INTO z1.Message was edited by: Rob Burbank
‎2006 Mar 21 11:43 PM
Sorry Rob, both did not work, I find it really strange, because for an earlier program I used the 'SHIFT' command to eliminate the leading '#' for the values and was able to upload.
That was a Numeric char variable and this is a char variable.
Thanks foryour help. Let me know if You have any leads to it, I shall continue working on it.
I shall ward the points and keep the thread open.
Vinu.
‎2006 Mar 21 11:52 PM
SHIFT or REPLACE should work equally well.
Sorry it didn't work out, but remember others helped as well. Srinivas was the one who figured out your problem wasn't with the character '#'.
If you want, paste the portion of your code that you're having trouble with. I can look at it later.
Rob
Message was edited by: Rob Burbank
‎2006 Mar 22 12:03 AM
how about the Contains string variant:
IF ZAUS02 CS 'Operation'.
‎2006 Mar 22 12:05 AM
Last try - declare a variable:
DATA : var.
make sure you have 'Operation#' in z1, then:
MOVE z1+9(1) TO var. "Make sure it's the last char
REPLACE var WITH '' INTO z1.
Rob
‎2006 Mar 22 1:21 AM
Hi Vinu,
did you try this ..
DATA: z1(20) VALUE 'Operation#'.
replace all occurrances of CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB In Z1 with space .regards
satesh
‎2006 Mar 21 10:10 PM
Hi Vinu,
Please take a look at this link for sample code.
http://www.kabai.com/abaps/z82.htm
Hope this will help.
Regards,
Ferry Lianto
‎2006 Mar 21 10:15 PM
Hi Vinu,
DATA: TEXT(10) VALUE 'Operation#'.
SHIFT TEXT RIGHT DELETING TRAILING '#'.
write:/ TEXT.
‎2006 Mar 21 10:24 PM
Why not just use REPLACE:
DATA: z1(20) VALUE 'Operation#'.
REPLACE '#' WITH '' INTO z1.
Rob