<?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: Dynamic function module call in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-function-module-call/m-p/7041624#M1500733</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;Create Function module according to your requirment  and call the same  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;such as &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create functi0n module   where you are passing PLant  runtime   and get data related to Plant  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write  code in function according to requirment  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FUNCTION zrfc_test.&lt;/P&gt;&lt;P&gt;*"----&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&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(ZWERKS) TYPE  MARC-WERKS OPTIONAL&lt;/P&gt;&lt;P&gt;*"  EXPORTING&lt;/P&gt;&lt;P&gt;*"     VALUE(RETURN) LIKE  BAPIRET2 STRUCTURE  BAPIRET2&lt;/P&gt;&lt;P&gt;*"  TABLES&lt;/P&gt;&lt;P&gt;*"      ZIT_DATA STRUCTURE  MARC&lt;/P&gt;&lt;P&gt;*"----&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF zwerks IS NOT INITIAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    SELECT *&lt;/P&gt;&lt;P&gt;      FROM marc&lt;/P&gt;&lt;P&gt;      INTO CORRESPONDING FIELDS OF TABLE zit_data&lt;/P&gt;&lt;P&gt;     WHERE werks = zwerks .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ELSE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    SELECT *&lt;/P&gt;&lt;P&gt;      FROM marc&lt;/P&gt;&lt;P&gt;      INTO CORRESPONDING FIELDS OF TABLE zit_data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF sy-subrc = 0 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    MESSAGE ' Selected ' TYPE 'I' .&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Suppose  at runtime you get Plant  7100 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types : begin  of w_marc .&lt;/P&gt;&lt;P&gt;         include structure  marc  .&lt;/P&gt;&lt;P&gt;types : end of w_marc .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : it_data type standard table of w_marc with header line  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;p_plant  = 7100 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Call to function module  &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'ZRFC_TEST'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;   ZWERKS         = 'p_plant  &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  RETURN         =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  TABLES&lt;/P&gt;&lt;P&gt;    zit_data       =  it_data  .&lt;/P&gt;&lt;P&gt;          .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will get result in it_data .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note : if you don't know how to create  Function Module then  search on SDN you will get lots of Forum  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Deepak.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 17 Jul 2010 10:54:11 GMT</pubDate>
    <dc:creator>deepak_dhamat</dc:creator>
    <dc:date>2010-07-17T10:54:11Z</dc:date>
    <item>
      <title>Dynamic function module call</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-function-module-call/m-p/7041622#M1500731</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;I need to call few function modules dynamically.The exporting and importing parameters are also known only at run time.&lt;/P&gt;&lt;P&gt;Can somebody help me out in this regard,&lt;/P&gt;&lt;P&gt;Thanks and regards,&lt;/P&gt;&lt;P&gt;Archna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Jul 2010 06:10:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-function-module-call/m-p/7041622#M1500731</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-17T06:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic function module call</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-function-module-call/m-p/7041623#M1500732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;check the standard include LV69AF21, how the fm's PRICING_SUBSCREEN_PBO and PRICING_SUBSCREEN_PAI gets called.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;link:[http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/840ad679-0601-0010-cd8e-9989fd650822#q-29]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Jul 2010 08:32:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-function-module-call/m-p/7041623#M1500732</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2010-07-17T08:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic function module call</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-function-module-call/m-p/7041624#M1500733</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;Create Function module according to your requirment  and call the same  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;such as &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create functi0n module   where you are passing PLant  runtime   and get data related to Plant  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write  code in function according to requirment  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FUNCTION zrfc_test.&lt;/P&gt;&lt;P&gt;*"----&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&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(ZWERKS) TYPE  MARC-WERKS OPTIONAL&lt;/P&gt;&lt;P&gt;*"  EXPORTING&lt;/P&gt;&lt;P&gt;*"     VALUE(RETURN) LIKE  BAPIRET2 STRUCTURE  BAPIRET2&lt;/P&gt;&lt;P&gt;*"  TABLES&lt;/P&gt;&lt;P&gt;*"      ZIT_DATA STRUCTURE  MARC&lt;/P&gt;&lt;P&gt;*"----&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF zwerks IS NOT INITIAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    SELECT *&lt;/P&gt;&lt;P&gt;      FROM marc&lt;/P&gt;&lt;P&gt;      INTO CORRESPONDING FIELDS OF TABLE zit_data&lt;/P&gt;&lt;P&gt;     WHERE werks = zwerks .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ELSE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    SELECT *&lt;/P&gt;&lt;P&gt;      FROM marc&lt;/P&gt;&lt;P&gt;      INTO CORRESPONDING FIELDS OF TABLE zit_data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF sy-subrc = 0 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    MESSAGE ' Selected ' TYPE 'I' .&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Suppose  at runtime you get Plant  7100 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types : begin  of w_marc .&lt;/P&gt;&lt;P&gt;         include structure  marc  .&lt;/P&gt;&lt;P&gt;types : end of w_marc .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : it_data type standard table of w_marc with header line  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;p_plant  = 7100 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Call to function module  &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'ZRFC_TEST'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;   ZWERKS         = 'p_plant  &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  RETURN         =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  TABLES&lt;/P&gt;&lt;P&gt;    zit_data       =  it_data  .&lt;/P&gt;&lt;P&gt;          .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will get result in it_data .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note : if you don't know how to create  Function Module then  search on SDN you will get lots of Forum  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Deepak.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Jul 2010 10:54:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-function-module-call/m-p/7041624#M1500733</guid>
      <dc:creator>deepak_dhamat</dc:creator>
      <dc:date>2010-07-17T10:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic function module call</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-function-module-call/m-p/7041625#M1500734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello friend,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please refer to following example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT ZDANY_DYN_FM_CALL.

*The constants and structures required to use the dynamic function call

*is stored in the type pool ABAP.

type-pools abap.


*This is the name of the function you want to call.

data NAME type STRING value `READ_SPFLI_INTO_TABLE`.


* Parameter table, where you store all parameters, importing, exporting 

* and changing data PARA_TAB type ABAP_FUNC_PARMBIND_TAB. data PARA_LINE like line of PARA_TAB.


* Exception table to handle the exception that can occur during the

* execution of the function

data EXCP_TAB type ABAP_FUNC_EXCPBIND_TAB.

data EXCP_LINE like line of EXCP_TAB.


data CARRIER type SPFLI-CARRID.

data JTAB type SPFLI_TAB.

CARRIER = 'XYZ'.


* Name of the first parameter

PARA_LINE-NAME = 'ID'.


* type of the first parameter, could be :

* abap_func_exporting value 10,

* abap_func_importing value 20,

* abap_func_tables value 30,

* abap_func_changing value 40.

PARA_LINE-KIND = ABAP_FUNC_EXPORTING.


*We need the datatype of the parameter to pass

get reference of CARRIER into PARA_LINE-VALUE.

append PARA_LINE to PARA_TAB.


*Same thing for parameter 2

PARA_LINE-NAME = 'ITAB'.

PARA_LINE-KIND = ABAP_FUNC_IMPORTING.

get reference of JTAB into PARA_LINE-VALUE.

append PARA_LINE to PARA_TAB.


*Now we create the possible exceptions

EXCP_LINE-NAME = 'NOT_FOUND'.

EXCP_LINE-VALUE = 1.

insert EXCP_LINE into table EXCP_TAB.

EXCP_LINE-NAME = 'OTHERS'.

EXCP_LINE-VALUE = 4.

insert EXCP_LINE into table EXCP_TAB.


*... and we dynamically call the function with the parameter-table and

* exception-table addition

call function NAME   parameter-table      PARA_TAB   exception-table      EXCP_TAB.

* We check the result codecase SY-SUBRC.   when 1.      message id SY-MSGID type SY-MSGTY number SY-MSGNO.   when 2.      message E888(SABAPDOCU) with 'Error in function module'.endcase.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Jul 2010 13:10:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-function-module-call/m-p/7041625#M1500734</guid>
      <dc:creator>JerryWang</dc:creator>
      <dc:date>2010-07-17T13:10:27Z</dc:date>
    </item>
  </channel>
</rss>

