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 

executing a condition while using sort

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


Joined: 27 Dec 2002
Posts: 3
Topics: 2

PostPosted: Tue Dec 31, 2002 12:31 am    Post subject: executing a condition while using sort Reply with quote

Rolling Eyes
I have a scenario in which, one of the two values need to be moved to the output field after executing a condition on the two input fields, when using Syncsort.

The condition is between the two input fields(one for holding the cusip number and other for storing the description) which are of the same picture class x(9). Assume the two input fields are located at 35 and 120 respectively.

Condition:

If the two input fields are equal
a value of 9 spaces need to be moved.
else
one of the two input fields needs to be moved.

Can it be done through Syncsort.
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 Dec 31, 2002 12:50 am    Post subject: Reply with quote

Annamalai,

Let me know the Lrecl,RECFM and position to be updated in the output file. where should the 9 spaces be placed in the output file?? If the 2 fields are not equal, what is the value to be populated in the output file??

Thanks

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


Joined: 27 Dec 2002
Posts: 3
Topics: 2

PostPosted: Tue Dec 31, 2002 1:27 am    Post subject: Reply with quote

Hi Kolusu,

Thanks for your response and here are the details you asked for:

LRECL = 640 and RECFM = FB
Here is the piece of the SYSIN card.
Code:

OUTFIL FNAMES=NSRPLUG1,               
INCLUDE=(35,9,CH,NE,722,9,CH),         
OUTREC=(9:C'990999999',               
        22:22,9,                       
        35:35,9,                       
        48:C'1',                       
        49:8Z,                         
        57:19Z,                       
        88:C'PLG',                     
        103:C'10',                     
        156:-1,MUL,69,8,PD,PD,LENGTH=8,
        164:84Z,                       
        248:731,6,F,                   
        255:35Z,                       
        290:10Z,                       
        303:2Z,                       
        340:712,4,                     
        360:805,1,                     
        361:806,1,                     
        380:4Z,                       
        388:4Z,                       
        397:X'01',                     
        399:2Z,                       
        401:722,9,
        421:C'PROGRAM ERROR',         
        640:X)                         
OUTFIL FNAMES=NSRPLUG2,               
INCLUDE=(35,9,CH,EQ,722,9,CH),         
OUTREC=(9:C'990999999',               
        22:22,9,                       
        35:35,9,                       
        48:C'1',                       
        49:8Z,                         
        57:19Z,                       
        88:C'PLG',                     
        103:C'10',                     
        156:-1,MUL,69,8,PD,PD,LENGTH=8,
        164:84Z,                       
        248:731,6,F,                   
        255:35Z,                       
        290:10Z,                       
        303:2Z,                       
        340:712,4,                     
        360:805,1,                     
        361:806,1,                     
        380:4Z,                       
        388:4Z,             
        397:X'01',           
        399:2Z,             
        401:20C' ',
        421:C'PROGRAM ERROR',
        640:X)               



In the above code, we are writing into two NSRPLUG files (NSRPLUG1 and NSRPLUG2) and in the next step, we'll merge these two files into one.
The position of the output field is 401 and is highlighted in red.
If the two fields are not equal, the input field located at position 722 and of length 9 is to be moved to the output position 401.

Thanks,
Annamalai
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 Dec 31, 2002 6:55 am    Post subject: Reply with quote

Annamalai,

I actually needed the INPUT file LRECL. As I see from your sysin cards , the input file length is different. Your sysin cards needs slight modification at these place.
Code:

248:731,6,F,


You don't need to code the format of the field in here , you can just code it as
Code:

248:731,6,


Since you are splitting the job into 2 files and mering , the following JCl will give you the desired results.A brief explanation of the job.We add a seqnum at the end of every record to retain the original order of the file.

The first copy operator splits the input file into 2 temp files.File T1 will have all the records where the field1 at position 35 is equal to field2 at position 120. For this file using outrec we add the 9 spaces

File T2 will have rest of the records where in the 2 fields are not equal.For this file using we outrec we move the orginal value.

The second SORT step takes in these 2 files and sorts on the seqnum and while writting the output we strip off the seqnum.

since I don't know the input LRECL. I just put it as N in the sysin statement. you need to change to your input file length on the INREC fields statement and on the OUTREC fields also.

Code:

//STEP0100 EXEC PGM=SYNCTOOL
//*
//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) 
//T2       DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE) 
//CON      DD DSN=&T1,DISP=(OLD,PASS),VOL=REF=*.T1         
//         DD DSN=&T2,DISP=(OLD,PASS),VOL=REF=*.T2       
//OUT      DD DSN=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,N,SEQNUM,8,ZD)                       $ TOTAL LRECL + SEQNUM           
  OUTFIL FNAMES=T1,INCLUDE=(35,9,CH,EQ,120,9,CH),   
  OUTREC=(9:C'990999999',
          22:22,9,
          35:35,9,
          48:C'1',
          49:8Z,
          57:19Z,
          88:C'PLG',
         103:C'10',
         156:-1,MUL,69,8,PD,PD,LENGTH=8,
         164:84Z,
         248:731,6,
         255:35Z,
         290:10Z,
         303:2Z,
         340:712,4,
         360:805,1,
         361:806,1,
         380:4Z,
         388:4Z,
         397:X'01',
         399:2Z,
         401:9X,
         421:C'PROGRAM ERROR',
         640:X,
         641:N,8)                          $ SEQNUM
   OUTFIL FNAMES=T2,SAVE,
   OUTREC=(9:C'990999999',
          22:22,9,
          35:35,9,
          48:C'1',
          49:8Z,
          57:19Z,
          88:C'PLG',
         103:C'10',
         156:-1,MUL,69,8,PD,PD,LENGTH=8,
         164:84Z,
         248:731,6,
         255:35Z,
         290:10Z,
         303:2Z,
         340:712,4,
         360:805,1,
         361:806,1,
         380:4Z,
         388:4Z,
         397:X'01',
         399:2Z,
         401:20C' ',
         421:C'PROGRAM ERROR',
         640:X,
         641:N,8)                                   $ SEQNUM
//CTL2CNTL DD *
  SORT FIELDS=(641,8,ZD)                            $ SORT ON SEQNUM 
  OUTFIL FNAMES=OUT,
  OUTREC=(1,640)                                    $ REMOVE THE SEQNUM
/*


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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