Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Is it possible to create a Functional module dynamically?

Former Member
0 Likes
705

Hello All,

Does any one know whether is it possible to create a FM dynamically and write some code in it?

Regards,

Lisa.

1 ACCEPTED SOLUTION
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
582

Hi,

Yes it is possible.

Use this FM to create a function module on the fly programatically.

RS_FUNCTIONMODULE_INSERT.

Here is an example

Here an example how to call it:


call function 'RS_FUNCTIONMODULE_INSERT'                                                    
  exporting                                                                                
funcname                      = '/TEST40P/FB_TEST_EVE99'                                
    function_pool                 = 'CRAS1'                                                 
*   INTERFACE_GLOBAL              = ' '                                                     
*   REMOTE_CALL                   = ' '                                                     
    short_text                    = 'TEST Anlage FB'                                        
   suppress_corr_check           = ' '                -----------------> means with transport popup                                                  
   update_task                   = '1'                                                      
*   corrnum                       = 'B20K8A0V3F'                                            
   namespace                     = '/TEST40P/'                                              
*   suppress_language_check       = 'X'                                                     
*   AUTHORITY_CHECK               = 'X'                                                     
*    save_active                   = ' '                                                    
    new_source                    = it_report[]                                             
* IMPORTING                                                                                
*   FUNCTION_INCLUDE              =                                                         
*   CORRNUM_E                     =                                                         
 tables                                                                                
import_parameter              = if_import                                                
   export_parameter              = if_export                                                
   tables_parameter              = if_tables                                                
   changing_parameter            = if_change                                                
   exception_list                = if_except                                                
   parameter_docu                = if_docu_tab                                              
*   SOURCE                        =                                                         
 exceptions                                                                                
double_task                   = 1                                                        
   error_message                 = 2                                                        
   function_already_exists       = 3                                                        
   invalid_function_pool         = 4                                                        
   invalid_name                  = 5                                                        
   too_many_functions            = 6                                                        
   no_modify_permission          = 7                                                        
   no_show_permission            = 8                                                        
   enqueue_system_failure        = 9                                                        
   canceled_in_corr              = 10                                                       
   others                        = 11.

Regards,

Sesh

3 REPLIES 3
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
583

Hi,

Yes it is possible.

Use this FM to create a function module on the fly programatically.

RS_FUNCTIONMODULE_INSERT.

Here is an example

Here an example how to call it:


call function 'RS_FUNCTIONMODULE_INSERT'                                                    
  exporting                                                                                
funcname                      = '/TEST40P/FB_TEST_EVE99'                                
    function_pool                 = 'CRAS1'                                                 
*   INTERFACE_GLOBAL              = ' '                                                     
*   REMOTE_CALL                   = ' '                                                     
    short_text                    = 'TEST Anlage FB'                                        
   suppress_corr_check           = ' '                -----------------> means with transport popup                                                  
   update_task                   = '1'                                                      
*   corrnum                       = 'B20K8A0V3F'                                            
   namespace                     = '/TEST40P/'                                              
*   suppress_language_check       = 'X'                                                     
*   AUTHORITY_CHECK               = 'X'                                                     
*    save_active                   = ' '                                                    
    new_source                    = it_report[]                                             
* IMPORTING                                                                                
*   FUNCTION_INCLUDE              =                                                         
*   CORRNUM_E                     =                                                         
 tables                                                                                
import_parameter              = if_import                                                
   export_parameter              = if_export                                                
   tables_parameter              = if_tables                                                
   changing_parameter            = if_change                                                
   exception_list                = if_except                                                
   parameter_docu                = if_docu_tab                                              
*   SOURCE                        =                                                         
 exceptions                                                                                
double_task                   = 1                                                        
   error_message                 = 2                                                        
   function_already_exists       = 3                                                        
   invalid_function_pool         = 4                                                        
   invalid_name                  = 5                                                        
   too_many_functions            = 6                                                        
   no_modify_permission          = 7                                                        
   no_show_permission            = 8                                                        
   enqueue_system_failure        = 9                                                        
   canceled_in_corr              = 10                                                       
   others                        = 11.

Regards,

Sesh

Read only

0 Likes
582

Hi,

Could you please explain me a little bit about parameters.

Regards,

Lisa.

Read only

0 Likes
582

Hi

I have given comments for most used paramters

you can get the type of the parameters from SE37.


 exporting                                                                                
funcname                      = '/TEST40P/FB_TEST_EVE99'    " Function module name                            
    function_pool                 = 'CRAS1'  "Function group name                                                 
*   INTERFACE_GLOBAL              = ' '                                                     
*   REMOTE_CALL                   = ' '                                                     
    short_text                    = 'TEST Anlage FB'       "Shorttext from the Function module                                 
   suppress_corr_check           = ' '              " To supress any request for Transport reuqest  popup                                                  
   update_task                   = '1'                                                      
*   corrnum                       = 'B20K8A0V3F'                                            
   namespace                     = '/TEST40P/'   " This is optional and used to supply the namespace                                            
*   suppress_language_check       = 'X'                                                     
*   AUTHORITY_CHECK               = 'X'                                                     
*    save_active                   = ' '                                                    
    new_source                    = it_report[]   " If alreayd existing FM new source code for it                                           
* IMPORTING                                                                                
*   FUNCTION_INCLUDE              =      " Function module include that gets generated                                                   
*   CORRNUM_E                     =                                                         
 tables                                                                                
import_parameter              = if_import     " Function moduels import paramters                                           
   export_parameter              = if_export     " export paramters                                           
   tables_parameter              = if_tables     " Tables parameteers of the FM to be generated                                           
   changing_parameter            = if_change    "changing parameters                                            
   exception_list                = if_except        " Exception list                                        
   parameter_docu                = if_docu_tab   " Documentation of the paramters                                           
*   SOURCE                        =  " Table containing the Source code of the FM to be generated                                                        

Regards,

Sesh