Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to sort the file with the given criteria

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
harithaganna

New User


Joined: 03 Jun 2008
Posts: 14
Location: chennai

PostPosted: Wed Jan 13, 2010 3:28 pm    Post subject: How to sort the file with the given criteria
Reply with quote

I have the following requirements.

Input file has
Code:

C/D indicator             Amount
C                                100
C                                200
D                                300
D                                400


I should get the below result in output file (total of all credit records and debit records in the input file)
300 700
this I can acquire by the below sortcards and splice
sort exec pgm=icetool
toolin dd dsn=&splicecardlib,disp=shr
sortin dd dsn=&input file,disp=shr
temp dd dsn=&&tmpfile,disp=(mod,pass),
unit=sysda,space=(trk,(20,20),rlse)
sortout dd dsn=&outfile,
ctl1cntl dd dsn=&cardlib1,disp=shr
ctl2cntl dd dsn=&cardlib2,disp=shr



CARDLIB1:
INCLUDE COND=(1,01,CH,EQ,C'C')
SORT FIELDS=(1,01,CH,A)
SUM FIELDS=(2,3,ZD)
OUTREC BUILD=(1:2,3,ZD,TO=ZD,LENGTH=5,
6:99X,
100:C'1')
CARDLIB2:
INCLUDE COND=(1,01,CH,EQ,C'D')
SORT FIELDS=(1,01,CH,A)
SUM FIELDS=(2,3,ZD)
OUTREC BUILD=(1:2,3,ZD,TO=ZD,LENGTH=5,
6:99X,
100:C'1')

splice cardlib:
sort from(input) to (temp) using ctl1
sort from(input) to (temp) using ctl2
splice from(temp) -
to (output) -
on(100,1,zd) -
with(1,3)


But the same logic is not working if the input file has same set of records(either debit or credit) the output file is empty for the above condition.
the temp file is only has 1 record for one set of records (either credit or debit) It's not finding the other record to compare with the unique indicator in 100th position and write it to outfile as one record.

regards
haritha
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Jan 13, 2010 10:46 pm    Post subject:
Reply with quote

It's not clear what you're trying to do. Showing us what you did that didn't work without explaining what you're trying to do makes it difficult to help you.

Please start over and show examples of the input records and expected output for various cases (including the one that doesn't work with your job). Explain the "rules" for getting from input to output. Give the RECFM and LRECL of the input file. Give the starting position, length and format of each relevant field.
Back to top
View user's profile Send private message
harithaganna

New User


Joined: 03 Jun 2008
Posts: 14
Location: chennai

PostPosted: Thu Jan 14, 2010 5:51 pm    Post subject:
Reply with quote

I want your help for the below issue

i am having the input file with credit/debit indicator and amount.
LRECL is 80
file layout is given below
01 C/D indicator pic x(01)
01 Amount pic s9(3)v99

Now whatever i have explained above is working fine,if the input file is having both credit and debit records.
If the input file is having only credit or only debit records(one sided records),The amount is summing up for either credit or debit.But the other amount is getting displayed as spaces.
for example
If input file contains
C 100
C 200
The output file is getting only

300 spaces(DB amount)
as per the above code but i should not get these spaces. instead of these spaces i should move 000 amount to the db amount if no debit records found in the input file viceversa for credit amount also.

Thanks & regards
haritha
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Jan 15, 2010 12:35 am    Post subject:
Reply with quote

I can't fix your job because it doesn't make any sense.

However, you can use a DFSORT job like the following to do what I think you're asking for:

Code:

//S1    EXEC PGM=SORT                                           
//SYSOUT DD SYSOUT=*                                           
//SORTIN DD *                                                   
C00100                                                         
C00200                                                         
D00300                                                         
D00400                                                         
//SORTOUT DD SYSOUT=*                                           
//SYSIN DD *                                                   
  OPTION COPY                                                   
  INREC IFOUTLEN=80,                                           
   IFTHEN=(WHEN=(1,1,CH,EQ,C'C'),BUILD=(1:2,5,11:C'00000')),   
   IFTHEN=(WHEN=(1,1,CH,EQ,C'D'),BUILD=(1:C'00000',11:2,5))     
  OUTFIL REMOVECC,NODETAIL,                                     
    TRAILER1=(TOT=(1,5,ZD,EDIT=(TTTTT)),                       
    11:TOT=(11,5,ZD,EDIT=(TTTTT)))                             
/*


For that input, SORTOUT will have:

Code:

00300     00700 


With just the C records for input, SORTOUT will have:

Code:

00300     00000 


With just the D records for input, SORTOUT will have:

Code:

00000     00700 


If that's not what you want, then you need to do a better job of explaining what you do want with good examples of input and expected output.
Back to top
View user's profile Send private message
harithaganna

New User


Joined: 03 Jun 2008
Posts: 14
Location: chennai

PostPosted: Fri Jan 15, 2010 11:38 am    Post subject:
Reply with quote

Thank you soo much
The logic worked for me.

Thanks & regards
Haritha
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us