Skip to Content

There was a typical requirement in one of the Logistic reports. They had three variables in the input namely Sold-to, ship-to and strategic Account 1. Now the requirement was that if the user executes the report without putting value in any of the three he should get a message saying please enter values in atleast one of the three.

Well at first I thought its simple and I just have to code a message in i_step = 3. But actually speaking it wasnt so simple.

What I thought I would do is read the values of all the three variables in i_step = 3. But i_step = 3 will have only values of those variables which are mandatory. And if I make any of these variables as mandatory, then the purpose of the report would be defeated.

Then I thought of using a combination of i_step = 2 and i_step = 3. I.e. I would read the values for the variables Sold-to, ship-to and strategic account 1 in i_step = 2 and then based upon that in i_step = 3 would display the message.

Now here again the problem was i_step = 2 runs only for variables which are of type customer exit. And my all the three variables sold-to, ship-to and strategic group 1 were of type input value and not customer exit.

So finally got an idea to use a dummy variable for Sales document type. It will be of type user exit and optional as well as not ready for input. So that the user doesnt know that we are using any such variable for the report. (Note its a dummy variable and not actually required in the report, I just used it to be able to populate my exit).

  
Customer Exit Code

DATA: loc_var_range LIKE rrrangeexit,
        loc_var_range1 LIKE rrrangeexit,
        l_var_range type RRRANGESID,
        SOLDTO TYPE /bi0/oisold_to,
        shipto type /bi0/oiship_to,
        stra1 type /bic/oiZSTRAT1.

 

case i_vnam.
  when ‘ZSM_DTY’.

STATICS : temp type i.
temp = 1.

  IF i_step = 2.
    LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = ‘ZOM_STRA1’.
     clear temp.
    endloop.

    LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = ‘ZOM_SHIPTO’.
     clear temp.
    endloop.

    LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = ‘ZOM_STP’.
     clear temp.
    endloop.

  endif.
endcase.
“***************************************************************************

IF i_step = 3.

    if temp is not initial.

                          CALL FUNCTION ‘RRMS_MESSAGE_HANDLING’
                           EXPORTING
                           i_class  = ‘RSBBS’
                           i_type   = ‘I’
                           i_number = ‘000’
                           i_msgv1  = ‘ Select either Sold-to, ship-to or’
                           I_MSGV2  = ‘Strategic Account1’.
                           raise no_replacement.

     endif.

endif.
  

 Code Explanation :

I used a variable ZSM_DTY for document type as a dummy variable. Now in i_step = 2 for this variable, I am reading the values of sold-to, ship-to and strategic account 1 and then updating a temporary variable called temp. If at least one of the variable has a value entered this temp will be made as initial. If it is not initial means all the three variables are empty. Then in i_step = 3, I would raise a message based on the values of temp. Remember that the variable ZSM_DTY is a dummy one and we should not give any value to it, else it will impose a restriction on the query that is not needed.

NOTE : An important point to be noted here. Dont declare the temp variable as global, else it will be executed for all the queries you run and all the queries will display this message. I had faced this issue. So then I moved its definition in i_step = 2 which will execute only for my query.

Query Input screen

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

    1. Mansi Dandavate Post author
      Hi Shanti,

      Thanks for the info.
      But I really dont think we can use i_step = 3 for variables that are not mandatory.
      I had tried reading the internal table i_t_var_range in i_step = 3 to get the values of the variables. But it did not have the values of my variables sold-to, ship-to and strategic group 1 because they were not mandatory. As soon as I made any one mandatory its values were available in the internal table. But making them mandatory would defeat the purpose of the code. So I am really not sure how did you make it possible.

      (0) 

Leave a Reply