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

doubt in methods !

Former Member
0 Likes
277

Hi..,

what are dynamic method calls ?

what is the parameter table ?

when we have to go these functionalities ?

i know that parameter table are used along with dynamic method calls.!

what is the use of parameter table using along with Dynamic method calls ?

pls.., tell me about them briefly with Examples ?

Regard's

Rajesh.!

Edited by: rajesh k on Mar 2, 2008 5:17 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
252

hi,

Dynamic Method Call

Using the standard ABAP parenthesis semantics you can call methods dynamically.

· Calling an instance method meth:

CALL METHOD ref->(f)

· Calling a static method meth:

CALL METHOD class=>(f)

CALL METHOD (c)=>meth

CALL METHOD (c)=>(f)

· Calling a user-defined method meth:

CALL METHOD (f)

CALL METHOD ME->(f)

Here, f and c are fields containing the name of the method meth or of the class class. Unlike subroutines and function modules, a dynamic method call allows you to pass the actual parameters dynamically as well. To do this, you use the additions PARAMETER-TABLE and EXCEPTION-TABLE of the CALL METHOD statement:

CALL METHOD ... PARAMETER-TABLE ptab

EXCEPTION-TABLE etab.

The parameter table ptab must be a hash table of the table type ABAP_PARMBIND_TAB or of the line type ABAP_PARMBIND. These types are defined in the ABAP Dictionary. The table has the following three columns:

· NAME for the name of the formal parameter

· KIND for the type of parameter passing

· VALUE of the type REF TO DATA for the value of the actual parameter

The NAME column is the unique table key. For each non-optional parameter you must fill exactly one line of the internal table. For each optional parameter you can do this, but are not forced to.

The type of parameter passing is determined in the declaration of the method called for each formal parameter.

The exception table etab must be a hash table of the table type ABAP_EXCPBIND_TAB or of the line type ABAP_EXCPBIND. These types are defined in the ABAP Dictionary. The table has the following two columns:

· NAME for the name of the exception

· VALUE of type i for the value to be assigned to sy-subrc

The NAME column is the unique table key. For each exception, you can fill exactly one line of the internal table. The VALUE component is assigned the numeric value to appear in sy-subrc after the exception is triggered.

Hope this helps, Do reward.

1 REPLY 1
Read only

Former Member
0 Likes
253

hi,

Dynamic Method Call

Using the standard ABAP parenthesis semantics you can call methods dynamically.

· Calling an instance method meth:

CALL METHOD ref->(f)

· Calling a static method meth:

CALL METHOD class=>(f)

CALL METHOD (c)=>meth

CALL METHOD (c)=>(f)

· Calling a user-defined method meth:

CALL METHOD (f)

CALL METHOD ME->(f)

Here, f and c are fields containing the name of the method meth or of the class class. Unlike subroutines and function modules, a dynamic method call allows you to pass the actual parameters dynamically as well. To do this, you use the additions PARAMETER-TABLE and EXCEPTION-TABLE of the CALL METHOD statement:

CALL METHOD ... PARAMETER-TABLE ptab

EXCEPTION-TABLE etab.

The parameter table ptab must be a hash table of the table type ABAP_PARMBIND_TAB or of the line type ABAP_PARMBIND. These types are defined in the ABAP Dictionary. The table has the following three columns:

· NAME for the name of the formal parameter

· KIND for the type of parameter passing

· VALUE of the type REF TO DATA for the value of the actual parameter

The NAME column is the unique table key. For each non-optional parameter you must fill exactly one line of the internal table. For each optional parameter you can do this, but are not forced to.

The type of parameter passing is determined in the declaration of the method called for each formal parameter.

The exception table etab must be a hash table of the table type ABAP_EXCPBIND_TAB or of the line type ABAP_EXCPBIND. These types are defined in the ABAP Dictionary. The table has the following two columns:

· NAME for the name of the exception

· VALUE of type i for the value to be assigned to sy-subrc

The NAME column is the unique table key. For each exception, you can fill exactly one line of the internal table. The VALUE component is assigned the numeric value to appear in sy-subrc after the exception is triggered.

Hope this helps, Do reward.