IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Replace 4 digit code to 3 digit code if lookup present


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Jan 28, 2011 12:49 pm
Reply with quote

Hi All...

Here is my requirement..

I have two reference files..

1: Supplier file
RECFM FB, LRECL 10
Supplier code first is 5 byte remaining are spaces
Code:

ABC
DEF
GHI
JKL
MNO


Second reference is 3 digit to 4 digit reference file.

RECFM=FB, LRECL 7
First 3 bytes old code
Next 4 bytes new code
Code:

1111111
1122111
1133111
1155123


Actual input file is as below:
RECFM=FB,LRECL=80
Code:

CNTLABC
SEGA
SEGB
SEGC
SEGD5123
SEGE
CNTLPQR
SEGA
SEGB
SEGC
SEGD5123
SEGE

CNTL segment identifies supplier, if this supplier is present in first supplier reference file then whatever 4 digit code present in segment SEGD should be replaced with corresponding 3 digit code from reference file followed by one SPACE.
Expected output:
Code:

CNTLABC
SEGA
SEGB
SEGC
SEGD115
SEGE
CNTLPQR
SEGA
SEGB
SEGC
SEGD5123
SEGE

since first supplier ABC was present in supplier ref file 4 digit code in SEGD segment is replaced with 3 digit code using file2.
since PQR supplier is not present in the supplier ref file 4 digit code in SEGD is kept as it is.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Jan 28, 2011 8:32 pm
Reply with quote

I have DFSORT\ICETOOL on my shop
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jan 28, 2011 11:26 pm
Reply with quote

escapa,

You need two Joinkey steps to perform the match. Here is a DFSORT JCL which will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//INA      DD DSN=Your actual 80 byte input file,DISP=SHR
//INB      DD DSN=Your supplier 10 byte file,DISP=SHR                   
//SORTOUT  DD DSN=&&TEMP,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)           
//SYSIN    DD *                                                         
  OPTION COPY                                                           
  JOINKEYS F1=INA,FIELDS=(81,5,A)                                       
  JOINKEYS F2=INB,FIELDS=(01,5,A)                                       
  JOIN UNPAIRED,F1                                                     
  REFORMAT FIELDS=(F1:1,93,?)                                           
  OUTFIL IFTHEN=(WHEN=(94,1,CH,EQ,C'B',AND,1,4,CH,EQ,C'SEGD'),         
  OVERLAY=(94:5,4)),                                                   
  IFTHEN=(WHEN=NONE,OVERLAY=(94:4X))                                   
//JNF1CNTL DD *                                                         
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'CNTL'),                   
  PUSH=(81:5,5,SEQ=8))                                                 
//*                                                 
//STEP0200 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//INA      DD DSN=&&TEMP,DISP=SHR                                     
//INB      DD DSN=Your referencer 7 byte file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
  JOINKEYS F1=INA,FIELDS=(94,4,A)                                     
  JOINKEYS F2=INB,FIELDS=(04,4,A)                                     
  JOIN UNPAIRED,F1                                                     
  REFORMAT FIELDS=(F1:1,93,?,F2:1,3)                                   
  SORT FIELDS=(81,13,CH,A),EQUALS                                     
  OUTREC IFOUTLEN=80,IFTHEN=(WHEN=(94,1,CH,EQ,C'B'),OVERLAY=(5:95,3,X))
//*
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
Search our Forums:

Back to Top