Amal Antony
Amal Antony

Reputation: 6797

What is the significance of the CHANGING keyword when a method is called in ABAP?

I understand what IMPORTING and EXPORTING keywords do, but what is the significance of the CHANGING keyword?

Upvotes: 3

Views: 5939

Answers (2)

vlad-ardelean
vlad-ardelean

Reputation: 7622

Also, when declaring Subroutines with FORM and ENDFORM, the CHANGING keyword can be used either like CHANGING myvar or CHANGING VALUE(myvar).

CHANGING myvar makes it so that the value of myvar is changed as soon as it is changed in the subroutine.

In contrast, if CHANGING VALUE(myvar) is used, if the form does not return properly (if it throws an exception by example), the value of myvar will remain unchanged, in the calling code, even if it was changed in the subroutine that crashed.

Upvotes: 4

vwegert
vwegert

Reputation: 18483

IMPORTING passes an actual parameter as a formal parameter, thus transferring a value from the caller to the method. EXPORTING does the exact opposite, taking a value from the method and transferring it back to the caller. CHANGING combines these, transferring the value both from the caller to the method an back again, with any changes that happened in between.

Note that while IMPORTING and EXPORTING are reversed between declaration and call, CHANGING is not.

Upvotes: 6

Related Questions