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

Increment COBOL line numbers using REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Achroo

New User


Joined: 07 Jan 2008
Posts: 7
Location: noida

PostPosted: Tue Jul 22, 2008 1:29 am
Reply with quote

I want to make tools such that which simply fetches data in first 7 columns and increment it by one, from start position to end position.

e.g
Input

m/f numbering 1234567........................80
.A 200000 cobol line
20000 cobol line
30000 cobol line
.B cobol line


expected output


m/f numbering 1234567........................80
.A 200000 cobol line
20000 200001 cobol line
30000 200002 cobol line
.B 200003 cobol line

that is from A to B my rexx program would increase the number by one
and give me that output


thanks
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Jul 22, 2008 1:40 am
Reply with quote

Quote:
I want to make tools.....

OK, go ahead, what is the problem?
things to remember when posting
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Tue Jul 22, 2008 1:42 am
Reply with quote

Please clarify... do you want to run the tool from within the ISPF editor?

And if is for the editor, you need to learn how to code editor macros. See the ISPF Editor manual. At least read about the MACRO, and LINE instructions.

And it is not clear that you know rexx that much... you will need to study the TSO/E REXX Reference.
Back to top
View user's profile Send private message
Douglas Wilder

Active User


Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

PostPosted: Tue Jul 22, 2008 2:15 am
Reply with quote

I wrote an edit macro some time ago that does a similar function in a slightly different way.
Code:
/* REXX EDITOR MACRO INCR BY DOUGLAS WILDER OF AIC                   */
/* USE CC CC TO MARK LINES THEN ENTER COMMAND "INCR COL LEN"         */
/* NUMBER IN THE FIRST LINE MARKED WILL BE INCREMENTED IN NEXT LINES */
                                                                       
ADDRESS "ISREDIT" "MACRO (COLMN,LN) NOPROCESS"                         
ADDRESS "ISREDIT" "PROCESS DEST RANGE C M"                             
                                                                       
IF LN = "" THEN DO                                                     
    SAY "MISSING PARAMETERS"                                           
    SAY "USE CC CC TO MARK LINES"                                     
    SAY "INCR COL LENGTH"                                             
    SAY "THE NUMBER IN THE INDICATED COL IN THE FIRST LINE MARKED"     
    SAY "WILL BE INCREMENTED IN NEXT LINES"                           
    EXIT                                                               
END                                                                   
                                                                       
ADDRESS "ISREDIT" "ISREDIT" "(CMD)   = RANGE_CMD"                     
ADDRESS "ISREDIT" "ISREDIT" "(FIRST) = LINENUM .ZFRANGE"               
ADDRESS "ISREDIT" "ISREDIT" "(LAST)  = LINENUM .ZLRANGE"
                                                         
ADDRESS "ISREDIT" "(DATALN) = LINE (FIRST)"             
CNTR = SUBSTR(DATALN,COLMN,LN) + 1                       
DO CURRLN = FIRST + 1 TO LAST                           
   ADDRESS "ISREDIT" "(DATALN) = LINE (CURRLN)"         
   DATA1 = SUBSTR(DATALN,1,COLMN - 1)                   
   DATA2 = COPIES("0", LN - LENGTH(CNTR)) || CNTR       
   DATA3 = SUBSTR(DATALN, COLMN + LN)                   
   DATALN = DATA1 || DATA2 || DATA3                     
   ADDRESS "ISREDIT" "LINE (CURRLN) = (DATALN)"         
   CNTR = CNTR + 1                                       
END                                                     
                                                         
EXIT                                                     
This edit macro called INCR uses cc cc to indicate the lines to increment. It requires 2 parameters the column and the length of the number to be incremented. In your case I believe that the column would be 1 and the length 7. See if this will fit your needs or you may modify it any way you would like to.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Jul 22, 2008 4:09 am
Reply with quote

By the way COBOL is numbered in columns 1 - 6 not 1 - 7!
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 -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top