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

Cobol Program-ID: Is it must?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kalaignar_S
Warnings : 1

New User


Joined: 06 Jan 2006
Posts: 21

PostPosted: Mon May 22, 2006 5:07 pm
Reply with quote

Hi..

Its necessary to have the program-id as same as the program name or member name?

Thanks
Kalai
Back to top
View user's profile Send private message
ursprasanna
Warnings : 2

New User


Joined: 15 May 2006
Posts: 20
Location: chennai

PostPosted: Mon May 22, 2006 5:11 pm
Reply with quote

Not mandatory..
Back to top
View user's profile Send private message
sril.krishy

Active User


Joined: 30 Jul 2005
Posts: 183
Location: hyderabad

PostPosted: Tue May 23, 2006 5:37 pm
Reply with quote

Hi,
You can successfully compile the program if the program-id and the name of the program is diffrent.But you will get the error when you do linking of the job.

I tried in my system and I got the below error.

IEW2648E 5111 ENTRY xxxxx IS NOT A CSECT OR AN EXTERNAL NAME IN THE MODULE.

Where XXXXX is my program name.

Thanks&Regrds
Krishy
Back to top
View user's profile Send private message
vijayamadhuri

Active User


Joined: 06 Apr 2005
Posts: 180

PostPosted: Tue May 23, 2006 8:20 pm
Reply with quote

It is not necesary for u r pgm id to be the same as u r pgm name
Back to top
View user's profile Send private message
humpty
Warnings : 1

New User


Joined: 01 May 2005
Posts: 23

PostPosted: Thu May 25, 2006 10:39 am
Reply with quote

hi,

it is not mandatory for the program-id and the program name to be same.
in case you need to call the program, then we use the program-id in the calling program. that hardly matters, the two are set to be same only for our convinience and to avoid confusions with two different names for the same program.

thanks
Back to top
View user's profile Send private message
hikaps14

Active User


Joined: 02 Sep 2005
Posts: 189
Location: Noida

PostPosted: Thu May 25, 2006 11:17 am
Reply with quote

Hi,

i think the scene is geting a bit mixed up .

lets take a example .

there is a program-name = A1 (load name is A1)
with its program-id = A2.

there is another program-name = B

program B calls program (A1 or A2) Statically .

there is program C which calls (A1 or A2) Dynamically .


i guess now if any body coulld tell me the exact answers it would be much
better .
( because i was also confused with load name too so plz chk tat option also )

Thanks in advance ,
-Kapil .
Back to top
View user's profile Send private message
abhishekraghav

New User


Joined: 31 Mar 2006
Posts: 9
Location: Pune

PostPosted: Thu May 25, 2006 1:39 pm
Reply with quote

Kapil

in first case i think there will be no problem because a single load will be created in that case.

while in case of program C. thing matters is the load name for program A1 and A2.

say for A1 you create its load with load name A.
Now, in program C if you want to call program A1 you will be calling it as:

CALL A USING PARAMETERS.



Having program ID different doesn't effect execution because whatever program ID you give in program, it will go in to load name.

say in source of A1, program ID is ABC and you create A1,s load with name A.
now, if you browse load A then you will find program ID (ABC) for program A1 there.

try and check it with a test program.
Back to top
View user's profile Send private message
humpty
Warnings : 1

New User


Joined: 01 May 2005
Posts: 23

PostPosted: Thu May 25, 2006 4:42 pm
Reply with quote

hi kapil,

thats what i wanna say, that using two different names for program
name and program-id ultimately traps u into confusions, so please avoid using two different names. though company norms do not allow two different names for program and program-id.

going to your question.
program name is A1 and program-Id is A2.
now the program B will refer to A2 to call the program
and not A2, when a calling program directly gives the program-id,
it means it is being called statically (default).
i.e the procedure division of program B has to coded as
.
.
PROCEDURE DIVISION
.
.
CALL A2
.
.

With static calls statement, the COBOL program and all called programs are part of the same load module. When control is transferred, the called program already resides in storage, and a branch to it takes place


In case of dynamic call the compiler option set to DYNAM.
for the dynamic call teh program-name in the PROGRAM-ID paragraph or ENTRY statement must be identical to the corresponding load module name or load module alias of the load module that contains the program.


i guess it would resolve your confusions.
Back to top
View user's profile Send private message
humpty
Warnings : 1

New User


Joined: 01 May 2005
Posts: 23

PostPosted: Thu May 25, 2006 4:44 pm
Reply with quote

hi everyone,

Please go through the following to clarify all your doubts.

Examples: static and dynamic CALL statements
This example shows how you can code static and dynamic calls.

The example has three parts:

Code that uses a static call to call a subprogram
Code that uses a dynamic call to call the same subprogram
The subprogram that is called by the two types of calls
The following example shows how you would code static calls:


PROCESS NODYNAM NODLL
IDENTIFICATION DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 RECORD-2 PIC X. (6)
01 RECORD-1. (2)
05 PAY PICTURE S9(5)V99.
05 HOURLY-RATE PICTURE S9V99.
05 HOURS PICTURE S99V9.
. . .
PROCEDURE DIVISION.
CALL "SUBPROG" USING RECORD-1. (1)
CALL "PAYMASTR" USING RECORD-1 RECORD-2. (5)
STOP RUN.
The following example shows how you would code dynamic calls:


DATA DIVISION.
WORKING-STORAGE SECTION.
77 PGM-NAME PICTURE X(8).
01 RECORD-2 PIC x. (6)
01 RECORD-1. (2)
05 PAY PICTURE S9(5)V99.
05 HOURLY-RATE PICTURE S9V99.
05 HOURS PICTURE S99V9.
. . .
PROCEDURE DIVISION.
. . .
MOVE "SUBPROG" TO PGM-NAME.
CALL PGM-NAME USING RECORD-1. (1)
CANCEL PGM-NAME.
MOVE "PAYMASTR" TO PGM-NAME. (4)
CALL PGM-NAME USING RECORD-1 RECORD-2. (5)
STOP RUN.
The following example shows a called subprogram that is called by each of the two preceding calling programs:


IDENTIFICATION DIVISION.
PROGRAM-ID. SUBPROG.
DATA DIVISION.
LINKAGE SECTION.
01 PAYREC. (2)
10 PAY PICTURE S9(5)V99.
10 HOURLY-RATE PICTURE S9V99.
10 HOURS PICTURE S99V9.
77 PAY-CODE PICTURE 9. (6)
PROCEDURE DIVISION USING PAYREC. (1)
. . .
EXIT PROGRAM. (3)
ENTRY "PAYMASTR" USING PAYREC PAY-CODE. (5)
. . .
GOBACK. (7)
(1)
Processing begins in the calling program. When the first CALL statement is executed, control is transferred to the first statement of the PROCEDURE DIVISION in SUBPROG, which is the called program.
In each of the CALL statements, the operand of the first USING option is identified as RECORD-1.

(2)
When SUBPROG receives control, the values within RECORD-1 are made available to SUBPROG; however, in SUBPROG they are referred to as PAYREC.
The PICTURE character-strings within PAYREC and PAY-CODE contain the same number of characters as RECORD-1 and RECORD-2, although the descriptions are not identical.

(3)
When processing within SUBPROG reaches the EXIT PROGRAM statement, control is returned to the calling program. Processing continues in that program until the second CALL statement is issued.
(4)
In the example of a dynamically called program, because the second CALL statement refers to another entry point within SUBPROG, a CANCEL statement is issued before the second CALL statement.
(5)
With the second CALL statement in the calling program, control is again transferred to SUBPROG, but this time processing begins at the statement following the ENTRY statement in SUBPROG.
(6)
The values within RECORD-1 are again made available to PAYREC. In addition, the value in RECORD-2 is now made available to SUBPROG through the corresponding USING operand, PAY-CODE.
When control is transferred the second time from the statically linked program, SUBPROG is made available in its last-used state (that is, if any values in SUBPROG storage were changed during the first execution, those changed values are still in effect). When control is transferred from the dynamically linked program, however, SUBPROG is made available in its initial state, because of the CANCEL statement that has been executed.

(7)
When processing reaches the GOBACK statement, control is returned to the calling program at the statement immediately after the second CALL statement.
In any given execution of the called program and either of the two calling programs, if the values within RECORD-1 are changed between the time of the first CALL and the second, the values passed at the time of the second CALL statement will be the changed, not the original, values. If you want to use the original values, you must save them.
Back to top
View user's profile Send private message
umeshkmrsh

New User


Joined: 21 Sep 2005
Posts: 79
Location: India

PostPosted: Fri May 26, 2006 11:28 am
Reply with quote

sril.krishy wrote:
Hi,
You can successfully compile the program if the program-id and the name of the program is diffrent.But you will get the error when you do linking of the job.

I tried in my system and I got the below error.

IEW2648E 5111 ENTRY xxxxx IS NOT A CSECT OR AN EXTERNAL NAME IN THE MODULE.

Where XXXXX is my program name.

Thanks&Regrds
Krishy



It looks you people have taken the topic to an different track. Let me put it back on the track. The problem is that "Can we have different name for our program load module (pds member name or u may say load module name) and the PROGRAM-ID".

Our problem is: How the LINKER or dynamic LOADER (in case of dynamic call) locates the program and loads it? Does it uses PROGRAM-ID or load module name? Is there a table that maps PROGRAM-ID to the corresponding load module name?

So problem is not static and dynamic call and how they work.

Regards,
Umesh
Back to top
View user's profile Send private message
abhishekraghav

New User


Joined: 31 Mar 2006
Posts: 9
Location: Pune

PostPosted: Fri May 26, 2006 11:36 am
Reply with quote

Hi umeshkmrsh,

Just check my previouse post. it contains the answer to main question:

"Having program ID different doesn't effect execution because whatever program ID you give in program, it will go in to load."

as well as answer to hikaps14's doubt.

just check and correct me if i am wrong anywhere.

Regards,
Abhishek.
Back to top
View user's profile Send private message
umeshkmrsh

New User


Joined: 21 Sep 2005
Posts: 79
Location: India

PostPosted: Fri May 26, 2006 11:49 am
Reply with quote

Hi Abhishek,

Yes you have tried to explain and it a good explanation too. But I would like to know how a PROGRAM-ID (if used for calling) gets mapped to the load module (which may have different name).

Is there a table that maps both of these?
Back to top
View user's profile Send private message
abhishekraghav

New User


Joined: 31 Mar 2006
Posts: 9
Location: Pune

PostPosted: Fri May 26, 2006 12:03 pm
Reply with quote

See load name u decide at the link edit time.
for the sake of avoiding confusion we give it same as the program name and same for the program id.

but you can give as u want:
say program or source name is ABC and it has program id as ABCID, OK.

Now you compile and link edit this program and you give loadname as XYZ.

now after creation of load XYZ, if you browse it you will find your program id (ABCID) name for source ABC there in starting of load.
just check it with a sample program. you will get it cleared.


I think no such table is maintained. only program ID goes into load module. and suppose u want to call the program ABC. you must know the load module name, it is XYZ in case of prgram ABC. so you will write it as

CALL 'XYZ'

and in starting i told that for avoiding confusion we take load module name same as program name.
Back to top
View user's profile Send private message
umeshkmrsh

New User


Joined: 21 Sep 2005
Posts: 79
Location: India

PostPosted: Fri May 26, 2006 12:30 pm
Reply with quote

Thanks,

One more doubt: Can't we use program-id to call a program, say:

CALL "ABCID"

?
Back to top
View user's profile Send private message
abhishekraghav

New User


Joined: 31 Mar 2006
Posts: 9
Location: Pune

PostPosted: Fri May 26, 2006 12:34 pm
Reply with quote

I dont think So, because whatever name u give with CALL it searches that name in to the load library and if it is found there then it executes it.

one of the reason for unique program name and load with same name is this thing only. other wise by mistake u can execute other programs load.
Back to top
View user's profile Send private message
umeshkmrsh

New User


Joined: 21 Sep 2005
Posts: 79
Location: India

PostPosted: Fri May 26, 2006 12:58 pm
Reply with quote

OK,

I got what you want to say.

Just to add to this topic:

PROGRAM-ID does plays role. IN COBOL-II where we can have more than one programs written within a source file (source code). In this way we can have a program say.

PDS member. ABC.

Code:
IDENTIFICATION DIVISION.
PROGRAM-ID. ABC1.
---
---
PROCEDURE DIVISION
----
---- CALL "ABC2"
----
----
IDENTIFICATION DIVISION.
PROGRAM-ID. ABC2.
----
----
PROCEDURE DIVISION.
----
----
END PROGRAM ABC2.

END PROGRAM ABC1.


Will we be having two load modules in this case Or one?
Lets assume we have one load module - named ABCL.

Now:
(1) When we program ABC1 calls ABC2 it uses program-id i.e ABC2.
(2) And if we want to call program ABC1 from some other program we will use load modules name .. i.e "ABCL"

CALL "ABCL".

Correct me if I am wrong.
Back to top
View user's profile Send private message
abhishekraghav

New User


Joined: 31 Mar 2006
Posts: 9
Location: Pune

PostPosted: Fri May 26, 2006 1:09 pm
Reply with quote

Thanx! for telling this thing. i really didnt knew.
Back to top
View user's profile Send private message
mf_user
Currently Banned

New User


Joined: 05 Jan 2006
Posts: 47

PostPosted: Fri Jun 02, 2006 5:39 pm
Reply with quote

Guys, what happens if I have four programs (a, b, c, d) with same program-id (a)? Pls explain.

Tx a lot.
Back to top
View user's profile Send private message
abhishekraghav

New User


Joined: 31 Mar 2006
Posts: 9
Location: Pune

PostPosted: Fri Jun 02, 2006 5:50 pm
Reply with quote

see my previouse posts. it will be clear to you.
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 Replace each space in cobol string wi... COBOL Programming 2
No new posts Using API Gateway from CICS program CICS 0
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top