Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Need help in copy replacing

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Need help in copy replacing
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Tue Jul 08, 2014 2:55 pm    Post subject: Reply to: Need help in copy replacing
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    Post subject: Reply to: Need help in copy replacing
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Tue Jul 08, 2014 3:25 pm    Post subject: Reply to: Need help in copy replacing
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    Post subject: Reply to: Need help in copy replacing
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Tue Jul 08, 2014 5:02 pm    Post subject: Reply to: Need help in copy replacing
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
No new posts Single COPY CICS TS datasets and when... Kyle Carroll CICS 2 Tue Oct 11, 2016 9:47 pm
No new posts dataset copy question - REPRO or some... atulxp TSO/ISPF 2 Wed Aug 03, 2016 10:56 pm
No new posts How to copy Tape dataset to unix main... chaky All Other Mainframe Topics 4 Fri Jul 08, 2016 2:52 am
No new posts Using Field names in FILEAID Batch CO... Atul Banke Compuware & Other Tools 2 Wed Jun 29, 2016 9:54 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us