Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Writing a File in a Called Program.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
hitesh0000

New User


Joined: 01 Feb 2008
Posts: 6
Location: Noida

PostPosted: Wed Aug 06, 2008 12:01 pm    Post subject: Writing a File in a Called Program.
Reply with quote

Hi,

I am writing a file in a calling program, Is that possible?

Because I can see that the data is moving to the variable defined in FD section, but when i give the WRITE command it comes blank.

The output file is always empty.

The details are as follows:

Calling Program : AAAA

Called Program : BBBB

In my called program I am writing a file, details of which are:

Code:
SELECT TSS310C ASSIGN TO TSS310C     
ORGANIZATION         IS  SEQUENTIAL 
ACCESS               IS  SEQUENTIAL 
FILE STATUS          IS  FS-TSS310C.



Code:
FD  TSS310C                       
    LABEL RECORD STANDARD         
    DATA  RECORD TSS310C-RECORD. 
01  TSS310C-RECORD  PIC X(113).   



In my working storage section I have:

Code:
01  TSS310C-COPY.
    05 TSS310C-TAILLE                    PIC X(113).       
    05 FILLER                REDEFINES TSS310C-TAILLE.     
      10 TSS310C-ENREG.                                   
        15 TSS310C-CDMES       PIC X(12).                 
        15 TSS310C-LBMES       PIC X(30).                 
        15 TSS310C-CDNATMES    PIC X(03).                 
        15 TSS310C-LCTABLE     PIC X(03).                 
        15 TSS310C-IDTABLE     PIC 9(9).                 
        15 TSS310C-CLEF-TABLE  PIC X(36).                 
        15 TSS310C-FLPRES      PIC X(01).                 
        15 TSS310C-FLDERNIER   PIC X(01).                 
        15 TSS310C-FLMIN       PIC X(01).                 
        15 TSS310C-FLMAX       PIC X(01).                 
        15 TSS310C-VAMIN       PIC 9(04)V9(4).           
        15 TSS310C-VAMAX       PIC 9(04)V9(4).         



In my code I have:

MOVE TSS310C-COPY TO TSS310C-RECORD.
WRITE TSS310C-RECORD FROM TSS310C-COPY.


In the SYSOUT Displays I get:

Before Write Statement:

Code:
TSS310C-COPY   : A80T        A% 80MM TRAVERS               000NOR000003038G30EN
0000990000             
                                                       
TSS310C-RECORD : A80T        A% 80MM TRAVERS               000NOR000003038G30EN
0000990000 



After Write Statement:

Code:
TSS310C-COPY   : A80T        A% 80MM TRAVERS               000NOR000003038G30EN
0000990000     
                                                                 
TSS310C-RECORD : ...............................................................
..........     




Job is done this way:

Code:
//TSS310C  DD  DSN=E017134.TSS310C,                 
//         DISP=(NEW,CATLG,DELETE),UNIT=COMMUN,     
//         DCB=(LRECL=113,RECFM=FB,BLKSIZE=1130),   
//         SPACE=(CYL,(200,05),RLSE)   



Please mind that the code in which this file gets written is CALLED program...DYNAMIC CALL.


Could someone please let me know where is the issue...cause I have been looking into this issue since morning and I have not been able to find where is the issue....I would be highly obliged for your help.


Thanks,
Hitesh
Back to top
View user's profile Send private message

hitesh0000

New User


Joined: 01 Feb 2008
Posts: 6
Location: Noida

PostPosted: Wed Aug 06, 2008 12:02 pm    Post subject: Reply to: Writing a File in a Called Program.
Reply with quote

Kindly read the first statement as:

I am writing a file in a called program, Is that possible?

Rest of the query remains the same.
Back to top
View user's profile Send private message
hitesh0000

New User


Joined: 01 Feb 2008
Posts: 6
Location: Noida

PostPosted: Wed Aug 06, 2008 12:07 pm    Post subject: Reply to: Writing a File in a Called Program.
Reply with quote

I am very sorry for another mistake...please read the code statement as:



In my code I have:

Code:
MOVE TSS310C-COPY TO TSS310C-RECORD.
WRITE TSS310C-RECORD.


Hence before the Write I can see the values in TSS310C-COPY and TSS310C-RECORD.

But after Write I see value in only TSS310C-COPY (which is obvious), but not in TSS310C-RECORD (which is required).
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Aug 06, 2008 12:08 pm    Post subject:
Reply with quote

Hello,

You should not issue a DISPLAY after the write. The data is no longer available to your code after the write.

You need to look at the output file after the run is finished to see what is in the output file.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Aug 06, 2008 12:51 pm    Post subject: Re: Reply to: Writing a File in a Called Program.
Reply with quote

hitesh0000 wrote:
I am writing a file in a called program, Is that possible?
Yeah, that's possible, done recently.
Back to top
View user's profile Send private message
hitesh0000

New User


Joined: 01 Feb 2008
Posts: 6
Location: Noida

PostPosted: Wed Aug 06, 2008 2:32 pm    Post subject: Thanks: Problem Resolved.
Reply with quote

Hi Dick, Anuj

The problem is resolved now...thanks for your help.

What it was actually doing:

For every read of 1 VSAM record..I was calling the Batch pgm. BBBB

There are 95000+ records in my VSAM...now for each record code goes inside the called progarm BBBB and OPENS the file in OUTPUT mode (every time - for each call) and hence deleting the record written in the previous call.

The last call was such that nothing used to get written in the file and hence i used to get empty file.


Now I am opening the file in EXTEND mode and its working now.


Thanks,
Shitij
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Wed Aug 06, 2008 2:51 pm    Post subject:
Reply with quote

Open your file once.

As long as you are not using INITIAL, each CALL to the subprogram will find the program in the state that you left it in after the preceding CALL.

you do not have to continually reopen the file.........................................
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Aug 06, 2008 7:34 pm    Post subject:
Reply with quote

Hello,

Quote:
you do not have to continually reopen the file.........................................
And continually closing / re-opening the file uses a lot of system resources as well as makes your job run much slower.

Thank you for telling us what solved the problem icon_smile.gif

d
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2504
Location: Atlanta, Georgia, USA

PostPosted: Wed Aug 06, 2008 7:50 pm    Post subject: Re: Writing a File in a Called Program.
Reply with quote

Review the EXTERNAL clause for files (and other resources) in the Programming Guide associated with your COBOL version/release.

IIRC, EXTERNAL was introduced with COBOL2, so unless you're on OS/VS COBOL, it should be applicable.

Bill
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 How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts Accessing CICS tran with map from JCL... navdeepaggarwal CICS 5 Tue Oct 03, 2017 6:15 pm
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us