Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
ADD/ SUB Values

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
oerdgie

New User


Joined: 22 Nov 2007
Posts: 61
Location: Germany

PostPosted: Thu Jul 18, 2019 5:09 pm    Post subject: ADD/ SUB Values
Reply with quote

Hi Folks,

I need some help with the ADD/SUB Control Statements.

Input file = LRECL=80,RECFM=FB

Code:

--------------------------------------------------
=COLS> ----+----1----+----2----+----3----+----4---
002502 AAA      ø         BBB                     
       CCC0000007000000010CCC444444444444444444444
       111000C000C003C001C222000000000000000000000
--------------------------------------------------
002503 DDD                EEE                     
       CCC0000002000000040CCC444444444444444444444
       444000C010C013C000C555000000000000000000000


There are 4 PD-Fields :
1. Field (Pos=4, Len=4)
2. Field (Pos=8, Len=4),
3. Field (Pos=12, Len=4)
4. Field (Pos=16, Len=4)

I like to add the 2. and 3. Field to the 1. PD-Field
and subtract the 4. Field from the 1. Field.

The Result :

Code:

=COLS> ----+----1----+----2----+----3----+-
002502 AAA     ø         BBB             
       CCC0060007000000010CCC44444444444444
       111002C000C003C001C22200000000000000
-------------------------------------------
002503 DDD  c             EEE             
       CCC0080002000000040CCC44444444444444
       444013C010C013C000C55500000000000000


How can I resolve the problem ?

Many thanks in advance for help !
Back to top
View user's profile Send private message

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2247
Location: Hampshire, UK

PostPosted: Thu Jul 18, 2019 5:32 pm    Post subject: Reply to: ADD/ SUB Values
Reply with quote

What have you tried and what was wrong with your results?
Back to top
View user's profile Send private message
oerdgie

New User


Joined: 22 Nov 2007
Posts: 61
Location: Germany

PostPosted: Thu Jul 18, 2019 5:46 pm    Post subject:
Reply with quote

To add one value to the result field in my example is no problem, but more then one… no idea
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2247
Location: Hampshire, UK

PostPosted: Thu Jul 18, 2019 7:12 pm    Post subject: Reply to: ADD/ SUB Values
Reply with quote

The manual shows how:
((field1,add,field2),add,field3),sub,(field4)
Simply nest the ADDs.
At least, that is my interpretation of the example.

You may have to do it on INREC and place the result at the end of the record - extending it if necessary and then on OUTREC move it to where you want it.
I do not have access to modern DFsort so cannot play.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2299
Location: NY,USA

PostPosted: Thu Jul 18, 2019 7:22 pm    Post subject:
Reply with quote

Performing arithmetic with numeric fields and constants
Back to top
View user's profile Send private message
oerdgie

New User


Joined: 22 Nov 2007
Posts: 61
Location: Germany

PostPosted: Thu Jul 18, 2019 8:49 pm    Post subject:
Reply with quote

Hi Nic,

thanks for your support icon_smile.gif

I got it, my solution (it works):

Code:

OPTION COPY                                           
INREC IFTHEN=(WHEN=INIT,                             
              OVERLAY=(439:(((439,5,PD,ADD,498,5,PD),
                            ADD,194,5,PD),           
                            SUB,519,5,PD),           
                            TO=PD,LENGTH=5))         


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

Active Member


Joined: 29 Apr 2008
Posts: 609
Location: Maryland

PostPosted: Tue Jul 23, 2019 7:01 pm    Post subject: Re: Reply to: ADD/ SUB Values
Reply with quote

Nic Clouston wrote:
The manual shows how:
((field1,add,field2),add,field3),sub,(field4)
Simply nest the ADDs.

There is no need even in nesting when only ADD, and SUB are used:
these arithmetics can be done sequentially
(field1,ADD,field2,ADD,field3,SUB,field4)
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 609
Location: Maryland

PostPosted: Tue Jul 23, 2019 7:05 pm    Post subject:
Reply with quote

oerdgie wrote:

I got it, my solution (it works):

Code:

OPTION COPY                                           
INREC IFTHEN=(WHEN=INIT,                             
              OVERLAY=(439:(((439,5,PD,ADD,498,5,PD),
              ADD,194,5,PD),           
              SUB,519,5,PD),           
              TO=PD,LENGTH=5))         


Regards

For clarity:
Code:
OPTION COPY                                           
INREC IFTHEN=(WHEN=INIT,                             
              OVERLAY=(439:(439,5,PD,
                        ADD,498,5,PD,
                        ADD,194,5,PD,           
                        SUB,519,5,PD,           
                        TO=PD,LENGTH=5))
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts position, start pos, length of column... juares castro SYNCSORT 14 Fri Jun 21, 2019 8:47 pm
No new posts How can we create a flat file in JAVA... jasorn Java & MQSeries 2 Wed Aug 08, 2018 3:08 pm
This topic is locked: you cannot edit posts or make replies. I need to remove low values in my field shymala COBOL Programming 8 Sun Jul 29, 2018 11:15 am
No new posts KSDS file fields update by passing va... Anil Kumar Prajapati TSO/ISPF 5 Wed Jul 11, 2018 5:59 am
No new posts LOW VALUES as a KEY juares castro DB2 10 Sat Apr 07, 2018 1:06 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us