|
View previous topic :: View next topic
|
| Author |
Message |
balaji81_k
Active User
Joined: 29 Jun 2005 Posts: 155
|
|
|
|
Hi Team,
I have a input file which has LRECL=80, RECFM = FB .Out of 80 bytes it has only 35 bytes of data . I need to sort and get sum by date field and amount field which occupies at 10th position and 21st position. Amount is of packed decimal which occupies 10 bytes of length.
I am not getting the expected edited format .
| Code: |
SORT FIELDS=(10,10,CH,A)
INREC OVERLAY =(40:21,10,PD,TO=ZD,LENGTH=15)
SUM FIELDS=(40,15,ZD)
OUTREC BUILD=(01:01,10,X,12:40,15,ZD,DIV,+1000,EDIT=(I,III,III,IIT),
80:X)
|
SORT OUTPUT:-
| Code: |
01/19/2019 299,543,908
02/20/2018 77,025,384
|
Expected output:-
| Code: |
01/19/2019 2,995,439
02/20/2018 770,253
|
When i change the edit format to
I am missing the first byte . Please advise what edit should i use to achieve the expected format .
Thanks |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2283 Location: USA
|
|
|
|
Add temporary output of all intermediate results to find out where exactly it goes wrong?
This is the standard way for debugging any code, in any language, and under any circumstances.
Do not try guessing, or asking others to guess for you. |
|
| Back to top |
|
 |
balaji81_k
Active User
Joined: 29 Jun 2005 Posts: 155
|
|
|
|
Hi Sergeyken,
I am sorry. I almost done in editing the sum value to my expectation but still i am working on get rid of the values after decimal which i don't need .
| Code: |
SORT FIELDS=(10,10,CH,A)
INREC OVERLAY =(40:21,10,PD,TO=ZD,LENGTH=15)
SUM FIELDS=(40,15,ZD)
OUTREC BUILD=(01:01,10,X,12:40,15,ZD,DIV,+1000,
EDIT=(SII,III,III,III,III,III,III,III,III,IIT.TT),SIGNS=(,-),
80:X)
|
Thanks |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2283 Location: USA
|
|
|
|
| balaji81_k wrote: |
Hi Sergeyken,
I am sorry. I almost done in editing the sum value to my expectation but still i am working on get rid of the values after decimal which i don't need .
| Code: |
SORT FIELDS=(10,10,CH,A)
INREC OVERLAY =(40:21,10,PD,TO=ZD,LENGTH=15)
SUM FIELDS=(40,15,ZD)
OUTREC BUILD=(01:01,10,X,12:40,15,ZD,DIV,+1000,
EDIT=(SII,III,III,III,III,III,III,III,III,IIT.TT),SIGNS=(,-),
80:X)
|
Thanks |
You've ignored the suggestion to trace intermediate results....
For ZD format, you can use only the first positions from the result of DIV, and ignore the rest of it.
For instance, use another BUILD=(...truncated field(s) …) in OUTFIL.
Other ways are also possible. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
| Back to top |
|
 |
balaji81_k
Active User
Joined: 29 Jun 2005 Posts: 155
|
|
|
|
| Thank Rohit for the samples. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|