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

Clarification on interview questions


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
dilpreet

New User


Joined: 18 Mar 2008
Posts: 34
Location: INDIA

PostPosted: Sun Oct 25, 2009 10:24 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Sun Oct 25, 2009 10:37 pm
Reply with quote

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
View user's profile Send private message
dilpreet

New User


Joined: 18 Mar 2008
Posts: 34
Location: INDIA

PostPosted: Sun Oct 25, 2009 10:40 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Mon Oct 26, 2009 2:36 am
Reply with quote

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
View user's profile Send private message
dilpreet

New User


Joined: 18 Mar 2008
Posts: 34
Location: INDIA

PostPosted: Mon Oct 26, 2009 6:46 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Mon Oct 26, 2009 9:41 pm
Reply with quote

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
View user's profile Send private message
dilpreet

New User


Joined: 18 Mar 2008
Posts: 34
Location: INDIA

PostPosted: Mon Oct 26, 2009 10:27 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Oct 26, 2009 10:54 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Mon Oct 26, 2009 11:52 pm
Reply with quote

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
View user's profile Send private message
dilpreet

New User


Joined: 18 Mar 2008
Posts: 34
Location: INDIA

PostPosted: Tue Oct 27, 2009 12:06 am
Reply with quote

THANKS DICK!!!
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Tue Oct 27, 2009 3:21 am
Reply with quote

Hi,

Quote:
THANKS DICK!!!
would caps off make this a little dick icon_lol.gif



Gerry
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Wed Oct 28, 2009 12:40 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Wed Oct 28, 2009 5:18 pm
Reply with quote

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
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Wed Oct 28, 2009 5:56 pm
Reply with quote

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
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Wed Oct 28, 2009 8:11 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Oct 28, 2009 8:29 pm
Reply with quote

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
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Wed Oct 28, 2009 8:46 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Oct 28, 2009 8:53 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Oct 28, 2009 9:00 pm
Reply with quote

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. . . icon_confused.gif

Thanks for the clarification.
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Wed Oct 28, 2009 9:09 pm
Reply with quote

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
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Wed Oct 28, 2009 9:14 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Oct 28, 2009 9:26 pm
Reply with quote

Quote:
I just wanted to state something which I have worked on and wanted to share.
I'm glad you did icon_smile.gif

That's my "learned something new today" . . . icon_wink.gif

d
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Wed Oct 28, 2009 10:22 pm
Reply with quote

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
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 -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Comp interview questions Mainframe Interview Questions 5
No new posts Interview Questions on Cobol DB2 program Mainframe Interview Questions 5
No new posts The Last Two Question For You To Ask ... Mainframe Interview Questions 0
No new posts Mainframe Interview Questions CICS,CO... Mainframe Interview Questions 6
No new posts Viewing executing process in NDM .. q... IBM Tools 0
Search our Forums:

Back to Top