Do you have any question about this error?
Stop googling SAP errors. Use our Free Essentials plan instead - no credit card needed. Start Now →
Message type: E = Error
Message class: WER - Messages for the package WER
Message number: 158
Message text: Method could not be called dynamically
Since SAP believes that this specific error message is 'self-explanatory,' no more information has been given.The majority of messages in the SAP system have a message text, however this is frequently insufficient to comprehend or resolve the problem.
To make things easier, more detailed information is frequently added to describe the issue, how to fix it, and the necessary steps or configuration modifications.
Unfortunately, there isn't any extra information in this error notice.
First, use our AnswerBot below to get a possible cause and solution (requires a premium subscription).
Also, review the in-depth Common Questions & Answers listed below; you could discover a solution there or be able to connect with others who have faced similar challenges.
You can also try searching the SAP support portal (support.sap.com) but you need a special user ID to access it. It is possible that an SAP support note exists that provides additional details about the mistake or even steps for fixing it.
WER158
- Method could not be called dynamically ?The SAP error message WER158: Method could not be called dynamically typically occurs in ABAP Object-Oriented programming when there is an attempt to call a method dynamically (using
CALL METHOD
orCALL METHOD OF
with a method name determined at runtime), but the method call fails.
Cause
INITIAL
or not properly instantiated.Check the method name:
cl_abap_typedescr
or cl_abap_classdescr
to check if the method exists dynamically.Ensure the object reference is valid:
IS BOUND
before calling the method dynamically.Check method visibility and signature:
PUBLIC
or accessible in the current context.Use correct syntax for dynamic calls:
CALL METHOD object_ref (method_name) EXPORTING ... IMPORTING ...
CALL METHOD OF
:CALL METHOD OF object_ref method_name EXPORTING ... IMPORTING ...
Debugging:
cl_abap_classdescr=>describe_by_object
to get class info and check method existence.cl_abap_classdescr
to inspect classes and methods dynamically.CX_SY_DYNAMIC_CALL_ILLEGAL_METHOD
.DATA: obj TYPE REF TO zcl_my_class,
method_name TYPE string.
obj = NEW zcl_my_class( ).
method_name = 'MY_METHOD'.
IF obj IS BOUND.
CALL METHOD obj (method_name).
ELSE.
WRITE: 'Object not instantiated'.
ENDIF.
If MY_METHOD
does not exist or is not public, the error WER158 will occur.
If you provide the code snippet where the error occurs, I can help you pinpoint the exact issue.
Get instant SAP help. Sign up for our Free Essentials Plan.
WER157
Type &1 of parameter &2 is must be a DDIC data element
Self-Explanatory Message Since SAP believes that this specific error message is 'self-explanatory,' no more information has been given.The majority of...
WER156
Parameter &1 must be of type element, structure or table
Self-Explanatory Message Since SAP believes that this specific error message is 'self-explanatory,' no more information has been given.The majority of...
WER159
Not all obligatory parameters have been assigned a value
Self-Explanatory Message Since SAP believes that this specific error message is 'self-explanatory,' no more information has been given.The majority of...
WER160
Class method and method call signature do not match
Self-Explanatory Message Since SAP believes that this specific error message is 'self-explanatory,' no more information has been given.The majority of...
Click on this link to search all SAP messages.