Using CA 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?

Document ID : KB000011180
Last Modified Date : 14/02/2018
Show Technical Document Details
Introduction:

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.

Question:

Using CA 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.

Environment:
PDSMAN 7.7
Answer:

This is best accomplished in a two step job:

  1. Using SCOL and ECOL replace the desired text with a unique set of characters of the same length, so that no data shifting is required. (The unique text can be a portion of the final desired text, assuming that it will be unique throughout the entire record. This should be verified prior to executing the actual REPLACE steps.)

  2. With no ECOL specified (which defaults to LRECL), replace the new text from step 1 with the final new text of the desired length.

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 **   CA11                                    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 **   CA11                                   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 **   CA11                                   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 **   CA11                                   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 **   CA11                                   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 **   CA11                                   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 **   CA11                                   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 **   CA11                                   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:

  1. In the above example, WILDCARD was set to N so that the '+' character in the TARGET text would be interpreted as actual text (plus sign) rather than a wildcard.