Please enable JavaScript to view this site.
This program will return a substring of the String passed in PARM1 using PARM2 as the start position and PARM3 and the return string length. You may also use this program to replace part of the string if you specify a "Replacement String" in PARM4 or Insert the "Replacement String" if you specify *YES in PARM5. By default the string will be processed from the left; if you wish to process from the right then you will need to specify *YES in PARM6.
Note: If PARM6 = *YES then PARM4 & PARM5 will be ignored as there is no replacement facility if you are processing the string from the right.
Parameter |
In |
Len |
Out |
Len |
PARM1 |
String |
132 |
Substring |
132 |
PARM2 |
Start position #1 |
3 |
- |
|
PARM3 |
Return length #2 |
3 |
- |
|
PARM4 |
Replacement String #3 |
132 |
- |
|
PARM5 |
Insert / Replace? Blank or *YES#4 |
4 |
- |
|
PARM6 |
Process String from Right? Blank or *YES#5 Note: If *YES specified then any values passed in PARM4 & PARM5 will be ignored. |
4 |
- |
|
Notes:
#1 | If the Start position is left blank, contains non numeric characters, or is greater than 131 then a Start position of 1 is assumed unless PARM6 = *YES when then end of the supplied string is assumed. |
#2 | If the Return length is left blank, contains non numeric characters, or is greater than the string length minus the start position then a Return length of “the string length minus the start position” is assumed. |
#3 | If a Replacement String is specified then this will overwrite the original string starting from the Start position for the Return length. If you wish to replace with a blank string then use ‘*BLANK’ in this parameter and set the Return length to the number of blank characters you would like. Note: This parameter will be ignored if you have specified *YES in PARM6#5. |
#4 | If *YES is specified in PARM5 and you have also specified a Replacement String [PARM4] then the Replacement String will be inserted at the Start position for the Return length and the remainder of the string [up to 132 characters] will be added to the end - from version 6.2.57. Note: This parameter will be ignored if you have specified *YES in PARM6#5. |
#5 | If *YES is specified in PARM6 then you want to return data starting from the right of the string for a number of characters. The Start position will be the right most character of the string and the Return length the number of characters to the left of the Start position to be returned - from version 6.2.63. Note: You cannot use character Replacement or Insertion when processing the string from the right. |
Parameter |
Input |
Output |
PARM1 |
Here now brown fox |
brown |
PARM2 |
10 |
|
PARM3 |
6 |
|
PARM4 |
||
PARM5 |
||
PARM6 |
Example 2 - Replace Sub String
Parameter |
Input |
Output |
PARM1 |
Here now brown fox |
Here now small fox |
PARM2 |
10 |
|
PARM3 |
6 |
|
PARM4 |
small |
|
PARM5 |
||
PARM6 |
Parameter |
Input |
Output |
PARM1 |
Here now brown fox |
Here now small brown fox |
PARM2 |
10 |
|
PARM3 |
6 |
|
PARM4 |
small |
|
PARM5 |
*YES |
|
PARM6 |
Parameter |
Input |
Output |
PARM1 |
Here now brown fox |
brown fox |
PARM2 |
||
PARM3 |
9 |
|
PARM4 |
||
PARM5 |
||
PARM6 |
*YES |