View previous topic :: View next topic
Author
Message
Searchman New User Joined: 28 Dec 2006Posts: 80 Location: France
Is it possible to do this in a single step ?
else, what is the best solution ?
FICIN and FICOUT are VB file
FICIN
S01ENTETE
02XX000010000200003
02XX000010000200003
02YY000010000200003
S99000003
Gives
FICOUT
S01ENTETE
02XX000020000400006
02YY000010000200003
S99000002
S01ENTETE is copied idem
Enreg 02 are summed on key XX/YY (pos 4-5)
the trailer of FICOUT (compared to FICIN) changes, it gives the number of records after sum
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
You can use a DFSORT job like the following to do what you asked for:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
S01ENTETE
02XX000010000200003
02XX000010000200003
02YY000010000200003
S99000003
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OMIT COND=(2,2,CH,EQ,C'99')
SORT FIELDS=(2,4,CH,A)
SUM FIELDS=(6,5,ZD,11,5,ZD,16,5,ZD)
OUTFIL REMOVECC,
TRAILER1=(C'S99',COUNT-1=(M11,LENGTH=6))
/*
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Searchman wrote:
FICIN and FICOUT are VB file
Frank,
Should n't we consider the RDW field as the OP's requirement is regarding VB files?
Back to top
Searchman New User Joined: 28 Dec 2006Posts: 80 Location: France
Yes, arcvns,
in the sample of Franck, I think the recsize is the same for all records
But, in my case, first and trailer records are 9 long, and detail record is 20 long, so, it makes some problem with sort sum
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Oh, I missed the part where you said it was VB (it didn't help that you gave the positions of the key as 4-5 instead of 8-9). Here's a revised DFSORT job for VB.
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (VB)
//SORTOUT DD DSN=... output file (VB)
//SYSIN DD *
OMIT COND=(6,2,SS,EQ,C'01,99')
SORT FIELDS=(8,2,CH,A)
SUM FIELDS=(10,5,ZD,15,5,ZD,20,5,ZD)
OUTFIL REMOVECC,
HEADER1=(C'S01ENTETE'),
TRAILER1=(C'S99',COUNT=(M11,LENGTH=6))
/*
Back to top
Searchman New User Joined: 28 Dec 2006Posts: 80 Location: France
Sorry, but the header must be the header of FICIN and not a contant, it is unforeseeable...
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Ok, then try this:
Code:
OPTION VLSHRT
OMIT COND=(6,2,CH,EQ,C'99')
SORT FIELDS=(6,4,CH,A)
SUM FIELDS=(10,5,ZD,15,5,ZD,20,5,ZD)
OUTFIL REMOVECC,
TRAILER1=(C'S99',COUNT-1=(M11,LENGTH=6))
Back to top
Searchman New User Joined: 28 Dec 2006Posts: 80 Location: France
Thank you for your quick reply, exactly what I wanted !
Interesting, I didn't know this option VLSHRT
Back to top
Searchman New User Joined: 28 Dec 2006Posts: 80 Location: France
In application of this solution I want to add a build, i.e keep only 330 bytes of the 346 of FICIN, header and trailer remaining the same
First, I coded that :
Code:
OPTION VLSHRT
OMIT COND=(5,3,CH,EQ,C'S99')
SUM FIELDS=(53,10,63,10,73,10,83,10,93,10,103,10,113,10,123,10,
133,10,143,10,153,10),FORMAT=PD
SORT FIELDS=(18,12,BI,A,325,26,CH,A)
OUTFIL REMOVECC,
TRAILER1=(C'S99',COUNT-1=(M11,LENGTH=9)),
BUILD=(1,330)
But the result was :
Code:
ICE210I 0 SORTOUT : BSAM USED, LRECL = 330, BLKSIZE = 27966, TYPE = VB (SDB)
ICE218A 3 15 BYTE VARIABLE RECORD IS SHORTER THAN 330 BYTE MINIMUM FOR SORTOUT
So, I coded that to distinguish header from detail record
Code:
OPTION VLSHRT
OMIT COND=(5,3,CH,EQ,C'S99')
SUM FIELDS=(53,10,63,10,73,10,83,10,93,10,103,10,113,10,123,10,
133,10,143,10,153,10),FORMAT=PD
SORT FIELDS=(18,12,BI,A,325,26,CH,A)
OUTFIL REMOVECC,
TRAILER1=(C'S99',COUNT-1=(M11,LENGTH=9))
OUTFIL IFTHEN=(WHEN=(5,3,CH,EQ,C'S01'),BUILD=(1,15)),
IFTHEN=(WHEN=(5,3,CH,NE,C'S01'),BUILD=(1,330))
But it seems the OUTFIL IFTHEN are ignored
Note that I want the detail sortout recsize to be 330 long, not 346
(header and trailer are 15 long, detail is 346 long)
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
OUTFIL IFTHEN is ignored because you have it in a second OUTFIL with the same ddname (default of SORTOUT). The second OUTFIL statement is ignored as indicated by the following message you would have received:
ICE219I 0 DUPLICATE DDNAME SORTOUT IGNORED
You need to use one OUTFIL statement with IFTHEN and TRAILER1. This should work:
Code:
OPTION VLSHRT
OMIT COND=(5,3,CH,EQ,C'S99')
SUM FIELDS=(53,10,63,10,73,10,83,10,93,10,103,10,113,10,123,10,
133,10,143,10,153,10),FORMAT=PD
SORT FIELDS=(18,12,BI,A,325,26,CH,A)
OUTFIL REMOVECC,
IFTHEN=(WHEN=(5,3,CH,NE,C'S01'),BUILD=(1,330)),
TRAILER1=(C'S99',COUNT-1=(M11,LENGTH=9))
Back to top
Searchman New User Joined: 28 Dec 2006Posts: 80 Location: France
Exact, thank you
But, isn't possible to have 330 recsize after build, instead of 346
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Are you asking how to get LRECL=330 for the output data set?
If so, you just need to specify LRECL=330 on the SORTOUT DD.
If that's not what you're asking, then please explain what you want clearly in more detail.
Back to top
Searchman New User Joined: 28 Dec 2006Posts: 80 Location: France
Yes, I wonder, if I don't specify the LRECL in the SORTOUT DD, if DFSORT, with BUILD, could generate a 330 recsize (because in this case it takes the recsize of SORTIN and padds beyond 330)
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
If you want DFSORT to set the LRECL to 330 automatically, you can use this OUTFIL statement:
Code:
OUTFIL REMOVECC,
IFOUTLEN=330,
IFTHEN=(WHEN=(5,3,CH,NE,C'S01'),BUILD=(1,330)),
TRAILER1=(C'S99',COUNT-1=(M11,LENGTH=9))
Without IFOUTLEN=330, DFSORT has to assume that an unchanged input record of 346 bytes could be output so it sets the LRECL to 346. With IFOUTLEN=330, DFSORT knows that the largest output record is 330 bytes, so it sets the LRECL to 330.
Back to top
Searchman New User Joined: 28 Dec 2006Posts: 80 Location: France
Thank's again
Back to top
Please enable JavaScript!