JCL

Replace Low Values with Spaces using SORT

Many times LOW VALUES are present in the input file and the job abends. For a quick fix, developers have to replace LOW VALUES with SPACES or any other value like ZERO. Let’s take a look at the solution to the below-mentioned issues.

  • How to replace all LOW-VALUES (X’00’) in a file with SPACE (X’40’). The low values can show up anywhere; they aren’t in fixed positions.
  • How to replace all the occurrences of one character (say ‘a’) with another character (say ‘b’) in a sequential file.
  • How to replace specified fields (say ‘LOW-VALUES (X’00’) in the first 20 bytes) instead of all the occurrences in the entire record in a sequential file.

Replace Low Values using FINDREP

FINDREP feature of INREC, OUTREC, OUTFIL can be used to replace specified characters anywhere in your records with other characters. So we can change all low values (X’00’) to spaces (X’40’) in an FB or VB data set.

//SYSIN    DD  *                       
  OPTION COPY                           
  OUTREC FINDREP=(IN=X'00',OUT=X'40')   
/* 

If you want to change all ‘a’ (X’81’) and ‘x’ (X’A7′) characters to ‘b’ (X’82’) and ‘y’ (X’A8′) characters, respectively, in an FB or VB data set

//SYSIN    DD  *                       
  OPTION COPY                           
  OUTREC FINDREP=(INOUT=(C'a',C'b',C'x',C'y'))   
/* 

You can make your changes to specified fields instead of to the entire record. This comes in handy when you have mixed character and numeric fields in your records and want to avoid making changes to the numeric fields. IFTHEN reformat different records in different ways by specifying how to build, overlay, find/replace, or group operation items are applied to records that meet given criteria.

For example, if you had an FB input file that had characters in bytes 1-20, a PD field in bytes 21-25, and characters in bytes 26-80, you could change zeros to spaces in the character fields using:

INREC IFTHEN=(WHEN=INIT,                            
      FINDREP=(STARTPOS=1,ENDPOS=20,IN=X'00',OUT=X'40')), 
      IFTHEN=(WHEN=INIT,                      
      FINDREP=(STARTPOS=26,ENDPOS=80,IN=X’00',OUT=X'40')) 

By not using FINDREP for the PD field, we avoid changing PD values incorrectly, such as from X’000000001C’ (P’1′) to X’404040401C’ (P’404040401′).

Let’s say I have to replace all leading Low Values(X’00) in positions 1 to 5 with spaces (X’40’).

//SYSIN DD *
  OPTION COPY
  INREC 
  IFTHEN=(WHEN=(1,5,CH,EQ,X'00'),OVERLAY=(5X'40')),
  IFTHEN=(WHEN=(1,4,CH,EQ,X'00'),OVERLAY=(4X'40')),
  IFTHEN=(WHEN=(1,3,CH,EQ,X'00'),OVERLAY=(3X'40')),
  IFTHEN=(WHEN=(1,2,CH,EQ,X'00'),OVERLAY=(2X'40')),
  IFTHEN=(WHEN=(1,1,CH,EQ,X'00'),OVERLAY=(X'40'))
/*

Replace Low Values using ALTSEQ

In SORT, we have the keyword ALTSEQ, which can be used to change all the occurrences of a char to another desired character. It can be used to change the low-values or high-values to spaces in a file. Here’s an example of how you could change all low values (X’00’) to spaces (X’40’), in an FB data set with an LRECL of 80:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=YOUR INPUT FILE,
//            DISP=SHR
//SORTOUT  DD DSN=YOUR OUTPUT FILE,
//            DISP=(NEW,CATLG,DELETE),                 
//            UNIT=SYSDA,                             
//            SPACE=(CYL,(X,Y),RLSE)                 
//SYSIN DD * 
  ALTSEQ CODE=(0040)
  OUTREC FIELDS=(1,80,TRAN=ALTSEQ)
/* 

Replace Low Values using FILEAID 

File-AID/Batch is a data manipulation program that consolidates the functions of many standard IBM utilities. It can be used to replace specified characters anywhere in your records with other characters.

//STEP0100 EXEC PGM=FILEAID                           
//SYSPRINT DD SYSOUT=*                                 
//DD01     DD DSN=YOUR INPUT DATASET,
//            DISP=SHR
//DD01O    DD DSN=OUTPUT DATASET,             
//            DISP=(NEW,CATLG,DELETE),                 
//            UNIT=SYSDA,                             
//            SPACE=(CYL,(X,Y),RLSE),                 
//            DCB=(RECFM=FB,LRECL=ZZZ,BLKSIZE=0)       
//SYSIN    DD  *                                       
$$DD01 COPY REPLALL=(1,0,X'00',X'40')
/*  

Dataset Identifier – $$DD01
Function Name – COPY
Selection, Action, and Control Parameters – REPLALL=(1,0,X’00’,X’40’)

IBM Reference : Click Here

Admin

Share
Published by
Admin

Recent Posts

Increase Transparency and Collaboration Product Backlog

A well-maintained product backlog is crucial for successful product development. It serves as a single…

3 weeks ago

Product Backlog – Incremental value to the customer

Incremental value to the customer refers to the gradual delivery of small, functional parts of…

4 weeks ago

Product Market, Customer’s Desire, Need, and Challenges

A Product Market refers to the group of potential customers who might be interested in…

4 weeks ago

PAL-EBM Professional Agile Leadership – EBM Certification

The Professional Agile Leadership - Evidence-Based Management (PAL-EBM) certification offered by Scrum.org is designed for…

4 months ago

PAL I Professional Agile Leadership Certification

The Professional Agile Leadership (PAL I) certification, offered by Scrum.org, is designed to equip leaders…

4 months ago

Scrum Master Certification: CSM, PSM, SSM

Choosing the right Scrum Master Certification depends on your current experience and career goals. If…

6 months ago