1). Shift: truncates a string.
Shift {c} [by {n} Places] [{mode}].:
Purpose: remove the first n characters of the string. If n is not specified, the default value is 1. If the specified N is less than or equal to 0, the string remains unchanged. If N exceeds the length of the string, the string is null. Therefore, pay attention to n when you perform this operation. You can obtain the length of the string by Len = strlen (c ).
Mode: Specifies the direction of string truncation.
Left: Truncated from the left
Right: truncation from the right
Circular: place the character on the left to the right.
Shift {c} Up to {STR} {mode }.:
Purpose: Remove all the characters in the string before 'str'. You can also specify the mode. The principle is the same as above.
Shift {c} Left deleting leading {STR }.
Shift {c} Right deleting trailing {STR }.:
Purpose: remove the (left) or (right) character STR before the string C.
Common scenarios for the preceding statements:
A. Remove the leading characters from the string. For example, if ALV determines that a field is a 10-character with so, Po, and other numbers in it, and you do not want to display the preceding 0, you can do this: shift {c} Left deleting leading 0.
B. If you know that a string contains a fixed character and want to delete the character before the fixed character, you can use Shift {c} Up to {STR }. For example, an item adds a prefix to mga00002 and mga00003 by enhancing the prefix. The prefix is the data obtained in a fixed value table. In the specific display, remove the prefix. If you want to remove te In the TE-MRP-MAT1, MRP indicates that the material is running MRP, the requirement requires that the Te-remove, MRP can be obtained in the fixed value table, you can use Shift {c} Up To 'mrp '.
2) shift <C> [by <n> places] [<mode>].
Move a string by the given number of locations
This statement moves <C> <n> fields. If by <n> places is omitted, <n> is interpreted as a position. If <n> is 0 or a negative value, <C> the value remains unchanged. If the length of <n> exceeds <C>, <C> enter a space. <N> can be a variable.
For different (<mode>) options, you can move the field <C>:. left: Move to the left <n> position, and fill the right with <n> spaces (default ). B. Right: Move right to the <n> position, and fill the left with <n> spaces. C. Circular: Move to the left <n> position so that <n> characters on the left appear on the right.
Move a field to a specified string
Shift <C> up to <STR> <mode>. ABAP/4 searches for the <C> Field content until the <STR> string is found and the <C> field is moved to the edge of the field. <Mode> the options are the same as those described in moving field strings by given positions. <STR> it can be a variable.
If <C> cannot find <STR>, set the SY-SUBRC to 4 without moving <C>. Otherwise, set SY-SUBRC to 0.
Move the field string based on the first or last character
If the first or last character meets certain conditions, the shift statement can be used to move the field to the left or right. Therefore, use the following syntax: shift <C> Left deleting leading <STR>. shift <C> right deleting trailing <STR>. if the first character on the left or the last character on the right appears in <STR>, this statement moves the field <C> to the left or right. Fill the right or left of the field with spaces. <STR> it can be a variable.