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

COBOL file handling


IBM Mainframe Forums -> HomeWorks & Requests
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
KSKPRIYA
Currently Banned

New User


Joined: 25 May 2012
Posts: 3
Location: INDIA

PostPosted: Fri May 25, 2012 10:13 pm
Reply with quote

Why do we need a logical and a physical file name for a file in cobol file handling..?? i understand the importance of physical file name as re-usability of the compiler JCL but what is with the logical name??
Back to top
View user's profile Send private message
KSKPRIYA
Currently Banned

New User


Joined: 25 May 2012
Posts: 3
Location: INDIA

PostPosted: Fri May 25, 2012 10:14 pm
Reply with quote

what does prioroty 144 for a jOB indicate? I thot the priorities are only as 1-15.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Fri May 25, 2012 11:04 pm
Reply with quote

KSKPRIYA wrote:
Why do we need a logical and a physical file name for a file in cobol file handling..?? i understand the importance of physical file name as re-usability of the compiler JCL but what is with the logical name??

Your question is confused, possibly because you do not use standard terminology.

A data set is a named collection of data on a physical device. Toy computers often use the term "file" for this, but on a mainframe a file is the logical representation of a data set.

In z/OS the link between a data set and a file is in the JCL, thus:
Code:
//PATIENCE JOB
//STEPONLY EXEC PGM=RORA
//FOO      DD   DSN=BAR,DISP=SHR

Here FOO is the file, which is this instance represents the data set BAR. A COBOL program would coded something like:
Code:
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
    SELECT THIS-FILE ASSIGN TO FOO-S.
DATA DIVISION.
FILE SECTION.
FD THIS-FILE.
01 THIS-RECORD.
    etc.

If this seems complex, remember that COBOL is a universal programming language, not just a mainframe language. Toy computers often lack any equivalent of JCL, requiring that the logical/physical linkage be defined in the program itself. Thus, writing a MicroFocus COBOL program to run on a Wintel box, you would code
Code:

    SELECT THIS-FILE ASSIGN TO "C:\FOO\BAR.DAT"
    ORGANIZATION IS SEQUENTIAL.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri May 25, 2012 11:37 pm
Reply with quote

The closest I can think of to what your question seems to be about is to quote the COBOL Language Reference manual:
Quote:
5.1.5.1 File data




File data is contained in files. (See "File section" in topic 5.2.1.) A file is a collection of data records that exist on some input-output device. A file can be considered as a group of physical records; it can also be considered as a group of logical records. The data division describes the relationship between physical and logical records.

A physical record is a unit of data that is treated as an entity when moved into or out of storage. The size of a physical record is determined by the particular input-output device on which it is stored. The size does not necessarily have a direct relationship to the size or content of the logical information contained in the file.

A logical record is a unit of data whose subdivisions have a logical relationship. A logical record can itself be a physical record (that is, be contained completely within one physical unit of data); several logical records can be contained within one physical record, or one logical record can extend across several physical records.
File description entries specify the physical aspects of the data (such as the size relationship between physical and logical records, the size and names of the logical records, labeling information, and so forth).

Record description entries describe the logical records in the file (including the category and format of data within each field of the logical record), different values the data might be assigned, and so forth. After the relationship between physical and logical records has been established, only logical records are made available to you. For this reason, a reference in this information to "records" means logical records, unless the term "physical records" is used.

And as far as your second post goes, you'll need to clarify your question. There is job priority, dispatch priority, JES priority -- in other words, there is not just ONE priority in a z/OS system to make your question easy to answer.
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: Sat May 26, 2012 12:08 am
Reply with quote

Hello and welcome to the forum,

Quote:
Why do we need a logical and a physical file name for a file in cobol file handling..?? i understand the importance of physical file name as re-usability of the compiler JCL but what is with the logical name??
I believe you have considerable confusion here. . .

In a COBOL SELECT statement you provide both the file name that will be used for the compiler and you provide the name that relates the program to the physical file:
SELECT COMPILE-NAME ASSIGN TO S-MYFILE.
COMPILE-NAME will be used throughout the program code (open/close/read).
S-MYFILE will be used in the "JCL" to relate the actual dataset to your program.
Quote:
It must be either the name specified in the DD statement for this file or the name of an environment variable that contains file allocation information.


As far as i know, this has nothing to do with the reuse of the compiler JCL. . .
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Tue May 29, 2012 1:18 pm
Reply with quote

KSKPRIYA wrote:
Why do we need a logical and a physical file name for a file in cobol file handling..?? i understand the importance of physical file name as re-usability of the compiler JCL but what is with the logical name??
There are some rules of every game you need to abide by. The logical file includes the record layout. The physical file includes the name of the file on the disk and the information on how the file will be organized.

I'll try an example, in lay-man terms, think about a situation, where you need a physical-file to be used in two differnt COBOL programs. The structure of file is:
Code:
EMPLOYEE-DEPT-NO  PIC 9(3)
UNIQUE-IDENTITY     PIC 9(3)

First Program (PGM1) uses the file as shown above while the second program needs employee-number as input. Employee-number is a 6-digit number, which is a combination of employee-dept and unique-identity. Now as a programmer how would one differntiate two different inputs from the same physical file? One have to have a layout of input-file in the program. And when you've multiple files, you would want to refer them seprately. The solution comes in the form of "logical file name".
Back to top
View user's profile Send private message
KSKPRIYA
Currently Banned

New User


Joined: 25 May 2012
Posts: 3
Location: INDIA

PostPosted: Wed May 30, 2012 9:27 pm
Reply with quote

ohkkk... thank you.. it was quite useful icon_smile.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Thu May 31, 2012 1:57 pm
Reply with quote

Glad to hear that curiosity subsides with a smile! icon_smile.gif
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 -> HomeWorks & Requests

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top