No, you can't change the value of an IMPORTING parameter (unless it happens to be a TYPE REF TO, in which case you can change the value of the referenced object/data). You can only change values of CHANGING parameters. However, there is a dirty trick you might be able to use here. If you want to access the variable foo in the calling program Z_BAR, then you can do this:
FIELD-SYMBOLS <foo>.
ASSIGN ('(Z_BAR)FOO-DATA') TO <foo>.
IF sy-subrc = 0.
<foo> = newValue.
ENDIF.
(By the way, Z_BAR does not even need to be the direct caller of the function module. It just needs to be somewhere in the call stack.)
Why am I calling this a "dirty" trick?
- It creates "spooky effects at a distance". Anyone examining
Z_BAR would never expect a function module to change foo when it's not in its parameter list.
- The variable name gets resolved at runtime, so there is no syntax check when you misspell it.
- It breaks when the variable in the calling program gets renamed, and you won't know until it fails at runtime.
- You need to know the name of the calling program in advance. When the function module gets called from another program, then it's not going to work anymore.
So I would only recommend this as a last resort measure.