The REPLACE statement instructs PDSM18 to scan selected members for a specified target string and then replace the target string with a specified new string. You can code multiple REPLACE control statements, in any order.
Using PDSMAN, how can I change the first few characters of a record with a longer string that shifts remaining data, yet will not also change the same characters if they occur in another location in the record?
For example, we need to restrict the replacement to the first few characters of the record, replacing six characters with seven so shifting the remaining record data is needed.
I have a REPLACE command using SHIFTOPT=2 (the rest of the line following the replacement is simply shifted left or right as required, effectively adding blanks to, or removing blanks from the rightmost position of the line).
If SCOL (start column) and ECOL (end column) are defined to the section of the record where the changes should be limited, shifting only occurs within that SCOL/ECOL section causing a truncation of the data.
This is best accomplished in a two step job:
FOR EXAMPLE:
Change Col 1-4 from '+ABC' to 'DEFGHI!'. Shift the remaining record data to the right and do not replace any text beyond those first columns.
STEP 1: Replace first four characters of the record ? (If 'DEFG' occurs elsewhere in any of the records, a different four characters would have been necessary.)
PDSMAN r7.7 GLOBAL STRING SCAN/REPLACE
** PDSM18 ** SYSID CONTROL STATEMENT EDIT
SEQ CONTROL STATEMENT
----- -------------------------------------------------------------------------
OPT OPTION LISTMEM=N MISSMSG=N WILDCARD=N TRANSLATE=N
SCOL=1 ECOL=4
TRANSNEW=Y SHIFTOPT=2 BEFOREIMAGE=Y SIMULATE=N FORCE=Y
1 REPLACE TARGET='+ABC'
NEW='DEFG'
PDSMAN r7.7 GLOBAL STRING SCAN/REPLACE
** PDSM18 ** SYSID USER01.MY.CNTL
FLG LINENO --- HITS/REPLACES FOUND FOR MEMBER PDSMTEST ---
OLD 1 +ABCaaaaaaaaaaabbbbbbbbbbbbccccc
NEW 1 DEFGaaaaaaaaaaabbbbbbbbbbbbccccc
OLD 2 +ABC +abc +ABC bbbbbbbccccc
NEW 2 DEFG +abc +ABC bbbbbbbccccc
END OF REPORT
PROCESSING COMPLETED - HIGHEST RETURN CODE WAS 0000
STEP 2: Change this new unique 4-character text to the final seven characters that is required...
PDSMAN r7.7 GLOBAL STRING SCAN/REPLACE
** PDSM18 ** SYSID CONTROL STATEMENT EDIT
SEQ CONTROL STATEMENT
----- -------------------------------------------------------------------------
OPT OPTION LISTMEM=N MISSMSG=N WILDCARD=N TRANSLATE=N
SCOL=1
TRANSNEW=Y SHIFTOPT=2 BEFOREIMAGE=Y SIMULATE=N FORCE=Y
1 REPLACE TARGET='DEFG'
NEW='DEFGHI!'
PDSMAN r7.7 GLOBAL STRING SCAN/REPLACE
** PDSM18 ** SYSID USER01.MY.CNTL
FLG LINENO --- HITS/REPLACES FOUND FOR MEMBER PDSMTEST ---
OLD 1 DEFGaaaaaaaaaaabbbbbbbbbbbbccccc
NEW 1 DEFGHI!aaaaaaaaaaabbbbbbbbbbbbccccc
OLD 2 DEFG +abc +ABC bbbbbbbccccc
NEW 2 DEFGHI! +abc +ABC bbbbbbbccccc
END OF REPORT
PROCESSING COMPLETED - HIGHEST RETURN CODE WAS 0000
If ECOL had not been used in the first step, or if this had been done in one step, additional characters in record 2 would have been changed as follows:
PDSMAN r7.7 GLOBAL STRING SCAN/REPLACE
** PDSM18 ** SYSID CONTROL STATEMENT EDIT
SEQ CONTROL STATEMENT
----- -------------------------------------------------------------------------
OPT OPTION LISTMEM=N MISSMSG=N WILDCARD=N TRANSLATE=N
SCOL=1
TRANSNEW=Y SHIFTOPT=2 BEFOREIMAGE=Y SIMULATE=N FORCE=Y
1 REPLACE TARGET='+ABC'
NEW='DEFG'
PDSMAN r7.7 GLOBAL STRING SCAN/REPLACE
** PDSM18 ** SYSID USER01.MY.CNTL
FLG LINENO --- HITS/REPLACES FOUND FOR MEMBER PDSMTEST ---
OLD 1 +ABCaaaaaaaaaaabbbbbbbbbbbbccccc
NEW 1 DEFGaaaaaaaaaaabbbbbbbbbbbbccccc
OLD 2 +ABC +abc +ABC bbbbbbbccccc
NEW 2 DEFG +abc DEFG bbbbbbbccccc
END OF REPORT
PROCESSING COMPLETED - HIGHEST RETURN CODE WAS 0000
PDSMAN r7.7 GLOBAL STRING SCAN/REPLACE
** PDSM18 ** SYSID CONTROL STATEMENT EDIT
SEQ CONTROL STATEMENT
----- -------------------------------------------------------------------------
OPT OPTION LISTMEM=N MISSMSG=N WILDCARD=N TRANSLATE=N
SCOL=1
TRANSNEW=Y SHIFTOPT=2 BEFOREIMAGE=Y SIMULATE=N FORCE=Y
1 REPLACE TARGET='DEFG'
NEW='DEFGHI!'
PDSMAN r7.7 GLOBAL STRING SCAN/REPLACE
** PDSM18 ** SYSID USER01.MY.CNTL
FLG LINENO --- HITS/REPLACES FOUND FOR MEMBER PDSMTEST ---
OLD 1 DEFGaaaaaaaaaaabbbbbbbbbbbbccccc
NEW 1 DEFGHI!aaaaaaaaaaabbbbbbbbbbbbccccc
OLD 2 DEFG +abc DEFG bbbbbbbccccc
NEW 2 DEFGHI! +abc DEFGHI! bbbbbbbccccc
END OF REPORT
PROCESSING COMPLETED - HIGHEST RETURN CODE WAS 0000
NOTE: