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

Interview questions


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

New User


Joined: 22 Feb 2005
Posts: 11
Location: chennai

PostPosted: Mon Aug 29, 2005 1:15 pm
Reply with quote

Hai folks,

Here i am posting the interview questions i faced.Please post the answers for these as early as possible.

1.FD IN-FILE.
01 IN-REC. PIC X(80).
- - -
-
-
PROCEDURE DIVISION.

INITIALIZE IN-FILE.
OPEN IN-FILE.
WILL IT BE SUCCESSFUL??

2. FILE1. FILE2

1 3
2 4
3 5
4 6
5 7
8
9
NOW OUTPUT FILE SHOULD BE LIKE THIS.

FILE3

1
2
3
4
5
6
7
8
9
BUT we have to use pure COBOL LOGIC for this.it would be helpful if any of u can post the piece of code here.

3. How can u retrieve details of employees who have not assigned any project from a table having column PROJECT without using IS NULL option?
Back to top
View user's profile Send private message
sathish_rathinam

New User


Joined: 22 Aug 2005
Posts: 59
Location: india

PostPosted: Mon Aug 29, 2005 3:06 pm
Reply with quote

1.u can initialize a record but not a file .u will get some error.
3.select empname,empno,salary from emp where project ='null'.
by,
sathish
Back to top
View user's profile Send private message
mainframesguru

New User


Joined: 24 Jun 2005
Posts: 36
Location: Hyderabad

PostPosted: Wed Aug 31, 2005 11:06 am
Reply with quote

Hi

The following are the answers:

1. You cannot initialize a File. You can initialize only the Record
and also if you are trying to Initialize Record without Opening the File, you would get SOC04 Abend.

2. Follwo the Steps
1) Sort both the Files File1 and File2 Before Executing the Program.
Sort Key should be the one you are trying to compare
2)

*Initial Read
Read File1.
Read File2.

Perform Until Eof-File1 and Eof-File2

If Eof-File1
Continue
End-if

If Eof-File2
Cotinue
End-if

If File1 = File2
Write to Output File From File1 or File2
Read File1
Read File2
End-if

If File1 < File2
Write to Output File from File1
Read File1
End-If

If File1 > File2
Write to Output File from File2
Read File2
End-If
End-Perform.
------------------
Read File1 Para.
Read File1
At End Set Eof-File1 to True

Read File2 Para.
Read File2
At End Set Eof-File2 to True


3.
select empname,empno,salary from emp where project ='null'.

This Query will not work, for Null comparison, we have to use "IS NULL".
I dont have answer for this question.

Thanks And Regards
Vamshi
ICC-ISH
Back to top
View user's profile Send private message
Rameshs

New User


Joined: 15 Jun 2005
Posts: 53
Location: India, Chennai

PostPosted: Wed Aug 31, 2005 2:29 pm
Reply with quote

hi pravien,
This will give you the answer

select empname,empno from emp where project not like '_%';

if the query is wrong, inform me
Back to top
View user's profile Send private message
notonly4u

New User


Joined: 26 Apr 2005
Posts: 87
Location: Hyderabad

PostPosted: Wed Aug 31, 2005 6:31 pm
Reply with quote

Dear pravien,

In the program we use to give the null indicators while decalring the host variables. So if the field is Null, It'll have a value of '-1'.

So I think it is wise way to check whether the field is null or not without using IS NULL option.

If you have any queries please inform

Regards
Tanden
Back to top
View user's profile Send private message
David P

Active User


Joined: 11 Apr 2005
Posts: 106
Location: Cincinnati Ohio

PostPosted: Wed Aug 31, 2005 9:01 pm
Reply with quote

Hi Pravien,

Can you please elaborate more on your question 2.
I did not get exactly what the second question is?

regards,
David.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Sep 04, 2005 12:04 am
Reply with quote

Here's a cut & paste of a similar pgm. The key is to recognize the relationshp between the recs in each file and know what action to take. In your case you want to write to the O/P.
Code:

00067
00068  01  WS-SWITCHES-AND-COUNTERS.
00069
00070      05  WS-BOTH-FILES-EOF.
00071          88  BOTH-FILES-EOF                       VALUE 'YY'.
00072          10  FILLER              PIC  X(001) VALUE 'N'.
00073              88  DAILY-FILE-EOF                   VALUE 'Y'.
00074          10  FILLER              PIC  X(001) VALUE 'N'.
00075              88  MASTER-FILE-EOF                  VALUE 'Y'.
00086
00087  01  WS-WORK-FIELDS.
00088
00089      05  WS-BOTH-COMPARE-KEYS.
00090          10  WS-DAILY-COMPARE-KEY.
00091              15  WDC-USR-CDE     PIC  X(002).
00092              15  WDC-ACCT-NBR    PIC  X(008).
00093              15  WDC-SEC-NBR     PIC  X(005).
00094
00095          10  WS-MASTER-COMPARE-KEY.
00096              15  WMC-USR-CDE     PIC  X(002).
00097              15  WMC-ACCT-NBR    PIC  X(008).
00098              15  WMC-SEC-NBR     PIC  X(005).00103

00104  PROCEDURE DIVISION.
00105 ***************
00106  000-MAIN-LINE.
00107 ***************
00108      PERFORM 810-DISP-MSG-AND-OPEN-FILES
00113      WRITE MASTER-ACCRET-REC-OP  FROM WS-DAILY-HDR
00114      PERFORM 200-MATCH-DAILY-MASTER-RECS
00115        UNTIL BOTH-FILES-EOF
00116      PERFORM 900-END-IT
00117      STOP RUN
00118      .
00119 *****************************
00120  200-MATCH-DAILY-MASTER-RECS.
00121 *****************************
00122      EVALUATE TRUE
00123      WHEN WS-DAILY-COMPARE-KEY = WS-MASTER-COMPARE-KEY
00124           PERFORM 210-UPDATE-MASTER-REC
00125           PERFORM 700-GET-BOTH-COMPARE-KEYS THRU 700-EXIT
00126      WHEN WS-DAILY-COMPARE-KEY > WS-MASTER-COMPARE-KEY
00127 *===> I.E., NO DAILY ACCRETION RECORD
00129           PERFORM 220-REWRITE-MASTER-REC
00130           PERFORM 700-GET-MASTER-COMPARE-KEY
00131      WHEN OTHER
00132 *===> I.E., NEW DAILY ACCRETION RECORD, ADD TO MASTER FILE
00134           WRITE MASTER-ACCRET-REC-OP        FROM WS-DAILY-DTL
00135           ADD  +1                             TO WS-NO-MASTER-CNT
00136           PERFORM 700-GET-DAILY-COMPARE-KEY
00137      END-EVALUATE
00138      .
00167 ***************************
00168  700-GET-BOTH-COMPARE-KEYS.
00169 ***************************
00170      .
00171 ***************************
00172  700-GET-DAILY-COMPARE-KEY.
00173 ***************************
00174      IF NOT DAILY-FILE-EOF
00175         READ DAILY-ACCRET-FILE-IP  INTO WS-DAILY-DTL
00176         AT END
00177              SET DAILY-FILE-EOF TO TRUE
00178              MOVE HIGH-VALUES   TO WS-DAILY-COMPARE-KEY
00179         NOT AT END
00180              ADD  +1            TO WS-DAILY-REC-CNT
00181              MOVE PAD-USR-CDE   OF WS-DAILY-DTL
00182                   TO
00183                   WDC-USR-CDE
00184              MOVE PAD-ACCT-NBR  OF WS-DAILY-DTL
00185                   TO
00186                   WDC-ACCT-NBR
00187              MOVE PAD-SEC-NBR   OF WS-DAILY-DTL
00188                   TO
00189                   WDC-SEC-NBR
00190         END-READ
00191      END-IF
00192      .
00193 ****************************
00194  700-GET-MASTER-COMPARE-KEY.
00195 ****************************
00196      IF NOT MASTER-FILE-EOF
00197         READ MASTER-ACCRET-FILE-IP  INTO WS-MASTER-DTL
00198         AT END
00199              MOVE HIGH-VALUES    TO WS-MASTER-COMPARE-KEY
00200              SET MASTER-FILE-EOF TO TRUE
00201         NOT AT END
00202              ADD +1              TO WS-MASTER-REC-CNT
00203              MOVE PAD-USR-CDE    OF WS-MASTER-DTL
00204                   TO
00205                   WMC-USR-CDE
00206              MOVE PAD-ACCT-NBR   OF WS-MASTER-DTL
00207                   TO
00208                   WMC-ACCT-NBR
00209              MOVE PAD-SEC-NBR    OF WS-MASTER-DTL
00210                   TO
00211                   WMC-SEC-NBR
00212         END-READ
00213      END-IF
00214      .
00215  700-EXIT. EXIT.
Back to top
View user's profile Send private message
prasanth_thavva

New User


Joined: 28 Jul 2005
Posts: 86
Location: Chennai

PostPosted: Sun Sep 04, 2005 11:03 am
Reply with quote

Hi,
Quote:
Can u elaborate on with OUt IS NULL ...how to find the Null COlumn values
Back to top
View user's profile Send private message
sumivel

New User


Joined: 13 Sep 2005
Posts: 18

PostPosted: Wed Sep 14, 2005 9:50 am
Reply with quote

open input file1
open input file2
open output file3

Read file1
Read file2

perform until eofile1 and eofile2

if f1rec<f2rec
move f1rec to f3rec
write f3rec
read flie1

else
if f1rec >f2rec
move f2rec to f3rec
read file2
end-if
end-if
end-perform
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Sep 15, 2005 7:02 am
Reply with quote

Sumivel,

What happens when you have 10 recs in file1 and 100 recs in file2 and you hit EOF on file1?
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