2007 May 25 5:34 PM
Hi guys, I'm trying to implement a method that calls a bapi dynamically.
I try to create a type structure using RTTS and them fill each field dinamically... unfortunaly when I assign a data reference to a field symbol, casting it, it keeps giving me an error that the field symbol has no structure.
Please see the code above and give me ideias.
method CALLBAPI.
type-pools ABAP.
DATA: l_exceptionsTable TYPE ABAP_FUNC_EXCPBIND_TAB,
L_ParameterType TYPE REF TO cl_abap_structdescr,
L_ParameterTab TYPE STANDARD TABLE OF REF TO cl_abap_structdescr,
L_CompTab TYPE cl_abap_structdescr=>component_table,
L_Component TYPE CHAR30.
DATA: dref TYPE REF TO DATA.
FIELD-SYMBOLS: <l_parametersTable> TYPE ABAP_FUNC_PARMBIND,
<L_Struct_Components> TYPE abap_componentdescr,
<fs> TYPE ANY.
Get exporting Structures
LOOP AT L_PARAMETERSTABLE ASSIGNING <l_parametersTable> WHERE kind =
abap_func_exporting.
L_ParameterType ?= cl_abap_typedescr=>describe_by_name(
<l_parametersTable>-name ).
L_CompTab = L_ParameterType->get_components( ).
CREATE DATA dref TYPE HANDLE L_ParameterType.
ASSIGN dref->* TO <fs> CASTING TYPE HANDLE L_ParameterType.
LOOP AT L_CompTab ASSIGNING <L_Struct_Components>.
L_Component = <L_Struct_Components>-name.
*
number '1' is for tests purpose.
****!!!!!!!!!*****!!!!!****THIS LINE GIVES AN ERROR:
*The data object "<FS>" has no structure and therefore no component
*called "" .
<fs>-(L_Component) = '1'.
ENDLOOP.
ENDLOOP.
*... need some code here...
call function l_bapi_name
PARAMETER-TABLE
l_parametersTable
EXCEPTION-TABLE
l_exceptionsTable.
endmethod.
Message was edited by:
Luis Pereira
Message was edited by:
Luis Pereira
Message was edited by:
Luis Pereira
2007 May 25 6:08 PM
try something like this..
field-symbols : <FS> type standard stable. " change the declaration.
data : l_value(20).
Field-symbols : <FS1> type any.
l_value = (L_Component).
Assign component l_value of structure <FS> to <FS1>.
<FS1> = '1'.
Hi guys, I'm trying to implement a method that calls a bapi dynamically.
I try to create a type structure using RTTS and them fill each field dinamically... unfortunaly when I assign a data reference to a field symbol, casting it, it keeps giving me an error that the field symbol has no structure.
Please see the code above and give me ideias.
method CALLBAPI.
type-pools ABAP.
DATA: l_exceptionsTable TYPE ABAP_FUNC_EXCPBIND_TAB,
L_ParameterType TYPE REF TO cl_abap_structdescr,
L_ParameterTab TYPE STANDARD TABLE OF REF TO cl_abap_structdescr,
L_CompTab TYPE cl_abap_structdescr=>component_table,
L_Component TYPE CHAR30.
DATA: dref TYPE REF TO DATA.
FIELD-SYMBOLS: <l_parametersTable> TYPE ABAP_FUNC_PARMBIND,
<L_Struct_Components> TYPE abap_componentdescr,
<fs> TYPE ANY.
Get exporting Structures
LOOP AT L_PARAMETERSTABLE ASSIGNING <l_parametersTable> WHERE kind =
abap_func_exporting.
L_ParameterType ?= cl_abap_typedescr=>describe_by_name(
<l_parametersTable>-name ).
L_CompTab = L_ParameterType->get_components( ).
CREATE DATA dref TYPE HANDLE L_ParameterType.
ASSIGN dref->* TO <fs> CASTING TYPE HANDLE L_ParameterType.
LOOP AT L_CompTab ASSIGNING <L_Struct_Components>.
L_Component = <L_Struct_Components>-name.
*
number '1' is for tests purpose.
****!!!!!!!!!*****!!!!!****THIS LINE GIVES AN ERROR:
*The data object "<FS>" has no structure and therefore no component
*called "" .
<fs>-(L_Component) = '1'.
ENDLOOP.
ENDLOOP.
*... need some code here...
call function l_bapi_name
PARAMETER-TABLE
l_parametersTable
EXCEPTION-TABLE
l_exceptionsTable.
endmethod.
Message was edited by:
Luis Pereira
Message was edited by:
Luis Pereira
Message was edited by:
Luis Pereira
2007 May 25 6:08 PM
try something like this..
field-symbols : <FS> type standard stable. " change the declaration.
data : l_value(20).
Field-symbols : <FS1> type any.
l_value = (L_Component).
Assign component l_value of structure <FS> to <FS1>.
<FS1> = '1'.
2007 May 25 6:11 PM
Hi
The <FS> is defined TYPE ANY so you can't indicate the name of a possible field of <FS>, because the system see <FS> like a structure only at run time:
<b><fs>-(L_Component) = '1'. <----
</b>
Try to use another field-symbols:
ASSIGN COMPONENT L_COMPONENT OF STRUCTURE <FS> TO <COMP>.
IF SY-SUBRC = 0.
<COMP> = '1'.
ENDIF.Max
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |