|
View previous topic :: View next topic
|
| Author |
Message |
oerdgie
New User
Joined: 22 Nov 2007 Posts: 64 Location: Germany
|
|
|
|
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 |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
| What have you tried and what was wrong with your results? |
|
| Back to top |
|
 |
oerdgie
New User
Joined: 22 Nov 2007 Posts: 64 Location: Germany
|
|
|
|
| To add one value to the result field in my example is no problem, but more then one… no idea |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
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 |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
| Back to top |
|
 |
oerdgie
New User
Joined: 22 Nov 2007 Posts: 64 Location: Germany
|
|
|
|
Hi Nic,
thanks for your support
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 |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
| 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 |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
| 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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|