Thursday, 15 April 2021

COBOL interview questions | MF COBOL Interview Questions 2021 | [Best COBOL interview questions].

COBOL Interview Questions, Best COBOL Interview Questions

COBOL Interview Questions.


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 covers different topics from COBOL. Let's get started with 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 efficient as compare 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.

01 WS-FNAME       PIC X(50).
01 WS-EMP-NAME  REDEFINES WS-FNAME  PIC X(100).

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 - 

► Youtube
► Facebook 
► Reddit

Thank you for your support. 
Mainframe Forum™

Saturday, 10 April 2021

COBOL Interview Questions | 10 Incredible COBOL Interview Questions and Answers [COBOL Interview]

COBOL Interview Questions, COBOL Interview Questions and Answers

COBOL Interview Questions.


Welcome back to the "COBOL Interview Question" session. In this session, you'll go through COBOL interview questions and answers from different COBOL topics. These top 10 COBOL interview questions also include scenario-based questions. Let's get started with Introduction to COBOL. 


Introduction to COBOL. 

The term COBOL stands for COmmon Business Oriented Language. COBOL is one of the oldest and mature programming languages. COBOL is a robust, simple, and powerful programming language. COBOL has a proven track record of 60 years and COBOL still dominates enterprise computing. 

Now, let's get started with the top 10 COBOL Interview Questions and Answers.  

What is the difference between COBOL COPY and COBOL CALL Statements?

  • The COPY statement is used to bring into a program a source member consisting of a series of prewritten COBOL statements.
  • The CALL statement transfers control from one program to another. The main program containing the CALL statement that references or calls a program is referred to as the calling program.

What is the purpose of the PROGRAM-ID and in which division it is defined?

  • PROGRAM-ID parameter is defined in the IDENTIFICATION DIVISION.
  • It is used to specify the name of the COBOL program. It can consist of 1 to 30 characters.

How many divisions does a COBOL Program contain? Can you name each division?

A COBOL program has four divisions:
  • Identification Division.
  • Environment Division.
  • Data Division.
  • Procedure Division.

What is the difference between a level 77 item and a level 01 item with no subordinate levels?

Well, The two items are functionally the same. Both are elementary level items if the 01 level does not have any subordinate items (i.e. Group fields). If 01 is defined as a group field then it would be different from level 77.
  • 01 EMP-NAME PIC X(35).
  • 77 EMP-ADD PIC X(40).

When using Declarative, can you perform another paragraph with the declarative area?

Yes, you can have a common error paragraph within the declarative that is executed. However, you must not Perform any paragraph outside the declarative.

Which statement is coded to update the record in a sequential file? What has specified with the statement: the record description or the file name?

The COBOL REWRITE Statement is used to update the record. The record description is specified in the REWRITE statement, instead of the file name.

REWRITE in COBOL Example. 

REWRITE EMP-REC FROM WS-EMP-REC
END-REWRITE.

Is the At End clause valid when issuing a Random Read?

No. You cannot use the "At End Clause" because you are reading records directly via key. You'll never have an end-of-file condition in such a scenario. However, you should code Invalid Key Clause to handle "record not found" - File status 23.

COBOL REWRITE Example. 

READ EMP-REC INTO WS-EMP-REC
     INVALID KEY
             DISPLAY “EMP REC NOT FND"
             DISPLAY "FLE ST CDE:“ WS-STAT-CDE
END-READ.


If a file is defined as optional and it doesn’t exist, which file status is returned if the file is opened Input? What about Output?

The input file status code would be 05. An OPEN statement was successfully executed, but the referenced optional file was unavailable at the time the OPEN statement was executed. The output file status code would 00.

COBOL OPEN Statement Example: 

READ EMP-REC INTO WS-EMP-REC 
     INVALID KEY 
         DISPLAY 'EMP REC NOT FND'
END-READ.

In which mode must you open a file to update the record in the file?

If you want to update data in the file, then it should be opened in I-O mode (i.e. Input-Output Mode). Make sure you read the record from the file before updating the record in the file. 
 
COBOL OPEN Statement Example: 

 OPEN I-O EMPFILE.

How you record from the file and what must be done before you can read records from a file?

The record from the file is read by using the COBOL READ statement. You should open the input file in the desired mode by using the COBOL OPEN Statement before reading records from the file. 

COBOL OPEN Statement Example: 

 OPEN INPUT EMPFILE.

COBOL Interview Question - You tube.



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 - 

► Youtube
► Facebook 
► Reddit

Thank you for your support. 
Mainframe Forum™

Wednesday, 7 April 2021

COBOL CALL Statement CALL BY Reference, CALL BY Value, CALL BY Content [CALL statement in COBOL].

COBOL CALL Statement, Dynamic Call in COBOL

CALL Statement in COBOL.

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" and 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 statement 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 IBM mainframe is a combination of many online and batch programs. These programs are categorized into 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 as the main program, and all other programs in the run unit are termed as subprogram/subroutines. The main program is also known as the "calling program", and the subprogram is known as the "called program". 
Let's deep dive into COBOL CALL statement definition, syntax, and variants. 

COBOL CALL Statement. 

The COBOL CALL statement is used to transfer control from the main program to 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 main program should be mapped properly with the variable defined in linkage section. Refer to the following CALL statement example for more details. 

COBOL CALL Statement Example: 

The following example of showcase how main program call a subprogram. 

        CALL “EMPTAX01” USING EMP-SAL, EMP-TAX.

In the below example PGMDSP01 is the main COBOL program. It has the CALL statement that call 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 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, CALL Syntax 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 default value. The next set of parameter that 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 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 subprogram update 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 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 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. 

static CALL in COBOL transfers control 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 main-program and subprogram. The program should be compiled with NODYNAM and NODLL option.

From a performance perspective, COBOL Static Calls are better incase you have high number of calls because load module reside in the main memory. 

COBOL DYNAMIC CALLS.

dynamic program CALL in COBOL transfers control 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 a 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 transfer 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've a COBOL call statement to invoke the sub-program.


CALL Statement in COBOL, CALL statement

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 transfer 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, CALL BY CONTENT. Lastly, what is the difference between the 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 - 

► Youtube
► Facebook 
► Reddit

Thank you for your support. 
Mainframe Forum™