For my desired output, I want to combine those 17 lines into 1,
something like side by side splice, but I am having trouble.
Desired output LRECL will be 17 * 101 = 1717.
Code:
HDAAAAAAAAAAAAAA01BBBBBBBBBB.....16QQQQQQQQQQQ
Any suggestions on how to do it?
I am not familiar with splice, and that the sample i found only combines two lines..
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
The "....." means row 02 to 15?
Why when row 02 is "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" long do you want the output for that row to be only "BBBBBBBBBB" long?
What is the maximum number of rows per each "HD", 16 or greater (or less?)?
Joined: 06 Nov 2008 Posts: 46 Location: Manila, Philippines
From my search here, I found a sort card that joins 2 files laterally.
For my task, I am thinking :
1. Extract record based on their record id (i.e. the first two bytes)
- i will then have a sort with SORTOF01 TO SORTOF17 ( 17 files)
2. By two's, join the records laterally
- join HD recs with 01 recs
02 recs with 03 recs
.
.
.
14 recs with 15 recs
16 recs
- i will then have 9 files on the first batch
3. Join the files again laterally... until I get one file.
- i will have 5 files on second batch
- i will have 3 files on the 3rd batch
- i will have two files on the 4th batch
- then finally one file with LRECL=1717.
But this looks sooooooooo tedious, and I am hoping there's someone out there who can give me an idea how to simplify this one.
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
Hi,
it's not the prettiest code but will do the trick
Code:
//GENER1 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
//SYSUT2 DD DSN=&&SYSPROC(MRGERECS),
// DISP=(,PASS),
// UNIT=VIO,
// SPACE=(TRK,(1,1,1)),
// DCB=(RECFM=FB,LRECL=80)
//SYSUT1 DD *,DLM='$$'
/**** REXX ****/
TRACE O
/*********************************************************************/
EOFFLAG = 2 /* RETURN CODE TO INDICATE END-OF-FILE */
RETURN_CODE = 0 /* INITIALIZE RETURN CODE */
IN_CNTR = 0 /* INITIALIZE # OF LINES READ */
OUT_CNTR = 0 /* INITIALIZE # OF LINES WRITTEN */
REC = ''
/*********************************************************************/
/* OPEN THE "DDNAME" FILE, BUT DO NOT READ ANY RECORDS YET. ALL */
/* RECORDS WILL BE READ AND PROCESSED WITHIN THE LOOP BODY. */
/*********************************************************************/
"EXECIO 0 DISKR "FILEIN" (OPEN" /* OPEN "DDNAME" */
/*********************************************************************/
/* NOW READ ALL LINES FROM "DDNAME" STARTING AT LINE 1. */
/*********************************************************************/
DO WHILE (RETURN_CODE ¬= EOFFLAG) /* LOOP WHILE NOT END-OF-FILE */
"EXECIO 1 DISKR FILEIN" /* READ 1 LINE TO THE DATA STACK */
RETURN_CODE = RC /* SAVE EXECIO RC */
IF RETURN_CODE = 0 THEN /* GET A LINE OK? */
DO /* YES */
IN_CNTR = IN_CNTR + 1 /* INCREMENT INPUT LINE CNTR */
PARSE PULL RECORD /* PULL LINE JUST READ FROM STACK*/
REC = REC||RECORD
END
END
QUEUE REC
OUT_CNTR = OUT_CNTR + 1 /* INCREMENT INPUT LINE CNTR */
SAY 'RECS READ =' IN_CNTR
SAY 'RECS OUT =' OUT_CNTR
"EXECIO 0 DISKR FILEIN (FINIS" /* CLOSE THE INPUT FILE DDNAME */
"EXECIO * DISKW MERGRECS (FINIS" /* CLOSE THE INPUT FILE DDNAME */
$$
//*
//**********************************************************************
//*
//MERGRECS EXEC PGM=IKJEFT01,DYNAMNBR=30,
// PARM=('MRGERECS') /* REXNAME
//SYSPROC DD DSN=&&SYSPROC,
// DISP=(SHR)
//SYSTSPRT DD SYSOUT=*
//FILEIN DD DSN=input-file,DISP=SHR
//SYSTSIN DD DUMMY
//MERGRECS DD DSN=output-file,
// DISP=(,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(TRK,(10,5),RLSE),
// DCB=(RECFM=FB,LRECL=1717)
//*
//**********************************************************************
Joined: 06 Nov 2008 Posts: 46 Location: Manila, Philippines
I modified my above steps to:
1. 1. Extract record based on their record id (i.e. the first two bytes)
- i will then have a sort with SORTOF01 TO SORTOF17 ( 17 files)
2. Use splice to merge the file: