Search This Blog

Saturday, 11 February 2012

cobol previously asked Faq-2(asked by interviewers in companies)


31  how we separate the cobol cics statements from  cobol&cics programming?

Ans) CICS statements starts with
EXEC CICS
 and end with
 END-EXEC.

32) 01 text-data pic x(100).
move 'xyzdbfrjjg  u' to text-data.
how to find the value of last index of text-data?
Or) Presumably you mean the last character? Redefine the field
as OCCURS 100 PIC X. Start your subscript/index at
the "end" and work backwards to find the first non-blank
character. Careful if the whole field is blank, or if there
are no blanks.

33 There are two flat files one having 10 records and other
having 5 records. write a cobol pgm to find the duplicate
records(matching records)from both files.
Ans) perform 10 times
read file1
   perform 5 times
   read file2
      if file1rec = file2rec
         write file1rec to file3rec
      end-if
   end perform
end perform.

34)what is soc7 abend?how u can trace it?
Answer # 1 )
        Soc7 generally occurs when a non mumeric data moved to a
numeric data type and perform computation.
Or) SOC7 occurs when numeric operations are performed on non-
numeric data
35) Re: what is soc7 abend?how u can trace it?
Answer # 3
        hi i will give you one eg

x1 pic x(10)
x2 pic 9(4)

i want to move x1 to x2 but it is not possible becoz how
can we send the alpha -numeric data in to numeric. at that
time Soc7 will raise. but it will possible if the alpha-
numeric data is only numeric data i.e alpha numeric means
combination of A-Z and 0-9 if we send the digits to digits
it is no problem

Kindly tell me if answer is wrong? i will waiting for reply.
36) Re: what is soc7 abend?how u can trace it?
Answer
 # 4         all answers r correct but ther r many cause of soc7 abend
like

1.Numeric operation
on non-numeric data
2.Un-initialize working-storage
3.Coding past the maximum allowed sub scrip
Re: what is soc7 abend?how u can trace it?
Answer
 # 3         hi i will give you one eg

x1 pic x(10)
x2 pic 9(4)

i want to move x1 to x2 but it is not possible becoz how
can we send the alpha -numeric data in to numeric. at that
time Soc7 will raise. but it will possible if the alpha-
numeric data is only numeric data i.e alpha numeric means
combination of A-Z and 0-9 if we send the digits to digits
it is no problem

Kindly tell me if answer is wrong? i will waiting for reply
Or) Re: what is soc7 abend?how u can trace it?
Answer
 # 4         all answers r correct but ther r many cause of soc7 abend
like

1.Numeric operation
on non-numeric data
2.Un-initialize working-storage
3.Coding past the maximum allowed sub scrip

36)  what is sync clause?
Answer # 1)
sync clause is specified with comp,comp-1 and comp-2items.these items are expected to start at half/full/double word boundaries for faster address resolution.sync clause does this but it may introduce slack bytes before the binary item.
exemple
01 ws-test.
 10 ws-var1 pic x(02).
 10 ws-var2 pic s9(6) comp sync.
assumes ws-test starts at relative location 0 in the memory,ws-var1 occupies zero and first byte .ws-var2 is expected to start at second byte. as the comp item in the example needs one word and it is coded with sync clause,it will start only at the next word boundary that is 4th byte.so this introduces two slack bytes between ws-var1 and
ws-var2.

37)  what is subscript in cobol?give realtime example?
Answer# 1)
          it is a number of occrances of array data name. subscript is
coded in working-storage section with separate variable.
example.
01 g1.
  02 ele pic x(3) occurs 10 times.
01 i pic 99.
procedure division.
    perform varying i from 1 by 1 until i > 10
    accept ele(i)
    display ele(i)
    end-perform.
    in this is case i is a subscript variable
or) 01 g1.
  02 ele pic x(3) occurs 10 times.
01 i pic 99.
procedure division.
    perform varying i from 1 by 1 until i > 10
    accept ele(i)
    display ele(i)
    end-perform.
    in this is case i is a subscript variable

38)  In a COBOL program, 2 tables TABLE1 and TABLE2 are defined that are indexed by INDEX1 and INDEX2 respectively. Can we use INDEX1 with TABLE2 and INDEX2 with TABLE1?
Answer# 1)
Because the index is defined to the corresponding table,
INDEX1 cannot work with TABLE2 and vice versa.

39)  in cobol main pgm is calling sub pgm but sub pgm does not exists , what abend i get if submit the job?
Answer
 # 1         S0C1 ABEND will be issued.
39) Re: describe 805 error
Answer # 1)
805 error means token not found.
it's nothing but inserting duplicates...
or)
the  sqlcode=-805  get in db2 application program   due to the mis matching of the load library for program-id(program name ).
Or)
-805 error means at the binding process time,dbrm or
package not found in plan.

40) How will 128 be saved in s9 (3) comp-3
How will 12 be saved in s9 (2) comp
a) n=128 it is a even number  thaty  (128/2)+1  65  in comp3
in comp  s9(12)  8bytes it occupies

41) comp-3 is stored as (n+1)/2 where n is number of digits.Since here n is 3 for numeric 128,(3+1)/2=2 bytes.

12 8C here c represents positive(D for negative)

Comp is stored as n/2,where n is number of digits.Since n is 2 for numeric 12,(2)/2=1 byte(1/2 word)
12 is saved as 12

42)  How will 128 be saved in s9 (3) comp-3 How will 12 be saved in s9 (2) comp
Answer)
for comp-3 will store data in packed decimal format
s9(3)comp-3
0.5+1.5=2 bytes,
for 128 it will store c128 or f128.
for comp will store data in binary format
s9(2) will occupy 2 bytes
for 12 it will store binary format i.e 12=1100

43) how we rectify soc4 and soc7 error in project(need real timeAnswer)
go to sysdump there you can find the 8bytes offset
address,,copy that offset,,,go to the expanded version of
your program,,paste the offset adress there,,,
then it will show the exact line where the abend occurs,,

44) I have dataset DS1 which has records say
1
2
3
4
5
...
...
etc

And also I have second dataset DS2 whcih has records
1
3
4
5
6
8
..
...

Both the files are sorted and now I want to compare these files and write it into the third files if the records are matching.?
a) Use following JCL
//STEP010  EXEC PGM=ICETOOL                      
//SYSOUT   DD   SYSOUT=*                         
//SYSPRINT DD   SYSOUT=*                         
//TOOLMSG  DD   SYSOUT=*                         
//DFSMSG   DD   SYSOUT=*                         
//FILEIN   DD  DSN=XXXXXXXXXXXXXX,DISP=SHR    
//TOOLIN   DD *                                  
  SELECT FROM(FILEIN) TO(UNIQFL)                -
  ON(1,73,CH) NODUPS                             
  SELECT FROM(FILEIN) TO(DUPFL)                 -
  ON(1,73,CH) ALLDUPS                            
/*                                               
//*                                              
//DUPFL    DD  SYSOUT=*                          
//UNIQFL   DD  SYSOUT=*                          
//*                                

Label DUPFL will show all duplicate records
Label UNIQFL will show all unique records
Or) Using matching logic:

perform following code until either of EOF is found.

EVALUATE TRUE

WHEN KEY1> KEY2
READ FILE2
WHEN KEY2> KEY1
READ FILE1
WHEN KEY1=KEY2
WRITE FILE3 (WHATEVER FORMAT YOU WANT)
READ FILE1
READ FILE 2

END-EVALUATE

You can perform above code until both EOF found, incase you
need to create another file for non matching records. for
matching records only performing until either of EOF will
work.

45) WORKING-STORAGE SECTION.
01 A PIC X(3) VALUE 'ABC'
01 B PIC 9(3).
PROCEDURE DIVISION.
MOVE A TO B.
STOP RUN.

OUTPUT IS: AB3
WHY AND HOW THIS IS HAPPENING.
You won't get AB3 as Output,Job will abend with SOC7 as you
r moving Character to Numeric variable

46) Re: what is the advantage of using redefines instead of delaring the variables ?
Answer)
redifine will used to change the pic clause of already declared variable.

47) what is the advantage of using redefines instead of delaring the variables ?
a) redifine will used to change the pic clause of already
declared variable.
Redefines is basically used to occupy same same storage space for different data items.In this case if we declare new variable then there is wastage of memory
Or)
Redefines is used to re-use the storage space irrespective of the data type.
--Using redefines more than one field can re-use the same memory.

Ex:  01 a pic x(5) value 'xyz12'.
     01 b redefines a pic x(3).

Here a=xyz12 value is stored and
     b=xyz value is stored. B is reuse the A's Memory

48)  what are difference organizations in cobol and access mode in cobol? can you expalin what organization means while declaring for ksds,esds,rrds?
Answer)
organization is a class which is to specify the type of file.
org'n can be sequential,indexed,relative.
acess mode is used to acess the records in
seqential,random,dynamic.
KSDS:org'n is indexed
ESDS:org'n is SEQUENTIAL
RRDS:org'n is ,relative.

49) what is filler and what is use of filler
Answer1)
filler command is used  for declaring space .

Answer2)
  Filler can be used to fill the gap between to variable of our interest. Filler is the part of record/data we don't use for any computational purpose.
self explanatory... to fill up the gap either with some spaces or strings or data.
Or) filler command is used  for declaring space .

50) how will u pass dadta to cobol+db2 program...?
Answer)
        using host Variables
51)  how we rectify soc7 and soc4 errors in project?
Answer)
SOC4 means address exception

when we are trying to move a value into a variable which is having more length than defined

SOC7 -  Data Exception.

eg: when we try to move a non-numeric data into a numeric data item.

52)  how can we find total no of records in a file ....is there any utility......?
Answer# 1
        fileaid
 how can we find total no of records in a file ....is there any utility......?
Answer  # 2)  
      Use ICETOOL utility as below.

//TOOLIN DD *
COPY FROM(IN1) USING(CTL1)
/*
//CTL1CNTL DD *
  OUTFIL FNAMES=OUT,REMOVECC,NODETAIL,
    TRAILER1=('FILE1',5X,COUNT=(M10,LENGTH=5))
/*

53) We know that size of redefine and redefining need not to be
same..Then does the below case true

01 ws-date pic 9(6).
01 ws-redf-date REDEFINES ws-date
    05 ws-year pic 9(4)
    05 ws-mon pic 9(2)
    05 ws-day pic 9(2)
a) Yes, It is true because the size of the variable which is
redefining can have same or more than the size of the
original variable and it can be a group or an elementary
variable.

54  Syntax for JCLLIB & JOBLIB???
Answer)
JCLLIB: The PDS, where all the JCL (procedures) are present.
JOBLIB: The PDS, which contains the load modules of the programs.

In a JCL, if we are including any procedures, the system should know where it needs to be searched. That's why we are mentioning JCLLIB.. here is the syntax..

//DDNAME  JCLLIB ORDER=(Emer.proclib,prod.proclib)
Where, DDNAME can be anything within 8 chars, JCLLIB & ORDER are the keywords and there is no DISP is needed.

When a program is try to run the system will execute the macro to load the executable code(load module of the program) from the load library to main memory. So we should mention where it should find the same. here is the syntax.....

//JOBLIB DD DSN=emer.loadlib,DISP=SHR
//       DD DSN=prod.loadlib,DISP=SHR
//       DD DSN=test.loadlib,DISP=SHR

Where, other than the library name, all others are keyworkds.

Please include if I missed anything..
Re: What is COMP-1? COMP-2?
Answer)
COMP-1  - Single precision floating point. Uses 4 bytes.
COMP-2 - Double precision floating point. Uses 8 bytes
What is COMP-1? COMP-2?
Answer # 2 )
comp-1 is single floatig item where as
comp-2 is double floating item.
comp-1,comp-2 we are not using pic clause.

 What is COMP-1? COMP-2?
Answer# 3  
comp 1:single precision floating point//4 bytes
comp 2:double precision floating point//8 bytes

55 How can we pass data from cobol to JCl?
Answer # 1)
We can pass the data from cobol to JCl

ex: Move 4 t0o return code.
How can we pass data from cobol to JCl?
Answer # 2)
we can pass data from cobol to jcl by using return-code like
move 450 to return-code
if we are passing data likeit then at run time the maxx 
return code will be this code if move code is a negative
number then after subtracting from 4096 maximum return code
will be displayed

56) How can we pass data from cobol to JCl?
Answer)
create a Symbolic Parameter in jcl woith out goiving any
value.In the job step passthis symbolic parameter through
PARM parameter to cobol program.in the linkage section of
the cobol program assign the value/string to the symbolic
variable. It will automatically reflect to the symbolic
variable which was defined in JCL program.0

57) How can we pass data from cobol to JCl?
Answer)
i need Passing a variable parm from JCL to a cobol/db2
program
I'm trying to write a batch cobol/db2 pgm wich receive in
linkage section some paremeters
I succeeded to pass a static string of characters but what
I need is variable parameters (INPUT )

    //DDB5A59     JOB  CLASS=A,MSGCLASS=R,MSGLEVEL=(1,1),NOTIFY=xxxx
    //  REGION=0M                                                
   // SET  INPUT=MYNAME                           
<=====
 //PH01S01 EXEC PGM=IKJEFT01,DYNAMNBR=20,COND=(4,LT)         
 //SYSTSPRT  DD  SYSOUT=*                                      
 //SYSTSIN  DD  *                                           
  DSN SYSTEM
     (DBSN)                                                
 RUN  PROGRAM(COBPROG) PLAN(NACPLN) -
                          
       PARMS('INPUT') -
                                         
       LIB
('MYDB.TRNSCTN.LOADLIB')                             
 //SYSPRINT DD
SYSOUT=*                                         
 //SYSUDUMP DD
SYSOUT=*                                         
 //INFILE     DD  DSN=MYDB(&INPUT),DISP=SHR                
 //ERRLST     DD 
SYSOUT=P,DCB=RECFM=F,FCB=L56                  
The program (cobprog) is that when I run the job ,if  PARMS
('&INPUT')  returns :&INPUT and
if PARMS(&INPUT)  returns :null
i need "myname" to the cobol/db2 program and  name of  the
member (DSN=MYDB(&INPUT),DISP=SHR)

58) what are the error codes in cobol, db2, cics, vsam , and jcl
Answer)
ERROR CODES ARE NOTHING BUT THE REPRESENTATION OF CERTAIN
ABNORMAL TERMINATION
E.G;-811 TRYING TO SELECT THE SECOND ROW
+100-NO CURSOR IS AVAILABLE OR NO RECORD FOUND
SOC7-INVALID NUMERIC FIELD
SOC-4 STORAGE VIOLATION ERROR AND ETC.
59)  what is a zoned decimal data type and how it will be stored?
Answer)
       zoned decimal data type pix 9(2).
ex:
 01 var1.
 02 a pic 9(2).
here 9 is a zoned decimal data type.
it is a numeric field.
Or) what is a zoned decimal data type and how it will be stored?
Answer# 2 )
         Zoned decimal is the numeric format  used for display usage.
For an unsigned field the digits in the field are
represented by EBCDIC code (F0 thru F9).In a signed number
the zoned bit in the right mosted byte of the field are
either hex C for postive or hex D for negative.

eg:F0 F0 F1 F2 F3    unsigned 234

   F0 F0 F1 F2 C3    signed +234
   F0 F0 F1 F2 D3    signed -234

60)  copy 100 records without using ibm utilities
Answer# 1 )
         USING AN OCCURS CLAUSE WE MOVE RECORD FROM ONE PS FILE TO
ANOTHER PS
Re: copy 100 records without using ibm utilities
Answer# 2)
MOVE 0 TO WS-COUNTER
MOVE N TO END-OF-FILE

PERFORM 1000-COPY-PARAGRAPH UNTILL (WS-COUNTER = 100 OR END-
OF-FILE = 'Y'.

100-COPY-PARAGRAPH.
READ INPUT FILE
AT END MOVE Y TO END-OF-FILE
NOT AT END MOVE IN-REC TO OUT-REC
ADD +001 TO WS-COUNTER.
1000-EXIT.
EXI.

61) Why we need to use redefine clause when we can define the variable seperately... what is actual need....
Answer# 1)
 whenever declaring the file structure , the same storage
for the different records are redefined without againg
defining the same records, we used the redefined clause

 Why we need to use redefine clause when we can define the variable seperately... what is actual need....
Answer# 2)
yes when ever we face two type of records in the file in
that  we use this redefines  i will expline that best example
01 salse-record
  05 salse-re
   o2 qua        pic    x(04).
   o2 unit-pric  pic    x(08).
 05 amount   redefine salse-re  pic   x(12).

 in this eaither we get qandity and price  or amount nobothar about it .

62 I have program P1 which calls file F1 which has 100 records
and following structure
001 ..................
002 ..................
003 ..................
098 ....................
099 ...................
100 ....................

Now I want to read these files and write these records in
file F2 in following manner.

001 ......    051 .....
002 ......    052 .....
003 ......    053 .....  
..........       .......
..........       .......
..........       .......
048 ........   098 ......
049 .......... 099 .......
050 ....       100 ......
Ans) 1.first use JCL to sort the file then split the file into
two or read the file first 50 record by using count after
reached 50 then move to one file then remaining 50 move to
other file then read file1 and write by using write para
(PERFORM FILE1-WRITE1) then READ SECOND file then write
second FILE2 record(PERFORM FILE2-WRITE2)into the same
output file.

63)  why we are using set in searchall?
Answer
 # 1         no need use the SET verb in search all (Binary Search)
because it will automatically initialise and increase the
index variable in the table.
Or) Re: why we are using set in searchall?
Answer
  In search all(bynary search)
  set is used in 2 ways
 1) if u incress/decress indexed varibles
       ie set ws-a upto/downto 5.
    it incress/decress indexvalue 5.
 2) we canot use move clause in indexed  so we use set  
place of move like
       ie set ws-a to 5.
 it simply move 5 to ws-a.

64) How to delete the records of a dataset through cobol programme?We should not use jcl utilitities like IDCAMS.
Answer
we can delete by usinf the files concept.

if case of sequential file there is no direct delete option.
for this

1) read the record and rewrite with spaces.
2) read record from one file and write it into another file
by excluding the record which has to be deleted.

if case of indexed file we can directly delete the record
as it contains the indexed no.

same for relative files.

  
How to delete the records of a dataset through cobol programme?We should not use jcl utilitities like IDCAMS.
Answer
If the file we are using is VSAm file then we can go for Key mentioned,
If it is a sequential file we have to read till the 49th record then needs to delete the 50th record, this is the main disadvantage with Sequential files.

Syntax for deleting record.

DELETE file_name RECORD
65) Re: if you give cylinder(1,1)how many cylinders it will be allocate?
Answer
 # 1         Maximum of 16 cylinders
this is VSAM question.
 the maximum extents to secondary is depend on the files
used:
For sequential: 15
for VSAM : 123

in this case the answer is : 1+1*123=124 cylinders

66)  if we have a 10 steps how to override the 4th step in jcl?
Answer 
       Code cond parameter as
 cond= (0,GT).. Thats all.

67)  how would you resolve sb37 and SE37?
Answer # 1)
         SB37 is the space abend we will get this abend when both
primary and secondary space is fill. we can increase the
primary and s3condary space for rectifying the abend.
sSE37 we will get this abend mostly for partitioned data
sets because of end of volume. we can rectify this abend
just zip the data set by just press the (z) in front of
this data set it will get compressed
Re: how would you resolve sb37 and SE37?
Answer # 2)
Following are the space abends...
1. SD37 - no secondary allocation was specified.
2. SB37 - end of vol. and no further volumes specified.
3. SE37 - Max. of 16 extents already allocated.

Solutions....
1. provide the secondary allocation in the JCL.
2. Need to increase the values of space parameter or provide more than one volume
3. Increase the space parameter values.

67) how to display the dataset information?
Answer)
         Using IDCAMS utility, use LISTCAT you can get the information

68)  where did you see the information regarding abend codes in jcl?
Answer
       CEEDUMP, JESMSGLG

69) How can you display the SPOOL information ?
Answer# 1 
        SPOOL- (simultaneous peripheral operation online)
TSO SDSF ST is the command display the spool information.

How can you display the SPOOL information ?
Answer#2)
     Simply write DISPLAY in the program.
and in the JCL write //SYSOUT DD SYOUT=*
This will display the the information which was coded with
the DISPLAY in the program.

70) What is XDC ?
Answer # 1 
       XDC is the command used to store the SPOOL information in Dataset.
XDC is the command used to store the spool information in a dataset.

The Job details get deleted from the spool after soem time but if we want to see the details after some time then it is quiet useful.especially in testing etc

71)How can you declare the file ?
Answer)
ENVIRONMENT DIVISION.
FILE-CONTROL.
   SELECT FILE1 ASSIGN TO DISK1

72) What is the maximum data length for Numeric DataType ?
Answer# 1)
18 is Maximum Data length for Numeric Data Type.
What is the maximum data length for Numeric DataType ?
Answer#2
BY USING COMPILER OPTION MATH, IT WILL INCREASE THE VARIABLE CAPACITY UP TO 31 DIGITS.

73 file status 00 is checked after opening the file or reading the file
Answer # 1 
       File status is checked at both times i.e while opening as
well as while reading the file also.
file status 00 is checked after opening the file or reading the file
Answer # 2 
   it can be used for both the situation for successful opening
and reading the file

74  How to concatenation one or more string?
Answer
using concatenate operator
 e.g string1||strting2||'string3'

How to concatenation one or more string?
Answer
Suppose ther are two strings

string1=Anne
string2=Marrie
The command to concanate above strings is

String string1 delimited by size
       string2 delimited by size
into string3
end-string.
string3  would ce: how to create temporary data set in jcl? what is the use?
Answer
 # 1         dsn=&&dsname or By not giving data set name.ontain-Anne Marrie

75)how to create temporary data set in jcl? what is the use?
Answer)
  by using the symbolic parameter we can create temporary data
set. the temporary dataset is used for storing the sorted
records before it store into the output file..

76 can we declare occurs in 01 level?
Answer)
       occurs clause cannot be used in '01' level because it is
used to repeat the elementary data item

77  how you will define variables length in cobol.
Answer)
We can define variable length in cobol in the File section as :
RECORDING MODE IS V OR VB ( where V stands for variable and
VB stands for variable block )

 how you will define variables length in cobol.
Answer)
file section.
 fd recseqv
     recording mode is v
     record varying from 3 to 80 characters.
 01 recseqv-fd-record       pic x
         occurs 3 to 80 times
         depending on ws-record-length.


78) WHAT HAPPENS IN THE BACKGROUND OF SPOOL WHEN WE SUBMIT A JOB FOR COMPILATION AND EXECUTION... THIS IS A RECENT QUESTION IN IBM...KINDLY HELP ME.....
Answer)  both of them
compilation is display the erros of the appllication program
execution is display the o/p
uring compilation, first step would be precompilation process which would look for any EXEC SQL or EXEC CICS statements (which are other than host language) and produces a object deck. In case of EXEC SQL statements, cobol code is created with SQL statements commented & the SQL statements are separated and segregated as DBRMs. The cobol code is compiled for syntax errors. Only basic syntax check is made for SQL DBRM. Then the object deck is link edited to produce load module. For the DBRMs the executable form of code is produced only during the DB2 bind process

No comments:

Post a Comment