Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Wed Mar 23, 2005 8:47 pm Post subject:
bprasanna,
Adding a constant at the end of every record is not possible with the traditional features of sort. You need an e15 exit to do it.The following JCL will give you the desired results.
A brief explanation of the job.
Step0100 : We first convert the FB file into a Variable block file and trim the trailing spaces.
step0200: Using an exit we pad the desired character "z" at the end of every record.
Step0300: we now convert the Variable block file back to fixed block.
This is the E15z exit for padding the character "z" at the end of every record.
Code:
/* REXX E15Z */
ADDRESS 'SYNCREXX' 'GIVE'
LS = LENGTH(SYRECORD)
IF LS > 0
THEN DO
SYACTION = 'REPLACE'
SYRECORD = OVERLAY("Z",SYRECORD,LS+1)
SAY RC
END
ELSE DO
SYACTION = 'CLOSE'
END
ADDRESS 'SYNCREXX' 'TAKE'
RETURN
ADDZ CSECT
R0 EQU 0
R1 EQU 1
R2 EQU 2
R3 EQU 3
R4 EQU 4
R5 EQU 5
R6 EQU 6
R7 EQU 7
R8 EQU 8
R9 EQU 9
R10 EQU 10
R11 EQU 11
R12 EQU 12
R13 EQU 13
R14 EQU 14
R15 EQU 15
STM R14,R12,12(R13) SAVE ALL REGS EXCPT 13
BALR R12,R0 SET BASE REG
USING *,R12 SHOW BASE REG
ST R13,SAVE15+4 SAVE BACKWARD POINTER
LA R14,SAVE15 SET FORWARD POINTER IN CALLER
ST R14,8(,R13) SET SAVE AREA
LR R13,R14 SET OUR SAVE AREA
ICM R2,15,0(R1) GET POINTER TO RECORD
BZ EOI IF EOI, DO NOT RETURN
MVC NEWRCD,0(R2) COPY RECORD
* IF NO BLANKS IN RECORD, TELL DFSORT TO ACCEPT THE RECORD AS IS.
* OTHERWISE, OVERLAY THE FIRST BLANK IN THE RECORD WITH 'Z' AND
* TELL DFSORT TO ACCEPT THE CHANGED RECORD.
LA R1,NEWRCD POINT TO START OF COPIED RECORD
LR R4,R1 COPY POINTER
LA R3,133 SET LENGTH OF RECORD
FNDBLK DS 0H
CLI 0(R4),C' ' IF FIRST BLANK FOUND,
BE Z ADD Z
LA R4,1(,R4) INCREMENT RECORD POINTER
BCT R3,FNDBLK CONTINUE LOOKING FOR BLANK
B ACCEPT NO BLANKS IN RECORD - ACCEPT IT
Z DS 0H
MVI 0(R4),C'Z' OVERLAY FIRST BLANK WITH 'Z'
B ACCEPT ACCEPT CHANGED RECORD
EOI DS 0H
LA R15,8 INDICATE DO NOT RETURN
B GOBACK RETURN TO DFSORT
ACCEPT DS 0H
SLR R15,R15 INDICATE ACCEPT
GOBACK DS 0H RETURN TO DFSORT
L R13,4(,R13)
L R14,12(,R13)
LM R2,R12,28(R13)
BR R14
*
SAVE15 DS 18F
NEWRCD DS CL133
LTORG
END
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Mon Mar 28, 2005 11:40 am Post subject:
coolman,
SyncSort provides a number of special REXX variables to facilitate the development of REXX exits. These variables offer a simple, efficient means of establishing communicationbetween the exit and the sort/merge.
To load these variables, the following command must be used when the exit is called.
Code:
ADDRESS 'SYNCREXX' 'GIVE'
When the exit completes its work, the exit should use the following sequence of commands to return the variables to SyncSort.
Code:
ADDRESS 'SYNCREXX' 'TAKE'
RETURN
The following table describes the special REXX variables.
SYRECORD : When the exit is entered, SYRECORD contains the current data record. The exit can accept the record, modify it or add a new record; SYACTION should be set accordingly.
If SYRECORD is null, then SyncSort has no data remaining. When this happens, the exit can either CLOSE or continue to INSERT new records.
SYACTION : This variable must be set before the exit returns control to SyncSort. It describes the disposition of the current record. Possible values for SYACTION are as follows:
Code:
ACCEPT : Retain the current record with no modification.
REPLACE: Replace the current record with the contents of the SYRECORD.
DELETE: Delete the current record.
INSERT: Insert the contents of the SYRECORD before the current record.
CLOSE: Do not return to the exit.
ABEND: Terminate SyncSort.
If an E15 is providing all the input (SORTIN not present), the only valid values for SYACTION are INSERT, CLOSE or ABEND.
SYEXITYP: This variable will automatically be set to E15 or E35, depending on which type of exit is being called. SYGBLN1... ...SYGBLN8
These eight special variables are global variables. The user may set these to any value provided that the value does not exceed 15 characters in length. SyncSort will insure that these variables are preserved across calls to the exit.
SYGBLSTRP: This is an additional global variable. The user may set this to any value, provided the string does not exceed 1024 characters in length.SyncSort will insure that this variable is preserved across calls to the exit.
You can find the same information in chapter 7 (coding rexx exits) in the syncsort manual
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
Posted: Mon Mar 28, 2005 2:48 pm Post subject:
if you can use USS, use of regular expressions is pretty quick. A sed command like
sed '/s\(..*\)/\1Z/g' filename
will add a Z to every nonblank line (only tested on Linux, but it should work in USS).
My regular expressions and sed syntax are a bit rusty so there may be a better way to do this. You can run shell scripts in batch.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Thu Oct 19, 2006 6:59 pm Post subject:
With DFSORT's new JFY function, you can do what was requested quite easily in one pass - you don't need an E15 exit. Here's the DFSORT/ICETOOL job. You'll need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) in order to use DFSORT's SQZ function. If you don't have the April, 2006 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:
Note that the data here is left-justified (no leading blanks), so JFY works fine. If there were leading blanks of different lengths in different records, this technique wouldn't work because JFY would remove them which may or may not be what someone wants for a particular case. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum