Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

problem in input and output procedure in sort

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

New User


Joined: 20 Oct 2006
Posts: 29

PostPosted: Thu Jan 09, 2014 11:43 pm    Post subject: problem in input and output procedure in sort
Reply with quote

Code:
Sort
:
:
INPUT PROCEDURE 0100-READ-FILE 
OUTPUT PROCEDURE 0200-WRITE-FILE

0100-READ-FILE
 START FILE-TEMP KEY IS >= WS-BUILDkey
 PERFORM UNTIL WS-EOF3 = 'Y'         
   READ FILE-TEMP NEXT RECORD               
        AT END MOVE 'Y' TO WS-EOF3   
   NOT AT END                                   
       MOVE FILE-TEMP-REC TO SORT-RECORD
   END-READ                                 
 END-PERFORM.                               
 MOVE 'N' TO WS-EOF3.               

0200-WRITE-FILE
PERFORM UNTIL WS-EOF2 = 'Y'                     
RETURN SORT-FILE
AT END                             
MOVE 'Y' TO WS-EOF2                                         
NOT AT END                                             
   MOVE    SPACES                TO   WS-TEMP-INPUT-AREA
   MOVE SORT-RECORD       TO SORT-FILE-TEMP-REC     
   WRITE SORT-FILE-TEMP-REC                             
END-RETURN
END-PERFORM


The input to sort KSDS file and ouput is flat file.
The 0100-read-file para is working fine but in 0200-write-file para while 'RETURN' the control is always is 'AT END' and does not go to 'Not At End'.
Am I missing anything ?

Code'd
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Fri Jan 10, 2014 12:09 am    Post subject: Reply to: problem in input and output procedure in sort
Reply with quote

RELEASE.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Fri Jan 10, 2014 12:12 am    Post subject:
Reply with quote

raviprabhu,
Please use Code tags.
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: Fri Jan 10, 2014 12:33 am    Post subject:
Reply with quote

Hello,

And when the output procedure completes, you should make sure sort-return is zeros.
Back to top
View user's profile Send private message
raviprabhu

New User


Joined: 20 Oct 2006
Posts: 29

PostPosted: Fri Jan 10, 2014 12:47 am    Post subject:
Reply with quote

sorry..I did not understand the comments..
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: Fri Jan 10, 2014 12:55 am    Post subject:
Reply with quote

Hello,

At the top of the page is a link to IBM Manuals. From that list read in the COBOL Language Reference about the SORT verb.

Somehow, you knew that you needed to RETURN the sorted records, but did not RELEASE them to the sort, so nothing was sorted.

When the code completes the "output procedure" the code needs to make sure the sort ran successfully (i.e. sort-return = zeros).

Look at your original post and notice that it is now highlighted and aligned (Coded"). JCL, SQL, data, code, that need to keep their alignment need to have the Code tag applied. Someone has done this for you. In the future, you should do this before posting. Use the Preview function to ensure the post appears as you want. Then Submit.
Back to top
View user's profile Send private message
raviprabhu

New User


Joined: 20 Oct 2006
Posts: 29

PostPosted: Fri Jan 10, 2014 1:01 am    Post subject: Reply to: problem in input and output procedure in sort
Reply with quote

Code:


0100-READ-FILE
 START FILE-TEMP KEY IS >= WS-BUILDkey
 PERFORM UNTIL WS-EOF3 = 'Y'         
   READ FILE-TEMP NEXT RECORD               
        AT END MOVE 'Y' TO WS-EOF3   
   NOT AT END                                   
       MOVE FILE-TEMP-REC TO SORT-RECORD
         RELEASE SORT-RECORD
     END-READ                                 
 END-PERFORM.                               
 MOVE 'N' TO WS-EOF3. 


when I use release in 0100-read para the program abends with U1003.
Is the release correct where i Have coded.
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: Fri Jan 10, 2014 1:18 am    Post subject:
Reply with quote

Hello,

At a glance, this appears ok.

How is the SD coded?

What does the JCL look like?

Is there any other diagnostic info presented?

Also note that Bolding does not work within the code tag icon_cool.gif
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Fri Jan 10, 2014 1:22 am    Post subject: Reply to: problem in input and output procedure in sort
Reply with quote

Hi Dick,

Sorry, fixed the bolding already :-)

Hi raviprabhu,

You don't just get U1003. We need to see what else you got, again in the Code tags please.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Jan 13, 2014 7:19 pm    Post subject:
Reply with quote

instead of this:

Code:

0100-READ-FILE
 START FILE-TEMP KEY IS >= WS-BUILDkey
 PERFORM UNTIL WS-EOF3 = 'Y'         
   READ FILE-TEMP NEXT RECORD               
        AT END MOVE 'Y' TO WS-EOF3   
   NOT AT END                                   
       MOVE FILE-TEMP-REC TO SORT-RECORD
         RELEASE SORT-RECORD
     END-READ                                 
 END-PERFORM.                               
 MOVE 'N' TO WS-EOF3.


why not this:
Code:

0100-READ-FILE.
 MOVE 'N' TO WS-EOF3
 START FILE-TEMP KEY IS >= WS-BUILDkey
 END-START
 PERFORM UNTIL WS-EOF3 = 'Y'         
   READ FILE-TEMP NEXT RECORD               
        AT END MOVE 'Y' TO WS-EOF3   
   END-READ                                 
   IF WS-EOF3 = 'N'
   THEN
       MOVE FILE-TEMP-REC TO SORT-RECORD
       RELEASE SORT-RECORD
   END-IF
 END-PERFORM.                               
 MOVE 'N' TO WS-EOF3.
0100-EXIT.
        EXIT.


can't remember and not going to look-it-up,
but I have always ended Paragraph names with a period.
I think it is required.

The NOT-AT-END is the same as the IF 'N' = WS-EOF3.

also, instead of continually using WS-EOF3,
use WS-EOF-INPUT and WS-EOF-OUTPUT
(actually, anything, just use two variables,
that way if you abend, you can tell from the variables where you are.)

and a final comment. why make this a cobol program?
just use SORT with an INPUT BUILD.

lost easier to debug, and may be easier for you, since you seem to be COBOL challanged.
Back to top
View user's profile Send private message
Peter cobolskolan

Active User


Joined: 06 Feb 2012
Posts: 104
Location: Sweden

PostPosted: Tue Jan 14, 2014 12:00 pm    Post subject:
Reply with quote

Quote:
The input to sort KSDS file.. .
Why sort a KSDS-file?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Jan 14, 2014 12:57 pm    Post subject: Reply to: problem in input and output procedure in sort
Reply with quote

To get the data into a different order than the KSDS key. We hope :-)
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: Tue Jan 14, 2014 7:50 pm    Post subject:
Reply with quote

Hello,

You should sort the SD (rather than an FD) to get the info you want in the new sequence.

Or, use the KSDS as inpout to a sort and a "temporary" file for thoutput of this sort. Only include the sort fields and the data fields needed.

When you use the SORT with input and output procedure, the input should not be modified.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Tue Jan 14, 2014 10:02 pm    Post subject:
Reply with quote

I have always preferred an external sort, even if I had to split the COBOL program.
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: Tue Jan 14, 2014 10:34 pm    Post subject:
Reply with quote

Hi Phil,

Quote:
I have always preferred an external sort
Many people / places do.

I just follow whatever standards are being used at the current site(s). . .

If it is not dictates, i look at the process to determine which way i believe is better.

@ravi - are you now able to proceed?
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 Performing arithmetic on input field zh_lad DFSORT/ICETOOL 24 Tue Dec 06, 2016 8:04 pm
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us