Monday, February 20, 2012

COBOL FAQS-5

Q.    Can the number of operands in the USING phrase in called program be different than the number of operands in the USING statement of calling programs?
A         The number of operands in the calling program USING phrase and the called program USING phrase must be identical.

Q.    How do file operands of the calling program USING phrase align with the operands of the called program USING phrase?
A         The correspondence is by position - not by name.

Q.    Can a called program contain CALL statements?
A:        Yes. However, a called program may not CALL the calling program directly or indirectly.

Q.    What is a COPY statement?
A         The COPY statement copies existing text from a copy library into a COBOL program. For example :
COPY text - name.

Q.    What is a copy library?
A.        A copy library is basically a COBOL source library containing members that can be, copied into COBOL source programs.



Q.    What type of text can be copied using the COPY statement?
A.        The type of text that can be copied into a COBOL program includes all types of components of a COBOL program, including file definitions, working storage and procedure division code.

Q.    What is the REPLACING option of a COPY statement?
A         The REPLACING option of a COPY statement contains two operands and performs the COPY, replacing all occurrences of the first operand within the copied library member text by the second operand.

Q.    Can the text of a copy library member contain nested COPY statements?
A         In COBOL II a copy library member may contain nested COPY statements. This is not the case in VS-COBOL.

Q.    Can a copy member with nested COPY statements contain the REPLACING option?
A         No, a nested COPY statement cannot contain the REPLACING option.

Q.    Can a COPY statement with the REPLACING option contain nested COPY statements?
A         No, a COPY statement with the REPLACING option cannot contain nested COPY statements.

Q.    What are some advantages to using COPY statements?
A         An installation can develop standard file descriptions and mandate their use for standardization and ease of testing and maintenance. Also, standard working storage descriptions, record descriptions and procedure division code can be developed, enhancing development and maintenance efforts.

Q.    What is the BY CONTENT phrase in COBOL II?
A         The BY CONTENT phrase permits constants to be passed to a called program by using the CALL statement.

Q.    What is the BY CONTENT LENGTH phrase in COBOL II?
A:        The BY CONTENT LENGTH phrase permits the length of a data item to be passed to a called program by using the CALL statement.

Q.    What is the PICTURE clause?
A         The PICTURE clause defines an elementary items basic characteristics and editing requirements.

Q.    What would be the result of moving 030193 to a PICTURE clause of PICTURE 99/99/99?
A         The result would be 03/01/93 - but only if the month, day and year were moved separately.

Q.    How are numbers stored in the computer?
A:        Each digit is stored in a single byte; the first 4 bits contain the “zone”. The last 4 bits contain the digit. For numbers the zone indicates positive numbers (a C or an F) and negative numbers (D).

Q.    What is EBCDIC?
A:        EBCDIC is an acronym for Extended Binary Coded Decimal Interchange Code.

Q.    In EBCDIC, how would the number 1234 be stored?
A         The number 1234 would be stored as : Fl F2 F3 F4.

Q.    What is packed decimal?
A.        It is a method of storing numbers in less space. The zone is eliminated from each of the digits except for the last digit which contains sign for number. Packed decimals are always stored in an even number of bytes and the last byte is always the sign.  The number of bytes used is determined by adding 1 to the total bytes requested and dividing by 2. The answer is always an even number.

Q.    How would the number +1234 be stored if a PIC clause of PICTURE S9(4) COMP-3 were used?
A         The answer will use 3 bytes (4 + 1 = 5 / 2 = 2.5 or 3), so a leading 0 will pad the answer : 01234F.

Q.    What are binary numbers?
A         Binary numbers are strings of 0s and 1s which are stored in half word, full word, or double word, depending on the size of the number.
·                     Up to 4 digits are stored in 2 bytes or a half word.
·                     5-9 digits are stored in 4 bytes or a word.
·                     10-18 digits are stored in 8bytes or a double word.

Q.    What is a common problem when doing a table lookup?
A         The maximum occurrences of the table are exceeded as a result of exiting perform based on testing the subscript for "equal to" the maximum number of occurrences rather than "greater than" the number of occurrences. By manipulating subscript, the subscript can become greater than the maximum number of occurrences, permitting the perform to continue beyond bounds of the table.

Q.    What will be the result of executing a VS-COBOL II program when a subscript exceeds the table limits?
A         The table data overwrites program code and will continue to do so until there is an abend. The abend message will reference gibberish code rather than a subscript out of range.

Q.    What will be the result of executing a VS-COBOL II program that was compiled with the SSRANGE option, when a subscript exceeds the table limits?
A         The program will terminate.

Q.    What is a common problem associated with reading a datafile in a test environment?
A         A read is executed on a file that has not been opened by the program.

Q.    What problem could occur when a file is read with an incorrect file definition?
A         A data exception could occur causing the program to terminate.

Q.    In a production environment, what should be programmed when an abnormal condition is encountered and it is undesirable to continue processing?
A         The program should go to a programmed abnormal exit and pass a condition code to the job control language via. an installation standard abend procedure. The job control language should in turn test the condition code and force the job to terminate with an abnormal condition code.

No comments:

Post a Comment