Add to Favorites    Make Home Page 1424 Online  
 Language Categories  
 Our Services  
 FAQs Home  


COBOL FAQs -- Part II

Home -- FAQs Home

A D V E R T I S E M E N T

Search Projects & Source Codes:

1. What is LENGTH in COBOL II?

Ans: LENGTH acts like a special register to tell the length of a group or an elementary item.

2. What is the function of a delimiter in STRING?

Ans: A delimiter in STRING causes a sending field to be ended and another to be started.

3. What is the function of a delimiter in UNSTRING?

Ans: A delimiter when encountered in the sending field causes the current receiving field to be switched to the next one indicated.

4. How will you count the number of characters in a null-terminated string?

Ans: MOVE 0 TO char-count

INSPECT null-terminated-string TALLYING char-count FOR CHARACTERS BEFORE X"00"

5. Which statement will you use to move non-null characters from a null-terminated String?

Ans: UNSTRING null-terminated-string DELIMITED BY X"00" INTO target-area

COUNT IN char-count. (There are other methods, such as 1) using PERFORM 2) using SEARCH 3) using INSPECT and MOVE etc...)

6. 77 COUNTR PIC 9 VALUE ZERO.

01 DATA-2 PIC X(11). . .

INSPECT DATA-2

TALLYING COUNTR FOR LEADING "0"

REPLACING FIRST "A" BY "2" AFTER INITIAL "C"

If DATA-2 is 0000ALABAMA, what will DATA-2 and COUNTER be after the execution of INSPECT verb?

Ans: Counter=4. Data-2 will not change as the Initial 'C' is not found.

7. 01 DATA-4 PIC X(11).

:::

INSPECT DATA-4 CONVERTING

"abcdefghijklmnopqrstuvwxyz" TO "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

AFTER INITIAL "/" BEFORE INITIAL"?"

What will the contents of DATA-4 be after the conversion statement is performed, if before conversion

a) DATA-4 = a/five/?six b) DATA-4 = r/Rexx/RRRr c) DATA-4 = zfour?inspe

Ans: a) a/FIVE/?six b) r/REXX/RRRR c) zfour?inspe (no change at all)

8. What kind of error is trapped by ON SIZE ERROR option?

Ans: Fixed-point overflow. Zero raised to the zero power.

Division by 0. Zero raised to a negative number.

A negative number raised to a fractional power.

9. What is the point of the REPLACING option of a copy statement?

Ans: REPLACING allows for the same copy to be used more than once in the same code by changing the replace value. COPY xxx REPLACING BY .

10. When is a scope terminator mandatory?

Ans: Scope terminators are mandatory for in-line PERFORMS and EVALUATE statements. For readability, it's recommended coding practice to always make scope terminators explicit.

11. Can you use REDEFINES clause in the FILE SECTION?

Ans: No

12. How will you define your record descriptions in the FILE SECTION if you want to use three different record descriptions for the same file?

Ans: FD filename

DATA RECORDS ARE rd01, rd02, rd03.

01 rd01 PIC X(n).

01 rd02 PIC X(n).

01 rd03 PIC X(n).

13. When will you open a file in the EXTEND mode?

Ans: When an existing file should be appended by adding new records at its end. EXTEND mode opens the file for output, but the file is positioned following the last record on the existing file.

14. What does a CLOSE WITH LOCK statement do?

Ans: The statement closes an opened file and it prevents the file from further being opened by the same program.

15. Which mode of opening is required when REWRITE is used?

Ans: I-O mode

16. Why is it necessary that the file be opened in I-O mode for REWRITE?

Ans: Before the REWRITE is performed, the record must be read from the file. Hence REWRITE includes an input operation and an output operation. Therefore, the file must be opened in I-O mode.

17. Which clause can be used instead of checking for FILE STATUS = 10?

Ans: FILE STATUS 10 is the end of file condition. Hence AT END clause can be used.

18. What is the format of a simple SORT verb? What kinds of files can be sorted using SORT?

Ans: SORT workfile ON ASC/DESC KEY key1, ASC/DESC KEY key2 ...

USING inputfile GIVING outputfile

Only sequential files can be sorted in this way.

19. What are the different rules of SORT that needs to be considered?

Ans: The input and output files must remain closed because SORT opens them and closes during the operation, The work file must have a SELECT clause. The work file must have sort description SD entry in the FILE SECTION. Input and Output files must have FD entries

20. What are INPUT PROCEDURE and OUTPUT PROCEDURE?

Ans: Sometimes, it is necessary that the records must be edited before or after the sorting. In such cases,

SORT workfile ASC/DESC KEY key1, ...

INPUT PROCEDURE IS ipproc

OUTPUT PROCEDURE is outproc

Is used. In the INPUT PROCEDURE the input file is opened, records are read and edited and then are released to the sorting operation. Finally the file is closed. RELEASE sortrecname FROM inp-rec.

In the OUTPUT PROCEDURE, output file is opened, the sorted record is returned to the Output record area and then the record is written. Finally the file is closed. RETURN workfile RECORD into out-rec.

21. What is the format of a simple MERGE verb? Can INPUT PROCEDURE and OUTPUT PROCEDURE can be specified for MERGE verb?

Ans: MERGE work file ON ASC/DESC KEY key1...

USING inputfile1, inputfile2...

GIVING outputfile

INPUT PROCEDURE cannot be specified. Only OUTPUT PROCEDURE can be specified

22. How will you position an indexed file at a specific point so that the subsequent sequential operations on the file can start from this point?

Ans: Use START

START filename KEY IS EQ/GT/LT.. dataname

INVALID KEY ...

23. What are the access mode requirements of START statement?

Ans: Access mode must be SEQUENTIAL or DYNAMIC

24. What are the opening mode requirements of START statement?

Files must be opened in the INPUT or I-O mode.

25.What is the LINKAGE SECTION used for?

Ans: The linkage section is used to pass data from one program to another program or to pass data from a PROC to a program. It 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.

26. If you were passing a table via linkage, which is preferable - a subscript or an index?

Ans: Wake up - you haven't been paying attention! It's not possible to pass an index via linkage. The index is not part of the calling programs working storage. Indexing uses binary displacement. Subscripts use the value of the occurrence.

27. What is the difference between a subscript and an index in a table definition?

A subscript is a working storage data definition item, typically a PIC (999) where a value must be moved to the subscript and then increment or decrement it 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. Subscript refers to the array occurrence while index is the displacement (in no of bytes) from the beginning of the array. An index can only be modified using PERFORM, SEARCH & SET. Need to have index for a table in order to use SEARCH, SEARCH ALL Cobol statements.

28. What is an in line PERFORM? When would you use it? Anything else to say about it?

The PERFORM and END-PERFORM statements bracket all COBOL II statements between them. The COBOL equivalent is to PERFORM or PERFORM THRU a paragraph. In line PERFORMs work as long as there are no internal GO TOs, not even to an exit. The in line PERFORM for readability should not exceed a page length - often it will reference other PERFORM paragraphs. When the body of the Perform will not be used in other paragraphs. If the body of the Perform is a generic type of code (used from various other places in the program), it would be better to put the code in a separate para and use PERFORM paraname rather than in-line perform.

29. What is the use of EVALUATE statement? How do you come out of an EVALUATE statement?

Ans: Evaluate is like a case statement and can be used to replace nested Ifs. The difference between EVALUATE and case is that no 'break' is required for EVALUATE i.e. control comes out of the EVALUATE as soon as one match is made, There is no need of any extra code. EVALUATE can be used in place of the nested IF THEN ELSE statements.

30. What are the different forms of EVALUATE statement?

Ans: EVALUATE EVALUATE SQLCODE ALSO FILE-STATUS

WHEN A=B AND C=D WHEN 100 ALSO '00'

Imperative stmt imperative stmt

WHEN (D+X)/Y = 4 WHEN -305 ALSO '32'

imperative stmt imperative stmt

WHEN OTHER WHEN OTHER

imperative stmt imperative stmt

END-EVALUATE END-EVALUATE

EVALUATE SQLCODE ALSO A=B EVALUATE SQLCODE ALSO TRUE

WHEN 100 ALSO TRUE WHEN 100 ALSO A=B

imperative stmt imperative stmt

WHEN -305 ALSO FALSE WHEN -305 ALSO (A/C=4)

imperative stmt imperative stmt

END-EVALUATE END-EVALUATE

31. Can you use the INSPECT (with TALLYING option) Cobol verb in a CICS COBOL program?

Ans: Yes, under COBOL II environment, but not OS/VS COBOL.

32. What is an explicit scope terminator?

A scope terminator brackets its preceding verb, eg. IF .. END-IF, so that all statements between the verb and its scope terminator are grouped together. Other common COBOL II verbs are READ, PERFORM, EVALUATE, SEARCH and STRING.

33. What is the significance of 'above the line' and 'below the line'?

Ans: Before IBM introduced MVS/XA architecture in the 1980's a program's virtual storage was limited to 16 megs. Programs compiled with a 24-bit mode can only address 16 MB of space, as though they were kept under an imaginary storage line. With COBOL II a program compiled with a 31 bit mode can be 'above the 16 Mb line. (This 'below the line', 'above the line' imagery confuses most mainframe programmers, who tend to be a literal minded group.)

34. What was removed from COBOL in the COBOL II implementation?

Ans: Partial list: REMARKS, NOMINAL KEY, PAGE-COUNTER, CURRENT-DAY, TIME-OF-DAY, STATE, FLOW, COUNT, EXAMINE, EXHIBIT, READY TRACE and RESET TRACE.

35. Explain call by context by comparing it to other calls.

Ans: The parameters passed in a call by context are protected from modification by the called program. In a normal call they are able to be modified.

36. What is the difference between comp and comp-3 usage? Explain other COBOL usages.

Comp is a binary usage, while comp-3 indicates packed decimal. The other common usages are binary and display. Display is the default. 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.' 37. I understand the possible causes for S0C1 & S0C4 abends, but what are they really?

Ans: A S0C1 occurs if the CPU attempts to execute binary code that isn't a valid machine instruction; e.g. if you attempt to execute data. A S0C4 is a memory protection violation. This occurs if a program attempts to access storage beyond the areas assigned to it.

38. What happens when we move a comp-3 field to an edited ( say z(9).zz-)

Ans: The editing characters are to be used with data items with usage clause as display, which is the default. When you try displaying a data item with usage as computational it does not give the desired display format because the data item is stored as packed decimal. So if u want this particular data item to be edited u have to move it into a data item whose usage is display and then have that particular data item edited in the format desired.

39. What are the causes for S0C1, S0C4, S0C5, S0C7, S0CB abends

Ans: S0C1 - May be due to 1.Missing or misspelled DD name 2.Read/Write to unopened dataset 3.Read to dataset opened output 4.Write to dataset opened input 5.Called subprogram not found. S0C4 may be due to 1.Missing Select statement(during compile) 2.Bad Subscript/index 3.Protection Exception 4.Missing parameters on called subprogram 5.Read/Write to unopened file 6.Move data from/to unopened file.

S0C5 May be due to 1.Bad Subscript/index 2.Close an unopen dataset 3.Bad exit from a perform 4.Access to I/O area(FD) before read.

S0C7 may be due to 1.Numeric operation on non-numeric data 2.Un-initialize working-storage 3.Coding past the maximum allowed sub script. S0CB may be due to 1.Division by Zero

40. What will happen if you code GO BACK instead of STOP RUN in a stand-alone COBOL program i.e. a program which is not calling any other program.

Ans: Both give the same results when a program is not calling any other program.

41. What is the difference between an External and a Global Variable 's?

Ans: Global variables are accessible only to the batch program whereas external variables can be referenced from any batch program residing in the same system library.

42. WHAT IS REPORT-ITEM?

Ans: A REPORT-item is a field to be printed that contains EDIT SYMBOLS

43. You are writing report program with 4 levels of totals:city,state,region and country. The codes being used can be the same over the different levels, meaning a city code of 01 can be in any number of states, and the same applies to state and region code show. Do you do your checking for breaks and how do you do add to each level?

Ans: Always compare on the highest-level first, because if you have a break at a highest level, each level beneath it must also break. Add to the lowest level for each rec but add to the higher level only on break.

44. What is PSB & ACB?

Ans: PSB : Program specification block. Inform about how a specific program is to be access one or more IMS DB. It consists of PCB(Prg Communication Block). Information to which segment in DB can be accessed, what the program is allowed to do with those segment and how the DB is to be accessed. ACB : Access Control Blocks are generated by IMS as an expansion of information contained in the PSB in order to speed up the access to the applicable DBD's.

45. What's a LDS(Linear Data Set) and what's it used for ?

Ans: LDS is a VSAM dataset in name only. It has unstructured 4k (4096 bytes) fixed size CIs which do not contain control fields and therefore from VSAM's standpoint they do not contain any logical records. There is no freespace, and no access from Cobol. Can be accessed by DB2 and IMS fast path datasets. LDS is essentially a table of data maintained on disk. The 'table entries' must be created via a user program and can only be logically accessed via a user program. When passed, the entire LDS must be mapped into storage, then data is accessed via base and displacement type processing.

46. What is the Importance of GLOBAL clause According to new standards of COBOL

Ans: When any data name, file-name , Record-name, condition name or Index defined in an Including Program can be referenced by a directly or indirectly in an included program, Provided the said name has been declared to be a global name by GLOBAL Format of Global Clause is01 data-1 PIC 9(5) IS GLOBAL.

47. What is the Purpose of POINTER Phrase in STRING command

Ans: The Purpose of POINTER phrase is to specify the leftmost position within receiving field where the first transferred character will be stored

48.How do we get currentdate from system with century?

Ans: By using Intrinsic function, FUNCTION CURRENT-DATE

49.what is the difference between search and search all in the table handling?

Ans: Search is a linear search and search all is a binary search.

50.What is the maximum length of a field you can define using COMP-3?

Ans: 10 Bytes (S9(18) COMP-3).

FAQs Home||COBOL FAQs


A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/faqs/cobol-faq-part2.asp


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review