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

Result after the EXAMINE statement is executed


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
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
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: 2146
Location: At my coffee table

PostPosted: Fri Sep 14, 2007 12:56 pm
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
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: 1436
Location: Bangalore,India

PostPosted: Fri Sep 14, 2007 1:13 pm
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
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

Moderator Emeritus


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

PostPosted: Fri Sep 14, 2007 8:43 pm
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
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

Superior Member


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

PostPosted: Mon Sep 17, 2007 5:07 pm
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
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
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: 2146
Location: At my coffee table

PostPosted: Mon Sep 17, 2007 7:21 pm
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
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: 2146
Location: At my coffee table

PostPosted: Tue Sep 18, 2007 1:29 pm
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

Moderator Emeritus


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

PostPosted: Tue Sep 18, 2007 7:28 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts RACF - Rebuild SETROPTS command which... All Other Mainframe Topics 3
No new posts first column truncated in search result IBM Tools 13
No new posts SDSF like solution in EJES (store com... All Other Mainframe Topics 4
No new posts executing XCTL command in COBOL witho... CICS 10
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
Search our Forums:

Back to Top