I have a requirement where I have to find certain words in a COBOL program using an Edit Macro (I will be using both Rexx and Edit Macro commans in the same code). I have to first find the occurence of the PROCEDURE DIVISION and then the WORKING-STORAGE. I use the "FIND" command to accomplish this. It works fine when I am searching for the first term, however on searching for the second term, I get a RC(-4) although the second term (ie, WORKING-STORAGE) is present.
Please find below a snippet of the code. Both the FIND commands are issued in separate subroutines that are called consecutively.
SUBROUTINE1
TERM = 'PROCEDURE'
"FIND" TERM
<do something>
SUBROUTINE2:
WS = 'WORKING-STORAGE'
"FIND" WS
<do something>
TERM = 'PROCEDURE'
"FIND" TERM
<do something>
SUBROUTINE2:
WS = 'WORKING-STORAGE'
"FIND" WS
<do something>
I don't seem to understand what the problem is. It would be great if someone can help me out with this!