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

ADD/ SUB Values


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 2453
Location: Hampshire, UK

PostPosted: Thu Jul 18, 2019 5:32 pm
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
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: 2453
Location: Hampshire, UK

PostPosted: Thu Jul 18, 2019 7:12 pm
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

Global Moderator


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

PostPosted: Thu Jul 18, 2019 7:22 pm
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
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: 932
Location: Maryland

PostPosted: Tue Jul 23, 2019 7:01 pm
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: 932
Location: Maryland

PostPosted: Tue Jul 23, 2019 7:05 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts a copybook getting improper values in... COBOL Programming 7
No new posts JDBC Driver -Default Values DB2 1
No new posts Not able to view the values of variab... CA Products 1
No new posts position, start pos, length of column... SYNCSORT 14
No new posts How can we create a flat file in JAVA... Java & MQSeries 3
Search our Forums:

Back to Top