Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PERFORM REPLACING 1

Status
Not open for further replies.

Yanndewael

Programmer
Mar 14, 2003
12
GB
HEllo,

Is it possible to use "replacing" option in a PERFORM
such as:

PERFORM TODO THRU TODO-FN
REPLACING XXXX BY ABCD

PERFORM TODO THRU TODO-FN
REPLACING XXXX BY EFGH

?? This would be useful when I have to make some treatments on different tables with the same layout.

Thank you in advance
 
01 w-table pic x(10) occurs 200.

...

perform varying w-index from 1 by 1 until w-index > 200
inspect w-table(w-index) converting "xxxx" to "bbbb"
end-perform.

Now if the xxx and bbb are not the same size you have a problem.

Do give us a full example of what you need to do, with real cases.




Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Here is the real example:

Instead of doing this:

* a) For IN , we read IND41

PERFORM READ-IND41 THRU READ-IND41-FN.

* b) For IR , we read IRD42

PERFORM READ-IRD42 THRU READ-IRD42-FN.


READ-IND41.
*----------*

INITIALIZE IND41-01.

@STARTZ,"1","GE",IND41-01,XX.

PERFORM UNTIL NOT ACCESS-OK

@READNX,IND41-01,XX
MOVE IDTENC OF IND41-01 TO IDTENC OF ZCD11-01
....

@WRITE,ZCD11-01,XX

END-PERFORM.


READ-IND41-FN.
*-------------*
EXIT.


READ-IRD42.
*----------*

INITIALIZE IRD42-01.

@STARTZ,"1","GE",IRD42-01,XX.
PERFORM UNTIL NOT ACCESS-OK

@READNX,IRD42-01,XX
MOVE IDTENC OF IRD42-01 TO IDTENC OF ZCD11-01
...
@WRITE,ZCD11-01,XX
END-PERFORM.


READ-IRD42-FN.
*-------------*
EXIT.



I would like to do instead something like

* a) For IN , we read IND41

PERFORM READ-XXDYY THRU READ-XXDYY-FN
REPLACING "XXDYY" BY "IND41".

* b) For IR , we read IRD42

PERFORM READ-XXDYY THRU READ-XXDYY-FN
REPLACING "XXDYY" BY "IRD42".


READ-XXDYY.
*----------*

INITIALIZE XXDYY-01.

@STARTZ,"1","GE",XXDYY-01,XX.
PERFORM UNTIL NOT ACCESS-OK

@READNX,XXDYY-01,XX
MOVE IDTENC OF XXDYY-01 TO IDTENC OF ZCD11-01
...
@WRITE,ZCD11-01,XX
END-PERFORM.


READ-XXDYY-FN.
*-------------*
EXIT.



Thank you in advance
 
There is no REPLACING option of the PERFORM statement.

Without details I'm just guessing as to exactly what you're asking, but it looks like you have two different tables that have identical layouts and different datanames. You want to be able to execute the same piece of code with either table by making the code 'changeable' at execution time.

How about this? Set up a third table that is defined just like the other two and use that one to do your processing. Let's say you have TABLE-1 and TABLE-2 as your two tables to process. Create TABLE-3 that is an identical layout. Determine which table you want to use, move it to TABLE-3, process your generic paragraph that accesses TABLE-3 and then when you come back (if you expect updates to happen) move TABLE-3 back to the original table.

MOVE TABLE-1 TO TABLE-3
PERFORM TODO THRU TODO-FN
MOVE TABLE-3 TO TABLE-1

or

MOVE TABLE-2 TO TABLE-3
PERFORM TODO THRU TODO-FN
MOVE TABLE-3 TO TABLE-2



 
Looks like the assumptions I made were wrong. I assumed you were talking about COBOL tables. Looks like you're talking about 'files'. That shows the need to give examples so we all are talking about the same thing.

In any event, there is still not an option to change code during execution.
 
Thank you for your answer, but the tables are Oracle ones, with thousands of records in. So, it is not possible to move tables like that (I think at least...).

I will multiply PERFORM then...

Cheers
 
Ok.

First it seems that you are using a precompiler. Is this correct? If it is it may affect the following.

What you are after can be accomplished by the use of a copybook.

You would have a copybook containing

READ-(XXDYY).
*----------*

INITIALIZE (XXDYY)-01.

@STARTZ,"1","GE",(XXDYY)-01,XX.
PERFORM UNTIL NOT ACCESS-OK

@READNX,(XXDYY)-01,XX
MOVE IDTENC OF (XXDYY)-01 TO IDTENC OF ZCD11-01
...
@WRITE,ZCD11-01,XX
END-PERFORM.


READ-(XXDYY)-FN.
*-------------*
EXIT.

And on your main program you would code
PERFORM READ-IND41 THRU READ-IND41-FN.
PERFORM READ-IRD42 THRU READ-IRD42-FN.
.....

copy "copybookx" replacing ==(XXDYY)== by ==IND41==.
copy "copybookx" replacing ==(XXDYY)== by ==IRD42==.


Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Indeed, I had thought to this solution. But I'd rather have only one file instead one main program + several copybooks... Easier to transfer, to debug, ...

And yes, we have precompiler.

Thank you anyway,

Yannick
 
You would have one copybook for each big block of code.
so on the case you mentioned you would have ONE copybook, eventually two if you whished to have the "performs" on a copybook also.

If as you say the code is equal to all tables then the copybook is the way to go.

The precompiler is the one that is going to cause you trouble.

As for debugging it depends on the COBOL you are using. For the ones I use copybooks is not a problem.


Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top