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

Need help in copy replacing


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
himanshu_pant

New User


Joined: 08 Jul 2014
Posts: 14
Location: India

PostPosted: Tue Jul 08, 2014 2:24 pm
Reply with quote

Hi,

I am facing an issue. I need to have a group level variable in my code which is not present in the copybook.

for e.g,

The copybook copy1, the field has been defined as:

Code:
05 ws-ele1 pic x(15).
05 ws-ele2 pic 9(03).
05 ws-array-element occurs 99 times.
     10 ws-array-ele1 pic x(03).
     10 ws-array-ele2 pic 9(03).
05 ws-ele3 pic s9(4) comp.


I need to have in my code as:

Code:
05 ws-ele1 pic x(15).
05 ws-ele2 pic 9(03).
05 ws-array.
    10 ws-array-element occurs 99 times.
         15 ws-array-ele1 pic x(3).
         15 ws-array-ele2 pic 9(3).
05 ws-ele3 pic s9(4) comp.


Can this be done using cobol copy replacing as I don't want to perform the loop and copy the element in a working storage array variable unless that is the only option and if number of array element changes, I would have to make corresponding changes in my program as well ?

I tried this with copy replacing but its giving me compilation [/color]error:

Code:
COPY COPY1
REPLACING
== 05 ws-array-element == BY
== 05 ws-array.==
10 ws-array-element ==.


Please advise.

Code'd
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jul 08, 2014 2:55 pm
Reply with quote

No.

I dislike tables which are defined like that, but other than editing the copybook you're not going to get it to look different, and as you have mentioned, there are potential problems if you try to define it how you want elsewhere.

What is the particular problem that it causes you.
Back to top
View user's profile Send private message
himanshu_pant

New User


Joined: 08 Jul 2014
Posts: 14
Location: India

PostPosted: Tue Jul 08, 2014 3:03 pm
Reply with quote

Thanks Bill.

Actually I need to pass the entire array group element, ws-array in this case, to a subprogram. So if there is no other way, I guess I would define a working storage variable in my cobol program for that and fill it with each and every occurence of ws-array-element and then pass to the subprogram.

Regards,
Himanshu Pant
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jul 08, 2014 3:25 pm
Reply with quote

If that is what you want, the answer is simple:

Code:
CALL sub-program USING ...  ws-array-element ( 1 )


The address of the start of ws-array-element ( 1 ) is the same as the address of the start of the table (because it is the start of the table).

How does the sub-program know how many items are in the table?
Back to top
View user's profile Send private message
himanshu_pant

New User


Joined: 08 Jul 2014
Posts: 14
Location: India

PostPosted: Tue Jul 08, 2014 4:20 pm
Reply with quote

Thanks Bill.

It really resolved my query. I think I only needed to pass the address of the array element because in my subprogram I have the follwing code:

call subprogram using copy1
ws-array-element(1).



SET RECORD-ADD TO ADDRESS OF REC-BYTE (REC-IDX).

SET CALC-FIELD-ADD TO ADDRESS OF CALC-FLD.

PERFORM UNTIL RECORD-ADD EQUAL CALC-FIELD-ADD
SET REC-IDX UP BY PLUS-ONE
SET RECORD-ADD TO ADDRESS OF REC-BYTE (REC-IDX)
END-PERFORM.

This loop is performed until the first field recieved from main program is equal to address of second field recieved.

Thank you.
Regards.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jul 08, 2014 5:02 pm
Reply with quote

OK. Now I don't know what you are doing. I think you may be wasting a lot of CPU.

Can you post the definitions of everything used in that code snippet, including their locations (WORKING-STORAGE or LINKAGE) and explain what it is you want to do with that table in the sub-program.

I have a feeling you are greatly overcomplicating a simple task.
Back to top
View user's profile Send private message
chrakesh

New User


Joined: 03 May 2010
Posts: 16
Location: india

PostPosted: Thu Sep 11, 2014 5:33 pm
Reply with quote

Good.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts VB to VB copy - Full length reached SYNCSORT 8
No new posts Need COBOL COPY Help in MVS Environment COBOL Programming 4
No new posts Issue after ISPF copy to Linklist Lib... TSO/ISPF 1
No new posts DB2 Table - Image copy unload IBM Tools 2
Search our Forums:

Back to Top