<?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: Function Module in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module/m-p/2894297#M680268</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;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;Creating Function Modules&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;P&gt;You can only create function modules and function groups using the Function Builder in the ABAP Workbench. This section uses an example to illustrate how a function module is created from the point of view of ABAP programming.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We are going to create a function module READ_SPFLI_INTO_TABLE to read&lt;/P&gt;&lt;P&gt;data for a specified airline from table SPFLI into an internal table, which it then&lt;/P&gt;&lt;P&gt;passes back to the calling program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Function Groups and Function Modules&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Firstly, we create a new function group DEMO_SPFLI to hold the function module. Then, we can create the new function module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Parameter Interface&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;You can specify the types of interface parameters in function modules in the&lt;/P&gt;&lt;P&gt;same way as the parameter interfaces of subroutines. Since function&lt;/P&gt;&lt;P&gt;modules can be used anywhere in the system, their interfaces can only contain&lt;/P&gt;&lt;P&gt;references to data types that are declared systemwide. These are the elementary&lt;/P&gt;&lt;P&gt;ABAP data types, the systemwide generic types, such as ANY TABLE, and types&lt;/P&gt;&lt;P&gt;defined in the ABAP Dictionary. You cannot use LIKE to refer to data types declared in the main program.&lt;/P&gt;&lt;P&gt;The function module READ_SPFLI_INTO_TABLE requires an import parameter&lt;/P&gt;&lt;P&gt;to restrict the selection to a single airline. To specify the type, we can refer to the&lt;/P&gt;&lt;P&gt;key field CARRID of the database SPFLI&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Under Ref. field/structure, you can enter a column of a database table, a component of a ABAP Dictionary structure, or a whole ABAP Dictionary structure.&lt;/P&gt;&lt;P&gt;The import parameter ID is optional, and has a default value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ref. type can contain any generic or full data type that is recognized systemwide.&lt;/P&gt;&lt;P&gt;Here, the parameter is defined with reference to the elementary ABAP Dictionary&lt;/P&gt;&lt;P&gt;type (or data element) S_CARR_ID. This is the type used to define the field&lt;/P&gt;&lt;P&gt;SPFLI-CARRID.&lt;/P&gt;&lt;P&gt;To pass data back to the calling program, the function module needs an export&lt;/P&gt;&lt;P&gt;parameter with the type of an internal table. For this, we define a systemwide&lt;/P&gt;&lt;P&gt;table type SPFLI_TAB with the line type SPFLI in the ABAP Dictionary.&lt;/P&gt;&lt;P&gt;The internal table is passed by value. Only internal tables that are passed using&lt;/P&gt;&lt;P&gt;tables parameters can be passed exclusively by reference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Exceptions&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Our function module needs an exception that it can trigger if there are no entries&lt;/P&gt;&lt;P&gt;in table SPFLI that meet the selection criterion. The exception NOT_FOUND&lt;/P&gt;&lt;P&gt;serves this function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Source Code&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Having defined the parameter interface and exceptions, we can now write the&lt;/P&gt;&lt;P&gt;source code of our function module. To do this, choose Source code in the&lt;/P&gt;&lt;P&gt;Function Builder. This opens the ABAP Editor for the include program L&amp;lt;fgrp&amp;gt;U&amp;lt;xx&amp;gt;. This is the include that will hold the program code for the function module;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The source code of the function module occurs between the FUNCTION and&lt;/P&gt;&lt;P&gt;ENDFUNCTION statements. The definitions of the parameter interface and the&lt;/P&gt;&lt;P&gt;exceptions is displayed here in comment lines. Its real coding is generated&lt;/P&gt;&lt;P&gt;invisibly by the Function Builder.&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;FUNCTION READ_SPFLI_INTO_TABLE.&lt;/P&gt;&lt;P&gt;*"----&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------" /&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;"&lt;/STRONG&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;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;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;ENDFUNCTION.&lt;/P&gt;&lt;P&gt;The function module reads all of the data from the database table SPFLI where&lt;/P&gt;&lt;P&gt;the key field CARRID is equal to the import parameter ID and places the entries&lt;/P&gt;&lt;P&gt;that it finds into the internal table SPFLI_TAB. If it cannot find any entries, the&lt;/P&gt;&lt;P&gt;exception NOT_FOUND is triggered using MESSAGE...RAISING. Otherwise, the&lt;/P&gt;&lt;P&gt;table is passed to the caller as an exporting parameter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Calling READ_SPFLI_INTO_TABLE&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;The following program calls the function module READ_SPFLI_INTO_TABLE:&lt;/P&gt;&lt;P&gt;REPORT DEMO_FUNCTION_MODULE.&lt;/P&gt;&lt;P&gt;PARAMETERS CARRIER TYPE S_CARR_ID.&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;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;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;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;The actual parameters CARRIER and JTAB have the same data types as their&lt;/P&gt;&lt;P&gt;corresponding interface parameters in the function module. The exception&lt;/P&gt;&lt;P&gt;NOT_FOUND is handled in the program. It displays the same message that the&lt;/P&gt;&lt;P&gt;function module would have displayed had it handled the error.&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>Fri, 19 Oct 2007 09:40:40 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-10-19T09:40:40Z</dc:date>
    <item>
      <title>Function Module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module/m-p/2894294#M680265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can any one help me in creating my own function  module ? A simple example will be of very good help .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Plz tell me in brief about all the parametrs or tabs in se37 .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Oct 2007 09:17:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module/m-p/2894294#M680265</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-19T09:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: Function Module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module/m-p/2894295#M680266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw70/helpdata/en/d1/801e9a454211d189710000e8322d00/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw70/helpdata/en/d1/801e9a454211d189710000e8322d00/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw2004s/helpdata/en/d1/801ece454211d189710000e8322d00/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw2004s/helpdata/en/d1/801ece454211d189710000e8322d00/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Oct 2007 09:23:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module/m-p/2894295#M680266</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-19T09:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: Function Module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module/m-p/2894296#M680267</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;T-code for Function Module : SE37&lt;/P&gt;&lt;P&gt;You can only create function modules and function groups using the Function Builder in the ABAP Workbench.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An example to illustrate how a function module is created from the point of view of&lt;/P&gt;&lt;P&gt;ABAP programming:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Firstly, we create a new function group DEMO_SPFLI to hold the function module.Then, we can create the new function module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. You can specify the types of interface parameters in function modules in the&lt;/P&gt;&lt;P&gt;same way as the parameter interfaces of subroutines. Since function&lt;/P&gt;&lt;P&gt;modules can be used anywhere in the system, their interfaces can only contain&lt;/P&gt;&lt;P&gt;references to data types that are declared systemwide.&lt;/P&gt;&lt;P&gt;The function module READ_SPFLI_INTO_TABLE requires an import parameter&lt;/P&gt;&lt;P&gt;to restrict the selection to a single airline. To specify the type, we can refer to the&lt;/P&gt;&lt;P&gt;key field CARRID of the database SPFLI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. To pass data back to the calling program, the function module needs an export&lt;/P&gt;&lt;P&gt;parameter with the type of an internal table. For this, we define a systemwide&lt;/P&gt;&lt;P&gt;table type SPFLI_TAB with the line type SPFLI in the ABAP Dictionary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. Our function module needs an exception that it can trigger if there are no entries&lt;/P&gt;&lt;P&gt;in table SPFLI that meet the selection criterion. The exception NOT_FOUND&lt;/P&gt;&lt;P&gt;serves this function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5. Having defined the parameter interface and exceptions, we can now write the&lt;/P&gt;&lt;P&gt;source code of our function module. To do this, choose Source code in the&lt;/P&gt;&lt;P&gt;Function Builder. This opens the ABAP Editor for the include program&lt;/P&gt;&lt;P&gt;L&amp;lt;fgrp&amp;gt;U&amp;lt;xx&amp;gt;. This is the include that will hold the program code for the function module.&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;REPORT DEMO_FUNCTION_MODULE.&lt;/P&gt;&lt;P&gt;PARAMETERS CARRIER TYPE S_CARR_ID.&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;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;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;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;The actual parameters CARRIER and JTAB have the same data types as their&lt;/P&gt;&lt;P&gt;corresponding interface parameters in the function module. The exception&lt;/P&gt;&lt;P&gt;NOT_FOUND is handled in the program. It displays the same message that the&lt;/P&gt;&lt;P&gt;function module would have displayed had it handled the error.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Oct 2007 09:31:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module/m-p/2894296#M680267</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-19T09:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: Function Module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module/m-p/2894297#M680268</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;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;Creating Function Modules&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;P&gt;You can only create function modules and function groups using the Function Builder in the ABAP Workbench. This section uses an example to illustrate how a function module is created from the point of view of ABAP programming.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We are going to create a function module READ_SPFLI_INTO_TABLE to read&lt;/P&gt;&lt;P&gt;data for a specified airline from table SPFLI into an internal table, which it then&lt;/P&gt;&lt;P&gt;passes back to the calling program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Function Groups and Function Modules&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Firstly, we create a new function group DEMO_SPFLI to hold the function module. Then, we can create the new function module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Parameter Interface&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;You can specify the types of interface parameters in function modules in the&lt;/P&gt;&lt;P&gt;same way as the parameter interfaces of subroutines. Since function&lt;/P&gt;&lt;P&gt;modules can be used anywhere in the system, their interfaces can only contain&lt;/P&gt;&lt;P&gt;references to data types that are declared systemwide. These are the elementary&lt;/P&gt;&lt;P&gt;ABAP data types, the systemwide generic types, such as ANY TABLE, and types&lt;/P&gt;&lt;P&gt;defined in the ABAP Dictionary. You cannot use LIKE to refer to data types declared in the main program.&lt;/P&gt;&lt;P&gt;The function module READ_SPFLI_INTO_TABLE requires an import parameter&lt;/P&gt;&lt;P&gt;to restrict the selection to a single airline. To specify the type, we can refer to the&lt;/P&gt;&lt;P&gt;key field CARRID of the database SPFLI&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Under Ref. field/structure, you can enter a column of a database table, a component of a ABAP Dictionary structure, or a whole ABAP Dictionary structure.&lt;/P&gt;&lt;P&gt;The import parameter ID is optional, and has a default value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ref. type can contain any generic or full data type that is recognized systemwide.&lt;/P&gt;&lt;P&gt;Here, the parameter is defined with reference to the elementary ABAP Dictionary&lt;/P&gt;&lt;P&gt;type (or data element) S_CARR_ID. This is the type used to define the field&lt;/P&gt;&lt;P&gt;SPFLI-CARRID.&lt;/P&gt;&lt;P&gt;To pass data back to the calling program, the function module needs an export&lt;/P&gt;&lt;P&gt;parameter with the type of an internal table. For this, we define a systemwide&lt;/P&gt;&lt;P&gt;table type SPFLI_TAB with the line type SPFLI in the ABAP Dictionary.&lt;/P&gt;&lt;P&gt;The internal table is passed by value. Only internal tables that are passed using&lt;/P&gt;&lt;P&gt;tables parameters can be passed exclusively by reference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Exceptions&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Our function module needs an exception that it can trigger if there are no entries&lt;/P&gt;&lt;P&gt;in table SPFLI that meet the selection criterion. The exception NOT_FOUND&lt;/P&gt;&lt;P&gt;serves this function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Source Code&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Having defined the parameter interface and exceptions, we can now write the&lt;/P&gt;&lt;P&gt;source code of our function module. To do this, choose Source code in the&lt;/P&gt;&lt;P&gt;Function Builder. This opens the ABAP Editor for the include program L&amp;lt;fgrp&amp;gt;U&amp;lt;xx&amp;gt;. This is the include that will hold the program code for the function module;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The source code of the function module occurs between the FUNCTION and&lt;/P&gt;&lt;P&gt;ENDFUNCTION statements. The definitions of the parameter interface and the&lt;/P&gt;&lt;P&gt;exceptions is displayed here in comment lines. Its real coding is generated&lt;/P&gt;&lt;P&gt;invisibly by the Function Builder.&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;FUNCTION READ_SPFLI_INTO_TABLE.&lt;/P&gt;&lt;P&gt;*"----&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------" /&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;"&lt;/STRONG&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;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;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;ENDFUNCTION.&lt;/P&gt;&lt;P&gt;The function module reads all of the data from the database table SPFLI where&lt;/P&gt;&lt;P&gt;the key field CARRID is equal to the import parameter ID and places the entries&lt;/P&gt;&lt;P&gt;that it finds into the internal table SPFLI_TAB. If it cannot find any entries, the&lt;/P&gt;&lt;P&gt;exception NOT_FOUND is triggered using MESSAGE...RAISING. Otherwise, the&lt;/P&gt;&lt;P&gt;table is passed to the caller as an exporting parameter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Calling READ_SPFLI_INTO_TABLE&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;The following program calls the function module READ_SPFLI_INTO_TABLE:&lt;/P&gt;&lt;P&gt;REPORT DEMO_FUNCTION_MODULE.&lt;/P&gt;&lt;P&gt;PARAMETERS CARRIER TYPE S_CARR_ID.&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;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;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;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;The actual parameters CARRIER and JTAB have the same data types as their&lt;/P&gt;&lt;P&gt;corresponding interface parameters in the function module. The exception&lt;/P&gt;&lt;P&gt;NOT_FOUND is handled in the program. It displays the same message that the&lt;/P&gt;&lt;P&gt;function module would have displayed had it handled the error.&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>Fri, 19 Oct 2007 09:40:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module/m-p/2894297#M680268</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-19T09:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: Function Module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module/m-p/2894298#M680269</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;&amp;lt;a href="http://www.saptechnical.com/Tutorials/ABAP/RFCCall/Page1.htm"&amp;gt;FM&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reard if useful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Oct 2007 09:46:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module/m-p/2894298#M680269</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-19T09:46:04Z</dc:date>
    </item>
  </channel>
</rss>

