Sie sind auf Seite 1von 11

Q1:What is the difference between comp and comp-3 usage? Explain other COBOL usages?

ANS :Comp is a binary usage, while comp-3 indicates packed decimal. The other common usages are binary and display.
Display is the default. 3/28/00 Dave Herrmann: 'I was reading your FAQ on Cobol, as an fyi Comp is defined as the
fastest/preferred numeric data type for the machine it runs on. IBM Mainframes are typically binary and AS400's are
packed.' 

COMP
Comp is used for Binary Representation
it allows only S and 9 ...
s9(01) to s9(04) it takes 2 bytes memory
s9(05) to s9(09) it takes 4 bytes memory
s9(10) to s9(18) it takes 8 bytes memory

COMP-3
Comp-3 is used for Packed Decimal values
it allows S 9 V
mostly it is useful for Decimal Caluculation Values
it takes (n/2)+1 Bytes Memory

Q2 : How include time & date in the report generation in cobol programing?
ANS : This can be done in 2 ways 1 is u can enter the date by user itself or u can excpet date form system into requried
formate date/time variable then u can get time and day into ur report generation file.

MOVE FUNCTION CURRENT-DATE TO SOME-FIELD.

This will place the system timestamp in CCYYMMDDHHMMSSmmmmmmm format into SOME-FIELD.

There are 2 methods to include Time and date :

1. Move FUNCTION CURRENT-DATE to WS-Timestmp.

2a. Accept WS-timestmp from DATE .


2b. Accept WS-timestmp from TIME .

Q3: Suppose i have array of 10 elements in it how to access 5 element from the array using sup script and
index?
ANS : if you have an array with 10 elements like this :
int a[] = {1 2 3 4 5 6 7 8 9 10};
To access the 5th element you need to write a[4]. Because Array index starts from 0. In this case 0th element
is 1 1st element is 2.. etc

Can we able to execute the following statement move a,b toc,d' What will happen ?
Q4 :
ANS: We ll not be able to execute the statement... It will give us a error message... As per syntax... we can move 1
variable to many or 1 to i but not many to many or many to one...

Q5: Can we use redefine clause in occurs clause?


ANS: No we cannot use redefines in occurs clause. Compiler wont allow that

Can Redefines clause be used at 01 level ?


Q6 :
ANS: The REDEFINES clause cannot be used in a level 01 entry in the File Section. But It can be used in at 01 level in
woriking Section

Q7 : What happens if we code Exit program instead of Stop Run in main program
Ans : If Exit program is coded in the main program it will throw abend 4038 (compilation error) since it wont be able to
return control to the O.S

Q8:What does LINK-EDIT do actually?


Ans: LINK-EDIT converts object computer to load module. While converting will link system modules to object code to
generate load module. This system module are required in order to execute the load module.
Q9 :How may do the following definitions occupy?

(a) s(3)v99 comp-3


(b) s(9)v99 comp
ANS : Poor syntax. S9(3)V99 is correct and occupies 3 bytes. Count the number of 9's add 1 and divide by 2 rounding up
if necessary. ex.
S9(7)v99. there are 9 nines. (9+1)/2 = 5 bytes.
S9(6)V99. there are 8 nines (8+1)/2 = 4.5 = 5 bytes.
binary data (COMP) has no fractions integers only.

Q10 : INSEPCT
Give example of Inspect TALLYING / BEFORE INTIAL / AFTER INITIAL. In which situation will use this in COBOL?

Ans : In INSPECT claues Taylling is used to count the number of char's in the string. Before and after intial is used in termes of
intialized the particular char. Before start counting or after done the counting it will intinalzs that char. 

For example; variable - vara pic x(20) value mainframe question INSPECT vara tallying tally-count 'a' before intial 'e' after intial
'i'

Q11:In Cobol we may get return code of 4 or 8 or 12 or 16, If this is the case why the picture clause of return code in
alphanumeric field? why not numeric?
 ANS: RETURN-CODE is a 2 byte binary field. Hence it can very much be defined as a numeric field also. It is defined as alpha
numeric field i.e. PIC X(02) because it occupies 2 bytes and COBOL converts numbers in binary to char format when they are
accessed through a variable of definition PIC X(n). RETURN-CODE can very much be defined as PIC S9(04) COMP or PIC 9(2) also.
 

Q12 :If a simple cobol program has no syntax error, then is it necessary to compile it?
ANS :However simple be a COBOL program (it can even be a subprogram) it is always a good practice
to copile it and make sure its syntax error free. Moreover when we compile the COBOL code it will be
converted by the compiler in to object code (the load module) and this object code is the one that a
computer(machine) can understand. Thus only after proper compilation will a program run
successfully. Also this load module will help us to run the program multiple times without
recpmpilation (if no source code changes are made)
 

Q13What does the initialize statement do ?


ANS : Initialize will move zeroes to numeric items(9) and spaces to alpha-numeric items.(X)  

Q14 :Redefine

What is redefine in COBOL? 


 ANS : Re define is used to reuse the memory space from the first bit onwards.
here is an example
01 name pic x(6) value 'murali'.
01 cname redefines name pic x(6).
suppose when ever we want to store same value in two variable iit is better to make the second variable as redefining item.
in the above example we have saved 6byte of memory

Q15:How to edit comp-3 variable in cobol?


I have date 20101010 which is stored as comp-3 . Now I want to change this date to 2010-10-10 format. How to achieve
this?. I also believe that we can't split comp-3 variable.Am I rite?..Help folks!!  

ANS : If you have accepted the amount as 126778.12 from user and have to move it in COMP-3 variable then declares a
user defined fields as 9(11).99 and accept the above variable into it then move it into the desired comp-3 variable For ex
PIC 9(11)V99 COMP-3.
Amount will get modified.

To again display this amount in some report or so you can again do the reverse of above.
Move PIC 9(11)V99 COMP-3 to PIC 9(11).99
 
 

Q16 :Explain the Endevor list selection options - BX, CX, HX, LL, LO, LI, LC and SX Which among these are used to
browse the components?
Ans : BX - Browse A Browse command presents a read-only view of the element content.
CX - Changes The Changes display shows changed (and deleted) lines from the previous revision. 
HX - History A History command presents a read-only view of the “history” of the source content. Every line of source for the
element is shown whether it is still present or not.
SX - Summary Summary of levels shows information about each revision.
LI - List Inputs List the inputs for a program. 
LO - List Outputs list the outputs for a program.
LL - List Listings
LC - List Component
 
 

Q17 :COPY Statement


Which one of the following COPY statement is correct?1) COPY COPYFILE REPLACE ==PRE-== ==WK-==2) COPY COPYFILE
REPLACING =PRE-= =WK-=3) COPY COPYFILE SUPPRESS4) COPY REPLACING ==PRE-== ==WK-== IN COPYFILE5)  
 
Ans : COPY COPYFILE REPLACING =PRE-= =WK-=
 

Q18 :Comp-3

what is comp-3 and advantage with examples?  


  Ans : All computational usages are to compress data.
 comp3 is converts data into packet decimal format.
 each byte is divided into two characters in comp3.
 based on the type of length specified lengths are categorized
 if the length is odd the formula is (n/2)+(1/2)
 if the lenth is even the formula is (n/2)+1

Q19 : We have two files. and we want to write the matching records from both the files to a third file.There can be
duplicate records in both the input files.

Ans : You can use SPLICE is jcl.

Q20 : What is the difference between static & dynamic call?


ANS:  When you are compiling this program you set the dynamic versus static call setting. If the program is compiled
statically the subprogram becomes a part of the load. Whereas if the program is compiled with the program dynamically
then the subprogram will not be a part of main programs load. It only gets loaded into memory when the main program
makes the call to it.

ANS: In case of STATIC CALL t load module of both t main prog and t sub prog wil b combined together.... in case of DYNAMIC
CALL t load module of main and sub prog are both seperate. suppose that if u make any change in ur sub prog then in case of
DYNAMIC CALL u nee not recompile your MAIN prog once again. only t sub prog needs to b recompiled...... wher as in case of
STATIC CALL u need to recompile both t main and t sub prog Hope u understood

Q21: in-line PERFORM and out-line PERFORM


ANS: In-line PERFORM have explicit scope terminator END-PERFORM where as Out-line PERFORM does not. Out-line perform
have paragraphs.
If you want to perform certain amount of code only one time in the program then we use in-line PERFORM.
If you want to perform the same code many times within the program then you put that code in a paragraph and use it
wherever you want.
Q22What is the difference between INSPECT & EXAMINE?
ANS: INSPECT and Examine Both are same examine was used in cobol version-I and 
Inspect is using in COBOL Version_II. Both has the same functionality to 
calculate the numbers of characters in the string by tallying. 

Syntax 

INSPECT (indintifier-1) Tallying { FOR all ( literals-1 ) } Leading Replace by

Q2:What is difference between RM COBOL & MF-COBOL & Pro COBOL & VS-COBOL or Do we have
any other type of COBOL ?
ANS: We have ND-COBOL ACU-COBOL...all these depends on the machine in which we work

Q24: What is the difference between a subscript and an index in a table definition?
ANS:  subscript is a working storage data definition item, typically a PIC (999) where a value must be moved to the subscript
and then incremented or decremented by ADD TO and SUBTRACT FROM statements. An index is a register item that exists
outside the program's working storage. You SET an index to a value and SET it UP BY value and DOWN BY value. 

Q25:What is the linkage section?


ANS:The linkage section is part of a called program that 'links' or maps to data items in the calling program's working
storage. It is the part of the called program where these share items are defined. 

Q26: How to find the number of records in a flat file using COBOL ?

ws-x pic 9(09).

open input-file.

perform read-para 
until ws-end-of-file = 'y'.

display 'number of record in input-file : ' ws-x.

close input-file.

stop run.

read-para.

read input-file
at end move 'y' to ws-end-of-file

compute ws-x = ws-x + 1.

Q27:What will happen if a cursor is opened again before closing?


ANS: If cursor is opened again before closing The error will be happen as Cursor already opened. Error code is 501

Q28: How do you delete specific record using COBOL


ANS: The file which 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

ANS2: You can use SORT: copy first 49 record to a file

SORT FIELDS=COPY STOPAFT=49


then copy the rest of the records starting from 51 to another file

SORT FIELDS=COPY SKIPREC=50

then concatinate them to output file.

Q29:There are 2 files. These 2 files contains some common (duplicate) records. How do you copy
these common

ANS: Step 1: using pgm SORT sort and merge the two files
SORTIN DD file 1 (i/p file 1)

SORTIN DD file 2 (i/p file 2)

SORTOUT DD file 3 (o/p file containing the sorted and merged recs of both the i/p files)

Step 2: Using SUM FIELDS = NONE XSUM : the duplicates will be eliminated and written in to the file defined in the
SORTXSUM DD step

Using COBOL :
Use the MERGE verb along with the OUTPUT PROCEDURE. In the OUTPUT PROCEDURE code the logic for eliminating the
duplicates and writing them in to an output file.

Q0:What is the difference between NEXT SENTENCE and CONTINUE?


ANS: NEXT SENTENCE gives control to the verb following the next period. CONTINUE gives control to the next verb after the
explicit scope terminator. (This is not one of COBOL II's finer implementations). It's safest to use CONTINUE rather than NEXT
SENTENCE in COBOL II. 

If A>B

next sentence

end-if

display 1

display 2.

display 3.

     it will display only 3. if a>b

if a>b

continue

end-if

display 1

display 2.

display 3.
it will display 1 2 3. if a>b. let me know if it is not correct.

Q1:Comp and Comp-3


ANS: Whwn USAGE is specified as COMP the numeric data item is represented in pure binary.The item must be an integer.no
assumed decimal point is allowed.
COMP item should not contain any characters other than 9 S
size:half word full word binary word. e.g 02 ws-var picx(04) USAGE COMP.

Where as in COMP-3 data is stored in d form of packed decimal.i.e two digit will occupy 1 byte

Q2: When is a scope terminator mandatory?


ANS: in line perform & evaluate verb. in these two scope terminator is mandatory.

QWhat is the difference between static call and dynamic call?


Ans:Static calls refer to calls made to subprograms that was link-edited to the main program at compile time. That is the
subprogram's object code is part of the main programs object code. This is established on compile time with the NODYNAM
compiler option.Dynamic calls refer to calls made to programs with separate object code from the main program. This is
established on compile time with the DYNAM compiler option.Subprogram called in STATIC mode will always contain values
from previous calls if the INITIAL keyword was not coded in the Program-ID declaration in the subprogram's IDENTIFICATION
DIVISION. But you can reset the values by coding CANCEL from the main program.Subprogram called in DYNAMIC mode will
always be in initial state.Hope this helps.
Q4:What is the difference between Working-storage Section & Linkage Section?

 Ans: Working storage section is the part of data divsion where you declare your variables you are using in your program.

But Linkage section is the part of data division which is used to 1) Receive Parameters passed from other Cobol program
(Calling program).

2) It's used to accept the Paramaters passed from the JCL to the COBOL program.

Q5: How will work GOBACK statement & STOP RUN & EXIT-PROGRAM in COBOL ?

ANS: GOBACK gives the controll to main program if we have called the subprogram from the main program.

STOP RUN: This statement halts the execution of the object program and returns control to the system.

EXIT-PROGRAM: This statement specifies the end of a called program and returns control to the calling program.
Q6:What is the reference modification
 Ans: 00340 01 TREE-TYPE PIC X(15) VALUE 'BANANATREE'. 000350 01 FRUIT-TYPE PIC X(15) VALUE 'BANANA'. 000360 01 TREE-
FRUIT PIC X(5). If you wanna move only particular value to another variable instead of as a whole value you can use reference
modification.
For Eg :
You can say
004310 004320 MOVE TREE-TYPE(1:5) TO TREE-FRUIT. 004440
This will move "BANAN" to TREE-FRUIT. (The letters from position 1 of TREE-TYPE for 5 positions.So this : (colon) is called ref
modification indicator.Like this you can use MOVE TREE-TYPE(2:4) TO TREE-FRUIT.So the character from 2nd position for 4 character
length will get move.

Q7: What is an index for tables?

Ans: Generally index is created in either primary key or alternate key of a table for faster access of records.

Q8:What is Load module & Link edit and How will it work Dynamic call?
Ans: Load Module: The object code converted into Load Module (Machine readable form) by using Link edit that's common in
COBOL.
But in Dynamic call first we have to submit the sub progs later we can use that in Link section in COBCOMP. That's the
procedure. 
Q9:What if Stop Run is missing in COBOL program?
Ans: Stop Run" and "Go Back" both indicate to the program to end processing and in the latter case to transfer control to
the calling program.

If you dont specify either of these in your program the behaviour might be unpredictable. Most probably your program
will not end execution and an out of time error (S322) will be thrown...

Q40What is the use of Level 49 in COBOL?


 Ans: Hi Level 49 is the last sub level and is used to declare identifiers for which we are not sure that what length they can
occupy. For exapmle we have a filed NAME in our file and its length is 50 and we want that if name of a person is of 20 chars
only rest 30 chars positions could be reused than to leave the space unused.EX. Say our Rec is01 EMP-REC 05 EMPID PIC X(10).
05 DEPT PIC X(20). 49 NAME PIC X(50). 49 ADDRESS PIC X(50). And if NAME is 'PRADEEP' i.e. using only 7 chars out of allocated
50 then the next field ADDRESS will start right from where the NAME filed ends instead of leaving the 43 positions unused.All
Please advise me if I am wrong.pradeep
Q41Isit possible that the REDEFINES clause has different picture clauses compared to the one it
redefined?
ANS: Yes. I believe the keyword REDEFINES is meant to define a new field with picture clause different from the old one. That
is:1. The new field's length maybe greater than or less than the field being redefined:05 COMPANY-NAME PIC X(20).05
COMPANY-SHORT-NAME REDEFINES COMPANY-NAME PIC X(12).2. The new field's type is different from the field being
redefined:05 REPORT-DATE PIC X(8).05 REPORT-DATE-N REDEFINES REPORT-DATE PIC 9(8).Hope this clarifies.  
Q42What is the difference between COPY and INCLUDE
Ans: COPY statements are executed at compile time.
INCLUDE executed at run time. 
Q4:Explain call by context by comparing it to other calls?
Ans: When during the Call the shared data is moved to the temporary work area which is then passed to the subprogram intead
of the original data. As a result when control is passed back to the calling program the value of that field is not modified.
ex. CALL 'SUBPGM' USING BY CONTENT FA FB FC
Q44Give example of Inspect TALLYING / BEFORE INTIAL / AFTER INITIAL. In which situation
will use this in
Ans: var1 = 'abc sarath pqrs sawanth xyz' 

INSPECT var1 TALLYING count1 FOR ALL 'S' 


BEFORE INITIAL 'sarath' AFTER 'sawanth'
end-inspect.

sol: count1 = 1

Q45: What is the diffrence between endeavor and changeman?


ANS: Both Endeavor and Changeman are version control tool in Mainframe where you can elevate your components into
production. A pacakge can be created and stage the componets that to be elevated to prodcution

Q46:Impact Analysis
ANs: i) why the new file is being introduced to the program?

ii) adding extra two columns to the output file - will that impact the other programs which might be using that file?

ii) is there any user interface linked to the program?

iii) if yes how frequently that interface is used and will there be any change in that interface?
iv) if program is used for any reporting etc will there by any changes to the hard copy reports spool settings etc.

v) the two extra columns - can they be accommodated with the existing LRECL of the output file or will that need to be reconsidered.

should be answered and the changes should be considered.

Q47:Real time requirement in global payments-mainframes

Q48:Differentiate between literal and figurative constant


Ans: Literal means any values given by the user..
It may be of strings numeric like that..constants given/defined by User..

Figurative constant means compiler defined constants. They are zeros spaces etc.
 Q49:What is the need of using comp field in COBOL
Ans: 1. When we want to store the datas in BINARY format.
2. When we are receving the datas from the JCL. 
 Q50:How can you redefine pic x(10) with pic 9(10) without loosing the existing data from the
record.
You can redefine pic x(10) with pic 9(10) without any data loss as long as you don't move the value of the x-variable to 9-
variable.
 Q51:What is Addressing mode
Ans: AMODE is addressing mode.AMODE can be 24 31 or any. AMODE 24 implies that the addresses below the 16Meg line can be
fetched but the addresses below the 16 Meg line cannot be fetched. AMODE 31 implies that the addresses above and below the
16Meg line can be fetched. All new codes in COBOL 3 have amode as 31 by default.Hope this helps!!
 Q52:Difference between GOBACK & CHAIN in COBOL?
Ans: goback:
controller should return back to where ever it comes from.
chain:
controller will go to subprogram after compleation of subprogram it will go to os.
 

Q5:How to pass paramter from cobol to Jcl


Ans: that we can move the parameter from cobol to JCL via MOVE in the application and it will receive by the internal reader
in the JCL SYSOUT in DD statement.
Without execution cobol program how to see output?2) how to rename input filename and
 Q54
outputfile

Ans: According to my knowledge

1) without execution cobol program how to see output?

You cannot see the output of a program unless you have executed the program. but You can see the results of a CICS
pgm using INTERTEST.

2) how to rename input file name and outputfile name?


I DONT KNOW

3) what is flag?

Flags would be assigned a value based on some condition. While using it for some processing there is no need to
calculating every time. u can calculate one time and keep the decision saved in a varibale. this can be used multiple
times.

4) what is impact analysis what basis how will you write test cases?
Say you are changing a module this module may be interacting with many other modules or the results of this module
may be used by some other module. Any changes done for some bug fix in this module should not change the
functionality of any module. This is main purpose of Imapct analysis.

To write the test cases we need to be aware of the functioanlity of the module and the working of the module. 

5) how you sea output of cics command?

INtertest while testing.....

6) how are datasets concatenated explain with example?


//DDNAME DD DSN=file1.file DISP=SHR

// DD DSN=file2.file DISP=SHR

// DD DSN=file3.file DISP=SHR

if any answers are wrong plz do correct me.

Q55: Can Redefines clause be used in File section, if yes at which level number ? ?
Ans: We can use redifine in file section and also at any level. Redifine is just the method of representing thr
data in different formats. But the only clause is that lenght of the redefining field should be less than or
equal to the lenght of the redifined field.

Q56: Inthe example below 05 WS-VAR1 PIC X(5),05 WS-VAR2 REDEFINES WA-VAR1 PIC
9(5),PROCEDURE DIVISION MOVE MOVE 'ABCDE' TO WS-VAR1.Now what is the value of WS-
VAR1 and WS-VAR2 ?
ANS:

Q57 Infile section of a COBOL program, I have the following line.Record varying from 122 to
160 depending on WS00_RECORD_LENGTH. How would the value of
WS00_RECORD_LENGTH found out? Where will it be?

Q58:Whatare the two cobol verbs that are used in data division? (one is
COPY..what is the other)

Ans: 1)COPY

2)INCLUDE

Q59: Whatis the difference between write & move in COBOL.? What is the
meaning of 'TALLING' verb  in cobol? What is the meaning of 'Eject' verb in cobol?
Ans:
 

Q60:Can we use search and search all in embedded sql?


ANS: SEARCH and SEARCH ALL are only used for tables within the program and have nothing to do with SQL. SQL is used for
queries and other such functions on external relational tables maintained by a DBMS.  
Q61What is the difference between Call and Link in cobol?

  ANS: call means u r calling a predifined cobol app in to u r called program while running time only.

but link u r calling sub program into main while compiling time.

Q62:What are the HIGH Values,LOW values and where we can use?

ANS: HIGH-VALUES and LOW-VALUES are the largest and smallest possible values a given variable can hold respectively.
Typically they are usually used with alphanumeric PIC X type field

Q6) Is more than one record description is allowed in a FD?2) Is NUMERIC


EDIT fields can be used for
1) Is more than one record description is allowed in a FD?2) Is NUMERIC EDIT fields can be used for
Arithmatic operations?3) Is COMPUTE P,Q,W = A+ B/C -E ** 2 is a valid statement?4) Is LINKAGE
SECTION is mandatory in a sub program?5) In edit fiels the character used for check protection is
__________6) COMP-2 occupies _________ bytes?7) Maximum length of a numeric item ________ ?

 ANS: 1) No

2) no

3) yes

4) yes

5) '*'

6) 8 bytes

7) 31

Q64 :How to initialize a group data which is containing occur clause?

ANS: #.1 . Here is an example for how to initialize the normal group variable .

ex : 01 ws-details .

02 ws-name a(10 ) .

02 ws-desig a(5) .

move spaces to ws-details .

#.2 . If occurs clase exist here is the example

move all spaces to ws-details 

Das könnte Ihnen auch gefallen