MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Writing extra fields in the output

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Param
Beginner


Joined: 31 Mar 2003
Posts: 16
Topics: 7

PostPosted: Tue Aug 05, 2003 2:14 am    Post subject: Writing extra fields in the output Reply with quote

Hi,

I have an input file of length of 1000 bytes.
The output file has a length of 1010 bytes.

There is a date field in the input file which I would want to compare with a constant and if it is lesser than the constant I want to write 'A' in to the last ten bytes of output file and if it is greater I want to write 'B' in the last ten bytes.

Is it possible to do the above using SORT and if so please let me know how.

Thnx in advance...
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Aug 05, 2003 6:29 am    Post subject: Reply with quote

Param,

The following JCl will give you the desired results. I am assuming that yout data field starts at 25 for a length of 10 bytes in the format CCYY-MM-DD.


Code:

//STEP100  EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=YOUR INPUT FILE,
//            DISP=SHR
//A        DD DSN=YOUR OUTPUT FILE A,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//B        DD DSN=YOUR OUTPUT FILE B,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD    *
  SORT FIELDS=COPY
  OUTFIL FNAMES=A,INCLUDE=(25,10,CH,LT,C'2003-08-05'),  $ DATE CHECK
  OUTREC=(01,1000,                                      $ FIRST 1000 BYTES
          25,10)                                        $ DATE IN LAST 10 BYTES
  OUTFIL FNAMES=B,INCLUDE=(25,10,CH,GT,C'2003-08-05'),  $ DATE CHECK
  OUTREC=(01,1000,                                      $ FIRST 1000 BYTES
          25,10)                                        $ DATE IN LAST 10 BYTES   
//*


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Param
Beginner


Joined: 31 Mar 2003
Posts: 16
Topics: 7

PostPosted: Tue Aug 05, 2003 6:36 am    Post subject: Reply with quote

Thanks Kolusu...
It was really helpful..
I merged the the datasets using seqnum to give the desired result.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Aug 05, 2003 11:11 am    Post subject: Reply with quote

Kolusu,

Shouldn't you have C'constant' instead of 25,10 since Param wanted to write 'A' or 'B' in the last 10 bytes, and of course, you need to add the SEQNUM and sort on it to get the records in the right order as Param recognized.
_________________
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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Aug 05, 2003 2:40 pm    Post subject: Reply with quote

Frank,
I guess I intrepreted the question wrong. I assumed that param wanted the date field in the last 10 bytes. But you may be right that he wanted the "constant" in the last 10 bytes.

Param here is a revised DFSORT/ICETOOL JCl which will give you the desired results.If you have syncsort at your shop then change the pgm name to synctool.

Code:

//STEP100  EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//IN       DD DSN=YOUR INPUT FILE,
//            DISP=SHR
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE),UNIT=SYSDA
//T2       DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE),UNIT=SYSDA
//CON      DD DSN=&T1,DISP=OLD,VOL=REF=*.T1 
//         DD DSN=&T2,DISP=OLD,VOL=REF=*.T2 
//OUT      DD DSN=YOUR OUTPUT FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//TOOLIN   DD *
  COPY FROM(IN)  USING(CTL1)
  SORT FROM(CON) USING(CTL2)
//CTL1CNTL DD *
  INREC FIELDS=(1,1000,SEQNUM,8,ZD)
  OUTFIL FNAMES=T1,INCLUDE=(25,10,CH,LT,C'2003-08-05'),  $ DATE CHECK
  OUTREC=(01,1000,                                       $ FIRST 1000 BYTES
          C'ABCDEFGHIJ',                                 $ CONSTANT VALUE
          1001,8)                                        $ SEQNUM 
  OUTFIL FNAMES=T2,INCLUDE=(25,10,CH,GT,C'2003-08-05'),  $ DATE CHECK
  OUTREC=(01,1000,                                       $ FIRST 1000 BYTES
          C'KLMNOPQRST'                                  $ CONSTANT VALUE
          1001,8)                                        $ SEQNUM 
//CTL2CNTL DD *
  SORT FIELDS=(1011,8,ZD,A)                              $ SORT ON SEQNUM 
  OUTFIL FNAMES=OUT,OUTREC=(1,1010)                      $ STRIP OFF SEQNUM
/*



Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Param
Beginner


Joined: 31 Mar 2003
Posts: 16
Topics: 7

PostPosted: Tue Aug 05, 2003 11:29 pm    Post subject: Reply with quote

Kolusu,
As Frank Yaeger pointed I indeed needed a constant in the last ten bytes.
Anyway the problem was solved..

Thanx for your help and

Thanx to you Frank
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group