1

Is it possible to call multiple instances of a subroutine that has both USING and CHANGING parameters? Like so:

PERFORM FM_CHECK_INPUT:
   USING INPUT_A  FIELD_B
CHANGING MESSAGE_A,
   USING INPUT_B  FIELD_B
CHANGING MESSAGE_B,
...
   USING INPUT_E  FIELD_E
CHANGING MESSAGE_E.

Or do I have to call each instance separately?

PERFORM FM_CHECK_INPUT USING INPUT_A
                             FIELD_A
                    CHANGING MESSAGE_A.
PERFORM FM_CHECK_INPUT USING INPUT_B
                             FIELD_B
                    CHANGING MESSAGE_B.
...
PERFORM FM_CHECK_INPUT USING INPUT_E
                             FIELD_E
                    CHANGING MESSAGE_E.

I've used compound statements for subroutines before but only when the subroutine had only USING or CHANGING statements, and I'm not sure if I can do the same when both USING and CHANGING parameters are used.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Noir Antares
  • 242
  • 1
  • 10

1 Answers1

2

Generally speaking, the chained statements, i.e. using : and ,, are used for repeating the words at the left of :, and work with any sequence of words before and after it, and is not specific to any statement (it can work for DATA, PERFORM, CALL, TRANSLATE, and all other statements).

For instance the Following statement :

AAA BBB : CCC DDD, EEE, FFF GGG.

is equivalent to these 3 statements :

AAA BBB CCC DDD.
AAA BBB EEE.
AAA BBB FFF GGG.

(of course, if you compile this dummy example, the compilation fails because AAA is unknown, so use real statements)

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48