Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
IMPORTING, EXPORTING and CHANGING Keywords in ABAP
IMPORTING transfers a value from the caller to the called method by passing an actual parameter.
EXPORTING is just opposite to what IMPORTING does. It passes value from the method to caller.
CHANGING is transferring the value from caller to method by a variable which is processed or changed and the changed value is passed back to the caller. Thus it combines both IMPORTING and EXPORTING function.
CHANGING Parameter Syntax
There are a couple of ways in which CHANGING can be used ?
CHANGING myvar CHANGING VALUE(myvar)
By using CHANGING myvar, the value of a variable is changed and passed back to the caller or main program.
Using CHANGING VALUE(myvar) is a kind of exception handling. In case there is an exception or error in subroutine, the value of a variable will be returned unchanged although it is possible that it has been changed in the subroutine.
Example
Here's a practical example demonstrating all three parameter types ?
REPORT z_parameter_demo.
DATA: lv_input TYPE i VALUE 10,
lv_output TYPE i,
lv_change TYPE i VALUE 5.
PERFORM process_data
IMPORTING lv_input
EXPORTING lv_output
CHANGING lv_change.
FORM process_data
USING p_input TYPE i
CHANGING p_output TYPE i
p_change TYPE i.
p_output = p_input * 2.
p_change = p_change + 10.
ENDFORM.
In this example, lv_input passes value to the form, lv_output receives value from the form, and lv_change both sends and receives modified value.
Conclusion
IMPORTING, EXPORTING, and CHANGING keywords provide flexible parameter passing mechanisms in ABAP, allowing methods to receive input, send output, and modify variables bidirectionally.
