cancel
Showing results for 
Search instead for 
Did you mean: 

Customer Exits - Multiple Variables

Former Member
0 Kudos

I have to write customer exit which is taking value from one variable to multiple variables depending on conditions.

like from VAR1 (Customer Exit) have to fill 2 variables VAR2(Cust Exit) , and VAR3 ( Cust Exit).

How i will my manage my code for e_t_range? any sample code which can fit my requirement.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

You can adapt the following - (It fills VAR2 and VAR3 from VAR1 value)


CASE I_VAM.

WHEN 'VAR2'.
IF I_STEP = 2.
READ TABLE i_t_var_range INTO loc_var_range 
WITH KEY vnam = 'VAR1'.

IF SY-SUBRC = 0.
loc_range-low = loc_var_range-low.

loc_range-sign = 'I'.
loc_range-opt = 'EQ'.
APPEND loc_range TO e_t_range.
endif.

WHEN 'VAR3'.
IF I_STEP = 2.
READ TABLE i_t_var_range INTO loc_var_range 
WITH KEY vnam = 'VAR1'.

IF SY-SUBRC = 0.
loc_range-low = loc_var_range-low.

loc_range-sign = 'I'.
loc_range-opt = 'EQ'.
APPEND loc_range TO e_t_range.
endif.

Former Member
0 Kudos

rewarding system not working will reward u points once it will start working.

let me ask u one more thing:

when i am filling VAR2 from VAR1 i also wanna update value of VAR3, is it possible?

and if yes, how LOC_RANGE i.e. e_t_range is going to recognize that the value if for VAR2 or VAR3?

Former Member
0 Kudos

This exit is called once for each variable. That is why there is a CASE statement at the top. It will come to this code once for VAR2 (at which time e_t_range will be filled for this variable) and once for VAR3 (for similar).

As you can see, there are separate 'WHEN' statements accordingly in the code. In its current form, it IS updating variable values for both VAR2 and VAR3.

Former Member
0 Kudos

Do u have idea in which sequence it will read variables?

like first VAR2 then VAR3....?

and can i update value of VAR3 inside CASE of VAR2?

Former Member
0 Kudos

Sequence I am not sure.

CASE statement is going to be one. But you can not fill values for VAR3 within the 'WHEN' clause of VAR2 if that is what you ask.

You can think of it like this - everytime the code comes to this exit, it is for one specific variable, so e_t_range is each time for one specific var, you do not have values for all variables in the same e_t_range.

Former Member
0 Kudos

Hi,

Wat ajay have provided is not going to work.

Read this..

"The second step (I_STEP = 2) is called after the processing of the variable pop-up. This step is called only for those variables that are not marked as “ready for input” and are set to “mandatory variable entry”."

So your 'Var1' will never to called in "Read table.." statement.

The other reason for not workin is that VAR1 is itself deriving value from some user entry variable.

<b>Solution</b>

you have to keep 'var1' in a global variable in Global data of comd.

Then call that in your I_STEP = 2 of 'VAR2' and 'VAR3'.

Regards,

San!

Former Member
0 Kudos

how will i create global variable?

Former Member
0 Kudos

What San! has said is correct. I overlooked the fact that your VAR1 is also a customer exit valriable (is it not entered by the user)?

If so, you will be putting values for VAR1 in your exit code. At this point , you can save those values in a global work-area (go to your function module in SE37 (EXIT_SAPLRSAP_001) --> from menu go to 'global data', goto change mode, add a data declaration there, it will be of the form

data : w_var_range type RRS0_T_VAR_RANGE occurs 1.). You can move your VAR1 data to w_var_Range when you are processing VAR1 in user-exit.

Afterwards you can fill VAR2 and VAR3 values in the 'WHEN' block from this work-area (w_var_Range).

What SAN! meant was defining a work-area variable in function groups global data section to store VAR1 data(so it is available for use in your exit code).