IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

problem in input and output procedure in sort


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

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

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

JCL Moderator


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

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

raviprabhu,
Please use Code tags.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Jan 10, 2014 12:33 am
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
Reply with quote

sorry..I did not understand the comments..
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Jan 10, 2014 12:55 am
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
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

Moderator Emeritus


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

PostPosted: Fri Jan 10, 2014 1:18 am
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Jan 10, 2014 1:22 am
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
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jan 14, 2014 12:57 pm
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

Moderator Emeritus


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

PostPosted: Tue Jan 14, 2014 7:50 pm
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

Senior Member


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

PostPosted: Tue Jan 14, 2014 10:02 pm
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

Moderator Emeritus


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

PostPosted: Tue Jan 14, 2014 10:34 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top