<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how to write the exceptions in function module in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-the-exceptions-in-function-module/m-p/3566552#M858330</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; In Tcode SE37 __--&amp;gt;change mode --&amp;gt;click on exception tab&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----" /&gt;&lt;P&gt;&amp;gt;enter exception name  and short description&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fro Ex : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Exception                                 Short description&lt;/P&gt;&lt;P&gt;ARGUMENT_ERROR                Incorrect call&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your code according to login raise exception&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RAISE  ARGUMENT_ERROR.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Mar 2008 08:21:54 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-03-27T08:21:54Z</dc:date>
    <item>
      <title>how to write the exceptions in function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-the-exceptions-in-function-module/m-p/3566550#M858328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;dear all,&lt;/P&gt;&lt;P&gt;     how to write the exceptions in function modules with example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanq&lt;/P&gt;&lt;P&gt;jyothi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 08:17:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-the-exceptions-in-function-module/m-p/3566550#M858328</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-27T08:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to write the exceptions in function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-the-exceptions-in-function-module/m-p/3566551#M858329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In FM exceptions you can define your exceptions with numbers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when the exception araised the Sy-subrc will consist the Number that you are already defined in the Function module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the following Example :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'READ_SPFLI_INTO_TABLE'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;ID = CARRIER&lt;/P&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;P&gt;ITAB = JTAB&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;NOT_FOUND = 1&lt;/P&gt;&lt;P&gt;OTHERS = 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CASE SY-SUBRC.&lt;/P&gt;&lt;P&gt;WHEN 1.&lt;/P&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO.&lt;/P&gt;&lt;P&gt;WHEN 2.&lt;/P&gt;&lt;P&gt;MESSAGE E702(AT).&lt;/P&gt;&lt;P&gt;ENDCASE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Viji on Mar 27, 2008 9:21 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 08:20:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-the-exceptions-in-function-module/m-p/3566551#M858329</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-27T08:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to write the exceptions in function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-the-exceptions-in-function-module/m-p/3566552#M858330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; In Tcode SE37 __--&amp;gt;change mode --&amp;gt;click on exception tab&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----" /&gt;&lt;P&gt;&amp;gt;enter exception name  and short description&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fro Ex : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Exception                                 Short description&lt;/P&gt;&lt;P&gt;ARGUMENT_ERROR                Incorrect call&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your code according to login raise exception&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RAISE  ARGUMENT_ERROR.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 08:21:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-the-exceptions-in-function-module/m-p/3566552#M858330</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-27T08:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to write the exceptions in function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-the-exceptions-in-function-module/m-p/3566553#M858331</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;in the exceptions tab, list your exceptions with their description&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;eg : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA_NOT_FOUND                 no data found&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the source code, raise the exception as follows&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RAISE DATA_NOT_FOUND&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while calling the fm, if the exception is raised, the value of the sy-subrc will be set according to the position of the exception in the list in the exception tab. if it is at the first position, sy-subrc  will be set to 1.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 08:21:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-the-exceptions-in-function-module/m-p/3566553#M858331</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-27T08:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: how to write the exceptions in function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-the-exceptions-in-function-module/m-p/3566554#M858332</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In function module Exception one option is there click that option &lt;/P&gt;&lt;P&gt;Give Exption name and Short text like this,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Refrence_not_allowed  &amp;lt;Give Short text&amp;gt;

In source code

IF REFERENCE = TRUE.
    RAISE REFERENCE_NOT_ALLOWED.
  ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 08:23:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-the-exceptions-in-function-module/m-p/3566554#M858332</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-27T08:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: how to write the exceptions in function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-the-exceptions-in-function-module/m-p/3566555#M858333</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Raising Exceptions&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are two ABAP statements for raising exceptions. They can only be used in function modules:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RAISE except.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;und&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MESSAGE.....RAISING except.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The effect of these statements depends on whether the calling program handles the exception or not. The calling program handles an exception If the name of the except exception or OTHERS is specified after the EXCEPTION option of the CALL FUNCTION statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the calling program does not handle the exception&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;· The RAISEstatement terminates the program and switches to debugging mode.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;· The MESSAGE..... RAISING statement displays the specified message. Processing is continued in relation to the message type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the calling program handles the exception, both statements return control to the program. No values are transferred. The MESSAGE..... RAISING statement does not display a message. Instead, it fills the system fields sy-msgid, sy-msgty, sy-msgno , and SY-MSGV1 to SY-MSGV4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Source Code of READ_SPFLI_INTO_TABLE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The entire source code of READ_SPFLI_INTO_TABLE looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FUNCTION read_spfli_into_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*"----&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="------------------------------------------------------" /&gt;&lt;P&gt;""Local Interface:&lt;/P&gt;&lt;P&gt;*" IMPORTING&lt;/P&gt;&lt;P&gt;*" VALUE(ID) LIKE SPFLI-CARRID DEFAULT 'LH '&lt;/P&gt;&lt;P&gt;*" EXPORTING&lt;/P&gt;&lt;P&gt;*" VALUE(ITAB) TYPE SPFLI_TAB&lt;/P&gt;&lt;P&gt;*" EXCEPTIONS&lt;/P&gt;&lt;P&gt;*" NOT_FOUND&lt;/P&gt;&lt;P&gt;*"----&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM spfli INTO TABLE itab WHERE carrid = id.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc NE 0.&lt;/P&gt;&lt;P&gt;MESSAGE e007(at) RAISING not_found.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFUNCTION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The function module reads all of the data from the database table SPFLI where the key field CARRID is equal to the import parameter ID and places the entries that it finds into the internal table spfli_tab. If it cannot find any entries, the exception NOT_FOUND is triggered with MESSAGE ... RAISING. Otherwise, the table is passed to the caller as an exporting parameter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Calling READ_SPFLI_INTO_TABLE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following program calls the function module READ_SPFLI_INTO_TABLE:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT demo_mod_tech_fb_read_spfli.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARAMETERS carrier TYPE s_carr_id.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: jtab TYPE spfli_tab,&lt;/P&gt;&lt;P&gt;wa LIKE LINE OF jtab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'READ_SPFLI_INTO_TABLE'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;id = carrier&lt;/P&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;P&gt;itab = jtab&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;not_found = 1&lt;/P&gt;&lt;P&gt;OTHERS = 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CASE sy-subrc.&lt;/P&gt;&lt;P&gt;WHEN 1.&lt;/P&gt;&lt;P&gt;MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno.&lt;/P&gt;&lt;P&gt;WHEN 2.&lt;/P&gt;&lt;P&gt;MESSAGE e702(at).&lt;/P&gt;&lt;P&gt;ENDCASE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT jtab INTO wa.&lt;/P&gt;&lt;P&gt;WRITE: / wa-carrid, wa-connid, wa-cityfrom, wa-cityto.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The actual parameters carrier and jtab have the same data types as their corresponding interface parameters in the function module. The exception NOT_FOUND is handled in the program. It displays the same message that the function module would have displayed had it handled the error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;just have to decide what exceptions u want and under what conditions.&lt;/P&gt;&lt;P&gt;then declarethese exeptions under the exceptions tab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the source code of ur function module.&lt;/P&gt;&lt;P&gt;if &lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;like this u can code .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now when u call the function module in tme mainprogram.&lt;/P&gt;&lt;P&gt;if some error occurs and u have declared a exception for this then it will set sy-subrc = value u give inthe call of this fm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the fm u can program these sy-subrc values and trigger the code for ur exception.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please reward if useful&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Ravikanth Alapati on Mar 27, 2008 9:36 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 08:23:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-the-exceptions-in-function-module/m-p/3566555#M858333</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-27T08:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to write the exceptions in function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-the-exceptions-in-function-module/m-p/3566556#M858334</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Define the whatever exceptions to be raised in Exceptions tab in Function module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Source code,  Raise those exceptions  depending on ur conditions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Automatically those exceptions will be coming  to the main program to handle if any error occurs.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Check Sy-subrc in the main program.&lt;/P&gt;&lt;P&gt;If sy-subrc  = 1. ( first Exception in Function Module)&lt;/P&gt;&lt;P&gt;   Write:/  '  text to understand'.&lt;/P&gt;&lt;P&gt;if sy-subrc = 2.  ( second Exception in Function Module if u've)&lt;/P&gt;&lt;P&gt;   write:/  '  text to understand'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Iyswarya&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Iyswarya  Godi on Mar 27, 2008 9:27 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 08:27:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-the-exceptions-in-function-module/m-p/3566556#M858334</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-27T08:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to write the exceptions in function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-the-exceptions-in-function-module/m-p/3566557#M858335</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Exceptions in Function Module&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Exceptions are used to handle error scenarios, which can occur in function modules.  The function module checks for any type of error and raise exception and returns SY-SUBRC to the calling program.  Main program checks this SY-SUBRC for any errors that have occurred and then takes action accordingly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To call a function module from an ABAP/4 program, use the CALL statement as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;  [EXPORTING		&lt;/P&gt;&lt;P&gt;f1   = s1&lt;/P&gt;&lt;P&gt;	f2  = s2&lt;/P&gt;&lt;P&gt;	fn  = sn (parameters which you pass from program to function are&lt;/P&gt;&lt;P&gt;	s1, s2, sn)]&lt;/P&gt;&lt;P&gt;  [IMPORTING &lt;/P&gt;&lt;P&gt;	f1   = r1&lt;/P&gt;&lt;P&gt;	f2  = r2&lt;/P&gt;&lt;P&gt;	fn  = rn (parameters which program receives you pass from function in&lt;/P&gt;&lt;P&gt;	r1, r2, rn)]&lt;/P&gt;&lt;P&gt;  [TABLES 	f1 = a1 &amp;#133; fn = an]&lt;/P&gt;&lt;P&gt;	EXCEPTIONS notvalid = 1&lt;/P&gt;&lt;P&gt;	not correct = 2&lt;/P&gt;&lt;P&gt;	OTHERS = 5].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can specify the name of the function module &amp;lt;module&amp;gt; as a literal or as a variable.  Parameters are passed to and from the function module by exactly assigning the actual parameters to the formal parameters in the lists after the EXPORTING, IMPORTING, TABLES.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If in your function if you have raised exception not valid then this exception can be handled in main program.  Functions return different sy-subrc for different exceptions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ex:&lt;/P&gt;&lt;P&gt;To create a physical file name from a logical file name in your ABAP programs, use the function module FILE_GET_NAME. To insert the function module call in your program, choose Edit   Insert statement from the ABAP Editor screen. A dialog box appears. Select Call Function and enter FILE_GET_NAME. The parameters of this function module are listed below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Import parameters&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Parameters----Function&lt;/P&gt;&lt;P&gt;CLIENT -&lt;/P&gt;&lt;HR originaltext="--------" /&gt;&lt;P&gt;The maintenance tables for the logical files and paths are clientdependent. Therefore, the desired client can be imported. The current client is stored in the system field SY-MANDT.&lt;/P&gt;&lt;P&gt;LOGICAL_FILENAME---- Enter the logical file name in upper case letters that you want to convert.&lt;/P&gt;&lt;P&gt;OPERATING_SYSTEM----You can import any operating system that is contained in the list in Transaction SF04. The physical file name will be created according to the syntax group to which the operating system is linked. The default parameter is the value of the system field SY-OPSYS.&lt;/P&gt;&lt;P&gt;PARAMETER_1&lt;/P&gt;&lt;P&gt;PARAMETER_2&lt;/P&gt;&lt;P&gt;--If you specify these import parameters, the reserved words&lt;/P&gt;&lt;P&gt;&amp;lt;PARAM_1&amp;gt; and &amp;lt;PARAM_2&amp;gt; in the physical path names will be replaced by the imported values.&lt;/P&gt;&lt;P&gt;USE_PRESENTATION _SERVER&lt;/P&gt;&lt;P&gt;--With this flag you can decide whether to import the operating&lt;/P&gt;&lt;P&gt;system of the presentation server instead of the operating system imported by the parameter OPERATING_SYSTEM.&lt;/P&gt;&lt;P&gt;WITH_FILE_EXTENSION If you set this flag unequal to SPACE, the file format defined for the logical file name is appended to the physical file name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Export Parameters&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Parameters-------Function&lt;/P&gt;&lt;P&gt;EMERGENCY_FLAG---If this parameter is unequal to SPACE, no physical name is defined in the logical path. An emergency physical name was created from table&lt;/P&gt;&lt;P&gt;FILENAME and profile parameter DIR_GLOBAL.&lt;/P&gt;&lt;P&gt;FILE_FORMAT--This parameter is the file format defined for the logical file name. You can use this parameter, for example, to decide in which mode the file should be opened.&lt;/P&gt;&lt;P&gt;FILE_NAME--This parameter is the physical file name that you can use with the ABAP statements for working with files.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Exception Parameters&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Parameters----Function&lt;/P&gt;&lt;P&gt;FILE_NOT_FOUND--This exception is raised if the logical file is not defined.&lt;/P&gt;&lt;P&gt;OTHERS--This exception is raised if other errors occur.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Source Code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: FLAG,&lt;/P&gt;&lt;P&gt;FORMAT(3),&lt;/P&gt;&lt;P&gt;FNAME(60).&lt;/P&gt;&lt;P&gt;WRITE SY-OPSYS.&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'FILE_GET_NAME'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;LOGICAL_FILENAME = 'MYTEMP'&lt;/P&gt;&lt;P&gt;OPERATING_SYSTEM = SY-OPSYS&lt;/P&gt;&lt;P&gt;PARAMETER_1 = '01'&lt;/P&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;P&gt;EMERGENCY_FLAG = FLAG&lt;/P&gt;&lt;P&gt;FILE_FORMAT = FORMAT&lt;/P&gt;&lt;P&gt;FILE_NAME = FNAME&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;FILE_NOT_FOUND = 1&lt;/P&gt;&lt;P&gt;OTHERS = 2.&lt;/P&gt;&lt;P&gt;IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;WRITE: / 'Flag :', FLAG,&lt;/P&gt;&lt;P&gt;/ 'Format :', FORMAT,&lt;/P&gt;&lt;P&gt;/ 'Phys. Name:', FNAME.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bhaskar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 08:34:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-the-exceptions-in-function-module/m-p/3566557#M858335</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-27T08:34:16Z</dc:date>
    </item>
  </channel>
</rss>

