Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Can I assign value to import parameter in Function Module? How?

Former Member
0 Kudos
2,907

Hi Experts,

Function Module " Ztest "

import num = num

export res = res.

in the function module, I am checking the condition as following:

if num is initial.

num = 100.

endif.

but, Syntax error is occuring that

"NUM cant be changed".

I want to assign new value to num like 200.

How do I assign ?

Please help me out.

thanks in advance.

regards

Sekhar

1 ACCEPTED SOLUTION

Former Member
0 Kudos
288

Hi,

Function Module " Ztest "

import num = num

export res = res.

where is the Data declarations for num and res in your calling program?

Is num mandatory or optional?

Check for them firstly.

Reward points if useful.

Anita

9 REPLIES 9

Former Member
0 Kudos
289

Hi,

Function Module " Ztest "

import num = num

export res = res.

where is the Data declarations for num and res in your calling program?

Is num mandatory or optional?

Check for them firstly.

Reward points if useful.

Anita

0 Kudos
288

Hi Anita,

num is optional and type is i (but not constant)

in the FM,

if num is initial.

num = 100.

endif.

but it is showing syntax error

"num cant be changed".

thanks your reply

0 Kudos
288

Flag your IMPORT parameter NUM as PASS BY VALUE.

Regards Jack

0 Kudos
288

Thank you!

I got it.

Former Member
0 Kudos
288

Hi Chandra,

It's impossible to change the value of IMPORTING parameters. Either you have to change the type to CHANGING or use a local variable.

Regards,

John.

Former Member
0 Kudos
288

Hi,

Inside the Function Module you can't assign the value for a Import Parameter.

But You can assign the value for "export" or "changing" Parameters.

Using Import parameters you can give Input to the Function Module, and Retrieve the result in Export Parameter.

If you want to assign the value to the Import parameter means ,

Num = 200.

Then Call the FM like,

Function Module " Ztest "

import num = num

export res = res.

Thanks.

Former Member
0 Kudos
288

Hi,

You can assign a default value to import parameter

in Default value

regrds,

siva chalasani.

Former Member
0 Kudos
288

hi chandra,

while declaring the import parameters in your function module use the default key word.

example:

""Local Interface:

*" IMPORTING

*" REFERENCE(number) TYPE i default '100'.

this will take 100 as the default value for num.

reward if found helpful.

thanks&regards.

Former Member
0 Kudos
288

U can pass that value in changing.

Function Module " Ztest "

changing num = num

export res = res.

try this.

Awrd POints if useful

Bhupal