Adding sequence numbers using input procedure in cobol



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Adding sequence numbers using input procedure in cobol

Postby Deepak kumar25 » Tue Oct 15, 2013 10:15 pm

Dear experts
I am having a file which have 10 records. I want to add sequence numbers in input records by using input procedure.
How can i achieve this. Please help.
Deepak kumar25
 
Posts: 34
Joined: Mon Jan 10, 2011 10:51 am
Has thanked: 0 time
Been thanked: 0 time

Re: Adding sequence numbers using input procedure in cobol

Postby Robert Sample » Tue Oct 15, 2013 10:33 pm

Are you using the COBOL SORT verb? If not, what does "input procedure" mean to you?

If you are using SORT with an INPUT PROCEDURE, why not just add another variable under the SD 01 level that has a sequence number of the appropriate size [that is, PIC 9(?)], define a WORKING-STORAGE counter to increment, and move the counter to the SD variable in the INPUT PROCEDURE?
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Adding sequence numbers using input procedure in cobol

Postby Deepak kumar25 » Wed Oct 16, 2013 4:45 pm

thanks
bt my requirement is that i want to reverse a file records. And want to add sequence number so that i can sort it in descending order using sequence number.

I will use wht u said make a working storage variable and increment the counter until as end of file is not come....



Deepak kumar
Deepak kumar25
 
Posts: 34
Joined: Mon Jan 10, 2011 10:51 am
Has thanked: 0 time
Been thanked: 0 time

Re: Adding sequence numbers using input procedure in cobol

Postby dick scherrer » Wed Oct 16, 2013 7:41 pm

Hello,

So, you can create the sequence number in the INPUT procedure and specify to sort descending on the SORT statement.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Adding sequence numbers using input procedure in cobol

Postby Deepak kumar25 » Thu Oct 17, 2013 12:24 pm

@disk scherrer
Yes exactly...
Deepak kumar25
 
Posts: 34
Joined: Mon Jan 10, 2011 10:51 am
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post