IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to sort the file with the given criteria


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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 Developer


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

PostPosted: Wed Jan 13, 2010 10:46 pm
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
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 Developer


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

PostPosted: Fri Jan 15, 2010 12:35 am
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top