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

Divide and edit the sum - OutRec


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

Active User


Joined: 29 Jun 2005
Posts: 155

PostPosted: Thu May 02, 2019 4:21 am
Reply with quote

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

Code:


EDIT=(I,III,IIT)



I am missing the first byte . Please advise what edit should i use to achieve the expected format .

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

Senior Member


Joined: 29 Apr 2008
Posts: 2017
Location: USA

PostPosted: Thu May 02, 2019 4:34 am
Reply with quote

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
View user's profile Send private message
balaji81_k

Active User


Joined: 29 Jun 2005
Posts: 155

PostPosted: Fri May 03, 2019 2:11 am
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2017
Location: USA

PostPosted: Fri May 03, 2019 6:17 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Fri May 03, 2019 8:57 pm
Reply with quote

Editing numeric fields
Also, sometimes, you need to twist little bit and adjust the EDIT to get your results right, like this.
Back to top
View user's profile Send private message
balaji81_k

Active User


Joined: 29 Jun 2005
Posts: 155

PostPosted: Tue May 07, 2019 8:25 pm
Reply with quote

Thank Rohit for the samples.
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 Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Need help to resolve a hard edit COBOL Programming 8
This topic is locked: you cannot edit posts or make replies. Need help to resolve a hard edit COBOL Programming 4
No new posts create rexx edit Macro that edits the... CLIST & REXX 3
Search our Forums:

Back to Top