title: How to use exceptions in a function module?
body: <p>I am pretty new at ABAP and I try to learn Function Modules in ABAP. I create a function and give it parameters for IMPORT and EXPORT,TABLES also I want to give an exception to the user while he/she make something what I don't want. </p>
  
  <p>So, I have two import parameters which are: These lines are the column items for Import and Export fields.</p>
  
  <pre><code>i_x TYPE xx
  i_type TYPE char2
  </code></pre>
  
  <p>I have 1 table parameters which is : </p>
  
  <pre><code>et_xx_sorted LIKE xx 'this is an exception'
  </code></pre>
  
  <p>I have 1 exception line : </p>
  
  <pre><code>MAX_RECORD 'There is no record for this.'
  </code></pre>
  
  <p>My source code is : </p>
  
  <pre><code> SELECT * INTO TABLE et_xx_sorted[] FROM xx WHERE yy = i_x.
  </code></pre>
  
  <p>I want to use the my exception line when user give an input to i_x which is maximum than the border which I choose. I mean there is numbers 1 to 30 , but I want that user just can give 1 to 20. He/she can not give 20 to 30. And if there is an input into 20 to 30, program needs to give MAX_RECORD exception and say to the user 'There is no record for this.'</p>
  
  <p>I used :</p>
  
  <pre><code>IF sy-subrc &lt;&gt; 0.
      MESSAGE 'No record' TYPE 'E' RAISING MAX_RECORD.
    ENDIF.
  </code></pre>
  
  <p>But this is not what I want. There is a line for 20 - 30 so this code block isnt work for my border items. There is 1 to 30 lines but user only can see 1 to 20. And if he/she give 20 to 30 then program should give an exception using which I determined into EXCEPTIONS field. </p>