Home ABAP Tutorials Dynamic Programming Dynamic Method calls in ABAP
Dynamic Method calls in ABAP PDF Print E-mail
User Rating: / 2
PoorBest 
ABAP Tutorials - Dynamic Programming
Written by mastram   
Tuesday, 12 August 2008 09:29

I always wondered if we can code some dynamic method calls in ABAP. So I tried and to my surprise, it was possible !!

Well its kinda simple only but sometimes it can be tricky also. The method name can be taken into a variable and called by placing it in brackets. But how to handle the prametes ! This is tricky.. The below code snippet shows how to do this..

TYPE-POOLS abap.

DATA : lv_control   TYPE seoclsname VALUE 'CL_GUI_ALV_GRID',
           lt_par_tab   TYPE abap_parmbind_tab,
           ls_param     LIKE LINE OF lt_par_tab,
           lv_data       TYPE REF TO data.

**  Prepare the Parameters table..
**  Here I am passing a object as an exporting parameter

    ls_param-name = 'I_PARENT'.
    ls_param-kind = 'E'.
    GET REFERENCE OF lref_cont INTO lv_data.
    ls_param-value = lv_data.
    INSERT ls_param INTO TABLE lt_par_tab.

**  Now create ALV Control.
    CREATE OBJECT lref_alv_ctrl
      TYPE
        (lv_control)
      PARAMETER-TABLE
        lt_par_tab.

Similarly you can pass many parameters and call methods also.

An complete example code is provided in the Example codes section.

Comments
Add New Search
Write comment
Name:
Email:
 
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 

Advertisement

 

Google Search

Advertisement