cancel
Showing results for 
Search instead for 
Did you mean: 

Customer Exit query

Former Member
0 Kudos

Dear SCN Members,

There is customer exit variable which gives the result of yesterday(Current month) and when we run on 1st day of the month there is no result because of current month. Customer exit variable is based on 0date.

Please see variable and code.

IF i_step = 2.     

l_date = sy-datum - 1.     

l_range-sign = 'I'.     

l_range-opt = 'EQ'.   

l_range-low = l_date.    

APPEND l_range TO e_t_range.

ENDIF.

Now user would like to have new variable with "variable is ready for input" enabled and I have written the same code as above for new variable & it's giving the same day result and not yesterday's.

Please help me if I have to tweak the code and any changes to variable.

Reg,

Guru.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Manpreet,

Option 2 already exists and we would like to have "variable ready for input" option checked.

IF we need to use I_step = 1, please let me know the code.

Thanks in advance.

Reg,

Guru.

former_member200967
Active Participant
0 Kudos

Hi Guru,

The code would be same as you have written above in your question. Just use the correct variable name for CASE and use I_STEP = 1.

CASE 'VNAM'.

IF I_STEP = 1.

L_S_RANGE-low = 'Initial Value for the selection screen'.

     L_S_RANGE-SIGN = 'I'.

    L_S_RANGE-OPT = 'EQ'.

     append L_S_RANGE to e_t_range.

ENDIF.

ENDCASE.


Regards,

Manpreet

Former Member
0 Kudos

Hi Guru,

I think you should read some of the already available documents on how to write the user exit for Bex query customer exits. I googled on 'user exit for bex query variable' and got the first link of detailed document.

Ideally you should be reading the table 'i_t_var_range' and then assign those values.

Your code for date subtraction 'l_date = sy-datum - 1' is correct however it should fit in the code that is provided in the detailed document.

Please go thru the document and then let us know if you face any issues.

@ : I would suggest you too to read that document to get a better understanding of i-steps.


Thanks

Amit

former_member200967
Active Participant
0 Kudos

HI Amit

Did I inform something incorrect in this thread with regards to I_STEPs?

Former Member
0 Kudos

Hello Manpreet, Guru,

Please find an excerpt from the document below:

If I_STEP = 1, the variable needs to be processed before the report’s selection screen appears, an example for this would be like, if some default values are to be populated to the selection screen variables before user input, I_STEP = 1 can be used.

If I_STEP = 2, the variable is to be processed after the report’s selection appears (ie after user input). An example for this step is explained in scenario 1 of this document

I_STEP = 3, is used for validation purpose, error messages can be raised here

Document Link:

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d09d4588-3832-2c10-e185-f778d9dbe...

Ideally if we want to manipulate the user input then we go for i-step = 2. And i-step = 1 is used for before selection screen manipulation purpose.

Please read the document, it is very helpful in understanding the concept.

Regards

Amit

Former Member
0 Kudos

Thanks for the document Amit,

It has helped me to understand basics.

I have written the below code but in the selection screen for variable default it's coming as "#".

If I_step = 1.

     l_date = sydatum -1.

     l_range-low = '00000000'.

     l_range-high = 'l_date.'.

     l_range-sign = 'I'.

     l_range-opt = 'EQ'.

APPEND l_range to e_t_range.

endif.

Please help me.

Reg,

Guru.

former_member200967
Active Participant
0 Kudos

Hi Guru,

This is beacuse you are using the option as EQ ( l_range-opt = 'EQ'.) and passing both low and High value to the variable.

Just pass the Low value to the variable and you should be able to see it in the selection screen.

If I_step = 1.

     l_date = sydatum -1.

     l_range-low = 'l_date.'.

    

     l_range-sign = 'I'.

     l_range-opt = 'EQ'.

APPEND l_range to e_t_range.

endif.

Regards,

Manpreet

Former Member
0 Kudos

Hi Manpreet,

If we do not mention l_range-high = 'l_date' , query is going into debug mode.

Reg,

Guru

former_member200967
Active Participant
0 Kudos

Hi GUru,

Then youo need to check the "details" tab of your variable, if it is of type "Single entry" or "interval".

If it is of type "Single Entry" then the code that i shared should work.

However if it is of type "interval" then you need to supply both high and low value, but you also need to use  l_range-opt = 'BT' and not l_range-opt = 'EQ'.

Regards,

Manpreet

EduardoR
Participant
0 Kudos

Hi,

I think there is a problem with the quotes.

Please, try with 

l_range-low = l_date.

Regards,

Eduardo

Former Member
0 Kudos

Hi Guru,

There are couple of thing I want to mention and know.

Is it all the code you have written? or are you reading i_t_var_range table too for your variable name? Can you send the entire code for this variable? probably should start with CASE statement.

Next, as per your current code - it will not work. Reason is in comments below.

     l_date = sy-datum -1.     " this is fine but sydatum should be sy-datum

     l_range-low = '00000000'. " This will not work as your variable is single entry because for single entry always the lower value is checked so l_date should be assigned here

     l_range-high = 'l_date.'.     " no quotes as Eduardo said already it should be only l_date. But ideally this value should be blank and l_date should be assigned to l_range-low

     l_range-sign = 'I'.               " this is fine

     l_range-opt = 'EQ'.             " this is fine

APPEND l_range to e_t_range.     " this is fine

Ideally your assignment code should be:

     l_date = sy-datum -1.

     l_range-sign = 'I'.

     l_range-opt = 'EQ'.

     l_range-low = l_date.

*          l_range-high = 'l_date.'. "Comment it

APPEND l_range to e_t_range.

Now, I would request you to follow the code in the document I suggested. And notice the highlighted part. Here the declared variable is checked and this is am important part for code. Also notice READ TABLE is in the i_step if statement.

Please let me know if there are any questions.

Regards

Amit

Former Member
0 Kudos

Correction to my previous reply:

I was in an assumption that user will enter a value. Which is incorrect assumption I think.

So you can follow Eduardo Resano Ladrón de Guevara suggestion and it should work.

Ideally below:

     l_date = sy-datum -1.           " remember sy-datum

     l_range-sign = 'I'.

     l_range-opt = 'EQ'.

     l_range-low = l_date.          " No quotes

*          l_range-high = 'l_date.'. "Comment it

APPEND l_range to e_t_range.

Thanks

Amit

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Manpreet, Eduardo Resano, Amit,

Thank you so much for guiding me.

After removing quotes for I_range-below = I_date it worked.

Reg,

Guru.

former_member200967
Active Participant
0 Kudos

Hi Guru,

You need to change the I_STEP varable value. When your variable is "Ready for Input" the system does not go to I_STEP = 2. CHange the value to I_STEP=3 and see if your code will work.

Regards,

Manpreet

former_member200967
Active Participant
0 Kudos

HI Guru,

I have a correction to make here, it is not possible to update or change variable values in the I_STEP= 3 and I understand your question correctly now,

1) Either you want to prefill the value of the variable for the user on the variable screen?

2) Or you want to calculate the previous day based on the date user will enter in the seelction screen?

OPtion 1 can be acheived using the I_STEP = 1 scenario.

For option 2: you should create a User entry variable for date field and then use the value that has been entered by the user to calculate "userdate -1 ". This has to be done using another Customer exit type of variable with "inout ready" not checked and using the I_STEP = 2.

Hope you get my point.

Let me know in case you have any other question.

Regards,

Manpreet