|
View previous topic :: View next topic
|
| Author |
Message |
mainfrae Currently Banned New User
Joined: 07 Feb 2006 Posts: 4
|
|
|
|
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 |
|
 |
Paddy
New User

Joined: 12 Sep 2005 Posts: 46 Location: Paris France
|
|
|
|
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  |
|
| Back to top |
|
 |
mainfrae Currently Banned New User
Joined: 07 Feb 2006 Posts: 4
|
|
|
|
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 |
|
 |
Paddy
New User

Joined: 12 Sep 2005 Posts: 46 Location: Paris France
|
|
|
|
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
| 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
| 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  |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|