MainframeMaster

COBOL Tutorial

COBOL RETURNING Phrase - Quick Reference

Progress0 of 0 lessons

Overview

The RETURNING phrase in COBOL is used in CALL and FUNCTION statements to specify the variable that will receive the value returned by a subprogram or intrinsic function. It is essential for modern modular and functional COBOL programming.

Purpose and Usage

  • Subprogram Calls - Receive a value from a called subprogram
  • Intrinsic Functions - Store the result of a function
  • Modular Programming - Enable reusable code with return values
  • Combined with USING - Pass arguments and receive a result

Syntax

cobol
1
2
3
4
5
6
7
8
9
10
11
* CALL statement with RETURNING CALL "SUBPROG" USING arg1 arg2 RETURNING result-var * FUNCTION statement with RETURNING COMPUTE result-var = FUNCTION MAX(a, b) * Example subprogram header PROCEDURE DIVISION USING arg1 arg2 RETURNING result-var * Example with both USING and RETURNING CALL "CALCULATE-TAX" USING income, rate RETURNING tax-amount

RETURNING is used to specify the receiving variable for a returned value from a subprogram or function.

Test Your Knowledge

1. What is the primary use of the RETURNING phrase in COBOL?

  • To return from a subprogram
  • To specify the receiving variable for a returned value
  • To end a program
  • To return a value from a function only

2. Which COBOL statement commonly uses the RETURNING phrase?

  • PERFORM
  • CALL
  • READ
  • WRITE

3. How is RETURNING used with intrinsic functions?

  • It is not used
  • It specifies the function to call
  • It specifies the variable to receive the function result
  • It ends the function call

4. Which of the following is a valid RETURNING usage?

  • CALL "SUBPROG" RETURNING result-var
  • COMPUTE x = FUNCTION MAX(a, b) RETURNING result-var
  • CALL "SUBPROG" USING arg1 RETURNING result-var
  • All of the above

5. Is RETURNING required in all CALL statements?

  • Yes
  • No
  • Only for intrinsic functions
  • Only for subprograms

Frequently Asked Questions