SORT card for addition.

IBM's Sort Product, ICETOOL, ICEMAN and ICEGENER.
Post Reply
Deepak Mahant
New Member
Posts: 2
Joined: Sun Feb 08, 2015 12:14 pm

SORT card for addition.

Post by Deepak Mahant »

Hi,

In a COBOL program I have this calculation:

Code: Select all

NBR-A = TRUNC((variable-x / variable-y) + 0.5 )


The question is, can I do this using SORT? Please suggest on this.

I tried the following:

Code: Select all

OUTREC BUILD=(1:1,22,((17,3,ZD,DIV,20,3,ZD),ADD,+0.5))


And

Code: Select all

OUTREC BUILD=(1:1,22,((17,3,ZD,DIV,20,3,ZD),ADD,(+50,DIV,+100)))
but not getting the desired result.

I want to divide to interger column and add 0.5 to get the output field.

Please suggest.

regards
enrico-sorichetti
Global Moderator
Global Moderator
Posts: 826
Joined: Wed Sep 11, 2013 3:57 pm

Re: SORT card for addition.

Post by enrico-sorichetti »

sort does not handle decimal digits ...
You will have to do it on Your own.
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort 8-)
enrico-sorichetti
Global Moderator
Global Moderator
Posts: 826
Joined: Wed Sep 11, 2013 3:57 pm

Re: SORT card for addition.

Post by enrico-sorichetti »

a working snippet to show some division and rounding

Code: Select all

 ****** ***************************** Top of Data ******************************
 000001 //ENRICO1  JOB NOTIFY=&SYSUID,
 000002 //             MSGLEVEL=(1,1),CLASS=A,MSGCLASS=X
 000003 //*
 000004 //S1      EXEC PGM=SORT
 000005 //SYSPRINT  DD SYSOUT=*
 000006 //SYSOUT    DD SYSOUT=*
 000007 //TOOLMSG   DD SYSOUT=*
 000008 //DFSMSG    DD SYSOUT=*
 000009 //SORTIN    DD *
 000010  5.12      2.34
 000011  5         2
 000012  102       2
 000013  7         2
 000014  6         3
 000015 //SORTOUT   DD SYSOUT=*
 000016 //SYSIN     DD *
 000017   OPTION COPY
 000018   INREC  IFTHEN=(WHEN=NONE,
 000019          OVERLAY=(22:02,09,UFF,M11,LENGTH=07,C'00',
 000020                   32:12,09,UFF,M11,LENGTH=09,
 000021                   42:(22,09,ZD,DIV,32,09,ZD),ZD,LENGTH=09,
 000022                   52:(42,09,ZD,ADD,+50),ZD,LENGTH=09,
 000023                   62:(52,07,ZD),ZD,LENGTH=09))
 ****** **************************** Bottom of Data ****************************
the result

Code: Select all

********************************* TOP OF DATA **********************************
 5.12      2.34      000051200 000000234 000000218 000000268 000000002
 5         2         000000500 000000002 000000250 000000300 000000003
 102       2         000010200 000000002 000005100 000005150 000000051
 7         2         000000700 000000002 000000350 000000400 000000004
 6         3         000000600 000000003 000000200 000000250 000000002
******************************** BOTTOM OF DATA ********************************
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort 8-)
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: SORT card for addition.

Post by William Collins »

Deepak Mahant,

The code you show is not COBOL.

Without seeing your data, expected result and achieved result, we can't do more than make useless guesses about what is wrong with the SORT cards you have shown.
enrico-sorichetti
Global Moderator
Global Moderator
Posts: 826
Joined: Wed Sep 11, 2013 3:57 pm

Re: SORT card for addition.

Post by enrico-sorichetti »

My idea is that any IT practitioner with the usual number of active neurons should be able to take a snippet
and adapt it to any similar logic ,

in my snippet there are FIVE stages

1 and 2 convert from free form to zoned decimal extending the first operand with 2 decimal digits of zeroes
3 carries on the division
4 rounds UP
5 drops the decimals

does not look too difficult to follow :mrgreen:
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort 8-)
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: SORT card for addition.

Post by William Collins »

I agree, enrico. I wasn't talking about your code, but the TS/OP's code. Clarified now.
enrico-sorichetti
Global Moderator
Global Moderator
Posts: 826
Joined: Wed Sep 11, 2013 3:57 pm

Re: SORT card for addition.

Post by enrico-sorichetti »

hello William,
I was just considering Your comment
we can't do more than make useless guesses about what is wrong
I really hate wen we are asked to spoon feed the TS down to the last bit

and..
in general I wonder about the lack of logic reasoning shown in too many questions asked
and when I ask a TS where the problem is - in the logic or the coding -
I am really surprised that in too many cases the problem is in devising the logic.
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort 8-)
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: SORT card for addition.

Post by William Collins »

Agreed again, enrico.

However my actual comment was specific:
we can't do more than make useless guesses about what is wrong with the SORT cards you have shown
Turns out I was wrong on that anyway. Still, no point in fixing without seeing the data, as equally don't know what to fix :-)
Deepak Mahant
New Member
Posts: 2
Joined: Sun Feb 08, 2015 12:14 pm

Re: SORT card for addition.

Post by Deepak Mahant »

The original equation is from the "requirement document" but that can be done in cobol program, at least that what is assumed. But we thought to do it in sort as well. So William that's not a Cobol code but I needed some direction to achieve it in sort.
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: SORT card for addition.

Post by William Collins »

And what do you think enrico's effort is other than giving you the direction you want? It is also well documented.

SORT only does integer operations, so you have to do the scaling yourself, and does not do rounding, so you have to do that yourself.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM DFSort, ICETOOL, ICEMAN, ICEGENER.”