|
Hi Shiva, By default all variables passed as parameters are by reference . So is u want to pass an array structure from PGMA using the statement Call Procedure "MODULEB" Using WS-Data. Any changes made by PGMB to itsWS-Data will also be reflected in PGMA. So u dont need to pass the address itself to PGMB.But in case u intentionally want to do that you can see the following source. TestArray moves all zeroes to GROUP1 and calls TESTA with the address of GROUP1.Any changes made to its contents by TESTA are reflected in TESTARRAY. So in the end GROUP1 is left with all 1's. I hope this helps _______________________________________________________________________ IDENTIFICATION DIVISION. PROGRAM-ID. TESTARRAY. ENVIRONMENT DIVISION. CONFIGURATION SECTION. DATA DIVISION. WORKING-STORAGE SECTION. 01 ARRAY-PTR USAGE POINTER. 01 GROUP1. 05 WS-X PIC X(5) OCCURS 10 TIMES. PROCEDURE DIVISION. TEST1-INIT. MOVE ALL '0' TO GROUP1. SET ARRAY-PTR TO ADDRESS OF GROUP1. CALL PROCEDURE "TESTA" USING BY VALUE ARRAY-PTR. DISPLAY GROUP1. STOP RUN. ____________________________________________________________________________ __ IDENTIFICATION DIVISION. PROGRAM-ID. TESTA. ENVIRONMENT DIVISION. CONFIGURATION SECTION. DATA DIVISION. WORKING-STORAGE SECTION. LINKAGE SECTION. 01 GROUP2. 05 WS-Y PIC X(5) OCCURS 10 TIMES. PROCEDURE DIVISION USING GROUP2. MOVE ALL '1' TO GROUP2. GOBACK. ___________________________________________________________________________ Thanks ! Sachin Kr. Gupta Computer Sciences Corporation Birmingham-AL ___________________________________________________________________________ ----- Original Message ----- From: "Sivasubrahmanian Ananthakrishnan" <sivasubrahmanian.ananthakrishnan@wipro.com> To: <cobol400-l@midrange.com> Sent: Friday, August 23, 2002 8:15 AM Subject: RE: Call by reference > > This is a multi-part message in MIME format. > -- > Jim > > Thanks for the explanation. Based on your explanation, my array should > be defined in both the programs as external as below:- > > Array-Table is external Pic X(1000) > > In PGMA, I will change some values of this array and call PGMB. In PGMB, > again I will do some processing on Array-Table and come back to PGMA. > > In the above situation, I am not calling PGMB with parameters. With the > above process, can I assume that any changes made in PGMB on Array-Table > will be reflected in PGMA? > > Thanks & Regards > Sivasubrahmanian. A > Project Engineer > Wipro Technologies (Finance & Insurance) > Electronics City, Bangalore, India > Phone - 8520408/8520416 x - 4364. > > -----Original Message----- > From: cobol400-l-admin@midrange.com > [mailto:cobol400-l-admin@midrange.com] On Behalf Of Jim Essinger > Sent: Friday, August 23, 2002 9:14 AM > To: cobol400-l@midrange.com > Subject: Re: Call by reference > > Shiva. > > If you are using using ILE COBOL, you can define the array as external > in > both programs, and simply call the array processing program. It will > have > access to the array from the calling program. You can do this with data > structures and files. I have used this many times to pass what would be > a > lot of data between two programs, such as file handling, etc. > > > * > ---------------------------------------------------------------- > * Lib: LibName SrcF: QCblSrc Copy Member Pgm008CBFD > * > ---------------------------------------------------------------- > * This Code is common to all Pgm008CB** modules, and is copied in > * to the DATA DIVISION, FILE SECTION for shared (externally > * described) files. > * > * Changes to these FD entries are reflected in all pgms at > compile > * time. > * > * > ---------------------------------------------------------------- > * > ---------------------------------------------------------------- > FD First-File > * > ---------------------------------------------------------------- > Is external. > 01 First-Rec. > COPY DDS-ALL-FORMATS IN FILE1PF. > > Using this code in both programs, ProgramA can open and read the files, > and > ProgramB can process the records without passing any parms. ProgramC > and > rewrite the changed records, ProgramD can delete the records from the > file. You can do the same thing with data structures in working > storage. They don't have to be named the same, but I find it helps in > knowing between programs what is being handled where. > > * > ---------------------------------------------------------------- > * Lib: LibName Srcf: QCblSrc Copy member: PGM008CBWS > * > ---------------------------------------------------------------- > * This Code is common to all PGM008CB** modules, and is copied in > * to Working-Storage section for shared (externally described) > * fields. > * > * Changes to these data definition statements are reflected in > * all pgms at compile time. > * > ---------------------------------------------------------------- > > 01 FILE-CONTROLLING-FIELDS is external. > 05 Changed-Records-Flag PIC X(01). > 88 Changed-Records VALUE 'Y'. > 88 No-Changed-Records VALUE 'N'. > 05 First-File-Flag PIC X(03). > 88 End-First-File VALUE 'EFF'. > 88 Not-End-First-File VALUE 'NEF'. > 88 Good-First-ReWrite VALUE 'GRW'. > 88 Good-First-Write VALUE 'GLW'. > 88 Good-First-Delete VALUE 'GLD'. > 88 Good-First-Read VALUE 'GLR'. > 88 Invalid-First-Key VALUE 'ILK'. > 88 Delete-First-OK VALUE 'DLO'. > 88 Dont-First-Lender VALUE 'DDL'. > > 01 Status-Group is external. > 05 First-File-STS PIC X(01). > 88 First-Open VALUE 'O'. > 88 First-Closed VALUE 'C' ' ' X'00'. > > 01 FILE-STATUS Typedef PIC X(02). > 88 IO-OK VALUE '00'. > 88 EOF VALUE '10'. > 88 NO-MOD-SFLRCDS VALUE '12'. > 88 IO-ERR VALUE '21' '24' '30' > '34' '90' '91' '92' '94' '95' '9A' '9H' '9I' '9K' > '9M' '9N' '9P'. > 88 Duplicate-Key VALUE '22'. > 88 NO-RECORD VALUE '23'. > 88 RECORD-LOCKED VALUE '9D'. > > 01 First-Status type File-Status is external. > > The above code is a sample of the copy books I use for all modules that > share external files, or working storage sections. I simply copy them > into > my programs at compile time. > > Hope this helps! > > Jim Essinger > Senior Programmer/Analyst > Student Loan Fund of Idaho > PO Box 730 > Fruitland ID 83619 > 208-452-4058 > > At 08:22 PM 8/22/2002 +0530, you wrote: > >-- > >Hi all > > > >I'm looking for a sample program that uses call by reference. I have a > >array in PGMA that needs to be processed in PGMB. I would like to > ignore > >calling the program with the array data itself as a parameter. Instead > >would like to use a pointer. If any of you have a sample program that > >will explain this functionality, it would be of great help. Please help > >with a sample program that uses call by reference > > > >Thanks & Regards > >Shiva > > > > > >-- > >**************************Disclaimer*********************************** > * > > > >Information contained in this E-MAIL being proprietary to Wipro Limited > is > >'privileged' and 'confidential' and intended for use only by the > individual > > or entity to which it is addressed. You are notified that any use, > copying > >or dissemination of the information contained in the E-MAIL in any > manner > >whatsoever is strictly prohibited. > > > >*********************************************************************** > **** > > > > > _______________________________________________ > This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) mailing > list > To post a message email: COBOL400-L@midrange.com > To subscribe, unsubscribe, or change list options, > visit: http://lists.midrange.com/cgi-bin/listinfo/cobol400-l > or email: COBOL400-L-request@midrange.com > Before posting, please take a moment to review the archives > at http://archive.midrange.com/cobol400-l. > > -- > **************************Disclaimer************************************ > > Information contained in this E-MAIL being proprietary to Wipro Limited is > 'privileged' and 'confidential' and intended for use only by the individual > or entity to which it is addressed. You are notified that any use, copying > or dissemination of the information contained in the E-MAIL in any manner > whatsoever is strictly prohibited. > > *************************************************************************** > _______________________________________________ > This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) mailing list > To post a message email: COBOL400-L@midrange.com > To subscribe, unsubscribe, or change list options, > visit: http://lists.midrange.com/cgi-bin/listinfo/cobol400-l > or email: COBOL400-L-request@midrange.com > Before posting, please take a moment to review the archives > at http://archive.midrange.com/cobol400-l. > >
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.