|
View previous topic :: View next topic
|
| Author |
Message |
vaibhavjadhav
New User

Joined: 27 Jul 2007 Posts: 33 Location: mumbai
|
|
|
|
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 |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
 |
vaibhavjadhav
New User

Joined: 27 Jul 2007 Posts: 33 Location: mumbai
|
|
|
|
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 |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
 |
vaibhavjadhav
New User

Joined: 27 Jul 2007 Posts: 33 Location: mumbai
|
|
|
|
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 |
|
 |
anshul_gugnani
New User

Joined: 02 Nov 2009 Posts: 73 Location: Mumbai
|
|
|
|
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 |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
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 |
|
 |
anshul_gugnani
New User

Joined: 02 Nov 2009 Posts: 73 Location: Mumbai
|
|
|
|
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 |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
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 |
|
 |
anshul_gugnani
New User

Joined: 02 Nov 2009 Posts: 73 Location: Mumbai
|
|
|
|
| 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.  |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|