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

Syncsort - Replace contents of a file dynamically


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
DKartiya

New User


Joined: 30 Jan 2008
Posts: 26
Location: Chennai

PostPosted: Tue Nov 25, 2008 10:04 am
Reply with quote

Hi,

I have a file named 'ABCD.ABC###.FILE1'. (### is a dynamic value eg: 123/234 etc). The contents of the file is

'ABCD.ABC$$$.FILE2'
'ABCD.ABC$$$.FILE3'

Where $$$ is a dynamic value. Eg: Can be 123/234 etc

I want the $$$ in the file content to replaced with the value ### present in the file name. Is there a way to do this using SORT.
(Using program i can do this).

Regards,
Karthi.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Nov 26, 2008 4:41 am
Reply with quote

DKartiya,

The following DFSORT JCL will give you the desired results. We create a symbols dataset with values to be replaced and use that symbols to replace the contents of the file.

Code:

//STEP0100 EXEC PGM=ICEMAN                                 
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                             
'ABCD.ABC123.FILE1'                                         
'ABCD.ABC234.FILE2'                                         
'ABCD.ABC345.FILE3'                                         
//SORTOUT  DD DSN=&&S1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE) 
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                         
  OUTREC BUILD=(C'FV',SEQNUM,3,ZD,C',C''',10,3,C'''',80:X) 
/* 


Assuming that you file ABCD.ABC123.FILE1 has the following data
Code:

$$$ RECORD 1     
RECORD 2 $$$     
BLAH $$$ RECORD 3


use the following JCL to replace the $$$ to 123
Code:

//STEP0200 EXEC PGM=ICEMAN                 
//SYMNAMES DD DSN=&&S1,DISP=SHR             
//SYSOUT   DD SYSOUT=*                     
//SORTIN   DD DSN=ABCD.ABC123.FILE1,DISP=SHR                             
//SORTOUT  DD SYSOUT=*                     
//SYSIN    DD *                             
  SORT FIELDS=COPY                         
  INREC FINDREP=(IN=C'$$$',OUT=FV001)       
//*


now the output is
Code:

123 RECORD 1     
RECORD 2 123     
BLAH 123 RECORD 3


Similarly code other steps for the list of dsn's in step0100
ie for second dataset you will use (notice FV002)

Code:

//SYSIN    DD *                             
  SORT FIELDS=COPY                         
  INREC FINDREP=(IN=C'$$$',OUT=FV002)       
//*


Note that the job uses DFSORT's new FINDREP function available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008). If you don't have this PTF, ask your System Programmer to install it (it's free).

For complete details on the new FINDREP function and the other new functions available with PTF UK90013, see:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
DKartiya

New User


Joined: 30 Jan 2008
Posts: 26
Location: Chennai

PostPosted: Wed Nov 26, 2008 9:55 am
Reply with quote

Thanks a lot.

The first step ran thru fine.

The 2nd step for replacing throws the ff error.
SYSIN :
SORT FIELDS=COPY
INREC FINDREP=(IN=C'196',OUT=FV001)
DATA DICTIONARY SYMBOLS SUBSTITUTED :
SORT FIELDS=COPY
INREC FINDREP=(IN=C'196',OUT=FV001)
*
WER268A INREC STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE

Please let me know what need to be done to correct the error.

Regards,
Karthi
Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Wed Nov 26, 2008 10:02 am
Reply with quote

You have SYNCSORT not DFSORT !
The given solution fits for DFSORT ( WERnnnx messages indicate Syncsort)
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Nov 26, 2008 9:18 pm
Reply with quote

DKartiya,

If you are interested in calling SORT from a small REXX program, you can achieve the same in a single step like this.
The REXX dynamically creates a symbol 'KEY' for the value '###' in your input file-name which gets overlayed to the data at pos-10.
Code:
//STEP1    EXEC PGM=IKJEFT01,PARM='REXXTEST'   
//SYSEXEC  DD DSN=XXXXXXXX.REXXLIB,DISP=SHR     
//SYSTSIN  DD DUMMY                             
//SYSTSPRT DD SYSOUT=*                         
//SORTIN   DD DSN=ABCD.ABC###.FILE1,DISP=SHR 
//SYMNAMES DD DSN=&&C1,DISP=(,PASS),DCB=LRECL=80
//SORTOUT  DD DSN=ABCD.ABC###.FILE1,DISP=SHR                         
//SYSOUT   DD SYSOUT=*                         
//SYSIN    DD *                                 
  OPTION COPY                                   
  INREC OVERLAY=(10:KEY)                       
/*                                           

XXXXXXXX.REXXLIB(REXXTEST)
Code:
/* REXX *** FIND THE STRING FROM THE INPUT FILE-NAME                 */
/***----------------------------------------------------------------***/
/*                  TRAP DSN FOR DD 'SORTIN'                          */
/***----------------------------------------------------------------***/
                                                                       
   X = OUTTRAP('DDN.')                   /* TURN ON CAPTURING OF DISP-*/
                                         /* LAY OUTPUT OF TSO COMMANDS*/
   "LISTA ST"                            /* LIST ALL ALLOCATED DATA-  */
                                         /* SETS WITH DD NAME AND DISP*/
   FOUND = 'NO'                                                         
   I = 1                                                               
/***----------------------------------------------------------------***/
/*             SEARCH THE LIST FOR DD NAME 'SORTIN'                   */
/***----------------------------------------------------------------***/
                                                                       
 DO WHILE (FOUND = 'NO') & (I <= DDN.0)                                 
     DSN = WORD(STRIP(DDN.I), 1)                                       
     IF DSN = 'SORTIN' THEN                                             
     DO                                                             
       FOUND = 'YES'                                                 
       I = I - 1                                                     
       TMP.1 = "KEY,C'" || SUBSTR(WORD(STRIP(DDN.I), 1),9,3) ||  "'"
       "EXECIO * DISKW SYMNAMES ( STEM TMP. FINIS"                   
       "CALL *(SORT)"                                               
       EXIT                                                         
     END                                                             
     ELSE                                                           
       I = I + 1                                                     
 END   
Back to top
View user's profile Send private message
DKartiya

New User


Joined: 30 Jan 2008
Posts: 26
Location: Chennai

PostPosted: Thu Nov 27, 2008 11:49 am
Reply with quote

I dont know the ABC of REXX ... Would prefer SORT ..

I dont have DFSORT at my shop ... only SYNCSORT is a standard ...

is there any possible way using SYNCSORT ????

Regards,
Karthi
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Nov 27, 2008 1:41 pm
Reply with quote

DKartiya,

The above solution uses Syncsort. The REXX part is just to write the variable part of the file-name to the SYMNAMES dataset which is further used by Syncsort. It's not necessary for you to know the A-Z of REXX to at least try this out.
Nobody is stopping you from learning something new. icon_smile.gif
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top