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 

DFSORT - SORT/COPY fields based on another field

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


Joined: 08 Apr 2010
Posts: 14
Topics: 9

PostPosted: Sun Dec 05, 2010 4:37 am    Post subject: DFSORT - SORT/COPY fields based on another field Reply with quote

Hello,

I have a sort jcl that extracts certain fields from a sequential file and creates an extract file. Now I have a change to add one more field from the input file to the output extract file.

Lets say the additional field is called 'payment amount' in my input file. Actually this field is in an OCCURS clause of OCCURS 3 times. Also, there is another field in the input layout called 'payment amount occurs flag'.
I need to copy the payment amount to the extract file based on the 'payment amount occurs flag'. For example: if the flag is havign value '2', then I need to copy data from 2nd occurs for the payment amount.

Assuming payment-amt1 is at position 10, payment-amt2 is at positon 22, payment-amt3 is at position 31. Now, if payment-occurs-flag is '1' then I need to copy amount value from position 10, else if the occurs-flag is '2' then I need to copy amount value from position 22 , else if the occurs-flag is '3' then I need to copy amount value from 31.

Can anyone please share a sample SORT JCL for this ? As I mentioned I already have a sort jcl that does the simple sort copy and outrec build.

Thanks
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: Sun Dec 05, 2010 3:29 pm    Post subject: Reply with quote

kumar26fl,

The following DFSORT JCL will give you the desired results. I assumed your input is FB and the contents you want to pick are from pos 50 for 30 bytes.

Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                         
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
1        PAYMENT1                                SOME DATA TO PICK-1   
2        PAYMENT1    PAYMENT2                    SOME DATA TO PICK-2   
3        PAYMENT1    PAYMENT2 PAYMENT3           SOME DATA TO PICK-3   
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  SORT FIELDS=COPY                                                     
  INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'1'),BUILD=(50,30,10,8)),             
        IFTHEN=(WHEN=(1,1,CH,EQ,C'2'),BUILD=(50,30,22,8)),             
        IFTHEN=(WHEN=(1,1,CH,EQ,C'3'),BUILD=(50,30,31,8))               
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kumar26fl
Beginner


Joined: 08 Apr 2010
Posts: 14
Topics: 9

PostPosted: Mon Dec 06, 2010 11:21 pm    Post subject: Reply with quote

Thank You so much Kolusu, it really helped.
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