2013 Nov 18 6:27 PM
Let me rephrase the below question:
How do we invoke any method that has an EXPORTING of type ANY or ANY TABLE?
If we try to import the data into a generic variable, the activation fails with an error message (image attached).
data lo_row_content type data.
mo_context->GET_ROW( importing es_row = lo_row_content ).
My thought was to get data into lo_row_content and then use RTTI to querry the type and cast it.
But evidently that is not the right approach as the activation itself fails.
-------------I tried to post an update to my earlier discussion but for some reason the update did not show up. Hence RE-posting-----------------------
Original post: http://scn.sap.com/thread/3456080
R
2013 Nov 20 12:52 PM
Sasha, Mathew, Sreenevasa and Arindam,
Thanks a lot for all your inputs.
Let me highlight what I tried based on your responses. Then I'll add more information relevant to your inputs:
1. TYPE REF TO data.
data lo_row_content type ref to data.
mo_context->GET_ROW( importing es_row = lo_row_content ).
The code got activated, but resulted in runtime error "Invalid operand type for the MOVE-CORRESPONDING statement."
2. I tried ANY TABLE and it would not activate.
===========================================================
The debugger option is interesting and I could use help in that area. Is there a way to find the runtime data type of object in es_row during runtime, using debugger, without actually invoking the method GET_ROW?
During debugging, I see mo_context (the variable of type /PLMU/CL_FRW_G_CONTEXT_SINGLE) having the user input values within a variable called MR_DATA_BUFFER (which is not defined public). I'm just trying to figure a way to get those values out.
Related methods SET_ROW and ADD_ROW (images attached) do exist. But the variable IS_ROW is generic type. Quite understandably so, as the class should be able to handle values of various type of UIBB context during runtime. Again this is a FPM based MDG application.
Regards,
R
Let me rephrase the below question:
How do we invoke any method that has an EXPORTING of type ANY or ANY TABLE?
If we try to import the data into a generic variable, the activation fails with an error message (image attached).
data lo_row_content type data.
mo_context->GET_ROW( importing es_row = lo_row_content ).
My thought was to get data into lo_row_content and then use RTTI to querry the type and cast it.
But evidently that is not the right approach as the activation itself fails.
-------------I tried to post an update to my earlier discussion but for some reason the update did not show up. Hence RE-posting-----------------------
Original post: http://scn.sap.com/thread/3456080
R
2013 Nov 18 9:09 PM
2013 Nov 18 11:06 PM
Hi Roger,
Use field symbols as below
FIELD-SYMBOLS <lo_row_content> TYPE data.
or
FIELD-SYMBOLS <lo_row_content> TYPE any.
and use this filed symbol in RTTI
we cannot define like
data lo_row_content type data in any programme except interface of programme
but we can define
data lo_row_content type ref to data.
If you define as above follow below.
assign lo_row_content->* to <Field symbol type any>
and use <Field symbol type any> in rtti
Regards,
Sreenivas.
2013 Nov 19 7:25 AM
I removed your original post.
A method with an exporting type of any or any table, may be invoked - at least syntactically - with any structure/table with a concrete type. Type ANY means anything that hasn't been defined as a table type. Type ANY TABLE means anything that is an internal table - whether STANDARD, HASHED or SORTED.
Semantically, though, the method may be expecting to export something with constraint on the structure. For ANY, it may require a non-deep structure for example. Presumably it is expecting a type that is the same that was used with SET_ROW or ADD_ROW.
2013 Nov 19 1:44 PM
Hi Roger,
it is not possible to create a generic variable in your scenario as adviced in some of the postings before, you need to know the correct type. That means that even if you would create a field-symbols with type any it will fail and as long a the importing value isn't a data refeference you cannot work with "type ref to". So we come to the reply of Matthew.
It really gives you the basics what you can expect and what should be looked at to understand what kind of data type you might need. At the end, if no corresponding method exists (i.e. SET_ROW etc.) from where you can get an idea about the expecting data type you need to debug or at least look inside the method. In your example you retrieve any type from a GET METHOD, so assuming that there is a SET METHOD you should get the data type. I have the feeling that a method GET_ROW is returning something like a SY-TABIX or ROW_ID or something similiar within the WD* name range?
Hope this helps.
regards, Sascha
2013 Nov 20 12:52 PM
Sasha, Mathew, Sreenevasa and Arindam,
Thanks a lot for all your inputs.
Let me highlight what I tried based on your responses. Then I'll add more information relevant to your inputs:
1. TYPE REF TO data.
data lo_row_content type ref to data.
mo_context->GET_ROW( importing es_row = lo_row_content ).
The code got activated, but resulted in runtime error "Invalid operand type for the MOVE-CORRESPONDING statement."
2. I tried ANY TABLE and it would not activate.
===========================================================
The debugger option is interesting and I could use help in that area. Is there a way to find the runtime data type of object in es_row during runtime, using debugger, without actually invoking the method GET_ROW?
During debugging, I see mo_context (the variable of type /PLMU/CL_FRW_G_CONTEXT_SINGLE) having the user input values within a variable called MR_DATA_BUFFER (which is not defined public). I'm just trying to figure a way to get those values out.
Related methods SET_ROW and ADD_ROW (images attached) do exist. But the variable IS_ROW is generic type. Quite understandably so, as the class should be able to handle values of various type of UIBB context during runtime. Again this is a FPM based MDG application.
Regards,
R
2013 Nov 20 1:18 PM
Hi Roger,
Use FIELD-SYMBOLS <lo_row_content> TYPE any
not data lo_row_content type ref to data.
Regards,
Sreenivas.
2013 Nov 20 1:28 PM
You're almost there. You just need to pass a structure which has the fields you are interested in - no field symbols, no "type any", no data references. Simply, if in the scenario where you did the debug, you'd had:
data: begin of my_data,
matnr TYPE matnr,
mtart TYPE mtart,
end of my_data.
mo_context->GET_ROW( importing es_row = my_data ).
Then, my_data-matnr would contain $159 and my_data-mtart would contain FERT.
This is a common way that generic methods work. I use this technique frequently for my generic data handling classes.
2013 Nov 20 2:10 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |