cancel
Showing results for 
Search instead for 
Did you mean: 

Help creating a user exit variable

Former Member
0 Kudos

Hi all,

I've never done a user-exit variable and I need help creating one I do need.

Here is the scenario:

Customer wants to see how many days an employee has worked in a specific month:

For example, let's immagine an employe XYZ has worked in two positions:

Position A      Begin date: 05.05.2011     End date: 20.02.2012

Position B      Begin date: 25:02:2012     End date: 15.10.2012

Query selection screen is compounded of just 0CALMONTH (Month + Year).

If customer selects 08.2011  ->  Employee has worked full month (I have to display in query value 1 as per 100%)

If customer selects 05.2012  ->  Employee has worked 25 days (I have to display 25/31 = 0.81 as per working full month is 1 - 100%)

If customer selects 10.2012  ->  Employee has worked 15 days (I have to display 15/31 = 0.48)

If customer selects 02.2012  ->  Employee has worked 24 days = 20 for Position A and 4 for Position B (I have to display 24/28 = 0.86)

I've been said this can be done at Query level by user-exit variables, can you please, give me instructions? In which characteristic should I create de user-exit variable?

Thanks!

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Alberto,

I think you should create formula user exit variable (please search on forum how to create exit formula variable).

Pseudocode

WHEN '<your formula exit variable>'.

DATA: wa_input TYPE RRS0_S_VAR_RANGE,

            wa_output TYPE rsr_s_rangesid,

            lv_result TYPE int4,

            lv_result2 TYPE dec.

Clear wa_input.

READ TABLE i_t_var_range INTO wa_input WITH KEY vnam = '0CALMONTH'.

IF sy-subrc EQ 0.

    <you should call specific FM to get number of work days>

    lv_result = <result from FM>

    lv_result2 = lv_result / <your logic to get total days in 0CALMONTH>

  

   wa_output-low = lv_result2

    wa_output-sign = 'I'.

    wa_output-opt = 'EQ'.

   APPEND wa_output TO e_t_range.

ENDIF.

Former Member
0 Kudos

Hi Albert,

  You can frame the code in the customer exit. The program will be ZXRSRU01.

Code Sample:

Case ivnam.

When 'User Exit Variable'.

Data: i_count type c value '0'.

   Loop at I_T_VAR_RANGE into W_T_VAR_RANGE.

(Customer Selection as you told as 08.2011).

           call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

           exporting

                   i_date_from          = FROMDATE (Position A Start Date)

                   i_date_to            = TODATE (Position A End Date)

            IMPORTING

                        E_DAYS               = EDAYS

                    

          Do E_DAYS times.

             IF 08.2011 >= FROMDATE and 08.2011 <= TODATE.

                 i_count =  i_count + 1.

                 FROMDATE = FROMDATE + 1.

                  TODATE = TODATE - 1.

             ENDIF.

         Result = i_count/31.

   EndLoop.

Thanks,

Umashankar

Former Member
0 Kudos

Hi Umashankar,

Thanks for replyaing.

Do you know in which characteristic should I create the customer exit? In 0CALMONTH, in BeginDate, in EndDate, or in all of them?

It's the first time I have to do a Customer-Exit so think I'm quite dumb

Thanks!

Former Member
0 Kudos

Hi Albert,

  Create the Customer Exit Variable for 0CALMONTH. This will work out lets hope for the best.

Thanks,

Umashankar

esjewett
Active Contributor
0 Kudos

Hi Alberto,

Please do not create duplicate posts (I've deleted the other one) and please read and follow the , which require searching before asking questions on SCN. If you had searched or Googled for something like "sap bw how to user exit variable", you would have found many tutorials on the topic. Try it using these tutorials and then if you are still having trouble, come back, tell us what you've done (show us the code), and ask for help with your specific problem.

I look forward to your questions in the future. As long as they follow the rules!

This thread will now be locked.

Regards,

Ethan

esjewett
Active Contributor
0 Kudos

Actually, as it turns out, I'm not a moderator in this space but rather in all the other BW spaces. Who knew?! So, this thread won't be locked, but I will report it as abuse. If a moderator in the space agrees with me, then it might be locked or deleted. Otherwise I've just been really grumpy in a space I don't own

Cheers,

Ethan

Former Member
0 Kudos

That's all right Ethan, I just published it on both forums as sometimes I publish something here and it's said it should be on the other one, and on the other way around too, it's quite confusing the way discussions and forums are created here. Anyway, that was the reason I created two, to be sure I publish it in the right place, so thanks for deleting the one in the wrong place 🙂

About tutorials and discussions already created, of course I read them, and download them in pdf!! But they didn't clarify my doubts as, for example "In which characteristic should I create de user-exit variable?" (what you didn't do on your two comments either...).

It's quite exhausting for someone who doesn't know abap and has little BI experience to deal with these kind of issues.

Cheers.

esjewett
Active Contributor
0 Kudos

I completely agree that it's a tough space to get in to in general (and it's an absolute nightmare to find the right forum on SCN sometimes). In the forums I moderate I try to strike a balance between not allowing basic and repetitive questions and still leaving space for people who are beginners but have legitimately done their research. One thing you can do to help the moderators and those answering the question is to link to documentation you've already read. That way people won't tell you to read things you've already looked at and my finger won't start itching to click the "lock" button. 🙂 Its even better if you can post code that you've created and explain how it's not working.

Usually when people do any of these things I let questions stand.

Thanks for responding and clarifying. I look forward to your further participation on SCN in the future!

Cheers,

Ethan