|
View previous topic :: View next topic
|
| Author |
Message |
kodalis
New User
Joined: 20 Nov 2009 Posts: 5 Location: Mumbai
|
|
|
|
| I want to write Header1 in output file if there is data in input file using DFSORT utility. I want to write Header2 if there is no data in input file. Can someone please tell me if IFTHEN can be used with OUTFIL to send different headers to output file. |
|
| Back to top |
|
 |
THINKSRINIII Warnings : 1 New User
.jpg)
Joined: 09 Jan 2009 Posts: 88 Location: India
|
|
|
|
Hi,
I would suggest read the input file in one step and set the return code accordiingly if data is present .
Based on the return code, execute the sort step to print the header to output file. |
|
| Back to top |
|
 |
kodalis
New User
Joined: 20 Nov 2009 Posts: 5 Location: Mumbai
|
|
|
|
| Thanks Elo. Actually, the DB2 step already generates 9 reports. We need to add headers in the reports thru 9 different SORT steps. Generating Return Code might not be feasible. Any other way we can handle this - using OUTFIL statement or something similar. |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
| Quote: |
| We need to add headers in the reports thru 9 different SORT steps. |
Seems like it might be better to add the headers in the program that generates the reports?
| Quote: |
| Generating Return Code might not be feasible. |
Why not
Is there one decision to make or 9 (1 per report)?
If there are 9, there is a slick little trick using powers of 2 that will let you set a return code that will cover all 9 off/on conditions. . . This would be much better than 9 steps to look for empty file(s). |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Kodalis,
For the empty and non-empty cases, show an example of what you expect for output. Give the RECFM and LRECL of each input file and the expected output files. |
|
| Back to top |
|
 |
kodalis
New User
Joined: 20 Nov 2009 Posts: 5 Location: Mumbai
|
|
|
|
Frank,
Input file:
RECFM = FB
LRECL = 132
Output is routed to Mobius. Sample attached.
Dick,
We need to make 9 decisions (1 per report). Can you please explain how to use powers of 2.
not everybody can see attachments
attachment inlined and deleted
Sample Input file:
| Code: |
****************************************************************************************************************
1ENO ERRORS FOUND
2N988004988004*07170GHANA CEDI NEW GHS 001.5340000002011-09-08 001.5055000002011-05-31
|
Sample Outputs:
1)
| Code: |
*****************************************************************************************************************
PROGRAM NAME: MSU380 PRICE RECORD IS FUTURE PAGE: 1
RUN DATE: 09/20/11 TIME: 00:36:44
NO ERRORS FOUND
|
2)
| Code: |
*****************************************************************************************************************
PROGRAM NAME: MSU380 PRICE RECORD IS FUTURE PAGE: 1
RUN DATE: 09/20/11 TIME: 00:36:44
PROCESS DATE: 09/20/11
BBH# CUSIP# DESC CURR LTST PX LTST PX DA M/E PX M/E PX DA
______ ____________ ______________________________ ____ ______________ __________ _____________ __________
988004 988004*07170 GHANA CEDI NEW GHS 001.5340000000 2011-09-08 001.505500000 2011-05-31
|
|
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
In the program that generates the 9 reports, set the Return Code as follows:
Define an accumulator (i call it ws-build-rc).
Move zero to ws-build-rc.
If the first report had data, add 1 to ws-build-rc.
If the second report had data, add 2 to ws-build-rc.
If the third report had data, add 4 to ws-build-rc.
If the fourth report had data, add 8 to ws-build-rc.
If the fifth report had data, add 16 to ws-build-rc.
If the sixth report had data, add 32 to ws-build-rc.
If the seventh report had data, add 64 to ws-build-rc.
If the eighth report had data, add 128 to ws-build-rc.
If the ninth report had data, add 256 to ws-build-rc.
Move ws-build-rc to RETURN-CODE.
GOBACK.
Looking over this, i would probably have the program that creates the reports use the same 9 compares and generate a jobstream that contains only the "copy" processes for the reports that had data (rather than setting the RETURN-CODE). This jobstream would then be submitted via the internal reader. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Kodalis,
All I see in your attachment is a sample input file with some records. That's not what I asked for. If you want my help, you need to give me what I asked for. Please don't attach files. Just show them inline here with code tags.
Again:
| Quote: |
| For the empty and non-empty cases, show an example of what you expect for output. Give the RECFM and LRECL of each input file and the expected output files. |
|
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| Quote: |
| Can someone please tell me if IFTHEN can be used with OUTFIL to send different headers to output file. |
IFTHEN cannot be used to control HEADERx. IFTHEN can be used to control BUILD. Whether or not you can do what you want depends on exactly what you need to do (see my previous posts). |
|
| Back to top |
|
 |
kodalis
New User
Joined: 20 Nov 2009 Posts: 5 Location: Mumbai
|
|
|
|
Frank, hope this helps....
| Quote: |
| For the empty case, example of header that we expect for output |
| Code: |
PROGRAM NAME: MSU380 PRICE RECORD IS FUTURE PAGE: 1
RUN DATE: 09/20/11 TIME: 00:36:44
|
| Quote: |
| For the non-empty case, example of header that we expect for output |
| Code: |
PROGRAM NAME: MSU380 PRICE RECORD IS FUTURE PAGE: 1
RUN DATE: 09/20/11 TIME: 00:36:44
PROCESS DATE: 09/20/11
BBH# CUSIP# DESC CURR LTST PX LTST PX DA M/E PX M/E PX DA
|
|
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Well, something like this would work for one report, and separate jobs like this would work for each report, but I don't think it's what you're looking for.
| Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DUMMY
//SYSIN DD *
OPTION COPY
OUTFIL NULLOFL=RC4
/*
//S2 EXEC PGM=SORT,COND=(0,EQ,S1)
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL HEADER1=('HEADER1')
/*
//S3 EXEC PGM=SORT,COND=(4,EQ,S1)
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL HEADER1=('HEADER1'),HEADER2=('HEADER2')
/*
|
|
|
| Back to top |
|
 |
kodalis
New User
Joined: 20 Nov 2009 Posts: 5 Location: Mumbai
|
|
|
|
| This will make 27 steps in total and doesn't work for us. Neverthelss, we learned some new features. Thanks for your help. |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
this would be more appropriate, no need to read the entire file to test if file is empty
| Code: |
OPTION COPY,STOPAFT=1
OUTFIL NULLOFL=RC4
|
Gerry |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Unless i am mistaken, you have 2 choices (other than do nothing):
1. Make the needed changes to the report creation program
2. Implement the multi-step solution Frank provided. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| kodalis wrote: |
| This will make 27 steps in total and doesn't work for us. Neverthelss, we learned some new features. Thanks for your help. |
Kodalis,
Not really. Have you considered using IDCAMS to set the return code and then copy the appropriate header contents?
ex:
You will have 2 header statements .
EMTHDR file will have DFSORT statements for a empty file
DATHDR file will have DFSORT statements if your input as atleast 1 record.
Now using the PRINT function of IDCAMS and validating the return code you will copy either EMTHDR file or DATHDR file. Return-code = 0 means your input has atleast 1 record and you will repro DATHDR file and if RETURN-CODE=4 means your input is empty and you will repro EMTHDR file.
| Code: |
//STEP0100 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//EMTHDR DD *
OUTFIL REMOVECC,
HEADER1=(001:'PROGRAM NAME: MSU380',
047:'PRICE RECORD IS FUTURE',
115:'PAGE :',PAGE,/,
001:'RUN DATE : ',DATE,
115:'TIME :',TIME,/)
//*
//DATHDR DD *
OUTFIL REMOVECC,
HEADER1=(001:'PROGRAM NAME: MSU380',
047:'PRICE RECORD IS FUTURE',
115:'PAGE :',PAGE,/,
001:'RUN DATE : ',DATE,
115:'TIME :',TIME,/,
001:'PROCESS DATE: ',DATE,/,/,
003:'BBH#',011:'CUSIP#',025:'DESC',
047:'CURR LTST PX',068:'LTST PX DA',
081:'M/E PX',096:'M/E PX DA',//)
//*
//IN01 DD DISP=SHR,DSN=Your Input FB 132 byte File1
//IN02 DD DISP=SHR,DSN=Your Input FB 132 byte File2
//IN03 DD DISP=SHR,DSN=Your Input FB 132 byte File3
//IN04 DD DISP=SHR,DSN=Your Input FB 132 byte File4
//IN05 DD DISP=SHR,DSN=Your Input FB 132 byte File5
//IN06 DD DISP=SHR,DSN=Your Input FB 132 byte File6
//IN07 DD DISP=SHR,DSN=Your Input FB 132 byte File7
//IN08 DD DISP=SHR,DSN=Your Input FB 132 byte File8
//IN09 DD DISP=SHR,DSN=Your Input FB 132 byte File9
//*
//HD01 DD DSN=&&HD01,DISP=(,PASS),
// SPACE=(TRK,(1,1),RLSE),
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=27920)
//*
//HD02 DD DSN=&&HD02,DISP=(,PASS),
// SPACE=(TRK,(1,1),RLSE),
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=27920)
//*
.... repeat the declarations of other header files
//SYSIN DD *
PRINT INFILE(IN01) CHARACTER COUNT(1)
IF LASTCC = 0 THEN DO
REPRO IFILE(DATHDR) OFILE(HD01)
END
ELSE IF LASTCC = 4 THEN DO
REPRO IFILE(EMTHDR) OFILE(HD01)
END
SET LASTCC = 0
PRINT INFILE(IN02) CHARACTER COUNT(1)
IF LASTCC = 0 THEN DO
REPRO IFILE(DATHDR) OFILE(HD02)
END
ELSE IF LASTCC = 4 THEN DO
REPRO IFILE(EMTHDR) OFILE(HD02)
END
SET LASTCC = 0
.... repeat the same for other 7 files
replacing the approriate DD names
//* |
Now once you generated the apporiate header file all you need to do is simply concatenate that file to your sysin card like shown below
| Code: |
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DISP=SHR,DSN=Your Input FB 132 byte File1
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
..any other Sort statements
// DD DSN=&&HD01,DISP=SHR
//* |
|
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|