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

Writing a File in a Called Program.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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

Moderator Emeritus


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

PostPosted: Wed Aug 06, 2008 12:08 pm
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

Superior Member


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

PostPosted: Wed Aug 06, 2008 12:51 pm
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
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: 6966
Location: porcelain throne

PostPosted: Wed Aug 06, 2008 2:51 pm
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

Moderator Emeritus


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

PostPosted: Wed Aug 06, 2008 7:34 pm
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Aug 06, 2008 7:50 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 8
No new posts Using API Gateway from CICS program CICS 0
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top