Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Syncsort - Replace contents of a file dynamically

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Syncsort - Replace contents of a file dynamically
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    Post subject: Reply to: Replace contents of a file dynamically
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:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
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    Post subject: Reply to: Replace contents of a file dynamically
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: 456
Location: Belgium

PostPosted: Wed Nov 26, 2008 10:02 am    Post subject:
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: 2285
Location: @my desk

PostPosted: Wed Nov 26, 2008 9:18 pm    Post subject:
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    Post subject:
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: 2285
Location: @my desk

PostPosted: Thu Nov 27, 2008 1:41 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Compare yesterday's date to the one o... migusd SYNCSORT 8 Fri Sep 22, 2017 11:35 pm
No new posts Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am
No new posts BUILD OUTFIL based on condition other... balaji81_k DFSORT/ICETOOL 13 Fri Sep 08, 2017 11:06 pm
No new posts Skip file from delete pema_yozer All Other Mainframe Topics 3 Tue Aug 29, 2017 3:19 pm
No new posts editting the file by inserting zeros ... pramodrsingh DFSORT/ICETOOL 9 Mon Aug 21, 2017 5:58 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us