Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Arithmetic operations using DFSORT
Using DFOSRT, we can perform arithmetic operations on input fields.

OUTFIL OUTREC now allows you to combine fields, decimal constants (+n
and -n), operators (MIN, MAX, MUL, DIV, MOD, ADD, SUB) and parentheses
to form arithmetic expressions, and place the results in your records
as BI, FI, PD, ZD, FS or edited CH values.

Syntax:
term,operator,term<,operator,...>

Where:
Term is a field (Start position, Number of characters, Format) or a
decimal constant (+n or -n). You can use BI, FI, PD, PD0, ZD, FS, DTn
and

Operator is MIN (minimum), MAX (maximum), MUL (multiplication), DIV
(division), MOD (modulus), ADD (addition) or SUB (subtraction).

The order of evaluation precedence for the operators is as follows
unless it is changed by parentheses:
1. MIN and MAX
2. MUL, DIV and MOD
3. ADD and SUB

The intermediate or final result of a DIV operation is rounded down to
the nearest integer. The intermediate or final result of a MOD
operation is an integer remainder with the same sign as the dividend.
If an intermediate or final result of an arithmetic expression
overflows 15 digits, the overflowing intermediate or final result will
be truncated to 15 digits. If an intermediate or final result of an
arithmetic expression requires division or modulus by 0, the
intermediate or final result will be set to 0.

Example 1: [(First 2 digits) * (-10)] + 10, and the output is formatted
by edit mask (M0 - M26), and is truncated to a length of 5

//SYSIN DD *
SORT FIELDS=(1,2,CH,A)
OUTREC FIELDS=(1,3,
(1,2,ZD,MUL,-10,ADD,+10),M6,LENGTH=5,
15X)
//*

Example 2, Divide the first field (positions 1, 2) by the second field
(position 3), and the output is converted to packed decimal format

//SYSIN DD *
SORT FIELDS=(1,2,CH,A)
OUTREC FIELDS=(1,3,
(1,2,ZD,DIV,3,1,ZD),TO=PD,
15X)
//*

Thanks,
MFTIPS
http://mftips.blogspot.com/


Report this thread to moderator Post Follow-up to this message
Old Post
mftips@gmail.com
01-25-06 08:55 AM


Re: Arithmetic operations using DFSORT
Wow!  I guess we don't need (mainframe) COBOL any more, do we?

Report this thread to moderator Post Follow-up to this message
Old Post
Colin Campbell
01-26-06 08:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:52 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.