2011 Apr 19 4:29 PM
Hi ,
I am working on the report that is supposed to read the tables dinamically for that we are using
field simbol of type table that holds table name during runtime.
field-symbols <ft> type table.
At the given moment in program I have to declare internal table and structure that have the same structure as
the table in field simbol.
Please can you advice how i can do it as in the field simbol values are changing .
Thanks
2011 Apr 20 7:42 AM
Hi Krsto,
I assume you are trying to create internal table from a field catalog using the class cl_alv_table_create.
data : lt_dyn_tab TYPE REF TO data.
FIELD-SYMBOLS : <fs_dyn_tab> TYPE STANDARD TABLE,
<fs_dyn_stru> TYPE ANY ,
<fs_dyn_stru_temp> TYPE ANY .
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_lvc_fcat
IMPORTING
ep_table = lt_dyn_tab
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc = 0.
ASSIGN lt_dyn_tab->* TO <fs_dyn_tab>.
ENDIF.
CREATE DATA ls_dyn_line LIKE LINE OF <fs_dyn_tab>.
ASSIGN ls_dyn_line->* TO <fs_dyn_stru>.
ASSIGN COMPONENT 'UMSKZ' OF STRUCTURE <fs_dyn_stru> TO <fs_fieldname>.
<fs_fieldname> = <fs_bsik>-zumsk.
APPEND <fs_dyn_stru> TO <fs_dyn_tab>.
Hope this helps.
Regards,
Sagar
Hi ,
I am working on the report that is supposed to read the tables dinamically for that we are using
field simbol of type table that holds table name during runtime.
field-symbols <ft> type table.
At the given moment in program I have to declare internal table and structure that have the same structure as
the table in field simbol.
Please can you advice how i can do it as in the field simbol values are changing .
Thanks
2011 Apr 19 4:33 PM
This has been asked many times and answered many more times. Search the forum.
2011 Apr 19 4:39 PM
Hi,
try this,
parameters tab_name type dd02l-tabname.
DATA ref_itab TYPE REF TO data.
field-symbols : <fs_itab> type standard table .
CREATE DATA ref_itab TYPE STANDARD TABLE OF (tab_name) . " here tab_name is a variable which contains table name
ASSIGN ref_itab->* TO <fs_itab>.
SELECT * FROM (tab_name) INTO TABLE <fs_itab> UP TO 20 ROWS.
now <fs_itab> contains the records .
hope this helps u,
Reply if u need some more clarifications,
Thanks & Regards
Kiran
2011 Apr 20 7:42 AM
Hi Krsto,
I assume you are trying to create internal table from a field catalog using the class cl_alv_table_create.
data : lt_dyn_tab TYPE REF TO data.
FIELD-SYMBOLS : <fs_dyn_tab> TYPE STANDARD TABLE,
<fs_dyn_stru> TYPE ANY ,
<fs_dyn_stru_temp> TYPE ANY .
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_lvc_fcat
IMPORTING
ep_table = lt_dyn_tab
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc = 0.
ASSIGN lt_dyn_tab->* TO <fs_dyn_tab>.
ENDIF.
CREATE DATA ls_dyn_line LIKE LINE OF <fs_dyn_tab>.
ASSIGN ls_dyn_line->* TO <fs_dyn_stru>.
ASSIGN COMPONENT 'UMSKZ' OF STRUCTURE <fs_dyn_stru> TO <fs_fieldname>.
<fs_fieldname> = <fs_bsik>-zumsk.
APPEND <fs_dyn_stru> TO <fs_dyn_tab>.
Hope this helps.
Regards,
Sagar
2011 Apr 20 8:14 AM
Hi ,
I am creating ALV report with an option to edit and save the changes. I have table on screen user can enter any table and it will be display in alv grid. This par i s ok . Now i have to create internal table and work area as to temporary stock for the chlanges user make on the screen .Later from that internal table i will modify DB table. As the table can be ANY table, declaration of internal table and work area has to be dynamic as well.
Thanks
2011 Apr 20 8:50 AM
Hi Krsto,
If I have understood the requirement correctly this time, you want to insert the data from dynamic itab to the database table.
DATA : lo_grid TYPE REF TO cl_gui_alv_grid.
FIELD-SYMBOLS : <fs_fieldname> TYPE ANY.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = lo_grid.
CALL METHOD lo_grid->check_changed_data.
LOOP AT <fs_dyn_tab> ASSIGNING <fs_dyn_stru>.
ASSIGN COMPONENT 'BVORG' OF STRUCTURE <fs_dyn_stru> TO <fs_fieldname>.
ls_structure-xblnr = <fs_fieldname>.
APPEND ls_structure TO lt_table.
ENDLOOP.
MODIFY yfibankguar FROM TABLE lt_yfibankguar.
Hope this is helps and I have actually understood the requirement.
Regards,
Sagar
2011 Apr 20 9:07 AM
>
> I am creating ALV report with an option to edit and save the changes. I have table on screen user can enter any table and it will be display in alv grid. This par i s ok . Now i have to create internal table and work area as to temporary stock for the chlanges user make on the screen .
Hello,
Are you using CL_GUI_ALV_GRID to display the ALV? If yes, the changes are stored in the attribute MT_MOD_CELLS of the class CL_ALV_CHANGED_DATA_PROTOCOL. You get the instance of this class when you handle the method DATA_CHANGED of CL_GUI_ALV_GRID!
So why do you need to store the data in a temporary table?
BR,
Suhas
2011 Apr 20 9:11 AM
Hi,
I think we are aproaching to solution , but still i need some clarifications.
There is my code.
loop at gi_index_rows into g_selected_row.
if sy-tabix = 1.
read table <ft> index g_selected_row-index into gw_select .
endif.
endloop.
move-corresponding gw_select to gt_select.
modify "DB Table" from gt_select.
- <ft> is dynamically declared table displayed in ALV Grid
- user has changed one or more lines in ALV grid and wants to save the changes
- read <ft> table with the index of the changed row INTO work area gw_select .
- move gw_select to gt_select and modify DB table from gt_select.
The problem is how to declare dynamically gw_select and gt_select.
SO I need work area and internal table having the same structure as
actual table in the time of execution.
This is one of combinations I tried.Most of the time i am getting error
saying that gw_select is not a structure or internal table.
field-symbols <ft> type standard table.
data gt_select type ref to data.
data gw_select type ref to data.
create data gt_select like standard table of <ft>.
create data gw_select like line of <ft> .
Thanks.
2011 Apr 20 12:26 PM
Hi ,
I am using temp storage because in example I found they did change/save in this manner.
If you have an example of please let me know where to find it.
Thanks
Edited by: Krsto Gjergja on Apr 20, 2011 1:31 PM
2011 Apr 20 12:27 PM
Hi ,
Do you have anu example ? I am using this method because i found an exampe BCALV_GRID_EDIT*
Thanks