2011 Jan 14 3:53 PM
Hello guys,
i use the method go_alv_grid->set_table_for_first_display
the table going to be passed to that function needs to be type of standard table.
Now, i have a table of type sorted table, and that leads to a type conflict.
is there a way to cast my sorted table to a standard table ?
thanks for help,
sven
2011 Jan 14 4:00 PM
Create a standard table with same type and pass the sorted table to standard internal table.e.g.
data : itab_sort type SORTED TABLE OF mara WITH UNIQUE KEY matnr,
itab_std type TABLE OF mara .
........................................
itab_std = itab_sort.
Hello guys,
i use the method go_alv_grid->set_table_for_first_display
the table going to be passed to that function needs to be type of standard table.
Now, i have a table of type sorted table, and that leads to a type conflict.
is there a way to cast my sorted table to a standard table ?
thanks for help,
sven
2011 Jan 14 4:00 PM
Create a standard table with same type and pass the sorted table to standard internal table.e.g.
data : itab_sort type SORTED TABLE OF mara WITH UNIQUE KEY matnr,
itab_std type TABLE OF mara .
........................................
itab_std = itab_sort.
2011 Jan 14 4:14 PM
oh i forgot to say, i'm using field symbols, and my table is dynamic
i tried:
FIELD-SYMBOLS:
<FS_1> TYPE SORTED TABLE,
<FS_1a> type STANDARD TABLE,...
<FS_1> = <FS_1a>.
CALL METHOD go_alv_grid->set_table_for_first_display
EXPORTING
is_layout = layout
CHANGING
it_outtab = <FS_1a>
it_fieldcatalog = LT_FIELDCATALOG.
+
it does not work , i still get a exception
2011 Jan 14 11:44 PM
Hi Sven,
Say your sorted table is assigned to <TSORT>, then I would do
field-symbols:
<rec> type any.
<TSTD> type table.
data:
lr_data type ref to data.
* read any record of sorted table
read table <tsort> assigning <rec> index 1.
* make surte table isn't empty
check sy-subrc = 0.
* create standard table of this structure
create data lr_data like table of <rec>.
* assign to field-symbol
assign lr_data->* to <TSTD>.
* move sorted to standard table
<TSTD> = <TSORT>.
* free unuesed memory (optional)
free <TSORT>.
* grid display <TSTD>
Regards,
Clemens
2011 Jan 15 8:02 AM
If you need the standard table to be defined even if the sorted table is empty, use:
DATA: lr_data TYPE REF TO DATA.
FIELD-SYMBOLS: <ls_record> TYPE ANY,
<lt_standard> TYPE STANDARD TABLE.
CREATE DATA lr_data LIKE LINE OF <sorted_table>.
ASSIGN lr_data->* TO <ls_record>:
CREATE DATA lr_data LIKE STANDARD TABLE OF <ls_record>.
ASSIGN lr_data->* TO <lt_standard>.
<lt_standard> = <lt_sorted>.If you ever go the other way - from a standard table to a sorted or hashed, or a hashed to a sorted, or sorted to a hashed, or a sorted/hashed table with a different key, use
INSERT LINES OF <source_table> INTO TABLE <destination_table>.matt
2011 Jan 14 6:09 PM
hey man..
do this::
data gt_sorted type sorted table of mara with unique key matnr.
data gt_standard type standard table of mara.
.
.
.
gt_standard[] = gt_sorted[].
CALL METHOD go_alv_grid->set_table_for_first_display
EXPORTING
is_layout = layout
CHANGING
it_outtab = gt_standard[]
it_fieldcatalog = LT_FIELDCATALOG.
if doesnt work try with gt_standard without [] in the set_table_for_first_display method..
Hope it works!
2011 Jan 14 6:42 PM
Your brackets are redundant in that statement based on the definition and it doesn't solve the requirement to be dynamic.
To the OP, you didn't mention the exception type but you haven't shown very much code or how your field symbols get assigned. At some point, order to get the code to compile or execute dynamically without exception, you need to provide a named external or internal type in order to use a data reference or the RTTS classes to make that move. Without some link back to the line type and sort key (whether it's 'default' or not), it's not going to work.
2011 Jan 19 2:53 AM
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |