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

sorting an input file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vaibhavjadhav

New User


Joined: 27 Jul 2007
Posts: 33
Location: mumbai

PostPosted: Thu Jun 03, 2010 3:27 pm
Reply with quote

Hi,

I want to sort an input file as given below:

Input
Emp Date sal
01 01022010 2
01 01022010 2
01 05022010 3
01 08092011 1
01 01062010 0
02 05022010 8
02 08092011 2
02 01062010 3

Output
Emp Date sal
01 01022010(min date) 8
02 05022010(min date) 13

In the above input the date field should be the minimum date for emp 01 and salary should be the summation of all the records of emp 01 or 02 respectively

Please do help me in achieving the output file as showm above.
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: Thu Jun 03, 2010 10:06 pm
Reply with quote

The min date for 02 would be 01062010, not 05022010.

You can use a DFSORT job like the following to do what you asked for:

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
01    01022010 2
01    01022010 2
01    05022010 3
01    08092011 1
01    01062010 0
02    05022010 8
02    08092011 2
02    01062010 3
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  INREC OVERLAY=(81:11,4,7,4)
  SORT FIELDS=(1,2,CH,A,81,8,ZD,D)
  OUTFIL REMOVECC,NODETAIL,
    BUILD=(1,80),
    SECTIONS=(1,2,
      TRAILER3=(1,14,15:TOT=(16,1,ZD,EDIT=(IIIIT))))
/*
Back to top
View user's profile Send private message
vaibhavjadhav

New User


Joined: 27 Jul 2007
Posts: 33
Location: mumbai

PostPosted: Mon Jul 05, 2010 5:39 pm
Reply with quote

Hi Frank Thanks for giving me the solution. Actually i tried doing the same with some more fields but didnt got the output. Will it be possible for you to ellaborate what exactly the fields are doing. Also i am a attaching the new input and output file, can you give output for this even. Thanks in advance.




Branch Agent Enddt Inpdt Amount
Input
122 2245 3041201 3041221 -3.75
122 2245 3051201 3051220 -3.75
122 2245 3061201 3061219 -3.75
122 2245 3071201 3071227 -3.75
122 2245 3041201 3041221 -3.00
251 1036 3070115 3070115 -200.00
251 1036 3070111 3070111 -200.00

Output
122 2245 3041201 3041221 -18.00
251 1036 3070111 3070111 -400.00
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: Tue Jul 06, 2010 2:51 am
Reply with quote

vaibhavjadhav,

What are the "rules" for getting from input to output for your new requirement? What is the starting position and length for each field?
Back to top
View user's profile Send private message
vaibhavjadhav

New User


Joined: 27 Jul 2007
Posts: 33
Location: mumbai

PostPosted: Tue Jul 06, 2010 9:44 am
Reply with quote

Hi Frank,

Apologize i didnt mention it clearly. Thanks for looking into my concern.

In the above input the date field should be the minimum date for all the Branch and agent and salary should be the summation of all the records of Branch 122 and 251 respectively. Please have a look at the below input and output structure.

Note: There should not be space between any two fields. Unfortunately if there seems to have any space could you tell me where exactly I have to change.

Please do help me with this issue. Do let me know if you have any concerns.

Input
Branch Agent Enddt Inpdt Amount
9(3) 9(4) 9(7) 9(7) S9(14)V9(4)
122 2245 3041201 3041221 -3.75
122 2245 3051201 3051220 -3.75
122 2245 3061201 3061219 -3.75
122 2245 3071201 3071227 -3.75
122 2245 3041201 3041221 -3.00
251 1036 3070115 3070115 -200.00
251 1036 3070111 3070111 -200.00

Output
Branch Agent Enddt Inpdt Amount
9(3) 9(4) 9(7) 9(7) S9(14)V9(4)
122 2245 3041201(min date) 3041221(min date) -18.00
251 1036 3070111(min date) 3070111(min date) -400.00
Back to top
View user's profile Send private message
anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Tue Jul 06, 2010 2:46 pm
Reply with quote

Hello Vaibhav,

Assuming the date is in format ddyyyy and input LRECL as 80, the following sort card can give you desired result -
Code:
INREC OVERLAY=(81:13,04,10,3,21,4,18,3,26,19,FS,PD,LENGTH=10)     
SORT FIELDS=(01,03,CH,A,81,7,ZD,D,88,7,ZD,D)                     
OUTFIL REMOVECC,NODETAIL,                                       
BUILD=(1,80),                                                   
SECTIONS=(01,03,                                                 
TRAILER3=(01,25,TOT=(95,10,PD,EDIT=(STTTTTTTTTTTTTTTTTTT.TT),SIGNS=(+,-))))


Hope this helps.
Anshul
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Tue Jul 06, 2010 4:01 pm
Reply with quote

Hi

I asked this question earlier but my post got deleted...I am asking again.
In the date field what does '3' in front of date indicate?

Also

Quote:
In the above input the date field should be the minimum date for all the Branch and agent and salary should be the summation of all the records of Branch 122 and 251 respectively.


here you said you wanted minimum input date for branch and agent but then you said salary should be summation of all the records for branch 122 and 251????

What if there is one more agent code for 122 or 251?

Thanks,
Back to top
View user's profile Send private message
anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Tue Jul 06, 2010 4:18 pm
Reply with quote

Hi sqlcode1,

I am not sure but I think date is in format of dddyyyy as in (julian date and year)

This will get clear once ts replies. However, I have posted my solution on this assumption.

Thanks,
Anshul.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Jul 06, 2010 7:07 pm
Reply with quote

the date data for the second request is something completely different
Quote:
3041201(min date) 3041221(min date)

I wonder what date format they use ?
Back to top
View user's profile Send private message
anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Tue Jul 06, 2010 7:12 pm
Reply with quote

Quote:
the date data for the second request is something completely different
Quote:
3041201(min date) 3041221(min date)

I wonder what date format they use ?


I did not notice this, I assumed format is dddyyyy.
Now, Even I wonder what date format this could be. icon_rolleyes.gif
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top