Mainframe Forum: A comprehensive repository for programming tutorials and technology news. Got a minute? Click upon those blue words to start learning in Cobol, DB2, CICS, JCL, CA7, APIs, DevOps, Agile, JAVA, SORT, Excel macro, python, and mainframe tools.
Welcome back to today's session on "COBOL Interview Questions". In this, interview question you'll go through different MF COBOL Interview questions and answers that cover different topics from COBOL. Let's get started with the best COBOL interview questions.
What is the initialize verb in COBOL and what is the difference between initialize and MOVE spaces in COBOL?
Initialize verb in COBOL is used to initialize the variables with the default value (i.e. SPACE or ZEROES). An INITIALIZE statement is functionally equivalent to one or more MOVE statements.
Generally, the COBOL INITIALIZE statement is used to initialize all the group data items without any hassle. However, it is unproductive to initialize an entire group unless you require all the items in the group to be initialized.
Alphabetic, Alphanumeric fields & alphanumeric edited variables are set to SPACES.
Numeric, Numeric edited items set to ZERO.
FILLER, OCCURS DEPENDING ON items left intact.
What is the difference between levels 66, 77, and 88 and what are they used for?
Well, Levels 66, 77, and 88 are functionally different and are used for different purposes.
Level 66 is a RENAME Clause and is used for rename items.
Level 77 is an elementary level item. It cannot have group items.
Level 88 is used to specify the condition name.
What is the difference between index and subscript in COBOL?
The subscript and index in COBOL are used to access items from the COBOL array/table. The subscript in COBOL refers to the array occurrence. However, an index in COBOL is the displacement of an item from the beginning of the array. An index in COBOL can only be changed by using COBOL PERFORM statement, COBOL SEARCH, and SET statement in COBOL.
You must always use an index for a table to use COBOL SEARCH or COBOL SEARCH ALL statements.
What is the difference between SEARCH and SEARCH ALL in COBOL?
The COBOL SEARCH and COBOL SEARCH ALL are used to search data within the table/array. COBOL SEARCH is a serial search. However, COBOL SEARCH ALL is a binary search and it is faster and more efficient as compared to SEARCH. The data in table/array should be sorted either in ASCENDING/DESCENDING before using COBOL SEARCH ALL.
What should be the sorting order for COBOL SEARCH ALL?
The data in the COBOL array/table should be sorted in a specific sequence i.e. either ASCENDING or DESCENDING. The default data sorting order is ASCENDING. If you need to search the data in descending order, you must use DESCENDING KEY Clause while declaring the array.
What is the basic difference between performing a SECTION and a PARAGRAPH in COBOL?
The COBOL PERFORM statement is used to execute a business logic defined in the paragraph or section. Performing a SECTION means executing a group of paragraphs within the section. However, performing a PARAGRAPH means executing a particular paragraph logic.
What is the COBOL EVALUATE statement and why it is recommended over the COBOL IF/ELSE statement?
The COBOL Evaluate statement is like an excel case statement and can be used instead of nested Ifs statements. The main difference between EVALUATE in COBOL and case is that no 'break' is required for EVALUATE i.e. control comes out of the EVALUATE as soon as criteria are satisfied.
You can use the EVALUATE statement instead of a series of nested IF statements to test several conditions and specify a different action for each. It is always recommended to use COBOL Evaluate instead of nested Ifs.
What is the difference between COBOL CONTINUE and NEXT COBOL SENTENCE Statement?
In general, both the COBOL CONTINUE statement and NEXT SENTENCE in COBOL are used to transfer control to the next executable statement. But, there is a difference in the way control is transferred. The NEXT SENTENCE transfers control to the next executable statement after a period ".", but the CONTINUE statement transfers control after the explicit scope terminator such as end-if, end-evaluate, etc.
Is it possible to REDEFINE an X(50) field with a field of X(100)?
Yes, it is possible. COBOL REDEFINE statement is used to define the same field in two or more ways. It means, that definition and the redefinition of both fields refer same storage.
What is the difference between COMP & COMP-3 and how is sign stored in COMP-3 fields?
Both COMP and COMP-3 in COBOL are used to define the storage format of numerical fields. COMP in COBOL represents the binary format while COMP-3 in COBOL represents the packed decimal format. In COMP-3 the sign is stored in the last nibble.
COBOL Interview Questions and Answers!
Conclusion.
Finally, this marks an end to the COBOL Interview Questions and answers. These interview questions are designed for both experienced and fresher. With the help of these COBOL interview Questions, you can easily clear your interview questions. Do check out COBOL LEVEL 88 Condition.
►Subscribe to Topictrick & Don't forget to press THE BELL ICON to never miss any updates. Also, Please visit mention the link below to stay connected with Topictrick and the Mainframe forum on -
Enable GingerCannot connect to Ginger Check your internet connection or reload the browserDisable in this text fieldRephraseRephrase current sentenceEdit in Ginger×
Enable GingerCannot connect to Ginger Check your internet connection or reload the browserDisable in this text fieldRephraseRephrase current sentenceEdit in Ginger×Enable GingerCannot connect to Ginger Check your internet connection or reload the browserDisable in this text fieldRephraseRephrase current sentenceEdit in Ginger×
COBOL CALL Statement is an important statement. It's used to transfer control from the main program to a sub-program or subroutine. CALL statement in COBOL has three different variants i.e. CALL BY REFERENCE, CALL BY VALUE, CALL BY CONTENT. COBOL CALL statement is divided into two categories i.e. static calls vs dynamic calls in COBOL.
Welcome back to today's session on "CALL Statement in COBOL". In this session, you'll learn the basics of the "COBOL CALL Statement" along with an overview of the COBOL calling program and called program. You'll deep dive into different variants of COBOL CALL statements along with COBOL CALL using statement syntax and CALL statements in COBOL examples.
Let's get started with today's agenda.
Agenda.
Introduction to COBOL main program, subroutine, or subprograms.
COBOL CALL Statement overview.
COBOL CALL Statement Syntax.
CALL BY REFERENCE in COBOL.
CALL BY CONTENT in COBOL.
CALL BY VALUE in COBOL.
COBOL CALL Statement Types.
Dynamic VS Static CALLs in COBOL.
COBOL CALL Statement Control Flow.
Conclusion.
Introduction.
Large-scale enterprise applications are generally a combination of many systems and sub-systems. These systems and subsystems are hosted on different computing platforms, such as IBM Mainframe or windows, etc.
A legacy application, which is hosted on an IBM mainframe is a combination of many online and batch programs. These programs are categorized into a main program, a subprogram, and copybooks based on the nature of the functionality and business logic.
Now, the first program in the run unit is considered the main program, and all other programs in the run unit are termed as subprograms/subroutines. The main program is also known as the "calling program", and the subprogram is known as the "called program".
The COBOL CALL statement is used to transfer control from the main program to the subprogram/subroutine. The main program (i.e. COBOL, JAVA, CICS, etc.) includes the CALL statement is referred to as the calling program. The program named in the CALL statement that is linked and executed within the main program (i.e. calling program) is referred to as the called program (i.e. subprogram or subroutine).
A called program (i.e. subprogram), should have a LINKAGE SECTION. The variable which will be used to transfer data from the main program should be mapped properly with the variable defined in the linkage section. Refer to the following CALL statement example for more details.
COBOL CALL Statement Example:
The following example showcases how the main program calls a subprogram.
CALL “EMPTAX01” USING EMP-SAL, EMP-TAX.
In the following example, PGMDSP01 is the main COBOL program. It has the CALL statement that calls EMPTAX01 tax subroutine to calculate monthly tax.
COBOL CALL Statement Example.
Let's deep dive into a COBOL CALL Statement Syntax.
COBOL CALL Statement Syntax.
The COBOL Call syntax is reasonably simple and easy to understand. You only need to remember a few different parameters. The COBOL CALL statement begins with the CALL keyword followed by the program name. If you want to pass value from the calling program to the called program then you have to use the keyword USING followed by variable names.
CALL "SUB PROGRAM NAME" USING identifier-1, identifier-2.
Now, let's go through the complex variant of the COBOL CALL statement. In this, variant you have more control over the data which is passed to the sub-program (i.e. subroutine). Specifically, the following three parameters are very important from a programming standpoint.
CALL BY REFERENCE in COBOL.
CALL BY CONTENT in COBOL.
CALL BY VALUE in COBOL.
COBOL CALL Statement Syntax
If you do not specify any of the three parameters then the system will assume CALL BY REFERENCE as the default value. The next set of parameters is on exception not on exception and returning. So these three parameters are generally used to execute a set of statements that you want to execute in case if there is any specific condition that happens.
CALL BY REFERENCE in COBOL.
In CALL BY REFERENCE, the subprogram refers to and processes the data items in the storage of the calling program instead of a copy of the data. If the subprogram updates any literal value then it will be reflected in the main program.
CALL BY CONTENT in COBOL.
In CALL BY CONTENT, the calling program passes only the copy of the content to the subprogram. If the subprogram updates any literal value then it will not be reflected in the main program.
CALL BY VALUE in COBOL.
In CALL BY CONTENT, the calling program passes only the copy of the content to the subprogram. If the subprogram updates any literal value then it will not be reflected in the main program. CALL BY Content is generally used in calling JAVA, C++, or any other programs.
COBOL CALL Statement Types.
The CALL statement in COBOL is broadly divided into the following two categories.
STATIC CALL in COBOL.
DYNAMIC CALL in COBOL.
Let's discuss each category one by one in detail.
COBOL STATIC CALLS.
A static CALL in COBOL transfers controls from a calling program to a subprogram that is compiled with the calling program. The subprogram is link edited into the main module. It means, that there is only one load module that includes both the main program and subprogram. The program should be compiled with NODYNAM and NODLL options.
From a performance perspective, COBOL Static Calls are better in case you have a high number of calls because the load module resides in the main memory.
COBOL DYNAMIC CALLS.
A dynamic program CALL in COBOL transfers controls from a calling program to a called program that has been compiled into a separate program. That is, both programs (i.e. main program and subprogram) are compiled into separate load modules. The called program is loaded into the main memory and executed only when it is called.
COBOL Dynamic Call happens when a program is compiled with the DYNAM and NODLL compiler options. Always, remember the called module will be in the last used state.
From a performance perspective, COBOL Dynamic Calls can be slow and deteriorate system performance because the system has to retrieve and link the two programs together during runtime.
What is the difference between Static call and Dynamic Call in COBOL?
Well, there is little or no difference in the coding between a dynamic program call and a static program call. But, the procedure to produce the executable program load module is different and it is due to different compiler options. You must follow the correct compiler option and correct compilation sequence.
COBOL CALL Example or COBOL CALL Control Statement Flow.
Now, let's focus on a CALL statement example in COBOL, to understand the underlying concept and how exactly control transfers between the main program and subprogram. In the following example, you have two programs first program is a calling program or it's a main program and the second one is a calling program or a subprogram. In the main program, you have a COBOL call statement to invoke the subprogram.
COBOL CALL Statement
When the call statement is executed in the main program the control will be transferred to the subprogram. The control will be transferred back to the main program after the execution of subprogram logic. The above flow diagram illustrates the control flow.
CALL Statement in COBOL - Youtube video.
Conclusion.
Finally, this marks an end to the COBOL CALL statement session. In this session, you learned what is COBOL CALL Statement and why it is an important statement. You also learned the different variants of COBOL CALL Statements such as CALL BY REFERENCE, CALL BY VALUE, and CALL BY CONTENT. Lastly, what is the difference between static calls vs dynamic calls in COBOL? Do check out COBOL LEVEL 88 Condition.
►Subscribe to Topictrick & Don't forget to press THE BELL ICON to never miss any updates. Also, Please visit mention the link below to stay connected with Topictrick and the Mainframe forum on -
Enable GingerCannot connect to Ginger Check your internet connection or reload the browserDisable in this text fieldRephraseRephrase current sentenceEdit in Ginger×Enable GingerCannot connect to Ginger Check your internet connection or reload the browserDisable in this text fieldRephraseRephrase current sentenceEdit in Ginger×
Welcome back to today's session on NEXT SENTENCE in COBOL or CONTINUE in COBOL. In this session, you'll learn the basics of COBOL NEXT Sentence and COBOL CONTINUE Statement. You'll also learn how to use NEXT Sentence, COBOL Continue with examples. Let's get started with the NEXT Sentence or COBOL Continue Statement.
Agenda.
Introduction.
What is the Next Sentence in COBOL?
Next Sentence in COBOL Syntax.
Next Sentence in COBOL Example.
What is the Continue in COBOL?
Continue in COBOL Syntax.
Continue in COBOL Example.
COBOL Next Sentence VS COBOL CONTINUE Statement.
Summary.
Introduction.
You can code any structured program using three basic structures: the sequence, selection, and iteration structures. Each structure has just one entry point and one exit point, and a program composed of these structures is a proper program.
Now that you know how to code conditions, you can learn more about the selection and iteration structures that use those conditions. Since the If statement implements the selection structure and the Perform Until implements the iteration structure, you already know how to code the simple forms of these structures.
In the topics that follow, you’ll see some other coding options such as NEXT SENTENCE in COBOL, CONTINUE in COBOL. So, without wasting time let's start with the tutorial of COBOL NEXT SENTENCE and COBOL CONTINUE verbs.
What is the NEXT SENTENCE in COBOL?
The NEXT SENTENCE in COBOL simply transfers control to an implicit CONTINUE statement immediately following the next separator period. In case the NEXT SENTENCE in COBOL is specified with the END-IF statement, then control does not pass to the statement following the END-IF. However, control passes to the statement after the closest following period.
NEXT SENTENCE in COBOL syntax.
IF condition-1 THEN
{statement-1 ... | NEXT SENTENCE}
.
COBOL NEXT SENTENCE example.
IF SALES-AMOUNT = ZERO
NEXT SENTENCE
ELSE
COMPUTE SALES-TAX ROUNDED = SALES-AMOUNT * .0785.
NEXT SENTENCE in COBOL.
What is the CONTINUE in COBOL?
The CONTINUE in COBOL statement allows you to specify a no-operation statement. COBOL CONTINUE statement indicates that no executable instruction is present and control will be transfer control to the next executable instruction after an explicit scope terminator (i.e. END-IF etc.).
CONTINUE in COBOL syntax.
IF condition-1 THEN
{statement-1 ... | CONTINUE}
[ELSE {statement-2 ... | CONTINUE}]
[END-IF]
CONTINUE in COBOL example.
IF SALES-AMOUNT = ZERO
CONTINUE
ELSE
COMPUTE SALES-TAX ROUNDED = SALES-AMOUNT * .0785
END-IF.
CONTINUE in COBOL.
CONTINUE in COBOL
Note: In laymen, term both NEXT SENTENCE in COBOL and CONTINUE in COBOL simply transfer control to the next executable statement.
Important Points: regarding the usage of Next Sentence in COBOL and CONTINUE in COBOL.
Don’t use the NEXT SENTENCE if you are using END-IF as the delimiter (and you should). The Use of NEXT SENTENCE causes execution to continue with the next closest period, which is probably the end of the paragraph.
NEXT SENTENCE is prominently used in COBOL 75. However, CONTINUE is used predominately in COBOL 85.
The NEXT SENTENCE / CONTINUE statement can be used anywhere a conditional statement or an imperative-statement can be used.
COBOL Next Sentence VS COBOL Continue Statement.
This COBOL Tutorial is associated with a youtube video, that clearly explain the COBOL Next Sentence and COBOL Continue Statement with example. Do watch this video for details understanding.
Summary.
You also can code the words NEXT SENTENCE in the If or Else portion of an If statement, but we don’t recommend that. When executed, NEXT SENTENCE causes the program to continue with the statement that starts after the period that ends the If statement, which is equivalent to a Go-To statement that provides a second exit to the structure.
►Subscribe to Topictrick & Don't forget to press THE BELL ICON to never miss any updates. Also, Please visit mention the link below to stay connected with Topictrick and the Mainframe forum on -
Welcome back to today's session on "COBOL START Statement". In this session, you'll learn the basics of START statements in COBOL, followed by COBOL START statement syntax and COBOL Start statement example for better understanding. You'll also learn how to use the COBOL start key is greater than in your COBOL program. Let's get started with an introduction to the COBOL START statement.
COBOL START Statement - Agenda.
Introduction.
What is a COBOL START Statement.
COBOL START Syntax.
How COBOL START Statement works.
COBOL START Example.
Conclusion.
Introduction.
File handling is one of the important aspects of any programming language. In COBOL you have many statements that can be used to read, write or update data into a sequential file, VSAM file, or DB2 database. COBOL START statement is one such statement that provides more control over the process to read data from the file.
What is a COBOL START Statement?
In laymen's terms, the START statement in COBOL is used to position the pointer within an indexed or relative file to retrieve a record from the file. You must open the associated indexed or relative file in an appropriate mode (i.e. Input or I-O mode) before you issue the COBOL START command.
COBOL START KEY Tutorial
The COBOL START statement enables the programmer to position the relative file at some specified point so that subsequent sequential operations on the file can start from this point instead of the beginning.
The KEY IS phrase in COBOL START indicates how the file is to be positioned.
The data-name in this phrase must be the data-name in the RELATIVE KEY phrase of the SELECT . . . ASSIGN . . . clause.
When the EQUAL TO or NOT LESS THAN condition is specified, the file is positioned at the point indicated by the relative key-data item.
When the GREATER THAN condition is specified, the file is positioned at the next relative position of the position indicated by the RELATIVE KEY data item.
COBOL START Statement Syntax.
The COBOL START statement is pretty simple and easy to understand. But, you have to be careful while using the COBOL START statement in your programs. You must clearly understand the requirement before implementing the COBOL START VERB. Let's focus on the following START statement syntax.
START STATEMENT in COBOL.
FILE Name: You must specify the file name after the START keyword. The file details must be defined correctly in your COBOL program.
KEY Phrase: When the KEY phrase is specified, the file position indicator is positioned at the logical record in the file whose key field satisfies the comparison. If the KEY phrase is not defined, KEY IS EQUAL (to the prime record key) is implied.
INVALID KEY: The invalid key function will be trigger if there is no record that satisfies comparison criteria.
END-START phrase: is the explicit scope terminator for the COBOL START statement.
How COBOL START Statement works?
In nutshell, the START statement in COBOL is used to set a pointer before you issue a COBOL READ command to read the record from the file. As a thumb rule, before you issue a Start statement, you must place a key value in the RECORD KEY field. Then, the Key clause of the Start statement establishes the first record to be processed. As you can see, that record can have a value that’s either equal to, greater than (i.e. COBOL start key is greater), or equal to the value you specify.
COBOL START Example.
In the following example, 1000 is moved to item-no. The item-no is used as a primary key to read the data from the file.
Finally, this marks an end to the COBOL START Statement. In this session, you learn the basics of the COBOL START statement. You also learn different parameters of COBOL START statement syntax followed by the COBOL Start statement example for better understanding. You also learned how to use the COBOL start key is greater than in your COBOL program. Do check out COBOL LEVEL 88 Condition.
►Subscribe to Topictrick & Don't forget to press THE BELL ICON to never miss any updates. Also, Please visit mention the link below to stay connected with Topictrick and the Mainframe forum on -
Enable GingerCannot connect to Ginger Check your internet connection or reload the browserDisable in this text fieldRephraseRephrase current sentenceEdit in Ginger×Enable GingerCannot connect to Ginger Check your internet connection or reload the browserDisable in this text fieldRephraseRephrase current sentenceEdit in Ginger×Enable GingerCannot connect to Ginger Check your internet connection or reload the browserDisable in this text fieldRephraseRephrase current sentenceEdit in Ginger×