02-20-2014 10:57 AM
Hi experts,
I have created a global class which has a method in it. Now I want to go to se93 and create a class based transaction for my global class. However, on creating the transaction and executing it, I am getting a runtime error stating "A mandatory parameter was not populated when dyn. calling a method". Please tell me the cause of this error and how I should rectify it. I have attached the screen shots for your reference.
Regards.
Manish.
Below is my class with method get_data having the following 3 parameters.
I created a transaction in se93 .
I am getting the following runtime error.
I have also attached the code for my method .
02-20-2014 1:27 PM
02-21-2014 5:29 AM
Hi Manish,
I did try your approach, but now the t-code is not running at all after making i_vbeln an optional parameter.
02-21-2014 5:42 AM
02-21-2014 5:49 AM
Hi Nabheet,
The code inside the get_data method is there as an attachment in my thread. In case its not visible, here is the below code:
METHOD GET_DATA .
DATA: LT_VBAP TYPE STANDARD TABLE OF ZVBAPSTR.
FIELD-SYMBOLS: <FS_VBAP> TYPE ZVBAPSTR.
SELECT VBELN
POSNR
MATNR
FROM VBAP
INTO TABLE LT_VBAP
WHERE VBELN = I_VBELN.
IF SY-SUBRC IS INITIAL.
LOOP AT LT_VBAP ASSIGNING <FS_VBAP>.
IF <FS_VBAP>-MATNR = 'M-01'.
E_FLAG = 'X'.
MESSAGE 'MATERIAL NUMBER M-01 EXISTS' TYPE 'S' .
ELSE.
E_FLAG = ''.
ENDIF.
ENDLOOP.
ELSE.
MESSAGE 'SALES ORDER DOESNT EXIST' TYPE 'E'.
ENDIF.
ET_VBAP = LT_VBAP.
ENDMETHOD.
Regards.
Manish.
02-21-2014 6:13 AM
Manish
What is the declaration you have done for method of the class..? Did you put a break point on select statement and tried executing it from SE93?
For me it works it display error message as no data is found
Nabheet
02-21-2014 7:04 AM
Hi Nabheet,
I did not call the method from any program. I executed it from se24 and it is working. But after I execute the t-code, it is giving the runtime error as I mentioned in the thread. Did you create a transaction and execute it from se93?
Manish
02-21-2014 7:23 AM
You can't pass any parameter in the method. Remove all the parameters in the signature.
For testing , just keep the error message 'Sales order does not exist' and then call it via SE93.
02-21-2014 7:45 AM
Yes i executed it from SE93 via tcode. Please attach screen shots of method declaration/its parameters
Nabheet
02-21-2014 11:30 AM
Hi,
below is the screenshot of the parameters that I declared.
Manish
02-21-2014 5:39 AM
Hi,
By the way, is it for academic purpose . Are you working on object services which manages OO transactions ( OO transaction model checkbox is ticked ). If not, remove the tick mark.
Second question, what does the method GET_DATA do. How are you displaying the results - are you calling any ALV FM's or classes inside the method. If you want to test whether it is calling the transaction, put a breakpoint in your method and see whether it is getting called, when you execute the transaction.
Another option, you can try is create a program with local class, write the data display logic or update database logic and fill the relevant details. In the transaction, fill the program name and local method name.
Regards,
DPM
02-21-2014 5:55 AM
Hi Debopriyo,
Yes, it is only for my learning purpose. The code for get_data method has been attached with my thread, else please refer to the above reply wherein I have pasted the code for your kind reference. I am not calling any FMs, I just want to see if the method runs or not after executing the t-code. When I execute the method from my class, I debugged it and saw that the method was working fine (even though there is an issue with the flag not being displayed). Only after executing the t-code am I getting the runtime error.
I have seen a similar example in the internet with a local class, but I want to know how to execute a t-code for a method of a global class.
Regards.
Manish.
02-21-2014 6:01 AM
I am not sure about this. But, one of my colleagues had told me once that in a method or function module, you need a container to display the results. Kindly check the 'POPUP*' FM or any method's which display output. Otherwise, instead of displaying the result , you can update a custom Z database table.
02-21-2014 10:34 AM
02-21-2014 11:23 AM
Hi ,
It seems what you are suggesting is correct that I ahve to hold the data in a container to display them. So I made a slight modification in my method which I have pasted below. What I have done is I have displayed them using the FM 'Reuse_alv_grid_display'. However, the same problem still persists i.e the method is executing from se24 and gets displayed via the FM but on executing the tcode, I am getting the same runtime error.
METHOD GET_DATA .
TYPE-POOLS: SLIS.
DATA: LT_VBAP TYPE STANDARD TABLE OF ZVBAPSTR,
LT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT TYPE SLIS_FIELDCAT_ALV.
FIELD-SYMBOLS: <FS_VBAP> TYPE ZVBAPSTR.
SELECT VBELN
POSNR
MATNR
FROM VBAP
INTO TABLE LT_VBAP
WHERE VBELN = I_VBELN.
IF SY-SUBRC IS INITIAL.
LOOP AT LT_VBAP ASSIGNING <FS_VBAP>.
IF <FS_VBAP>-MATNR = 'M-01'.
E_FLAG = 'X'.
MESSAGE 'MATERIAL NUMBER M-01 EXISTS' TYPE 'S' .
ELSE.
E_FLAG = ''.
ENDIF.
ENDLOOP.
ELSE.
MESSAGE 'SALES ORDER DOESNT EXIST' TYPE 'E'.
ENDIF.
ET_VBAP = LT_VBAP.
WA_FCAT-COL_POS = '1'.
WA_FCAT-TABNAME = 'ET_VBAP'.
WA_FCAT-FIELDNAME = 'VBELN'.
WA_FCAT-SELTEXT_L = 'SALES ORDER'.
APPEND WA_FCAT TO LT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '2'.
WA_FCAT-TABNAME = 'ET_VBAP'.
WA_FCAT-FIELDNAME = 'POSNR'.
WA_FCAT-SELTEXT_L = 'LINE ITEM'.
APPEND WA_FCAT TO LT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '3'.
WA_FCAT-TABNAME = 'ET_VBAP'.
WA_FCAT-FIELDNAME = 'MATNR'.
WA_FCAT-SELTEXT_L = 'MATERIAL NUMBER'.
APPEND WA_FCAT TO LT_FCAT.
CLEAR WA_FCAT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-CPROG
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
IT_FIELDCAT = LT_FCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ET_VBAP
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMETHOD.
On executing from se24, I am getting the output perfectly as shown below.
Regards.
Manish.
02-21-2014 11:31 AM
Hi,
You can't pass any parameters in the signature of the method . There are some restrictions. Remove the parameters, it should work fine.
Regards,
DPM
02-21-2014 11:40 AM
Nope, on removing the parameters the dump isnt coming, but the program is not giving the correct output. Moreover, why cant we give parameters in such methods which are calles via a transaction?
02-21-2014 12:53 PM
Hi,
As per the link, I changed my importing parameter , i_vbeln, as optional from mandatory, however the table et_vbap which is used for displaying the results is not getting populated.
Manish.
02-21-2014 1:39 PM
The idea is simple. When you run it using transaction, i_vbeln is optional, and blank during the call.
Your select query is having where clause as where vbeln = i_vbeln.
Since i_vbeln is blank, program does not find any match.
You can use existing query when i_vbeln has a value, and as when it is blank, change query to remove the where clause and add up to 100 rows. This way when i_vbeln is blank, program will just read up to 100 or 1000 or entire records.
02-21-2014 2:15 PM
You are right 🙂 But what if I have to use the where clause in my select query, how can I run the transaction, as I can only put optional import parameters?
Manish
02-21-2014 2:39 PM
Manish Malakar wrote:
. Moreover, why cant we give parameters in such methods which are calles via a transaction?
You are attempting to call a method that requires a parameter, from a type of transaction doesn't allow parameters.
You seriously expect this to work? How were you thinking of supplying the parameter to the transaction? Magic? Telepathy?
02-24-2014 5:28 AM
So, my question is that will I be able to call a method with parameters via a transaction or not? I do have my method which requires an importing parameter; so I will not be able to call it via a transaction?
02-24-2014 6:34 AM
Which part of my above answer was unclear?
No - you cannot create an OO transaction that calls a method with a parameter. You must create some kind of mechanism to prompt for the parameter - either a classic selection-screen (and a report transaciton) that then calls your method, or calling a function module from within your method that prompts for a parameter.
02-21-2014 12:14 PM