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

Inserting a line into a pgm thru REXX


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

New User


Joined: 07 Feb 2006
Posts: 4

PostPosted: Thu Feb 09, 2006 3:04 pm
Reply with quote

Hi
My requirement is to insert a line into a cobol pgm with some requirements
For example,
i will give a input variable thru my REXX code which is declared as a variable in workkingstorage division.

1) That variable should be inserted only in the procedure division only
2) Then if that variable comes inside the procedure division for 10 times in different places, i want to insert 10 lines whereever the variable is found

eg) working-storage section.
ws-eof pic x(10)
procedure division.
ws-eof
------ < = i want to insert here DISPLAY "WS-EOF"
ws-eof
Back to top
View user's profile Send private message
Paddy

New User


Joined: 12 Sep 2005
Posts: 46
Location: Paris France

PostPosted: Fri Feb 10, 2006 12:00 pm
Reply with quote

Hi mainfrae

You can to try this code it should work fine.





Code:
/* rexx                                                               */
/*                                                                    */
/*                                                               Paddy*/
trace o
pull var1 /* keyboard entry  */
DSNIN = 'your source cobol'
DSNOU = 'your output dsn'
INSER = 'text what you want to insert'
/* allocation and stem source */
'ALLOC FI($FIL1) DA('DSNIN') SHR REUSE'
 address MVS 'EXECIO * DISKR $FIL1 (STEM PRO. FINIS'
'FREE FI($FIL1)'
/* read stem and search var1 */
   do i = 1 to pro.0
      search = find(pro.i,var1)
          If search = 0
                    then
                        queue pro.i /* no var1 queue source line only */
                    else
                        do
                          queue pro.I /* var1 OK queue source line    */
                          queue inser /* and queue yr comment         */
                        end
   end
 /* write a new source with your comments */
'ALLOC FI($FIL2) DA('DSNOU') SHR REUSE'
ADDRESS MVS 'EXECIO * DISKW $FIL2 ( FINIS'
'FREE FI($FIL2)'
delstack
exit



Best regards

Paddy icon_smile.gif
Back to top
View user's profile Send private message
mainfrae
Currently Banned

New User


Joined: 07 Feb 2006
Posts: 4

PostPosted: Fri Feb 10, 2006 7:03 pm
Reply with quote

Thanks paddy
But when i tested this program,it is inserting when it is finding the variable first time.but I had that variable 10 times, i want to insert in 10 separate line also.

is there any way of using line_after and seek command
Back to top
View user's profile Send private message
Paddy

New User


Joined: 12 Sep 2005
Posts: 46
Location: Paris France

PostPosted: Fri Feb 10, 2006 8:09 pm
Reply with quote

hi Mainfrae,

This procedure inserts one line each time when it reach the variable. If one line contain several occurences of the designated variable then the procedure will not work well. Normally it must read each line of source file an reach the variable into. With my test file the procedure has inserted one line every time it reached variable. Perhaps what i not well understood your problem.

Before icon_smile.gif

Code:

******,***************************** Top of Data ******************************
000001,AAAAAAAAAAAAAAAAAAAAAAA
000002,BBBBBBBBBBBBBBBBBBBBB
000003,WEOF
000004,EEEEEEEEEEEEEEEEE
000005,AAAAAAAAAAAAAAAAAAAAAAA
000006,BBBBBBBBBBBBBBBBBBBBB
000007,WEOF
000008,EEEEEEEEEEEEEEEEE
000009,AAAAAAAAAAAAAAAAAAAAAAA
000010,WEOF
000011,END OF PROG
******,**************************** Bottom of Data ****************************


After icon_surprised.gif

Code:

******,***************************** Top of Data ******************************
000001,AAAAAAAAAAAAAAAAAAAAAAA
000002,BBBBBBBBBBBBBBBBBBBBB
000003,WEOF
000004,DISPLAY WEOF
000005,EEEEEEEEEEEEEEEEE
000006,AAAAAAAAAAAAAAAAAAAAAAA
000007,BBBBBBBBBBBBBBBBBBBBB
000008,WEOF
000009,DISPLAY WEOF
000010,EEEEEEEEEEEEEEEEE
000011,AAAAAAAAAAAAAAAAAAAAAAA
000012,WEOF
000013,DISPLAY WEOF
000014,END OF PROG
******,**************************** Bottom of Data ****************************




Regards.

Paddy icon_smile.gif
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 Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Write line by line from two files DFSORT/ICETOOL 7
Search our Forums:

Back to Top