Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Result after the EXAMINE statement is executed

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
Lavanya_Dhushetty
Warnings : 2

New User


Joined: 30 Aug 2007
Posts: 24
Location: Chennai

PostPosted: Fri Sep 14, 2007 11:38 am    Post subject: Result after the EXAMINE statement is executed
Reply with quote

. Consider the following code snippet:

01 WS-VAR PIC X(6) VALUE 'INDEPENDENCE'.


EXAMINE WS-VAR REPLACING UNTIL FIRST "E" by "D".

What will WS-VAR contain after the EXAMINE statement is executed?

Answers:
a. INDDPENDENCE
b. INEDPDNEDNCD
c. INDDPDNDDNCD
d. DDDDPENDENCE
e. DDDEPENDENCE
Back to top
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri Sep 14, 2007 12:56 pm    Post subject:
Reply with quote

Lavanya,
You are kidding, right?
Is this some kind of trick question? icon_lol.gif
Back to top
View user's profile Send private message
RamsIBM

New User


Joined: 08 Jan 2007
Posts: 53
Location: Chennai

PostPosted: Fri Sep 14, 2007 1:09 pm    Post subject:
Reply with quote

Ans ) E
Guys correct me if am wrong
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Fri Sep 14, 2007 1:13 pm    Post subject:
Reply with quote

Lavanya,

Quote:
01 WS-VAR PIC X(6) VALUE 'INDEPENDENCE'.

Provided options are all wrong.
Back to top
View user's profile Send private message
diwa_thilak

Active User


Joined: 13 Jul 2006
Posts: 205
Location: At my desk

PostPosted: Fri Sep 14, 2007 3:15 pm    Post subject:
Reply with quote

Lavanya,

I dont see any correct options are available for this question.

Quote:
If identifier is a nonnumeric data item, examination begins with the
leftmost character, and proceeds to the right. Each character is
examined in turn.

If identifier is a numeric data item, the data item may contain a sign,
and examination proceeds on a digit by digit basis. This examination
starts with the leftmost digit and proceeds to the right. If a sign is
included in the data item being examined, it is ignored regardless of its
physical location
.

Quote:
* If REPLACING ALL is specified, all occurrences of literal-3 in
identifier are replaced by literal-4.

* If REPLACING LEADING is specified, each occurrence of literal-3 is
replaced by literal-4 until the first occurrence of a character
other than literal-3 or the rightmost character of the data item
is examined.

* If REPLACING UNTIL FIRST is specified, every character of the data
item represented by identifier is replaced by literal-4 until
literal-3 is encountered in the data item. If literal-3 does not
appear in the data item, the entire data item is filled with
literal-4.

* If REPLACING FIRST is specified, only the first occurrence of
literal-3 is replaced by literal-4. If literal-3 does not appear
in the data item represented by identifier, the data item is
unchanged after execution of the EXAMINE statement.


I beleive the correct answer should be INDEPENDENCD
One more information, Examine is now replaced with INSPECT statement

Cheers,
Diwakar

-----------------------------------------
Nobody is Perfect. I am Nobody
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Fri Sep 14, 2007 8:43 pm    Post subject:
Reply with quote

Hello,

All of the answers are wrong.

The answers are 12 characters but the field is defined as 6. . . . icon_confused.gif

Here, the compiler complains if the value exceeds the defined length.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Sat Sep 15, 2007 2:49 am    Post subject:
Reply with quote

With the right (or wrong) compiler options, you will receive a warning message indicating that you were a little dumb allocating less space than the value you wanted to have contained.

compiler will truncate your value to the length provided in the picture clause and generate an object (if that was your only error).

I believe that the compiler will not generate an object if you provide a value that exceeds the pic clause length associated with a level-88 item.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


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

PostPosted: Mon Sep 17, 2007 5:07 pm    Post subject:
Reply with quote

Hi Dick,

Quote:
compiler will truncate your value to the length provided in the picture clause and generate an object (if that was your only error).

I used the following definition

Code:
01  VARIABLE.                                   
    05  FIELDA      PIC X(06)  VALUE 'ABCDEFGHI'.

There was below error message in the compiler listing:
Code:
VALUE" literal "'ABCDEFGHI'" exceeded the length specified in the "PICTURE" definition.  The literal was truncated to the "PICTURE" definition length.

and the compilation was failed, load module was not created.

So I think, even for some other level, load module will not be created..
Quote:
I believe that the compiler will not generate an object if you provide a value that exceeds the pic clause length associated with a level-88 item.


Quote:
With the right (or wrong) compiler options,

Can you please tell me, what right & wrong options you are talking about here ? Can compiler option play a role in above case, if yes, how ? Please let me know.
Back to top
View user's profile Send private message
Lavanya_Dhushetty
Warnings : 2

New User


Joined: 30 Aug 2007
Posts: 24
Location: Chennai

PostPosted: Mon Sep 17, 2007 7:02 pm    Post subject: Reply to: Result after the EXAMINE statement is executed
Reply with quote

If that is pic x(12).Can U tell me what would be the result??????
Back to top
View user's profile Send private message
raviprasath_kp
Warnings : 1

New User


Joined: 20 Feb 2005
Posts: 65
Location: chennai

PostPosted: Mon Sep 17, 2007 7:14 pm    Post subject: Reply to: Result after the EXAMINE statement is executed
Reply with quote

then the ans is

e. DDDEPENDENCE
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Mon Sep 17, 2007 7:21 pm    Post subject:
Reply with quote

Got to agree, but what manual did you find the EXAMINE in?
I could only find INSPECT as in:
INSPECT indentifier-1 REPLACING CHARACTERS BY literal-1 BEFORE INITIAL literal-2
Back to top
View user's profile Send private message
diwa_thilak

Active User


Joined: 13 Jul 2006
Posts: 205
Location: At my desk

PostPosted: Tue Sep 18, 2007 10:10 am    Post subject:
Reply with quote

Hi All,

I apologize for the wrong answer, correct answer has to be DDDEPENDENCE

Godd catch Dick and Anuj, I didnt notice the length of the picture clause.

CICS Guy you can check out this link for examine statement.

http://docs.hp.com/cgi-bin/doc3k/B3150090013.11820/84

Cheers,
Diwakar

--------------------------------------
Nobody is Perfect. I am Nobody
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Tue Sep 18, 2007 1:29 pm    Post subject:
Reply with quote

diwa_thilak wrote:
CICS Guy you can check out this link for examine statement.
Oh, thanks, I do remember EXAMINE, I just couldn't find it in current documnetation....
From your link: "HP COBOL II includes the EXAMINE statement for compatibility with COBOL'68"
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Tue Sep 18, 2007 7:28 pm    Post subject:
Reply with quote

Hello,

And the only HP cobol i've worked with is run on UNIX.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
No new posts COBOL DB2 - CALL statement - high CPU... TS70363 DB2 15 Sun Sep 11, 2016 6:07 am
No new posts Converting NULL column into NOT NULL ... Raghu navaikulam DB2 5 Sat Aug 06, 2016 3:45 pm
This topic is locked: you cannot edit posts or make replies. Updating value of key using rewrite s... ParminderKumar COBOL Programming 4 Thu Aug 04, 2016 12:46 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us