file-control

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Allen
Member
Posts: 19
Joined: Mon Aug 22, 2011 12:22 pm

file-control

Post by Allen » Thu Aug 25, 2011 2:03 pm

in file-control section.

select file-ref assign to file


can i give a sequential file name?
if i have file on my disk, how to specify the path ?

i gave 'C:\filename.txt'


but it takes as 'C00filename' by throwing below error

There was an unsuccessful OPEN or CLOSE of file C00filename in program FILEINP at relative location X'04C8'.
Neither FILE STATUS nor an ERROR declarative were specified. The status code was 35.
From compile unit FILEINP at entry point FILEINP at compile unit offset +000004C8 at entry offset +000004C8 at
address 11700C30.

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Thu Aug 25, 2011 7:15 pm

allen,
I can only point to the reference manual where it discusses environmental variables

am a little confused with:
i gave 'C:\filename.txt'
in the cobol program or your jcl?
if jcl, refer to the JCL manual.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Fri Aug 26, 2011 10:35 am

i gave 'C:\filename.txt'
Why? This is not valid mainframe syntax. Are you actually running on a mainframe?

How will the program be executed? Post the execution JCL.

The cobol program on the mainframe cannot automagically grab a file from "your disk".
Have a good one

Allen
Member
Posts: 19
Joined: Mon Aug 22, 2011 12:22 pm

Post by Allen » Fri Sep 02, 2011 11:22 am

Even if i give a sequential file as input file, it doesnt work.

COBOL Program:

IDENTIFICATION DIVISION.
PROGRAM-ID. SAMPLE1.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INFILE ASSIGN TO IN1.
SELECT OUTFILE ASSIGN TO OUT1.
DATA DIVISION.
FILE SECTION.
FD INFILE
RECORDING MODE F.
01 INREC.
05 INVAL PIC 9(3).
FD OUTFILE
RECORDING MODE F.
01 OUTREC.
05 OUTVAL PIC 9(3).
WORKING-STORAGE SECTION.
01 ARE-THERE-MORE-RECORDS PIC XXX VALUE 'YES'.
PROCEDURE DIVISION.
100-MAIN-MODULE.
OPEN INPUT INFILE.
OPEN OUTPUT OUTFILE.
PERFORM UNTIL ARE-THERE-MORE-RECORDS = 'NO'
READ INFILE
AT END
MOVE 'NO' TO ARE-THERE-MORE-RECORDS
NOT AT END
PERFORM 200-CALC
END-READ
END-PERFORM.
CLOSE INFILE.
CLOSE OUTFILE.
STOP RUN.
200-CALC.
MOVE INVAL TO OUTVAL
WRITE OUTREC.




in JCL program i have given : (i have just copied part of jcl)

//T388062S JOB (12345678),SAMPLE1,MSGCLASS=A,
// MSGLEVEL=(1,1),CLASS=A,NOTIFY=T388062,RESTART=*
//COBOL EXEC PGM=IGYCRCTL,REGION=640K,COND=(12,LE),
// PARM=(NOTERM,NOSEQUENCE,LIB,XREF,DYN,'')
//SYSPRINT DD SYSOUT=(*)
//SYSIN DD DSN=T388062.AB.S(SAMPLE1),DISP=SHR
//IN1 DD DSN=T388062.EMPDET,DISP=SHR
//OUT1 DD DSN=T388062.EMPOUT,DISP=SHR
//SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(2,2))
-
-
-

program is abended with error :

There was an unsuccessful OPEN or CLOSE of file IN1 in program SAMPLE1
at relative location X'04C6'. Neither FILE STATUS nor an ERROR declarative were specified. The status status code was 35. From compile unit SAMPLE1 at entry point SAMPLE1 at compile unit offset +000004C6 at entry offset +000004C6 at address 11700C16.


I have an input dataset named EMPDET(FB,Sequential file, LRECL=3) and empty output dataset (same as input file)

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Fri Sep 02, 2011 5:00 pm

http://www.mainframegurukul.com/ibmmain ... php?t=5956

And how does this help us to help you:
I have an input dataset named EMPDET(FB,Sequential file, LRECL=3) and empty output dataset (same as input file)
, specially after seeing your COBOL Code, JCL and error?
Regards,
Anuj

Allen
Member
Posts: 19
Joined: Mon Aug 22, 2011 12:22 pm

file-control

Post by Allen » Mon Sep 05, 2011 8:01 am

i meant to say that i have created both input and output files, just i want to move records to output file.

but i got to know what is my mistake, i have to give file reference,

//IN1 DD DSN=T388062.EMPDET,DISP=SHR
//OUT1 DD DSN=T388062.EMPOUT,DISP=SHR


while linking, i had given this in compilation.

now its working fine. thank you.

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Mon Sep 05, 2011 9:33 am

It is a bad practice to use SHR for sequential input and output files (unless the dataset is a pds and then there can be problems).

Well-managed systems will not allow this to be run in production.
Have a good one

Allen
Member
Posts: 19
Joined: Mon Aug 22, 2011 12:22 pm

file-control

Post by Allen » Mon Sep 05, 2011 10:52 am

oh ok. thanks for the information.

Allen
Member
Posts: 19
Joined: Mon Aug 22, 2011 12:22 pm

Post by Allen » Wed Sep 07, 2011 11:28 am

DikDude wrote:
i gave 'C:\filename.txt'
Why? This is not valid mainframe syntax. Are you actually running on a mainframe?

How will the program be executed? Post the execution JCL.

The cobol program on the mainframe cannot automagically grab a file from "your disk".

then how can i specify a disk file in cobol program?
i have seen in some books they have given disk file as input/output.

my jcl code doesnt specify anything about disk file. it just takes the cobol program. thats it.


//T388061G JOB (12345678),SORTCOB1,MSGCLASS=A,
// MSGLEVEL=(1,1),CLASS=A,NOTIFY=T388062,RESTART=*
//COBOL EXEC PGM=IGYCRCTL,REGION=640K,COND=(12,LE),
// PARM=(NOTERM,NOSEQUENCE,LIB,XREF,DYN,'')
//SYSPRINT DD SYSOUT=(*)
//SYSIN
DD DSN=T388062.AB.C(SORTCOB1),DISP=SHR

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Wed Sep 07, 2011 12:18 pm

you are not executing a cobol program with the jcl provided.
EXEC PGM=IGYCRCTL is the cobol compiler.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

Allen
Member
Posts: 19
Joined: Mon Aug 22, 2011 12:22 pm

file-control

Post by Allen » Wed Sep 07, 2011 12:24 pm

i have given that assign statement in a cobol program, so i have used a cobol compiler


my cobol code is :

IDENTIFICATION DIVISION.
PROGRAM-ID. SAMPLE.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT SORT-FILE
ASSIGN TO 'C:\COB\SOR.TMP'.
SELECT IN-FILE
ASSIGN TO 'C:\COB\IN.TXT'
ORGANIZATION IS LINE SEQUENTIAL.
SELECT OUT-FILE
ASSIGN TO 'C:\COB\OUT.TXT'
ORGANIZATION IS LINE SEQUENTIAL.

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Thu Sep 08, 2011 12:24 am

You used a cobol compiler because the code is cobol source.

You appear to be somewhat lost:
then how can i specify a disk file in cobol program?
i have seen in some books they have given disk file as input/output.
The SELECT and ASSIGN along with the FD is how you specify a file in a cobol program.

From what you have posted, there is no reason to be concerned with input/output (actually input-output if i understand what you are talking about).

Your ASSIGN statements are not valid for files on the mainframe - you should assign to a ddname.
Last edited by DikDude on Thu Sep 08, 2011 9:26 am, edited 1 time in total.
Have a good one

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Thu Sep 08, 2011 1:35 am

are you using micro/focus on a pc/server?
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

Allen
Member
Posts: 19
Joined: Mon Aug 22, 2011 12:22 pm

file-control

Post by Allen » Fri Sep 09, 2011 8:10 am

i am using IBM Personal Communications

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Fri Sep 09, 2011 9:43 am

i am using IBM Personal Communications
Which has NOTHING to do with the compiler. . . What you have named is a 3270-emulator . . . This is one way people connect to a mainframe. It should have nothing to do with assigning files. . .

You need to speak with someone who actually works with cobol on your mainframe. They can show you what you have mixed up.
Last edited by DikDude on Fri Sep 09, 2011 9:04 pm, edited 1 time in total.
Have a good one

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others