View previous topic :: View next topic
|
Author |
Message |
dilpreet
New User
Joined: 18 Mar 2008 Posts: 34 Location: INDIA
|
|
|
|
1) i have a main program p1 and 2 subprograms p1 and p2 .is it possible to link one program dynamically and othe statically and how
2) if i pass 5 values from jcl to cobol and have 6 accept statements then what will happen. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
What were your answers?
And for question number 2, there's no relationship between passing values from JCL to COBOL and COBOL ACCEPT statements so the question does not even make sense. |
|
Back to top |
|
|
dilpreet
New User
Joined: 18 Mar 2008 Posts: 34 Location: INDIA
|
|
|
|
these Q? WERE RAISED ON SOME OTHER PORTAL.
REGARDING SECOND Q
IF WE PASS 5 CHARACTER VALUES THRU SYSIN DD *
AND HAVE 6 ACCEPT STATEMENTS IN THE COBOL PROGRAM.THEN WILL THE PROGRAM ABEND WITH ANY REASON CODE |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
WERE RAISED ON SOME OTHER PORTAL. |
And what were the answers given. . .?
It is not proper to post things "across forums". . .
Oh, TURN OFF YOUR CAPS. |
|
Back to top |
|
|
dilpreet
New User
Joined: 18 Mar 2008 Posts: 34 Location: INDIA
|
|
|
|
i came across these Q while gng thru some other mainframe sites . so wanted to knw there correct answers as they were nt provided there.being true
thought of this to be a correct place to find the best answers.
so please help me out knowing there correct answers
thanks |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Personally, i believe there is at least some confusion with the questions. . . Which is why i asked about the answers given elsewhere.
Quote: |
i have a main program p1 and 2 subprograms p1 and p2. is it possible to link one program dynamically and othe statically |
P1 should not be both the main program and a sub-program?
Quote: |
if i pass 5 values from jcl to cobol and have 6 accept statements |
ACCEPT is not the way to pass values from JCL to the program. To pass values from JCL, the PARM is used? |
|
Back to top |
|
|
dilpreet
New User
Joined: 18 Mar 2008 Posts: 34 Location: INDIA
|
|
|
|
sorry my mistake
in Q1
we have main program p1 and its calling 2 subprograms p2 and p3. can we link p2 statically and p3 dynamically in a same program.
in q2
if we pass values in jcl thru sysin dd * to cobol program
then we need accept statements in the cobol program. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
then we need accept statements in the cobol program. |
oh my, sigh.... That is not true.
treat it as a file:
code a select for 'sysin' (or better yet, use something like CARDIN, whatever) with file-status clause,
an fd
and use COBOL OPEN, READ, CLOSE to process the input.
by using the file-status clause you can tell if you are at end-of-file. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
can we link p2 statically and p3 dynamically in a same program. |
Well, one can be called statically while the other is called dynamically, but i believe this would not be desirable. . .
Quote: |
if we pass values in jcl thru sysin dd * to cobol program |
Once the data is associated with a DD statement, it is no longer a "value in jcl" - it is a file. . . Files should be opened, read, and closed rather than ACCEPTed (many organizations do not permit the use of ACCEPT in any code to be promoted to Production). If an ACCEPT is issued after the end of data has been reached, an abend results (the same as a read after end of file). |
|
Back to top |
|
|
dilpreet
New User
Joined: 18 Mar 2008 Posts: 34 Location: INDIA
|
|
|
|
THANKS DICK!!! |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
would caps off make this a little dick
Gerry |
|
Back to top |
|
|
Succor
New User
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
|
|
|
|
Quote: |
If an ACCEPT is issued after the end of data has been reached, an abend results (the same as a read after end of file). |
It is true that the usage of ACCEPT is not recommended.
But the program will not face any abend if you try to ACCEPT after the end of data has been reached.
You will continue to read the last supplied data in SYSIN DD* |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
But the program will not face any abend if you try to ACCEPT after the end of data has been reached.
You will continue to read the last supplied data in SYSIN DD* |
This is not accurate -- once you hit EOF, the receiving field is unchanged so it may look like you read the last supplied data but you're not. The COBOL Language Reference manual says (emphasis added by me)
Quote: |
System input device
The length of a data transfer is the same as the length of the record on the input device, with a maximum of 32,760 bytes.
The system input device is read until the receiving area is filled or EOF is encountered. If the length of the receiving area is not an even multiple of the system input device record length, the final record will be truncated as required. If EOF is encountered after data has been moved and before the receiving area has been filled, the receiving area is padded with spaces of the appropriate representation for the receiving area. If EOF is encountered before any data has been moved to the receiving area, padding will not take place and the contents of the receiving area are unchanged. Each input record is concatenated with the previous input record. |
|
|
Back to top |
|
|
Succor
New User
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
|
|
|
|
Quote: |
This is not accurate -- once you hit EOF, the receiving field is unchanged so it may look like you read the last supplied data but you're not. |
I am in agreement to what you have referred to.
Quote: |
dilpreet:
2) if i pass 5 values from jcl to cobol and have 6 accept statements then what will happen. |
Quote: |
Dick :
If an ACCEPT is issued after the end of data has been reached, an abend results (the same as a read after end of file). |
My post was just to explain that in this particular instance it won't abend and you would continue to see the last value read from SYSIN DD* until and unless you don't initialize the variable.
Is it possible to face EOF in this case i.e. while using ACCEPT? |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Quote: |
Is it possible to face EOF in this case i.e. while using ACCEPT? |
If you have access to a mainframe, this is easy enough to find out via a test program. Let us know the results. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
Is it possible to face EOF in this case i.e. while using ACCEPT? |
and what would you interrogate? where would you look for an EOF indicator? |
|
Back to top |
|
|
Succor
New User
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
|
|
|
|
Dbz
Quote: |
and what would you interrogate? where would you look for an EOF indicator? |
And that is what i am trying to tell that how do we intend to do that in case of an ACCEPT.
Terry
Code: |
WORKING-STORAGE SECTION.
01 A PIC X(50) VALUE SPACES.
01 AC1 PIC 9(02) VALUE ZEROES.
PROCEDURE DIVISION.
0001-MAIN.
PERFORM UNTIL AC1 > 6
ACCEPT A
DISPLAY "VALUE FETCHED" A
COMPUTE AC1 = AC1 + 1
END-PERFORM |
JOB
Code: |
//SYSIN DD *
SDAKJFHDASLKGFDLGFHJDKAS
2222
44444
66666
/*
|
Spool
Code: |
VALUE FETCHEDSDAKJFHDASLKGFDLGFHJDKAS
VALUE FETCHED2222
VALUE FETCHED44444
VALUE FETCHED66666
VALUE FETCHED66666
VALUE FETCHED66666
VALUE FETCHED66666
|
If you Initialize the variable before you do next ACCEPT
Code: |
0001-MAIN.
PERFORM UNTIL AC1 > 6
ACCEPT A
DISPLAY "VALUE FETCHED" A
MOVE SPACES TO A
COMPUTE AC1 = AC1 + 1
END-PERFORM |
SPOOL
Code: |
VALUE FETCHEDSDAKJFHDASLKGFDLGFHJDKAS
VALUE FETCHED2222
VALUE FETCHED44444
VALUE FETCHED66666
VALUE FETCHED
VALUE FETCHED
VALUE FETCHED
|
So, the program doesn't abend and therefore I asked that question when we were discussing about EOF and ACCEPT,till the time we are not treating it as a file. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
how about:
Code: |
0001-MAIN.
Move high-values to A
ACCEPT A
PERFORM UNTIL A = high-values
DISPLAY "VALUE FETCHED: " A
MOVE high-values TO A
ACCEPT A
END-PERFORM
|
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
But the program will not face any abend if you try to ACCEPT after the end of data has been reached. |
Interesting - "once upon a time" this caused an S001-05 (get or read issued after end of file) - IIRC. . . It has been more than 30 years since anyone on any of the systems i've supported used an ACCEPT for data.
I guess the compiler folks decided to "dumb down" the process to prevent the abend. . .
Thanks for the clarification. |
|
Back to top |
|
|
Succor
New User
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
|
|
|
|
There are other ways to find out the end of valid data as well.The only point when i posted was to tell that the program will NOT ABEND and we donot set anything like AT END SET ACCEPT-EOF TO TRUE for ACCEPT. |
|
Back to top |
|
|
Succor
New User
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
|
|
|
|
Dick, I did not read your Post before replying....I just wanted to state something which I have worked on and wanted to share. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Quote: |
I just wanted to state something which I have worked on and wanted to share. |
I'm glad you did
That's my "learned something new today" . . .
d |
|
Back to top |
|
|
Ronald Burr
Active User
Joined: 22 Oct 2009 Posts: 293 Location: U.S.A.
|
|
|
|
If I understand the manual properly, if you issue multiple ACCEPTs, and do not ACCEPT data into the same target field each time, then the value in any target field AFTER EOF on SYSIN will NOT continue to be the last value read from SYSIN - rather the value will be that which resided in the target field prior to the ACCEPT. |
|
Back to top |
|
|
|