COBOL Sequence Programming Construction

COBOL Programming Construction COBOL Accept Statement

Advertisements


Sequence programming construction involves making the program execution in sequence.

Single line executable statements are the part of Sequence programming construction.

The best sequence execution commands in COBOL are


  1. ACCEPT
  2. CALL
  3. COMPUTE
  4. DISPLAY
  5. EXIT PROGRAM
  6. GO BACK
  7. INITIALIZE
  8. INSPECT
  9. EXAMINE
  10. MOVE
  11. STRING
  12. UNSTRING
  13. All arithmetic statements like ADD, SUBTRACT, MULTIPLY, DIVIDE etc,.

ACCEPT:

ACCEPT statement accepts the data from the outside of the program which may be from input device or system defined data items.

ACCEPT transfers the accepted data to the specified identifier along with ACCEPT.

ACCEPT statement used to receive the data during the program execution.

The ACCEPT statement explained in detail here


CALL:

When a particular task needs to be performed in more than one program, it is better to write a subprogram.

The need of CALL statement is to call the subprogram to perform the task.

CALL statement transfers the control from one object program to another object to complete a particular task.

The CALL statement explained in detail here


COMPUTE:

COMPUTE used to calculate the result of arithmetic expressions and stores the same in another variable/data-item.

COMPUTE can use the below arithmetic expressions.

ADD			-		+
SUBTRACT		-		-
MULTIPLY		-		*
DIVIDE			-		/
EXPONENT		-		**

The COMPUTE statement explained in detail here


DISPLAY:

DISPLAY used to transfer the data to the output device/screen.

Output device can be decided based on the SYSOUT in JCL if it is a batch program.

Syntax:
DISPLAY identifier-1 [WITH NO ADVANCING].

WITH NO ADVANCING is optional in DISPLAY.

The DISPLAY statement explained in detail here


STOP RUN:

STOP RUN is the last executable statement in the program which will returns the control back to OS.

STOP RUN always coded in the main program.

If STOP RUN coded in the sub program, the control will return to OS instead of returning to main program. In this case, the remaining task coded in main program will be incomplete.

STOP RUN closes all opened files in the program.

The STOP RUN statement explained in detail here


EXIT PROGRAM:

EXIT PROGRAM specifies that the program came to end.

EXIT PROGRAM also responsible for returning the control to the calling program.

EXIT PROGRAM always coded in subprogram.

EXIT PROGRAM passed control to the statement which is immediately next to the active CALL statement in the main program.

The EXIT PROGRAM statement explained in detail here


GOBACK:

GOBACK gives the control back from where it received it.

GOBACK statement is the logical end of the called program or invoked method.

GOBACK also responsible for returning the control to the calling program.

GOBACK can be coded in both main program and sub program.

The GO BACK statement explained in detail here


INITIALIZE:

INITIALIZE sets the data items to the predefined values based on the data types.

INITIALIZE can initialize single data item or a group of data items.

INITIALIZE set the predefined values based on data types like below.

The INITIALIZE statement explained in detail here


INSPECT:

INSPECT statement is used to do the following tasks by using its four formats.

1. INSPECT TALLYING: Used to count the characters of a particular string.

2. INSPECT REPLACING: Replaces single/group of characters by using single/group of characters in a particular string.

3. INSPECT TALLYING REPLACING: Above two operations in one shot.

4. INSPECT CONVERTING: Converts the each character in set of characters to corresponding characters in another set of characters.

The INSPECT statement explained in detail here


EXAMINE:

EXAMINE and INSPECT are used for same purpose.

Syntax is almost same for both EXAMINE and INSPECT.

INSPECT is using now a days, which replaced the EXAMINE.

The EXAMINE statement is an HP extension to the ANSI COBOL standard.

The EXAMINE statement explained in detail here


MOVE Statement:

MOVE statement is used to assign a value to a variable from another variable or literal.

MOVE statement actually transfers the data from one memory location to one or more memory location.

In MOVE statement, sending data item should be only one.

In MOVE statement, receiving data item can be more than one.

The MOVE statement explained in detail here


STRING:

The STRING statement concatenates the partial or complete contents of two or more data items or literals into one single data item.

STRING statement does the task of several MOVE statements job.

STRING used to concatenate one or more data items to a single data item.

The STRING statement explained in detail here


UNSTRING:

The UNSTRING statement separates the single data item into two or more data items.

UNSTRING statement does the task of several MOVE statements job.

UNSTRING used to separate single string to multiple based on the delimiter provided in the UNSTRING.

The UNSTRING statement explained in detail here


COBOL Programming Construction COBOL Accept Statement

Advertisements