2007 Jul 05 12:56 PM
Hi,
I want to create a dynamic structure in SE11...I do not want to use BDC...Is there any other Way to create????
Regards
Jiku
2007 Jul 05 1:02 PM
Hi,
You cant create dynamic structures in SE11..Its a global one..
Dynamic in the sense, you need to change the structure according to the requirement and thats done during run time..
You can do it programatically..
declare a structure in SE11 and in your program you can add more fields to that structure in run time..
rewards if useful,
regards,
nazeer
Hi,
You cant create dynamic structures in SE11..Its a global one..
Dynamic in the sense, you need to change the structure according to the requirement and thats done during run time..
You can do it programatically..
declare a structure in SE11 and in your program you can add more fields to that structure in run time..
rewards if useful,
regards,
nazeer
2007 Jul 05 12:58 PM
2007 Jul 05 1:00 PM
I want to create a structure with my fields programatically...
2007 Jul 05 1:02 PM
Hi,
You cant create dynamic structures in SE11..Its a global one..
Dynamic in the sense, you need to change the structure according to the requirement and thats done during run time..
You can do it programatically..
declare a structure in SE11 and in your program you can add more fields to that structure in run time..
rewards if useful,
regards,
nazeer
2007 Jul 05 1:11 PM
Is there any FM to create a database table / structure programatically???
2007 Jul 05 1:18 PM
Hi Jiku,
There are RTTC (Runtime Type Creation) classes which facilitates creation of structures/ internal tables (not db tables) dynamically..
Here is sample code..
DATA vfn_data type ref to data.
DATA: lt_comp_tab TYPE abap_component_tab,
ls_comp TYPE LINE OF abap_component_tab.
DATA: lv_data_descr TYPE REF TO cl_abap_datadescr,
lv_type_descr TYPE REF TO cl_abap_typedescr,
lv_stru_descr TYPE REF TO cl_abap_structdescr.
lt_scenario_param is internal table which contains field names (param_id) and corresponding DDIC types (param_type)
LOOP AT lt_scenario_param INTO ls_scenario_param.
lv_data_descr ?= cl_abap_datadescr=>describe_by_name( p_name = ls_scenario_param-param_type ) .
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ls_comp-name = ls_scenario_param-param_id.
ls_comp-type = lv_data_descr.
APPEND ls_comp TO lt_comp_tab.
CLEAR: ls_comp.
ENDLOOP.
*TRY.
lv_stru_descr ?= cl_abap_structdescr=>create( p_components = lt_comp_tab ).
CATCH CX_SY_STRUCT_CREATION .
*ENDTRY.
CREATE DATA vfn_data TYPE HANDLE lv_stru_descr.
vfn_data is your dynamic structure!
Dynamic creation of database tables (basically data definition statements) are not possible in SAP.. you need to use data dictionary for this activity (not dynamic!)
Regards,
Abhijit
2007 Jul 05 1:19 PM
Hi,
You can create a strcutre dynamically as follows.
ls_comp-name = "COMPONENT_NAME.
ls_comp-type = cl_abap_elemdescr=>get_string( ).
APPEND ls_comp TO lt_comp.
*Add as many fields as you want using APPENDS.
DATA: lr_rtti_struc TYPE REF TO cl_abap_structdescr.
DATA: lt_comp TYPE cl_abap_structdescr=>component_table.
DATA: ls_comp LIKE LINE OF lt_comp.
CALL METHOD cl_abap_structdescr=>create
EXPORTING
p_components = lt_comp
p_strict = abap_false
RECEIVING
p_result = lr_rtti_struc.
You can create a DATA of that type using the below line.
CREATE DATA lr_data TYPE HANDLE lr_rtti_struc.
But if you know the fields you can as well create using
DATA: Begin of STRUCT,
*Your fields here
DATA: END OF STRUCT.
Regards,
Sesh
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |