‎2006 Aug 31 12:36 AM
Hello friends,
In ALV reports (using either cl_salv_table or cl_gui_alv_grid) I always face a problem when a drilldown is performed on sorted output list.
I retrieve the sort columns and the selected row-column values using event-handler. Now, when I sort my internal table based on the sort columns it results in different sorted order...meaning, it is not the same as the sorted-order on the screen. What could be the reason? Please help me out!
Thanks,
Sam
‎2006 Aug 31 12:51 AM
‎2006 Aug 31 12:51 AM
‎2006 Aug 31 12:59 AM
Yeah Rich, it is weird
I will post my code, please look at it and let me know where I am going wrong.
‎2006 Aug 31 1:09 AM
hi sam,
i worked on somany reports in saplabs using cl_salv* classes, i never faced such problem.
If you can send the code we will test it...
‎2006 Aug 31 9:57 PM
Sorry, I couldn't post this yesterday. Please take a look!
(There are three different sources: one main program and two includes)
REPORT ztest NO STANDARD PAGE HEADING.
INCLUDE: ztesttop,
ztest_drill_down.
*----------------------------------------------------------------------*
* START OF SELECTION *
*----------------------------------------------------------------------*
START-OF-SELECTION.
*-Get Output/Data
PERFORM get_data.
END-OF-SELECTION.
*-Display Output Data
PERFORM display_data.
*----------------------------------------------------------------------*
* GET OUTPUT DATA *
*----------------------------------------------------------------------*
FORM get_data .
SELECT ebeln bukrs ekorg ekgrp lifnr zterm
FROM ekko
INTO TABLE i_output
WHERE bsart = 'NB'.
ENDFORM. " get_data
*----------------------------------------------------------------------*
* DISPLAY DATA IN OUTPUT TABLE USING ALV OBJECT MODEL *
*----------------------------------------------------------------------*
FORM display_data.
*-Build Field Catalog
PERFORM build_catalog.
*-Assign A Reference To The Internal Table With Field Catalog
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = i_fcat
IMPORTING
ep_table = dref.
ASSIGN dref->* TO <output_table>.
<output_table> = i_output[].
*-Generate ALV Factory Object
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
list_display = if_salv_c_bool_sap=>false
IMPORTING
r_salv_table = o_alv_table
CHANGING
t_table = <output_table>.
CATCH cx_salv_msg.
ENDTRY.
*-Activate ALV Generic Functions
o_functions = o_alv_table->get_functions( ).
o_functions->set_all( abap_true ).
o_functions->set_export_xml( abap_true ).
*-Display Settings
o_display = o_alv_table->get_display_settings( ).
o_display->set_striped_pattern( abap_true ).
*-Handle Events
o_events = o_alv_table->get_event( ).
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_double_click FOR o_events.
*-Customize Columns
o_columns = o_alv_table->get_columns( ).
o_columns->set_optimize( abap_true ).
*-Set Up Report Headers
PERFORM create_headers.
*-Display The Output Table
o_alv_table->display( ).
ENDFORM. " display_data
*----------------------------------------------------------------------*
* BUILD FIELD CATALOG FOR ALV DISPLAY *
*----------------------------------------------------------------------*
FORM build_catalog .
CLEAR: wa_fcat.
REFRESH: i_fcat.
*-Purchasing Doc No
wa_fcat-col_id = '1'.
wa_fcat-fieldname = 'EBELN'.
wa_fcat-ref_field = 'EBELN'.
wa_fcat-ref_table = 'EKKO'.
wa_fcat-tabname = 'I_OUTPUT'.
APPEND wa_fcat TO i_fcat .
CLEAR wa_fcat.
*-Company Code
wa_fcat-col_id = '2'.
wa_fcat-fieldname = 'BUKRS'.
wa_fcat-ref_field = 'BUKRS'.
wa_fcat-ref_table = 'EKKO'.
wa_fcat-tabname = 'I_OUTPUT'.
APPEND wa_fcat TO i_fcat .
CLEAR wa_fcat.
*-Purchasing Org
wa_fcat-col_id = '3'.
wa_fcat-fieldname = 'EKORG'.
wa_fcat-ref_field = 'EKORG'.
wa_fcat-ref_table = 'EKKO'.
wa_fcat-tabname = 'I_OUTPUT'.
APPEND wa_fcat TO i_fcat .
CLEAR wa_fcat.
*-Purchasing Group
wa_fcat-col_id = '4'.
wa_fcat-fieldname = 'EKGRP'.
wa_fcat-ref_field = 'EKGRP'.
wa_fcat-ref_table = 'EKKO'.
wa_fcat-tabname = 'I_OUTPUT'.
APPEND wa_fcat TO i_fcat .
CLEAR wa_fcat.
*-Vendor
wa_fcat-col_id = '5'.
wa_fcat-fieldname = 'LIFNR'.
wa_fcat-ref_field = 'LIFNR'.
wa_fcat-ref_table = 'EKKO'.
wa_fcat-tabname = 'I_OUTPUT'.
APPEND wa_fcat TO i_fcat .
CLEAR wa_fcat.
*-Purchasing Term
wa_fcat-col_id = '6'.
wa_fcat-fieldname = 'ZTERM'.
wa_fcat-ref_field = 'ZTERM'.
wa_fcat-ref_table = 'EKKO'.
wa_fcat-tabname = 'I_OUTPUT'.
APPEND wa_fcat TO i_fcat .
CLEAR wa_fcat.
ENDFORM. " build_catalog
*&---------------------------------------------------------------------*
*& CREATE ALV TOP-OF-PAGE HEADERS *
*&---------------------------------------------------------------------*
FORM create_headers .
DATA: l_system(12) TYPE c.
CREATE OBJECT o_header.
o_header->create_header_information( row = 1 column = 1 text = sy-title tooltip = sy-title ).
*-Create a grid in the cell [2,1]
o_header_1 = o_header->create_grid( row = 2 column = 1 ).
*-R3 System
CONCATENATE sy-sysid sy-mandt INTO l_system SEPARATED BY space.
o_flow = o_header_1->create_flow( row = 1 column = 1 ).
o_label = o_flow->create_label( text = 'System:'(t02) tooltip = 'System:'(t02) ).
o_text = o_flow->create_text( text = l_system tooltip = l_system ).
*-User
o_flow = o_header_1->create_flow( row = 1 column = 2 ).
o_label = o_flow->create_label( text = 'User :'(t03) tooltip = 'User :'(t03) ).
o_text = o_flow->create_text( text = sy-uname tooltip = sy-uname ).
*-Date
o_flow = o_header_1->create_flow( row = 2 column = 1 ).
o_label = o_flow->create_label( text = 'Date :'(t04) tooltip = 'Date :'(t04) ).
o_text = o_flow->create_text( text = sy-datum tooltip = sy-datum ).
*-Time
o_flow = o_header_1->create_flow( row = 2 column = 2 ).
o_label = o_flow->create_label( text = 'Time :'(t05) tooltip = 'Time :'(t05) ).
o_text = o_flow->create_text( text = sy-uzeit tooltip = sy-uzeit ).
o_alv_table->set_top_of_list( o_header ).
ENDFORM. " CREATE_HEADERS
*&---------------------------------------------------------------------*
*& Include ZTESTTOP
*&---------------------------------------------------------------------*
*-------------------------------------------------------------------------------------*
* TYPES *
*-------------------------------------------------------------------------------------*
*------Document Header Data
TYPES:
*-------Output Data
BEGIN OF ty_output,
ebeln TYPE ekko-ebeln,
bukrs TYPE ekko-bukrs,
ekorg TYPE ekko-ekorg,
ekgrp TYPE ekko-ekgrp,
lifnr TYPE ekko-lifnr,
zterm TYPE ekko-zterm,
END OF ty_output,
BEGIN OF ty_sort_columns,
name TYPE lvc_fname,
order TYPE i,
END OF ty_sort_columns.
*-------------------------------------------------------------------------------------*
* INTERNAL TABLES, STRUCTURES & WORKAREAS *
*-------------------------------------------------------------------------------------*
*-----Output Data
DATA: i_output TYPE STANDARD TABLE OF ty_output,
wa_output TYPE ty_output.
*-ALV DECLARATIONS
*-----Field Catalog
DATA: i_fcat TYPE lvc_t_fcat,
wa_fcat TYPE lvc_s_fcat,
*-----Output/Display Table Object
o_alv_table TYPE REF TO cl_salv_table,
*-----Output List Sort Objects
o_sort_defined TYPE sap_bool,
o_sort_table TYPE salv_t_sort_ref,
o_sort_column TYPE salv_s_sort_ref,
i_sort_columns TYPE STANDARD TABLE OF ty_sort_columns,
wa_sort_columns TYPE ty_sort_columns,
*-----Top Of Page Objects
o_header TYPE REF TO cl_salv_form_layout_grid,
o_header_1 TYPE REF TO cl_salv_form_layout_grid,
*-----End Of List Object
o_footer TYPE REF TO cl_salv_form_layout_grid,
*-----Top Of Page & End Of List Texts/Grid Objects
o_flow TYPE REF TO cl_salv_form_layout_flow,
o_label TYPE REF TO cl_salv_form_label,
o_text TYPE REF TO cl_salv_form_text,
g_text TYPE string.
*----------------------------------------------------------------------*
* CLASS alv_æ§vent_receiver DEFINITION
*----------------------------------------------------------------------*
CLASS alv_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_double_click
FOR EVENT double_click OF cl_salv_events_table
IMPORTING row column.
PRIVATE SECTION.
ENDCLASS. "alv_event_receiver DEFINITION
*-------------------------------------------------------------------------------------*
* GLOBAL VARIABLE *
*-------------------------------------------------------------------------------------*
*-ALV DECLARATIONS
DATA : dref TYPE REF TO data,
o_functions TYPE REF TO cl_salv_functions_list,
o_events TYPE REF TO cl_salv_events_table,
o_display TYPE REF TO cl_salv_display_settings,
o_sorts TYPE REF TO cl_salv_sorts,
o_columns TYPE REF TO cl_salv_columns,
o_selections TYPE REF TO cl_salv_selections,
event_receiver TYPE REF TO alv_event_receiver,
columns_table TYPE salv_t_column_ref,
column TYPE salv_s_column_ref.
FIELD-SYMBOLS : <output_table> TYPE table,
<sort_column> TYPE string.
*&---------------------------------------------------------------------*
*& Include ZTEST_DRILL_DOWN
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
* CLASS alv_event_receiver IMPLEMENTATION *
*----------------------------------------------------------------------*
CLASS alv_event_receiver IMPLEMENTATION.
METHOD handle_double_click.
PERFORM get_sort_sequence.
PERFORM adjust_output_table.
READ TABLE i_output INDEX row INTO wa_output.
IF sy-subrc = 0.
CASE column.
WHEN 'EBELN'.
CALL FUNCTION 'ME_DISPLAY_PURCHASE_DOCUMENT'
EXPORTING
i_ebeln = wa_output-ebeln
i_enjoy = 'X'
EXCEPTIONS
not_found = 1
no_authority = 2
invalid_call = 3
preview_not_possible = 4
OTHERS = 5.
WHEN 'LIFNR'.
CALL FUNCTION 'MMPUR_VENDOR_DISPLAY'
EXPORTING
im_lifnr = wa_output-lifnr
im_ekorg = wa_output-ekorg.
ENDCASE.
ENDIF.
ENDMETHOD. "handle_double_click
ENDCLASS. "alv_event_receiver IMPLEMENTATION
*&---------------------------------------------------------------------*
*& Get Sort Sequence From ALV Output *
*&---------------------------------------------------------------------*
FORM get_sort_sequence .
DATA: l_no_of_sorts TYPE i.
*-Instantiate An Object To Handle Sorts
o_sorts = o_alv_table->get_sorts( ).
*-Get An Handler To The Sorts Defined
o_sort_defined = o_sorts->is_sort_defined( ).
IF o_sort_defined = abap_true.
o_sort_table = o_sorts->get( ).
*---Collect Sort Columns And Corresponding Order (Asc or Desc)
LOOP AT o_sort_table INTO o_sort_column.
wa_sort_columns-name = o_sort_column-columnname.
wa_sort_columns-order = o_sort_column-r_sort->get_sequence( ).
APPEND wa_sort_columns TO i_sort_columns.
CLEAR wa_sort_columns.
ENDLOOP.
ENDIF.
ENDFORM. " get_sort_sequence
*&---------------------------------------------------------------------*
*& Sort Output Table Based On ALV-Sort Columns
*&---------------------------------------------------------------------*
FORM adjust_output_table .
CONSTANTS: c_ascending TYPE i VALUE 1,
c_descending TYPE i VALUE 2.
DATA: i_pool TYPE STANDARD TABLE OF string,
wa_pool TYPE string,
l_program TYPE string,
"l_routine TYPE string VALUE 'SORT_OUTPUT',
l_message TYPE string,
l_sid TYPE string,
l_line TYPE i,
l_sort_string TYPE string,
l_mem_id TYPE char17 VALUE 'ZTEST_SORT_OUTPUT'.
l_sort_string = 'SORT I_OUTPUT BY'.
IF i_sort_columns[] IS NOT INITIAL.
*---Build The Sort Command
LOOP AT i_sort_columns INTO wa_sort_columns.
CONCATENATE l_sort_string wa_sort_columns-name INTO l_sort_string SEPARATED BY space.
CASE wa_sort_columns-order.
WHEN c_ascending.
CONCATENATE l_sort_string 'ASCENDING' INTO l_sort_string SEPARATED BY space.
WHEN c_descending.
CONCATENATE l_sort_string 'DESCENDING' INTO l_sort_string SEPARATED BY space.
ENDCASE.
ENDLOOP.
CONCATENATE l_sort_string '.' INTO l_sort_string.
*-Upload output table to memory
EXPORT i_output[] TO MEMORY ID l_mem_id.
*---Build Source For Subroutine-Pool
APPEND 'PROGRAM SUBPOOL.' TO i_pool.
APPEND 'LOAD-OF-PROGRAM.' TO i_pool.
APPEND 'FORM LOOP_AT_TAB.' TO i_pool.
APPEND 'DATA: BEGIN OF I_OUTPUT OCCURS 0,' TO i_pool.
APPEND ' ebeln TYPE ekko-ebeln,' TO i_pool.
APPEND ' bukrs TYPE ekko-bukrs,' TO i_pool.
APPEND ' ekorg TYPE ekko-ekorg,' TO i_pool.
APPEND ' ekgrp TYPE ekko-ekgrp,' TO i_pool.
APPEND ' lifnr TYPE ekko-lifnr,' TO i_pool.
APPEND ' zterm TYPE ekko-zterm,' TO i_pool.
APPEND ' END OF I_OUTPUT.' TO i_pool.
APPEND 'DATA: l_mem_id TYPE char17.' TO i_pool.
APPEND 'l_mem_id = ' & '''ZTEST_SORT_OUTPUT''.' TO i_pool.
APPEND 'IMPORT i_output[] FROM MEMORY ID l_mem_id.' TO i_pool.
APPEND 'FREE MEMORY ID l_mem_id.' TO i_pool.
APPEND l_sort_string TO i_pool.
APPEND 'ENDFORM.' TO i_pool.
GENERATE SUBROUTINE POOL i_pool NAME l_program MESSAGE l_message LINE l_line SHORTDUMP-ID l_sid.
IF sy-subrc = 0.
PERFORM ('LOOP_AT_TAB') IN PROGRAM (l_program) IF FOUND.
ELSEIF sy-subrc = 4.
MESSAGE l_message TYPE 'I'.
ELSEIF sy-subrc = 8.
MESSAGE l_sid TYPE 'I'.
ENDIF.
ENDIF.
ENDFORM. " adjust_output_table
‎2006 Sep 01 1:57 AM
Hi Sam, first I liked to say.... very nice coding It is not often that I see coding like this. Very nice.
Now to your problem, I am a little confused about the need for these two forms. Can you explain to me what is the use of these?
METHOD handle_double_click.
<b> PERFORM get_sort_sequence.
PERFORM adjust_output_table.</b>
READ TABLE i_output INDEX row INTO wa_output.
IF sy-subrc = 0.
CASE column.
WHEN 'EBELN'.
CALL FUNCTION 'ME_DISPLAY_PURCHASE_DOCUMENT'
EXPORTING
i_ebeln = wa_output-ebeln
i_enjoy = 'X'
EXCEPTIONS
not_found = 1
no_authority = 2
invalid_call = 3
preview_not_possible = 4
OTHERS = 5.
WHEN 'LIFNR'.
CALL FUNCTION 'MMPUR_VENDOR_DISPLAY'
EXPORTING
im_lifnr = wa_output-lifnr
im_ekorg = wa_output-ekorg.
ENDCASE.
ENDIF.
ENDMETHOD. "handle_double_click
That fact that you are applying a sort between the time that you double clicking and actually reading the table with row index, I think this is causing your problem. Not sure why you have this coding here.
If you did this to try to handle the sorting of your internal table, there is no need, the ALV handles this for you. Try commenting out the calls to these PERFORMS and try again. I think you will see that the row being passed to your event handler is the correct row regardless of sorting.
Regards,
RIch Heilman
‎2006 Sep 05 6:11 PM
Well, what can I say! I am greatly excited & happy to hear this from you! Thanks much
I did comment out those those performs and tried again. But it didnt work. Is there something wrong in the way I declare my internal table? I am confused!
‎2006 Sep 05 6:26 PM
Sam,
I have encountered the same issue.
Change this statement:
l_sort_string = 'SORT I_OUTPUT BY'.
to
l_sort_string = 'SORT I_OUTPUT STABLE BY'.
‎2006 Sep 05 7:57 PM
No luck this time too!
Rich / John - If you have any working code, can I please look at it?
‎2006 Sep 05 9:01 PM
Sure check this sample.
report ZTE_DEMO_2.
data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions_list.
data: gr_display_settings type ref to cl_salv_display_settings.
data: gr_columns type ref to cl_salv_columns.
data: gr_column type ref to cl_salv_column.
data: gr_selections type ref to cl_salv_selections.
data: gr_sorts type ref to cl_salv_sorts.
data: gr_sort type ref to cl_salv_sort.
data: gr_agg type ref to cl_salv_aggregations.
data: gr_events type ref to cl_salv_events_table.
data: gr_dialog_table type ref to cl_salv_table.
*----------------------------------------------------------------------*
* CLASS lcl_event_handler DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_event_handler definition.
public section.
methods: handle_doubleclick for event double_click
of cl_salv_events_table
importing row column.
endclass. "lcl_event_handler DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_event_handler IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_event_handler implementation.
method handle_doubleclick.
data: xspfli type spfli.
data: isbook type table of sbook.
read table ispfli into xspfli index row.
if sy-subrc = 0.
select * into table isbook from sbook
where carrid = xspfli-carrid
and connid = xspfli-connid.
cl_salv_table=>factory(
importing r_salv_table = gr_dialog_table
changing t_table = isbook ).
gr_dialog_table->set_screen_popup( start_column = 1
end_column = 100
start_line = 1
end_line = 20 ).
gr_dialog_table->display( ).
endif.
endmethod. "handle_doubleclick
endclass. "lcl_event_handler IMPLEMENTATION
data: o_event_handler type ref to lcl_event_handler.
start-of-selection.
select * into corresponding fields of table ispfli from spfli.
cl_salv_table=>factory( importing r_salv_table = gr_table
changing t_table = ispfli ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
gr_display_settings = gr_table->get_display_settings( ).
gr_display_settings->set_list_header( 'This is the list header' ).
gr_columns = gr_table->get_columns( ).
gr_column = gr_columns->get_column( 'CITYTO' ).
gr_column->set_long_text( 'This is the cityto' ).
gr_selections = gr_table->get_selections( ).
gr_selections->set_selection_mode( '4' ).
data: icol type table of lvc_fname.
data: xcol type lvc_fname.
data: irow type salv_t_row.
data: xrow like line of irow.
xcol = 'CITYTO'. append xcol to icol.
xcol = 'CARRID'. append xcol to icol.
gr_selections->set_selected_columns( icol ).
xrow = '2'. append xrow to irow.
xrow = '8'. append xrow to irow.
gr_selections->set_selected_rows( irow ).
gr_sorts = gr_table->get_sorts( ).
gr_sorts->add_sort( columnname = 'CARRID'
subtotal = 'X' ).
gr_agg = gr_table->get_aggregations( ).
gr_agg->add_aggregation( 'DISTANCE' ).
gr_events = gr_table->get_event( ).
create object o_event_handler.
set handler o_event_handler->handle_doubleclick for gr_events.
gr_table->display( ).
Regards,
Rich Heilman
‎2006 Sep 05 9:46 PM
‎2006 Sep 05 10:02 PM
First of all - Thank you! I modified my code based on yours and it worked. Here is the modified version:
REPORT ztemp NO STANDARD PAGE HEADING.
TYPES: BEGIN OF ty_output,
ebeln TYPE ekko-ebeln,
bukrs TYPE ekko-bukrs,
ekorg TYPE ekko-ekorg,
ekgrp TYPE ekko-ekgrp,
lifnr TYPE ekko-lifnr,
zterm TYPE ekko-zterm,
END OF ty_output.
*-----Output Data
DATA: i_output TYPE STANDARD TABLE OF ty_output,
wa_output TYPE ty_output.
DATA: gr_table TYPE REF TO cl_salv_table.
DATA: gr_functions TYPE REF TO cl_salv_functions_list.
DATA: gr_display_settings TYPE REF TO cl_salv_display_settings.
DATA: gr_columns TYPE REF TO cl_salv_columns.
DATA: gr_events TYPE REF TO cl_salv_events_table.
*----------------------------------------------------------------------*
* CLASS lcl_event_handler DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
METHODS: handle_doubleclick FOR EVENT double_click
OF cl_salv_events_table
IMPORTING row column.
ENDCLASS. "lcl_event_handler DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_event_handler IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION.
METHOD handle_doubleclick.
READ TABLE i_output INTO wa_output INDEX row.
IF sy-subrc = 0.
CASE column.
WHEN 'EBELN'.
CALL FUNCTION 'ME_DISPLAY_PURCHASE_DOCUMENT'
EXPORTING
i_ebeln = wa_output-ebeln
i_enjoy = 'X'
EXCEPTIONS
not_found = 1
no_authority = 2
invalid_call = 3
preview_not_possible = 4
OTHERS = 5.
WHEN 'LIFNR'.
CALL FUNCTION 'MMPUR_VENDOR_DISPLAY'
EXPORTING
im_lifnr = wa_output-lifnr
im_ekorg = wa_output-ekorg.
ENDCASE.
ENDIF.
ENDMETHOD. "handle_doubleclick
ENDCLASS. "lcl_event_handler IMPLEMENTATION
DATA: o_event_handler TYPE REF TO lcl_event_handler.
*----------------------------------------------------------------------*
* START OF SELECTION *
*----------------------------------------------------------------------*
START-OF-SELECTION.
*-Get Output/Data
PERFORM get_data.
*-Display Output Data
PERFORM display_data.
*----------------------------------------------------------------------*
* GET OUTPUT DATA *
*----------------------------------------------------------------------*
FORM get_data .
SELECT ebeln bukrs ekorg ekgrp lifnr zterm
FROM ekko
INTO TABLE i_output
WHERE bsart = 'NB'.
ENDFORM. " get_data
*----------------------------------------------------------------------*
* DISPLAY DATA IN OUTPUT TABLE USING ALV OBJECT MODEL *
*----------------------------------------------------------------------*
FORM display_data.
TRY.
cl_salv_table=>factory( EXPORTING list_display = if_salv_c_bool_sap=>false
IMPORTING r_salv_table = gr_table
CHANGING t_table = i_output ).
CATCH cx_salv_msg.
ENDTRY.
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
gr_display_settings = gr_table->get_display_settings( ).
gr_display_settings->set_list_header( 'Purchase Orders' ).
gr_display_settings->set_striped_pattern( abap_true ).
gr_columns = gr_table->get_columns( ).
gr_columns->set_optimize( abap_true ).
gr_events = gr_table->get_event( ).
CREATE OBJECT o_event_handler.
SET HANDLER o_event_handler->handle_doubleclick FOR gr_events.
gr_table->display( ).
ENDFORM. " display_data
‎2006 Sep 05 10:08 PM
I believe my approach to display the output made the difference. I did not use the method "create_dynamic_table" using the field catalog to get an output reference. Previously, I assigned this reference to a field symbol and equate it to my output table contents. Instead, called the factory method directly (like in your sample).
Thanks Rich!
‎2006 Sep 05 9:49 PM
what rich is told is correct.
use
gr_sorts->add_sort( columnname = 'CARRID'
subtotal = 'X' ).
gr_sorts->add_sort( columnname = 'another column'
subtotal = 'X' ).
this is how you need to build sort sequence before calling display method.
and remove
PERFORM get_sort_sequence.
PERFORM adjust_output_table. from double click method...no need of generating subroutine pool to sort...
try this and let us know whether its working or not...
‎2006 Sep 05 11:00 PM
exactly you don't require to build internal table
with create_dynamic_table. it is required only when you don't know the no of fields you have in your internal table. like if you want to have fields depending on the clients in your r/3 system here you don't know how many clients you have in your system you have to know fileds dynamically(during run time only).