Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Why sort gives problem when coded as first stmt in program?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Wed Jul 04, 2007 5:59 pm    Post subject: Why sort gives problem when coded as first stmt in program?
Reply with quote

I know this has been discussed sometime back but I am not clear with the reason behind it.
Reference http://www.ibmmainframes.com/viewtopic.php?t=19664
When I coded SORT stmt as below-
Code:
 PROCEDURE DIVISION.                                               
     SORT SORT-FILE ON ASCENDING KEY ELEMENT         
......

I received warning message in sysout-
Code:
IGZ0026W The SORT-RETURN special register was never referenced, but the current
         operation in program TEST2 on line number 16 was unsuccessful.

First change I did was to print SORT-RETURN, after that warning message didnt come but still I received unsorted o/p and SORT-RETURN was 20.

Then I changed my code to -
Code:
PROCEDURE DIVISION.                             
     DISPLAY 'IN THE PROGRAM'.                 
     SORT SORT-FILE ON ASCENDING KEY ELEMENT 
.......

And o/p came sorted properly. icon_confused.gif
Back to top
View user's profile Send private message

agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Wed Jul 04, 2007 6:51 pm    Post subject: Some more information--
Reply with quote

when I compared assembly listing in both cases, there is a difference in two cases! ( Please note that I havent changed anything in SORT statement ) For your reference listing is given below,
Without DISPLAY stmt-
Code:
              L     2,296(0,9)              BL=1           
2010          XC    16(2,2),16(2)           SORT-RETURN   
              NI    85(9),X'FB'             TGTFIXD+85     
              L     3,92(0,9)               TGTFIXD+92     
              L     15,496(0,3)             V(IGZESMG )   
              LA    1,607(0,8)              PGMLIT AT +591
              BALR  14,15                                 
A0E8          MVC   240(4,10),232(10)       PSV=1         
              LA    4,362(0,11)             GN=8(00053A)   
              ST    4,232(0,10)             PVN=3         
              BC    15,476(0,11)            RELEASE-PARA   
     GN=8     EQU   *                                     
A0F0          MVC   232(4,10),240(10)       PVN=3         
              L     2,92(0,9)               TGTFIXD+92     
              L     15,496(0,2)             V(IGZESMG )   
              LA    1,606(0,8)              PGMLIT AT +590
              BALR  14,15                                 
A0EC          MVC   244(4,10),236(10)       PSV=2         
              L     11,40(0,12)             PBL=1         
              LA    3,404(0,11)             GN=9(000564)   
              ST    3,236(0,10)             PVN=4         
              BC    15,602(0,11)            RETURN-PARA   
     GN=9     EQU   *                                     
A0F4          MVC   236(4,10),244(10)       PVN=4         
              L     2,92(0,9)               TGTFIXD+92     
              L     15,496(0,2)             V(IGZESMG )   
              LA    1,605(0,8)              PGMLIT AT +589
              BALR  14,15                                 
     GN=24    EQU   * 



With DISPLAY before SORT-
Code:
               L     3,296(0,9)              BL=1           
 3010          XC    16(2,3),16(3)           SORT-RETURN   
               NI    85(9),X'FB'             TGTFIXD+85     
               L     15,496(0,2)             V(IGZESMG )   
               LA    1,621(0,8)              PGMLIT AT +605
               BALR  14,15                                 
 A0E8          MVC   240(4,10),232(10)       PSV=1         
               LA    4,372(0,11)             GN=8(000560)   
               ST    4,232(0,10)             PVN=3         
               BC    15,486(0,11)            RELEASE-PARA   
      GN=8     EQU   *                                     
 A0F0          MVC   232(4,10),240(10)       PVN=3         
               L     2,92(0,9)               TGTFIXD+92     
               L     15,496(0,2)             V(IGZESMG )   
               LA    1,620(0,8)              PGMLIT AT +604
               BALR  14,15                                 
 A0EC          MVC   244(4,10),236(10)       PSV=2         
               L     11,40(0,12)             PBL=1         
               LA    3,414(0,11)             GN=9(00058A)   
               ST    3,236(0,10)             PVN=4         
               BC    15,612(0,11)            RETURN-PARA   
      GN=9     EQU   *                                     
 A0F4          MVC   236(4,10),244(10)       PVN=4         
               L     2,92(0,9)               TGTFIXD+92     
               L     15,496(0,2)             V(IGZESMG )   
               LA    1,619(0,8)              PGMLIT AT +603
               BALR  14,15
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Jul 04, 2007 11:03 pm    Post subject:
Reply with quote

Hello,

Sounds like there may be a bit more to your situation. . .

I just looked at a few programs and other than a SECTION or a para-name, SORT is the first cobol statement after the PROCEDURE DIVISION statement and they all work successfully. In the one-time programs, there is no reference to SORT-RETURN and i get no warning nor an error.

You might try inserting a "dummy" paragraph between PROCEDURE DIVISION and SORT just to see if it makes a difference.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Thu Jul 05, 2007 11:50 am    Post subject:
Reply with quote

Dick,
I tried with a para-name and founf no change in the results. Without display statement I am still getting unsorted o/p and when I add Display I get sorted o/p. icon_sad.gif

I don't know assembler, can somebody justify the two set of code generated for same SORT statement? (Listed above)
Back to top
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Sat Jul 07, 2007 4:28 am    Post subject:
Reply with quote

The way I always did it was:

SORT SORT-FILE ON ASCENDING KEY ELEMENT
input procedure is 1000-sort-input thru 1999-exit
output procedure is 2000-sort-output thru 2999-exit
if sort-return is not zero - abend

I never ever used SECTIONs
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Jul 07, 2007 6:19 am    Post subject:
Reply with quote

Hi Abhijit,

Please post the JCL from this step and the SORT statement including 20 or so lines before and after the SORT statement.

The assembler shown is the rather awful generated stuff - not meant to be worked with for the most part. . . . If you still have it available, including the addresses that should be beside the instructions in the assembler code may be helpful.

Seeing the sort source and surrounding code may help with understanding why different registers were used in the 2 versions.
Back to top
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Mon Jul 09, 2007 12:30 am    Post subject:
Reply with quote

Yes, Dick, I believe you are correct - sortlib is missing from the JCL.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Mon Jul 09, 2007 1:08 pm    Post subject:
Reply with quote

Dick,
I was writing an adhoc program for some query in the forum when I faced this problem. you can see the program posted here-
http://www.ibmmainframes.com/viewtopic.php?t=22462

Jcl was very simple
Code:
//jobcard
//step1 exec pgm=test1
//steplib dd dsn=my.loadlib,disp=shr


@ Sandy,
Where do you want me to specify SORTLIB here?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Jul 09, 2007 6:26 pm    Post subject:
Reply with quote

Hi Abhijit,

Yup, remember that one well (it's been kinda recent icon_smile.gif ).

Did you have a chance to capture the addresses/displaments generated by the compiler for the 2 versions of the code?
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 4 Fri Sep 22, 2017 4:56 pm
No new posts LMINIT problem - not finding DDNAME Danielle.Filteau CLIST & REXX 7 Tue Sep 19, 2017 9:57 pm
No new posts OC4 in SORT Mohan Kothakota DFSORT/ICETOOL 2 Tue Sep 12, 2017 6:30 pm
No new posts SORT Trailer Count - LRECL Output co... amorante DFSORT/ICETOOL 5 Tue Aug 29, 2017 8:57 pm
No new posts Changing sort Card Dynamically vickey_dw DFSORT/ICETOOL 5 Sat Aug 19, 2017 2:33 pm

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