Event Link_click
Hello!!
I have a problem because when I click on the button-luggweight. I can't see any message so my program can't detect any event.
I think that in my code I forget something but I don't know what. Anybody can help me, please?
ZBC405_INCLUDE_CLASS
CLASS LCL_HANDLER DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
ON_LINK_CLICK
FOR EVENT LINK_CLICK OF CL_SALV_EVENTS_TABLE
IMPORTING
ROW
COLUMN.
ENDCLASS.
CLASS LCL_HANDLER IMPLEMENTATION.
METHOD ON_LINK_CLICK.
CASE COLUMN.
WHEN 'LUGGWEIGHT'.
MESSAGE I041.
ENDCASE.
ENDMETHOD.
ENDCLASS.
ZBC405_05_COLUM_TOP
TABLES: SBOOK,SCARR,SFLIGHT.
TYPE-POOLS: COL,ICON.
TYPES: BEGIN OF ST_BOOK.
INCLUDE STRUCTURE SBOOK.
TYPES: IT_CELL_TYPES TYPE SALV_T_INT4_COLUMN,
IT_HYPERLINK TYPE SALV_T_INT4_COLUMN,
URL TYPE SERVICE_RL,
END OF ST_BOOK.
DATA: IT_BOOK TYPE TABLE OF ST_BOOK.
DATA: WA_BOOK LIKE LINE OF IT_BOOK,
WA_CELL_TYPES LIKE LINE OF WA_BOOK-IT_CELL_TYPES.
DATA: GR_ALV TYPE REF TO CL_SALV_TABLE,
LR_COLUMNS TYPE REF TO CL_SALV_COLUMNS_TABLE,
LR_COLUMN TYPE REF TO CL_SALV_COLUMN_TABLE.
ZBC405_05_COLUMN_PROGRAM
SELECT * FROM SBOOK INTO CORRESPONDING FIELDS OF WA_BOOK
WHERE CARRID = M_CARRID.
INSERT WA_BOOK INTO TABLE IT_BOOK.
ENDSELECT.
CALL METHOD CL_SALV_TABLE=>FACTORY
EXPORTING
LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
* R_CONTAINER =
* CONTAINER_NAME =
IMPORTING
R_SALV_TABLE = GR_ALV
CHANGING
T_TABLE = IT_BOOK.
PERFOM PESO.
FORM PESO.
LOOP AT IT_BOOK INTO WA_BOOK.
IF WA_BOOK-LUGGWEIGHT = 0
AND WA_BOOK-WUNIT = 'KG'
AND WA_BOOK-SMOKER = ' '.
CLEAR WA_CELL_TYPES.
WA_CELL_TYPES-COLUMNNAME = 'LUGGWEIGHT'.
WA_CELL_TYPES-VALUE = IF_SALV_C_CELL_TYPE=><b>BUTTON.</b>
APPEND WA_CELL_TYPES TO WA_BOOK-IT_CELL_TYPES.
ENDIF.
MODIFY IT_BOOK FROM WA_BOOK TRANSPORTING IT_CELL_TYPES.
ENDLOOP.
LR_COLUMNS = GR_ALV->GET_COLUMNS( ).
TRY.
LR_COLUMNS->SET_CELL_TYPE_COLUMN( VALUE = 'IT_CELL_TYPES' ).
CATCH CX_SALV_DATA_ERROR.
ENDTRY.
TRY.
CALL METHOD GR_ALV->GET_EVENT
RECEIVING
VALUE = LR_EVENT.
CATCH CX_SALV_DATA_ERROR.
ENDTRY.
SET HANDLER LCL_HANDLER=>ON_LINK_CLICK
FOR LR_EVENT.
ENDFORM. "PESO
thanks a lot.
Hi Ana,
See the follow my example, it was based on 'SALV_DEMO_TABLE_EVENTS.
1 - It seems you forgetting to create a object of your class like
DATA: gr_events TYPE REF TO lcl_handle_events.
2 - You must instantiate this object like
CREATE OBJECT gr_events.
3 - You can set up your field as Hotspot with this statement
TRY.
lr_column ?= lr_columns->get_column( 'CARRID' ).
lr_column->set_cell_type( if_salv_c_cell_type=>hotspot ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
4 - You Must create and instantiate a object of class <b>cl_salv_events_table</b> responsible to get all events. You can do as follow
DATA: lr_events TYPE REF TO cl_salv_events_table.
lr_events = gr_table->get_event( ).
5 - You MUST active event handler for events that you want to work
SET HANDLER gr_events->on_link_click FOR lr_events.
<b>You can see it working running the code below. I hope I have helped you with this informations. Good Look !
Ps.: Don't forget to reward points for useful answers and close this thread when your question be answered !.
</b>
REPORT zsalv_event_mar NO STANDARD PAGE HEADING.
* CLASS lcl_handle_events DEFINITION
CLASS lcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS:
on_link_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING row column.
ENDCLASS. "lcl_handle_events DEFINITION
* CLASS lcl_handle_events IMPLEMENTATION
CLASS lcl_handle_events IMPLEMENTATION.
METHOD on_link_click.
DATA: l_row_string TYPE string,
l_col_string TYPE string,
l_row TYPE char128.
MESSAGE i000(0k) WITH 'You Clicked on Line'
row
'Of Column'
column.
ENDMETHOD. "on_single_click
ENDCLASS. "lcl_handle_events IMPLEMENTATION
DATA: gr_events TYPE REF TO lcl_handle_events.
DATA: gt_outtab TYPE STANDARD TABLE OF alv_tab.
DATA: gr_table TYPE REF TO cl_salv_table.
SELECTION-SCREEN BEGIN OF BLOCK gen WITH FRAME.
PARAMETERS: p_amount TYPE i DEFAULT 30.
SELECTION-SCREEN END OF BLOCK gen.
START-OF-SELECTION.
PERFORM select_data.
PERFORM display.
*& Form select_data
* text
* --> p1 text
* <-- p2 text
FORM select_data .
SELECT *
FROM alv_tab
INTO TABLE gt_outtab
UP TO p_amount ROWS.
ENDFORM. " select_data
*& Form display
* text
* --> p1 text
* <-- p2 text
FORM display .
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = gt_outtab ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
DATA: lr_functions TYPE REF TO cl_salv_functions_list.
lr_functions = gr_table->get_functions( ).
lr_functions->set_default( abap_true ).
*... set the columns technical
DATA: lr_columns TYPE REF TO cl_salv_columns_table,
lr_column TYPE REF TO cl_salv_column_table.
lr_columns = gr_table->get_columns( ).
lr_columns->set_optimize( abap_true ).
TRY.
lr_column ?= lr_columns->get_column( 'CARRID' ).
lr_column->set_cell_type( if_salv_c_cell_type=>hotspot ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
DATA: lr_events TYPE REF TO cl_salv_events_table.
lr_events = gr_table->get_event( ).
CREATE OBJECT gr_events.
SET HANDLER gr_events->on_link_click FOR lr_events.
gr_table->display( ).
ENDFORM. " display
Regards.
Marcelo Ramos
Similar Messages
-
How can i use LINK_CLICK event
Hi,
how can i use event LINK_CLICK in list tree.
Plz help me.
Regards ,
Venkat.use this....
CLASS cl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS on_expand_no_children
FOR EVENT expand_no_children OF cl_gui_simple_tree
IMPORTING node_key sender.
METHODS on_node_double_click
FOR EVENT node_double_click OF cl_gui_simple_tree
IMPORTING node_key sender.
ENDCLASS.
CLASS cl_event_receiver
IMPLEMENTATION
CLASS cl_event_receiver IMPLEMENTATION.
Triggering event: expand_no_children
Handling method: on_expand_no_children
Description:
The handling method is called whenever a node is supposed to be
expanded (by clicking on the expander icon) while subordinate entries
are not yet known in the GUI.
In this case the node table must be complemented with the respective
entries.
METHOD on_expand_no_children.
IF SENDER <> obj_simple_tree.
EXIT.
ENDIF.
Determine subnodes
REFRESH t_gui_node.
LOOP AT t_node INTO wa_node WHERE relatkey = node_key.
APPEND wa_node TO t_gui_node.
ENDLOOP.
Send node table to GUI
CALL METHOD obj_simple_tree->ADD_NODES
EXPORTING
TABLE_STRUCTURE_NAME = 'MTREESNODE'
NODE_TABLE = t_gui_node
EXCEPTIONS
ERROR_IN_NODE_TABLE = 1
FAILED = 2
DP_ERROR = 3
TABLE_STRUCTURE_NAME_NOT_FOUND = 4
others = 5.
IF SY-SUBRC <> 0.
MESSAGE i398(00) WITH 'Error' sy-subrc
'at methode ADD_NODES'.
ENDIF.
ENDMETHOD.
Triggering event: node_double_click
Handling method: on_node_double_click
The handling method is called every time a double-click is executed
on a node or a leaf.
METHOD on_node_double_click.
IF SENDER <> obj_simple_tree.
EXIT.
ENDIF.
Output message for selected node or leaf
CLEAR wa_node.
READ TABLE t_node
WITH KEY node_key = node_key
INTO wa_node.
IF SY-SUBRC = 0.
IF wa_node-isfolder = 'X'.
MESSAGE i398(00)
WITH 'Double-click on node' wa_node-node_key.
ELSE.
MESSAGE i398(00)
WITH 'Double-click on leaf' wa_node-node_key.
ENDIF.
ELSE.
MESSAGE i398(00)
WITH 'Double-click on unknown node'.
ENDIF.
Trigger PAI and transfer function code (system event)
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING new_code = 'FCODE_DOUBLECLICK'.
ENDMETHOD.
ENDCLASS.
*& Module STATUS_0100 OUTPUT
GUI status for dynpro
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'DYN_0100'.
SET TITLEBAR 'DYN_0100'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module create_objects OUTPUT
Create instances
MODULE create_objects OUTPUT.
IF NOT obj_custom_container IS INITIAL.
EXIT.
ENDIF.
Create instance for custom container
CREATE OBJECT obj_custom_container
EXPORTING
PARENT =
CONTAINER_NAME = 'DYNPRO_CONTAINER'
STYLE =
LIFETIME = lifetime_default
REPID =
DYNNR =
NO_AUTODEF_PROGID_DYNNR =
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
others = 6.
IF SY-SUBRC <> 0.
MESSAGE i398(00) WITH 'Error' sy-subrc
'when creating the custom container controls'.
ENDIF.
Create instance (back-end) for Simple Tree Model
CREATE OBJECT obj_simple_tree
EXPORTING
NODE_SELECTION_MODE = CL_SIMPLE_TREE_MODEL=>NODE_SEL_MODE_SINGLE
HIDE_SELECTION =
EXCEPTIONS
ILLEGAL_NODE_SELECTION_MODE = 1
others = 2.
IF SY-SUBRC <> 0.
MESSAGE i398(00) WITH 'Error' sy-subrc
'when creating the Simple Tree Model'.
ENDIF.
Create instance (representative object for control at front end)
CALL METHOD obj_simple_tree->CREATE_TREE_CONTROL
EXPORTING
LIFETIME =
PARENT = obj_custom_container
SHELLSTYLE =
IMPORTING
CONTROL =
EXCEPTIONS
LIFETIME_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
FAILED = 4
TREE_CONTROL_ALREADY_CREATED = 5
others = 6.
IF SY-SUBRC <> 0.
MESSAGE i398(00) WITH 'Error' sy-subrc
'when creating the Simple Tree Control'.
ENDIF.
ENDMODULE. " create_objects OUTPUT
*& Module register_events OUTPUT
Event handling
MODULE register_events OUTPUT.
Register events as system event at CFW *
CLEAR t_events.
Register event for double-click
CLEAR wa_event.
wa_event-eventid = CL_SIMPLE_TREE_MODEL=>EVENTID_NODE_DOUBLE_CLICK.
wa_event-appl_event = ' '.
APPEND wa_event TO t_events.
Register events at CFW and control at front end
CALL METHOD obj_simple_tree->SET_REGISTERED_EVENTS
EXPORTING
EVENTS = t_events
EXCEPTIONS
ILLEGAL_EVENT_COMBINATION = 1
UNKNOWN_EVENT = 2
others = 3.
IF SY-SUBRC <> 0.
MESSAGE i398(00) WITH 'Error' sy-subrc
'when registering the events'.
ENDIF.
Create event handler and register events
IF obj_event_receiver IS INITIAL.
CREATE OBJECT obj_event_receiver.
SET HANDLER obj_event_receiver->on_node_double_click
FOR obj_simple_tree.
SET HANDLER obj_event_receiver->on_expand_no_children
FOR obj_simple_tree.
ENDIF.
ENDMODULE. " register_events OUTPUT
*& Module create_tree OUTPUT
Create node table with root and 1st level
MODULE create_tree OUTPUT.
IF NOT t_node IS INITIAL.
EXIT.
ENDIF.
Create node table
PERFORM fill_node_table.
Fill node table t_gui_node for control
REFRESH t_gui_node.
t_gui_node = t_node.
Transfer entire node table to Simple Tree Model
CALL METHOD obj_simple_tree->ADD_NODES
EXPORTING
NODE_TABLE = t_gui_node
EXCEPTIONS
ERROR_IN_NODE_TABLE = 1
others = 2.
IF SY-SUBRC <> 0.
MESSAGE i398(00) WITH 'Error' sy-subrc
'at methode ADD_NODES'.
ENDIF.
ENDMODULE. " create_tree OUTPUT -
Event handling in abap objects
hello friends,
i want to use the event RAISE_LINK_CLICK for single click.
but i dont want 2 use this event for alv table.
i am displaying vendor name in my top of page,if the user click of the vendor name a new window should pop-up displaying the vendor details.
my code for top of page is
DATA: lr_grid TYPE REF TO cl_salv_form_layout_grid,
lr_grid_1 TYPE REF TO cl_salv_form_layout_grid,
lr_flow TYPE REF TO cl_salv_form_layout_flow,
lr_label TYPE REF TO cl_salv_form_label,
lr_text TYPE REF TO cl_salv_form_text,
l_text TYPE string.
CREATE OBJECT lr_grid.
lr_grid_1 = lr_grid->create_grid( row = 1 column = 1 ).
lr_text = lr_grid_1->create_text( row = 1 column = 1 colspan = 2 text = <b>vendor_name</b> ).
lr_grid_1 = lr_grid->create_grid( row = 2 column = 1 ).
lr_flow = lr_grid_1->create_flow( row = 2 column = 1 ).
lr_text = lr_flow->create_text( text = 'Reconcillation Statement'(t02) tooltip = 'Reconcillation Statement'(t02) ).
alv->set_top_of_list( lr_grid ).
do uc the VENDOR NAME in bold,wen the user clicks on it the pop should appear.
so how to use the event RAISE_LINK_CLICK for this purpose,or is there another way throughHi Amit,
I answered the similar question last week. You can see here or .
This example demonstrates how to use a Hiperlink field in ALV. These example was based on 'SALV_DEMO_TABLE_COLUMNS' that contains Hiperlink, icon, Hotspot...
The Code is:
REPORT zsalv_mar NO STANDARD PAGE HEADING.
* CLASS lcl_handle_events DEFINITION
CLASS lcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS:
on_link_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING row column.
ENDCLASS. "lcl_handle_events DEFINITION
* CLASS lcl_handle_events IMPLEMENTATION
CLASS lcl_handle_events IMPLEMENTATION.
METHOD on_link_click.
DATA: l_row_string TYPE string,
l_col_string TYPE string,
l_row TYPE char128.
WRITE row TO l_row LEFT-JUSTIFIED.
CONCATENATE text-i02 l_row INTO l_row_string SEPARATED BY space.
CONCATENATE text-i03 column INTO l_col_string SEPARATED BY space.
MESSAGE i000(0k) WITH 'Single Click' l_row_string l_col_string.
ENDMETHOD. "on_single_click
ENDCLASS. "lcl_handle_events IMPLEMENTATION
DATA: gr_events TYPE REF TO lcl_handle_events.
TYPES: BEGIN OF g_type_s_outtab.
INCLUDE TYPE alv_tab.
TYPES: t_hyperlink TYPE salv_t_int4_column,
END OF g_type_s_outtab.
DATA: gt_outtab TYPE STANDARD TABLE OF g_type_s_outtab.
DATA: gr_table TYPE REF TO cl_salv_table.
TYPES: BEGIN OF g_type_s_hyperlink,
handle TYPE salv_de_hyperlink_handle,
hyperlink TYPE service_rl,
carrid TYPE s_carrid,
END OF g_type_s_hyperlink.
DATA: gt_hyperlink TYPE STANDARD TABLE OF g_type_s_hyperlink.
SELECTION-SCREEN BEGIN OF BLOCK gen WITH FRAME.
PARAMETERS: p_amount TYPE i DEFAULT 30.
SELECTION-SCREEN END OF BLOCK gen.
START-OF-SELECTION.
PERFORM select_data.
PERFORM display.
*& Form select_data
* text
* --> p1 text
* <-- p2 text
FORM select_data .
DATA: line_outtab TYPE g_type_s_outtab,
ls_hype TYPE g_type_s_hyperlink,
lt_hyperlink TYPE salv_t_int4_column,
ls_hyperlink TYPE salv_s_int4_column,
v_tabix TYPE sytabix.
SELECT *
FROM alv_tab
INTO CORRESPONDING FIELDS OF TABLE gt_outtab
UP TO p_amount ROWS.
LOOP AT gt_outtab INTO line_outtab.
v_tabix = sy-tabix.
ls_hype-handle = sy-tabix.
ls_hype-hyperlink = line_outtab-url.
ls_hype-carrid = line_outtab-carrid.
INSERT ls_hype INTO TABLE gt_hyperlink.
ls_hyperlink-columnname = 'URL'.
ls_hyperlink-value = sy-tabix.
APPEND ls_hyperlink TO lt_hyperlink.
line_outtab-t_hyperlink = lt_hyperlink.
MODIFY gt_outtab FROM line_outtab INDEX v_tabix.
CLEAR line_outtab.
CLEAR lt_hyperlink.
CLEAR ls_hyperlink.
ENDLOOP.
ENDFORM. " select_data
*& Form display
* text
* --> p1 text
* <-- p2 text
FORM display .
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = gt_outtab ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
DATA: lr_functions TYPE REF TO cl_salv_functions_list.
lr_functions = gr_table->get_functions( ).
lr_functions->set_default( abap_true ).
*... set the columns technical
DATA: lr_columns TYPE REF TO cl_salv_columns_table,
lr_column TYPE REF TO cl_salv_column_table.
lr_columns = gr_table->get_columns( ).
lr_columns->set_optimize( abap_true ).
*... §4.7 set hyperlink column
DATA: lr_hyperlinks TYPE REF TO cl_salv_hyperlinks,
ls_hyperlink TYPE g_type_s_hyperlink.
DATA: lr_functional_settings TYPE REF TO cl_salv_functional_settings.
TRY.
lr_columns->set_hyperlink_entry_column( 'T_HYPERLINK' ).
CATCH cx_salv_data_error. "#EC NO_HANDLER
ENDTRY.
TRY.
lr_column ?= lr_columns->get_column( 'URL' ).
lr_column->set_cell_type( if_salv_c_cell_type=>link ).
lr_column->set_long_text( 'URL' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
lr_functional_settings = gr_table->get_functional_settings( ).
lr_hyperlinks = lr_functional_settings->get_hyperlinks( ).
LOOP AT gt_hyperlink INTO ls_hyperlink.
TRY.
lr_hyperlinks->add_hyperlink(
handle = ls_hyperlink-handle
hyperlink = ls_hyperlink-hyperlink ).
CATCH cx_salv_existing. "#EC NO_HANDLER
ENDTRY.
ENDLOOP.
DATA: lr_events TYPE REF TO cl_salv_events_table.
lr_events = gr_table->get_event( ).
CREATE OBJECT gr_events.
SET HANDLER gr_events->on_link_click FOR lr_events.
gr_table->display( ).
ENDFORM. " display
Regards.
Marcelo Ramos -
Event double -click doens't work
Dear All,
Pls help event double -click doens't work.
What can the reason be for it ?
Regards
Ilhan
data tree1 type ref to cl_gui_alv_tree.
data mr_toolbar type ref to cl_gui_toolbar.
include <icon>.
data: gt_sflight type ZQMCOMP occurs 0, "Output-Table
gt_fieldcatalog type lvc_t_fcat, "Fieldcatalog
ok_code like sy-ucomm. "OK-Code
* TREE_EVENT_RECEIVER *
class tree_event_receiver definition.
public section.
methods on_doubleclick
for event link_click of cl_gui_alv_tree
importing node_key fieldname.
ENDCLASS. "lcl_handler DEFINITION
* CLASS tree_event_receiver IMPLEMENTATION
class tree_event_receiver implementation.
METHOD on_doubleclick.
MESSAGE I000(38) WITH fieldname.
ENDMETHOD. "on_doubleclick
endclass.
start-of-selection.
end-of-selection.
call screen 100.
*& Module PBO OUTPUT
* process before output
module pbo output.
set pf-status 'MAIN100'.
if tree1 is initial.
perform init_tree.
endif.
call method cl_gui_cfw=>flush.
endmodule. " PBO OUTPUT
*& Module PAI INPUT
* process after input
module pai input.
case ok_code.
when 'EXIT' or 'BACK' or 'CANC'.
perform exit_program.
when others.
call method cl_gui_cfw=>dispatch.
endcase.
clear ok_code.
call method cl_gui_cfw=>flush.
endmodule. " PAI INPUT
*& Form build_fieldcatalog
* build fieldcatalog for structure sflight
form build_fieldcatalog.
data: ls_fieldcatalog type lvc_s_fcat.
ls_fieldcatalog-fieldname = 'DUNS'.
ls_fieldcatalog-col_pos = 7.
ls_fieldcatalog-coltext = 'Duns'.
APPEND ls_fieldcatalog TO gt_fieldcatalog.
clear ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'MONAT'.
ls_fieldcatalog-col_pos = 8.
ls_fieldcatalog-coltext = 'Monat'.
APPEND ls_fieldcatalog TO gt_fieldcatalog.
clear ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'ZE'.
ls_fieldcatalog-col_pos = 13.
ls_fieldcatalog-coltext = 'Ze'.
APPEND ls_fieldcatalog TO gt_fieldcatalog.
clear ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'MATKOSTEN'.
ls_fieldcatalog-col_pos = 14.
ls_fieldcatalog-coltext = 'Mat.Kosten'.
APPEND ls_fieldcatalog TO gt_fieldcatalog.
clear ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'ANTEIL'.
ls_fieldcatalog-col_pos = 15.
ls_fieldcatalog-coltext = 'Anteil'.
APPEND ls_fieldcatalog TO gt_fieldcatalog.
clear ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'GESMAT'.
ls_fieldcatalog-col_pos = 16.
ls_fieldcatalog-coltext = 'Ges.Mat'.
APPEND ls_fieldcatalog TO gt_fieldcatalog.
clear ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'GESLOH'.
ls_fieldcatalog-col_pos = 17.
ls_fieldcatalog-coltext = 'Ges.Lohn'.
APPEND ls_fieldcatalog TO gt_fieldcatalog.
clear ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'GESAMT'.
ls_fieldcatalog-col_pos = 19.
ls_fieldcatalog-coltext = 'Gesamt'.
APPEND ls_fieldcatalog TO gt_fieldcatalog.
call function 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZQMCOMP'
CHANGING
ct_fieldcat = gt_fieldcatalog.
endform. " build_fieldcatalog
*& Form build_hierarchy_header
* build hierarchy-header-information
* -->P_L_HIERARCHY_HEADER strucxture for hierarchy-header
form build_hierarchy_header changing
p_hierarchy_header type treev_hhdr.
p_hierarchy_header-heading = 'Hierarchy-Kopf'. "#EC NOTEXT
p_hierarchy_header-tooltip =
'Hierarchy-Kopf !'.
p_hierarchy_header-width = 30.
p_hierarchy_header-width_pix = ''.
endform. " build_hierarchy_header
*& Form exit_program
* free object and leave program
form exit_program.
call method tree1->free.
leave program.
endform. " exit_program
*& Form build_header
* build table for html_header
* --> p1 text
* <-- p2 text
form build_comment using
pt_list_commentary type slis_t_listheader
p_logo type sdydo_value.
data: ls_line type slis_listheader.
clear ls_line.
ls_line-typ = 'H'.
ls_line-info = 'LIBOLO '.
append ls_line to pt_list_commentary.
clear ls_line.
clear ls_line.
ls_line-typ = 'A'.
ls_line-info = 'Liste'.
append ls_line to pt_list_commentary.
* p_logo = 'ENJOYSAP_LOGO'.
endform.
* FORM create_hierarchy *
FORM create_hierarchy.
data: ls_sflight type ZQMCOMP,
lt_sflight type ZQMCOMP occurs 0.
* get data
select * from ZQMCOMP into table lt_sflight.
* sort lt_sflight by carrid connid fldate.
* add data to tree
data: l_carrid_key type lvc_nkey,
l_connid_key type lvc_nkey,
l_last_key type lvc_nkey.
loop at lt_sflight into ls_sflight.
on change of ls_sflight-KUNDE.
perform add_carrid_line using ls_sflight
changing l_carrid_key.
endon.
on change of ls_sflight-MONAT.
perform add_connid_line using ls_sflight
l_carrid_key
changing l_connid_key.
endon.
perform add_complete_line using ls_sflight
l_connid_key
changing l_last_key.
endloop.
* calculate totals
call method tree1->update_calculations.
* this method must be called to send the data to the frontend
call method tree1->frontend_update.
endform. " create_hierarchy
*& Form add_carrid_line
* add hierarchy-level 1 to tree
* -->P_LS_SFLIGHT sflight
* -->P_RELEATKEY relatkey
* <-->p_node_key new node-key
form add_carrid_line using ps_sflight type ZQMCOMP
p_relat_key type lvc_nkey
changing p_node_key type lvc_nkey.
data: l_node_text type lvc_value,
ls_sflight type ZQMCOMP.
* set item-layout
data: lt_item_layout type lvc_t_layi,
ls_item_layout type lvc_s_layi.
ls_item_layout-t_image = '@3P@'.
ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
ls_item_layout-style =
cl_gui_column_tree=>style_intensifd_critical.
append ls_item_layout to lt_item_layout.
* add node
l_node_text = ps_sflight-KUNDE.
call method tree1->add_node
exporting
i_relat_node_key = p_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = ls_sflight
it_item_layout = lt_item_layout
importing
e_new_node_key = p_node_key.
endform. " add_carrid_line
*& Form add_connid_line
* add hierarchy-level 2 to tree
* -->P_LS_SFLIGHT sflight
* -->P_RELEATKEY relatkey
* <-->p_node_key new node-key
form add_connid_line using ps_sflight type ZQMCOMP
p_relat_key type lvc_nkey
changing p_node_key type lvc_nkey.
data: l_node_text type lvc_value,
ls_sflight type sflight.
* set item-layout
data: lt_item_layout type lvc_t_layi,
ls_item_layout type lvc_s_layi.
ls_item_layout-t_image = '@3Y@'.
ls_item_layout-style =
cl_gui_column_tree=>style_intensified.
ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
append ls_item_layout to lt_item_layout.
* add node
l_node_text = ps_sflight-MONAT.
call method tree1->add_node
exporting
i_relat_node_key = p_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = ls_sflight
it_item_layout = lt_item_layout
importing
e_new_node_key = p_node_key.
endform. " add_connid_line
*& Form add_cmplete_line
* add hierarchy-level 3 to tree
* -->P_LS_SFLIGHT sflight
* -->P_RELEATKEY relatkey
* <-->p_node_key new node-key
form add_complete_line using ps_sflight type ZQMCOMP
p_relat_key type lvc_nkey
changing p_node_key type lvc_nkey.
data: l_node_text type lvc_value.
data: lt_item_layout type lvc_t_layi,
ls_item_layout type lvc_s_layi.
ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
append ls_item_layout to lt_item_layout.
l_node_text = ps_sflight-QMART.
call method tree1->add_node
exporting
i_relat_node_key = p_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = ps_sflight
i_node_text = l_node_text
it_item_layout = lt_item_layout
importing
e_new_node_key = p_node_key.
endform. " add_complete_line
*& Form register_events
* text
* --> p1 text
* <-- p2 text
form register_events.
data: lt_events type cntl_simple_events,
l_event type cntl_simple_event.
l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_header_context_men_req.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_item_context_menu_req.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_header_click.
append L_EVENT to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_item_keypress.
append L_EVENT to lt_events.
* set Handler
data: l_event_receiver type ref to tree_event_receiver.
create object l_event_receiver.
set handler l_event_receiver->on_doubleclick for tree1.
call method tree1->set_registered_events
exporting
events = lt_events
exceptions
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
if sy-subrc <> 0.
message x208(00) with 'ERROR'. "#EC NOTEXT
endif.
endform. " register_events
*& Form change_toolbar
* text
* --> p1 text
* <-- p2 text
form change_toolbar.
* get toolbar control
call method tree1->get_toolbar_object
importing
er_toolbar = mr_toolbar.
check not mr_toolbar is initial.
* add seperator to toolbar
call method mr_toolbar->add_button
exporting
fcode = ''
icon = ''
butn_type = cntb_btype_sep
text = ''
quickinfo = 'This is a Seperator'. "#EC NOTEXT
* add Standard Button to toolbar (for Delete Subtree)
call method mr_toolbar->add_button
exporting
fcode = 'DELETE'
icon = '@18@'
butn_type = cntb_btype_button
text = ''
quickinfo = 'Delete subtree'. "#EC NOTEXT
* add Dropdown Button to toolbar (for Insert Line)
call method mr_toolbar->add_button
exporting
fcode = 'INSERT_LC'
icon = '@17@'
butn_type = cntb_btype_dropdown
text = ''
quickinfo = 'Insert Line'. "#EC NOTEXT
endform. " change_toolbar
*& Form init_tree
* text
* --> p1 text
* <-- p2 text
FORM init_tree.
* create fieldcatalog for structure sflight
perform build_fieldcatalog.
* create container for alv-tree
data: l_tree_container_name(30) type c,
l_custom_container type ref to cl_gui_custom_container.
l_tree_container_name = 'TREE1'.
if sy-batch is initial.
create object l_custom_container
exporting
container_name = l_tree_container_name
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
if sy-subrc <> 0.
message x208(00) with 'ERROR'. "#EC NOTEXT
endif.
endif.
* create tree control
create object tree1
exporting
parent = l_custom_container
node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
item_selection = 'X'
no_html_header = ''
no_toolbar = ''
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
if sy-subrc <> 0.
message x208(00) with 'ERROR'. "#EC NOTEXT
endif.
* create Hierarchy-header
data l_hierarchy_header type treev_hhdr.
perform build_hierarchy_header changing l_hierarchy_header.
* create info-table for html-header
data: lt_list_commentary type slis_t_listheader,
l_logo type sdydo_value.
perform build_comment using
lt_list_commentary
l_logo.
* repid for saving variants
data: ls_variant type disvariant.
ls_variant-report = sy-repid.
* create emty tree-control
call method tree1->set_table_for_first_display
exporting
I_STRUCTURE_NAME = 'ZQMCOMP'
is_hierarchy_header = l_hierarchy_header
it_list_commentary = lt_list_commentary
* i_logo = l_logo
i_background_id = 'ALV_BACKGROUND'
i_save = 'A'
is_variant = ls_variant
changing
it_outtab = gt_sflight "table must be emty !!
it_fieldcatalog = gt_fieldcatalog.
* create hierarchy
perform create_hierarchy.
* add own functioncodes to the toolbar
perform change_toolbar.
* register events
perform register_events.
* adjust column_width
call method tree1->COLUMN_OPTIMIZE.
ENDFORM. " init_treeHi,
to do so, you need to declare those fields in the form CREATE_HIERARCHY.
For example, to add FLDATE node, you should do:
ON CHANGE OF LS_SFLIGHT-CARRID.
PERFORM ADD_CARRID_LINE USING LS_SFLIGHT
CHANGING L_CARRID_KEY.
ENDON.
ON CHANGE OF LS_SFLIGHT-CONNID.
PERFORM ADD_CONNID_LINE USING LS_SFLIGHT
L_CARRID_KEY
CHANGING L_CONNID_KEY.
ENDON.
ON CHANGE OF LS_SFLIGHT-FLDATE.
PERFORM ADD_FLDATE_LINE USING LS_SFLIGHT
L_CONNID_KEY
CHANGING L_FLDATE_KEY.
ENDON.
ON CHANGE OF LS_SFLIGHT-PRICE.
PERFORM ADD_PRICE_LINE USING LS_SFLIGHT
L_FLDATE_KEY
CHANGING L_PRICE_KEY.
ENDON.
and then create the new FORMS PERFORM ADD_PRICE_LINE and
PERFORM ADD_FLDATE_LINE by copy of the existent
PERFORM ADD_CONNID_LINE and change the L_NODE_TEXT in the form.
I suposed you are new to ALV's, so i have a sugestion for you.
Instead of CL_GUI_ALV_TREE try to use some examples of CL_GUI_ALV_TREE_SIMPLE. It's much more simple to understand and to work with. For example Report BCALV_TREE_SIMPLE_DEMO.
In this case, to add more nodes to the the you just need to add 3 lines of code in
perform build_sort_table.
Regards, -
Two trees on 1 screen, 1 Event - 1 Method = Which tree ?
Hi,
as I am fairly new to the Abap-OO this may be a silly question, but:
I have two list_trees on one screen to drag&drop between them. Now I need one event (Link_Click) for both trees. My problem now is how to determine and use the tree that raised the event.
Do I really need to define two methods like Handle_link_click_left & Handle_link_click_right ?
I thought somehow within the method I use an object like
"clicked_at_tree" instead of tree_left / tree_right ?!?!
I hope I was able to describe my problem and someones able to help me out
Thx in advance,
KarstenSimular to what I did in this program, you may be able to extend the class, by using a local class and inheriting from your other class. In this example, I have to text edit containers on the screen 100, the same event and handler is being executed for each instance of the text editor.
* Create the screen 100, add two container to the screen,
* CONTAINER1 and CONTAINER2.
* Double click in either control
report zrich_0001 .
* CLASS lcl_text_edit DEFINITION
class lcl_text_edit definition inheriting from cl_gui_textedit.
public section.
data: textlines type table of tline-tdline,
wa_text type tline-tdline.
events: customevent.
methods: constructor importing
im_parent type ref to cl_gui_container,
customeventhandle
for event dblclick of lcl_text_edit.
endclass.
* CLASS lcl_text_edit IMPLEMENTATION
class lcl_text_edit implementation.
method constructor.
call method super->constructor( parent = im_parent ).
endmethod.
method customeventhandle.
wa_text = 'Appended Line'.
append wa_text to textlines.
call method me->set_text_as_r3table
exporting
table = textlines
exceptions
others = 1.
endmethod.
endclass.
data: container1 type ref to cl_gui_custom_container.
data: container2 type ref to cl_gui_custom_container.
data: textedit1 type ref to lcl_text_edit.
data: textedit2 type ref to lcl_text_edit.
start-of-selection.
call screen 100.
*& Module STATUS_0100 OUTPUT
module status_0100 output.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
create object:
container1
exporting container_name = 'CONTAINER1',
textedit1
exporting
im_parent = container1.
call method textedit1->register_event_dblclick.
set handler textedit1->customeventhandle for textedit1.
create object:
container2
exporting container_name = 'CONTAINER2',
textedit2
exporting
im_parent = container2.
call method textedit2->register_event_dblclick.
set handler textedit2->customeventhandle for textedit2.
endmodule.
*& Module USER_COMMAND_0100 INPUT
module user_command_0100 input.
endmodule.
If you found any answers helpful, please award points. Thanks.
Regards,
Rich Heilman -
hi,
can any1 pls explain me the single click event LINK_CLICK in abap object.
does this single click event mean that if i click anywhere on my alv report it will trigger the event.
pls explain me about this LINK_CLICK event in details plsanswered the similar question last week. You can see here Event
Link_click or ALV_Object Model HYPERLINK.
This example demonstrates how to use a Hiperlink field in ALV. These example was based on 'SALV_DEMO_TABLE_COLUMNS' that contains Hiperlink, icon, Hotspot...
The Code is:
REPORT zsalv_mar NO STANDARD PAGE HEADING.
CLASS lcl_handle_events DEFINITION
CLASS lcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS:
on_link_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING row column.
ENDCLASS. "lcl_handle_events DEFINITION
CLASS lcl_handle_events IMPLEMENTATION
CLASS lcl_handle_events IMPLEMENTATION.
METHOD on_link_click.
DATA: l_row_string TYPE string,
l_col_string TYPE string,
l_row TYPE char128.
WRITE row TO l_row LEFT-JUSTIFIED.
CONCATENATE text-i02 l_row INTO l_row_string SEPARATED BY space.
CONCATENATE text-i03 column INTO l_col_string SEPARATED BY space.
MESSAGE i000(0k) WITH 'Single Click' l_row_string l_col_string.
ENDMETHOD. "on_single_click
ENDCLASS. "lcl_handle_events IMPLEMENTATION
DATA: gr_events TYPE REF TO lcl_handle_events.
TYPES: BEGIN OF g_type_s_outtab.
INCLUDE TYPE alv_tab.
TYPES: t_hyperlink TYPE salv_t_int4_column,
END OF g_type_s_outtab.
DATA: gt_outtab TYPE STANDARD TABLE OF g_type_s_outtab.
DATA: gr_table TYPE REF TO cl_salv_table.
TYPES: BEGIN OF g_type_s_hyperlink,
handle TYPE salv_de_hyperlink_handle,
hyperlink TYPE service_rl,
carrid TYPE s_carrid,
END OF g_type_s_hyperlink.
DATA: gt_hyperlink TYPE STANDARD TABLE OF g_type_s_hyperlink.
SELECTION-SCREEN BEGIN OF BLOCK gen WITH FRAME.
PARAMETERS: p_amount TYPE i DEFAULT 30.
SELECTION-SCREEN END OF BLOCK gen.
START-OF-SELECTION.
PERFORM select_data.
PERFORM display.
*& Form select_data
text
--> p1 text
<-- p2 text
FORM select_data .
DATA: line_outtab TYPE g_type_s_outtab,
ls_hype TYPE g_type_s_hyperlink,
lt_hyperlink TYPE salv_t_int4_column,
ls_hyperlink TYPE salv_s_int4_column,
v_tabix TYPE sytabix.
SELECT *
FROM alv_tab
INTO CORRESPONDING FIELDS OF TABLE gt_outtab
UP TO p_amount ROWS.
LOOP AT gt_outtab INTO line_outtab.
v_tabix = sy-tabix.
ls_hype-handle = sy-tabix.
ls_hype-hyperlink = line_outtab-url.
ls_hype-carrid = line_outtab-carrid.
INSERT ls_hype INTO TABLE gt_hyperlink.
ls_hyperlink-columnname = 'URL'.
ls_hyperlink-value = sy-tabix.
APPEND ls_hyperlink TO lt_hyperlink.
line_outtab-t_hyperlink = lt_hyperlink.
MODIFY gt_outtab FROM line_outtab INDEX v_tabix.
CLEAR line_outtab.
CLEAR lt_hyperlink.
CLEAR ls_hyperlink.
ENDLOOP.
ENDFORM. " select_data
*& Form display
text
--> p1 text
<-- p2 text
FORM display .
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = gt_outtab ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
DATA: lr_functions TYPE REF TO cl_salv_functions_list.
lr_functions = gr_table->get_functions( ).
lr_functions->set_default( abap_true ).
*... set the columns technical
DATA: lr_columns TYPE REF TO cl_salv_columns_table,
lr_column TYPE REF TO cl_salv_column_table.
lr_columns = gr_table->get_columns( ).
lr_columns->set_optimize( abap_true ).
*... §4.7 set hyperlink column
DATA: lr_hyperlinks TYPE REF TO cl_salv_hyperlinks,
ls_hyperlink TYPE g_type_s_hyperlink.
DATA: lr_functional_settings TYPE REF TO cl_salv_functional_settings.
TRY.
lr_columns->set_hyperlink_entry_column( 'T_HYPERLINK' ).
CATCH cx_salv_data_error. "#EC NO_HANDLER
ENDTRY.
TRY.
lr_column ?= lr_columns->get_column( 'URL' ).
lr_column->set_cell_type( if_salv_c_cell_type=>link ).
lr_column->set_long_text( 'URL' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
lr_functional_settings = gr_table->get_functional_settings( ).
lr_hyperlinks = lr_functional_settings->get_hyperlinks( ).
LOOP AT gt_hyperlink INTO ls_hyperlink.
TRY.
lr_hyperlinks->add_hyperlink(
handle = ls_hyperlink-handle
hyperlink = ls_hyperlink-hyperlink ).
CATCH cx_salv_existing. "#EC NO_HANDLER
ENDTRY.
ENDLOOP.
DATA: lr_events TYPE REF TO cl_salv_events_table.
lr_events = gr_table->get_event( ).
CREATE OBJECT gr_events.
SET HANDLER gr_events->on_link_click FOR lr_events.
gr_table->display( ).
ENDFORM. " display -
Program using class "cl_salv_table"
Hi Experts,
I am new to this class (cl_salv_table). I wrote a program with general ABAP code. But, according to my standard I should use standard ALV factory class i.e., 'CL_SALV_TABLE'. I wouls appreciate if anybody could send me the code using this class. Here is the code which I have written.
REPORT zrgae_acctquery
NO STANDARD PAGE HEADING
LINE-SIZE 190
LINE-COUNT 65
MESSAGE-ID zrga.
Program Title : SAP Account Coding Block Transaction Query Program*
Description : This program loads the legacy General Ledger *
account monthly net activity into the SAP-FI *
system using LSMW. This conversion pertains to *
companyu2019s GL account balances beginning with *
FY07 YE, posting monthly net changes in the *
accounts for FY2008 and FY2009 through go-live. *
Run Frequency: The Z-transaction must be available at any time *
an end user requires the conversion information. *
T A B L E D E C L A R A T I O N
TABLES: ztt_rga_xreft.
D A T A D E C L A R A T I O N
DATA: group_id(3) TYPE c,
l_line TYPE i.
I N T E R N A L T A B L E S
TYPES: BEGIN OF lty_ztt_rga_xreft,
ctacct TYPE ztt_rga_xreft-ctacct,
ctrc01 TYPE ztt_rga_xreft-ctrc01,
ctrc02 TYPE ztt_rga_xreft-ctrc02,
ctrc03 TYPE ztt_rga_xreft-ctrc03,
ctrc04 TYPE ztt_rga_xreft-ctrc04,
ctrc05 TYPE ztt_rga_xreft-ctrc05,
ctrc06 TYPE ztt_rga_xreft-ctrc06,
ctrc07 TYPE ztt_rga_xreft-ctrc07,
ctrc08 TYPE ztt_rga_xreft-ctrc08,
bukrs TYPE ztt_rga_xreft-bukrs,
prctr TYPE ztt_rga_xreft-prctr,
kostl TYPE ztt_rga_xreft-kostl,
saknr TYPE ztt_rga_xreft-saknr,
aufnr TYPE ztt_rga_xreft-aufnr,
sap_offset TYPE ztt_rga_xreft-sap_offset,
END OF lty_ztt_rga_xreft.
DATA: lt_data TYPE STANDARD TABLE OF lty_ztt_rga_xreft, lwa_data TYPE lty_ztt_rga_xreft.
S E L E C T I O N S C R E E N D E F I N I T I O N S *
SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
PARAMETERS: p_lgsap RADIOBUTTON GROUP b1 USER-COMMAND rad DEFAULT 'X',
p_saplg RADIOBUTTON GROUP b1.
SELECTION-SCREEN END OF BLOCK a1.
SKIP.
SELECTION-SCREEN BEGIN OF BLOCK a2 WITH FRAME TITLE text-002. "ACC
SELECT-OPTIONS: s_lccode FOR ztt_rga_xreft-ctrc01 MODIF ID acc,
s_ldiv FOR ztt_rga_xreft-ctrc02 MODIF ID acc,
s_lreg FOR ztt_rga_xreft-ctrc03 MODIF ID acc,
s_lloc FOR ztt_rga_xreft-ctrc04 MODIF ID acc,
s_lcctr FOR ztt_rga_xreft-ctrc05 MODIF ID acc,
s_lacct FOR ztt_rga_xreft-ctrc06 MODIF ID acc,
s_lsacct FOR ztt_rga_xreft-ctrc07 MODIF ID acc.
SELECTION-SCREEN END OF BLOCK a2.
SKIP.
SELECTION-SCREEN BEGIN OF BLOCK a3 WITH FRAME TITLE text-003. "ALL
SELECT-OPTIONS: s_bukrs FOR ztt_rga_xreft-bukrs MODIF ID all,
s_prctr FOR ztt_rga_xreft-prctr MODIF ID all,
s_kostl FOR ztt_rga_xreft-kostl MODIF ID all,
s_saknr FOR ztt_rga_xreft-saknr MODIF ID all,
s_aufnr FOR ztt_rga_xreft-aufnr MODIF ID all.
SELECTION-SCREEN END OF BLOCK a3.
A T S E L E C T I O N S C R E E N
AT SELECTION-SCREEN OUTPUT.
CASE 'X'.
WHEN p_saplg.
group_id = 'ACC'.
SET CURSOR FIELD 'S_BUKRS-LOW'.
WHEN p_lgsap.
group_id = 'ALL'.
SET CURSOR FIELD 'S_LCCTR-LOW'.
ENDCASE.
LOOP AT SCREEN.
IF screen-group1 = group_id.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
S T A R T O F S E L E C T I O N
START-OF-SELECTION.
CLEAR l_line.
IF p_lgsap = 'X'. " If legacy input filled
INFINIUM CASE-I VALIDATIONS & OUTPUT *
PASSING INFINIUM 'COST CENTER','ACCOUNT',& 'SUB ACCT' *
IF s_lcctr-low NE ' ' AND s_lacct-low NE ' ' AND s_lsacct-low NE ' '.
SELECT ctrc01
ctrc02
ctrc03
ctrc04
ctrc05
ctrc06
ctrc07
ctrc08
bukrs
prctr
kostl
saknr
aufnr
sap_offset
FROM ztt_rga_xreft INTO TABLE lt_data
WHERE ctrc05 IN s_lcctr
AND ctrc06 IN s_lacct
AND ctrc07 IN s_lsacct.
DESCRIBE TABLE lt_data LINES l_line.
IF l_line < 0.
MESSAGE e001(zrga) with 'Cost Ctr,Acct,SubAcct are not valid.pl check'.
ENDIF.
INFINIUM CASE-II VALIDATIONS & OUTPUT *
PASSING INFINIUM 'COST CENTER'&'ACCOUNT' *
ELSEIF s_lcctr-low NE ' ' AND s_lacct-low NE ' '
AND s_lsacct-low EQ ' '.
SELECT ctrc01
ctrc02
ctrc03
ctrc04
ctrc05
ctrc06
ctrc07
ctrc08
bukrs
prctr
kostl
saknr
aufnr
sap_offset
FROM ztt_rga_xreft INTO TABLE lt_data WHERE ctrc05 IN s_lcctr
AND ctrc06 IN s_lacct.
DESCRIBE TABLE lt_data LINES l_line.
IF l_line < 0.
MESSAGE e002(zrga) with 'Cost Center,Account are not valid...pl check'.
ENDIF.
ENDIF.
INFINIUM CASE-III VALIDATIONS & OUTPUT *
PASSING INFINIUM 'COMPANY CODE'&'ACCOUNT' *
ELSEIF s_lccode-low NE ' ' AND s_lacct-low NE ' '.
SELECT ctrc01
ctrc02
ctrc03
ctrc04
ctrc05
ctrc06
ctrc07
ctrc08
bukrs
prctr
kostl
saknr
aufnr
sap_offset
FROM ztt_rga_xreft INTO TABLE lt_data WHERE ctrc01 IN s_lccode
AND ctrc06 IN s_lacct.
DESCRIBE TABLE lt_data LINES l_line.
IF l_line < 0.
MESSAGE e003(zrga) with 'Company code,Acct are not valid.pl check'.
ENDIF.
ELSE. " If SAP input filled
SAP CASE-I VALIDATIONS & OUTPUT *
PASSING SAP 'COST CENTER','ACCOUNT'&'INTERNAL ORDER' *
IF s_kostl-low NE ' ' AND s_saknr-low NE ' ' AND s_aufnr-low NE ' '.
SELECT ctrc01
ctrc02
ctrc03
ctrc04
ctrc05
ctrc06
ctrc07
ctrc08
bukrs
prctr
kostl
saknr
aufnr
sap_offset
FROM ztt_rga_xreft INTO TABLE lt_data WHERE kostl IN s_kostl
AND saknr IN s_saknr
AND aufnr IN s_aufnr.
DESCRIBE TABLE lt_data LINES l_line.
IF l_line < 0.
MESSAGE e004(zrga) with 'Cost Ctr,Acct,Int order are not valid...pl check'.
ENDIF.
SAP CASE-II VALIDATIONS & OUTPUT *
PASSING SAP 'COST CENTER'&'ACCOUNT' *
ELSEIF s_kostl-low NE ' ' AND s_saknr-low NE ' ' AND s_aufnr-low EQ ' '.
SELECT ctrc01
ctrc02
ctrc03
ctrc04
ctrc05
ctrc06
ctrc07
ctrc08
bukrs
prctr
kostl
saknr
aufnr
sap_offset
FROM ztt_rga_xreft INTO TABLE lt_data WHERE kostl IN s_kostl
AND saknr IN s_saknr.
DESCRIBE TABLE lt_data LINES l_line.
IF l_line < 0.
MESSAGE e005(zrga) with 'Cost Ctr,Acct are not valid...pl check'.
ENDIF.
ENDIF.
ENDIF.
O U T P U T
IF p_lgsap = 'X'. " If legacy input filled
WRITE:/2 'Infinium Company', 40 s_lccode-low,
/2 'Infinium Division', 40 s_ldiv-low,
/2 'Infinium Region', 40 s_lreg-low,
/2 'Infinium Location', 40 s_lloc-low,
/2 'Infinium Cost center', 40 s_lcctr-low,
/2 'Infinium Account', 40 s_lacct-low,
/2 'Infinium Sub-account', 40 s_lsacct-low.
ELSE. "If SAP input filled
WRITE:/2 'SAP Company', 40 s_bukrs-low,
/2 'SAP Cost center', 40 s_kostl-low,
/2 'SAP Profit center', 40 s_prctr-low,
/2 'SAP Account', 40 s_saknr-low,
/2 'SAP order', 40 s_aufnr-low.
ENDIF.
WRITE:/ sy-uline(190).
FORMAT COLOR COL_HEADING ON.
WRITE:/1 sy-vline,
2 'Infinium Company',
17 sy-vline,
18 'Infinium Division',
37 sy-vline,
38 'Infinium Region',
57 sy-vline,
58 'Infinium Location',
77 sy-vline,
78 'Infinium Cost Center',
97 sy-vline,
98 'Infinium Account',
114 sy-vline,
115 'Infinium Sub Account',
134 sy-vline.
FORMAT COLOR COL_HEADING OFF.
FORMAT COLOR COL_POSITIVE ON.
WRITE: 135 'SAP Company',
144 sy-vline,
145 'SAP Profit Center',
154 sy-vline,
155 'SAP Cost Center',
164 sy-vline,
165 'SAP Account',
174 sy-vline,
175 'SAP Order',
190 sy-vline.
FORMAT COLOR COL_POSITIVE OFF.
WRITE:/1 sy-vline.
WRITE:/ sy-uline(190).
WRITE:/ sy-uline(190).
LOOP AT lt_data into lwa_data.
FORMAT COLOR COL_HEADING ON.
WRITE:/1 sy-vline,
2 lwa_data-ctrc01,
17 sy-vline,
18 lwa_data-ctrc02,
37 sy-vline,
38 lwa_data-ctrc03,
57 sy-vline,
58 lwa_data-ctrc04,
77 sy-vline,
78 lwa_data-ctrc05,
97 sy-vline,
98 lwa_data-ctrc06,
114 sy-vline,
115 lwa_data-ctrc07,
134 sy-vline.
FORMAT COLOR COL_HEADING OFF.
FORMAT COLOR COL_POSITIVE ON.
WRITE: 135 lwa_data-bukrs,
144 sy-vline,
145 lwa_data-prctr,
154 sy-vline,
155 lwa_data-kostl,
164 sy-vline,
165 lwa_data-saknr,
174 sy-vline,
175 lwa_data-aufnr,
190 sy-vline.
FORMAT COLOR COL_POSITIVE OFF.
WRITE:/ sy-uline(190).
append lwa_data to lt_data.
clear lwa_data.
ENDLOOP.HI nani,
welcome
This is a sample program to illustrate several techniques:
use of dynamic selections
persistent data stored into cluster INDX
data definition at runtime
display internal table using SALV class
Just copy the code into a new program, create include for events, then copy status STANDARD from program SAPLSALV.
u have to add the SAVE function code to the disk button. It allow you to save modifications to the database.
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
*& Report zkarthik_update
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
report zkarthik_update.
Data definition
type-pools: rsds.
data: is_x030l type x030l,
it_x031l type table of x031l,
is_x031l type x031l.
data: w_selid type rsdynsel-selid,
it_tables type table of rsdstabs,
is_tables type rsdstabs,
it_fields type table of rsdsfields,
it_expr type rsds_texpr,
it_ranges type rsds_trange,
it_where type rsds_twhere,
is_where type rsds_where,
w_active type i.
data: w_repid type sy-repid,
w_dynnr type sy-dynnr,
wt_dynp type table of dynpread,
ws_dynp type dynpread.
data: it_content type ref to data,
is_content type ref to data.
data: w_okcode type sy-ucomm.
data: w_fdkey type x value u201801u2032.
data: w_akey type indx-srtfd,
w_rkey type indx-srtfd,
w_fkey type indx-srtfd.
Include to handle events on ALV display screen
include zbc_query_events.
field-symbols: <itab> type standard table,
<irec> type any.
Macros
define table_error.
message e398(00) with u2018Tableu2019 p_table &1.
end-of-definition.
define fixed_val.
assign component is_x031l-fieldname of structure <irec> to <fld>.
if sy-subrc = 0.
<fld> = &1.
endif.
end-of-definition.
Selection screen
selection-screen: begin of block b01 with frame.
parameters: p_table type tabname obligatory u201Ctable
memory id dtb
matchcode object dd_dbtb_16.
selection-screen: begin of line,
pushbutton 33(20) selopt user-command sel,
comment 55(15) selcnt,
end of line.
selection-screen: skip.
parameters: p_field type fieldname, u201Cfield
p_value type text132. u201Cvalue
selection-screen: end of block b01,
skip,
begin of block b02 with frame.
parameters: p_displ type c as checkbox default u2018Xu2019, u201Cdisplay
p_systm type c as checkbox. u201Csystem
selection-screen: end of block b02.
Initialization
initialization.
move u2018@4G@ Filter recordsu2019 to selopt.
ws_dynp-fieldname = u2018P_TABLEu2019.
append ws_dynp to wt_dynp.
Get dynamic selection from cluster
w_akey(1) = u2018Au2019.
w_akey+1(12) = sy-uname.
import w_active from database indx(xy) id w_akey.
w_rkey(1) = u2018Ru2019.
w_rkey+1(12) = sy-uname.
import it_expr from database indx(xy) id w_rkey.
w_rkey(1) = u2018Fu2019.
w_rkey+1(12) = sy-uname.
import it_fields from database indx(xy) id w_fkey.
PBO
at selection-screen output.
if w_active is initial.
clear: selcnt.
else.
write w_active to selcnt left-justified.
endif.
PAI
at selection-screen.
if p_table ne is_x030l-tabname.
perform f_init_table.
endif.
if sy-ucomm = u2018SELu2019.
if w_selid is initial.
perform f_init_selections.
endif.
Display free selection dialog
call function u2018FREE_SELECTIONS_DIALOGu2019
exporting
selection_id = w_selid
title = u2018Selectionu2019
status = 1
as_window = u2018Xu2019
importing
expressions = it_expr
field_ranges = it_ranges
number_of_active_fields = w_active
tables
fields_tab = it_fields
exceptions
others = 1.
Write dynamic selection to cluster
w_akey(1) = u2018Au2019.
w_akey+1(12) = sy-uname.
export w_active to database indx(xy) id w_akey.
w_rkey(1) = u2018Ru2019.
w_rkey+1(12) = sy-uname.
export it_expr to database indx(xy) id w_rkey.
w_rkey(1) = u2018Fu2019.
w_rkey+1(12) = sy-uname.
export it_fields to database indx(xy) id w_fkey.
endif.
if p_field is not initial.
read table it_x031l into is_x031l
with key fieldname = p_field.
if sy-subrc = 0.
if is_x031l-flag1 o w_fdkey.
message e129(53) with p_field p_table.
endif.
else.
message e804(5g) with p_field p_table.
endif.
endif.
at selection-screen on value-request for p_field.
w_repid = sy-repid.
w_dynnr = sy-dynnr.
call function u2018DYNP_VALUES_READu2019
exporting
dyname = w_repid
dynumb = w_dynnr
tables
dynpfields = wt_dynp
exceptions
others = 1.
if sy-subrc = 0.
read table wt_dynp into ws_dynp index 1.
p_table = ws_dynp-fieldvalue.
call function u2018F4_DD_TABLE_FIELDSu2019
exporting
table = p_table
importing
result = p_field.
endif.
Start of processing
start-of-selection.
perform f_create_table using p_table.
perform f_select_table.
perform f_modify_table.
perform f_display_table using <itab>.
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
*& Form f_init_table
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
form f_init_table.
Prepare free selection on table
perform f_table_def using p_table.
refresh it_tables.
is_tables-prim_tab = p_table.
append is_tables to it_tables.
clear: w_selid.
endform. u201Cf_init_table
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
*& Form f_init_selections
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
form f_init_selections.
Init free selection dialog
call function u2018FREE_SELECTIONS_INITu2019
exporting
expressions = it_expr
importing
selection_id = w_selid
expressions = it_expr
tables
tables_tab = it_tables
fields_tab = it_fields
exceptions
others = 1.
endform. u201Cf_init_selections
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
FORM f_table_def *
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
form f_table_def using in_tabname.
call function u2018DDIF_NAMETAB_GETu2019
exporting
tabname = p_table
importing
x030l_wa = is_x030l
tables
x031l_tab = it_x031l
exceptions
others = 1.
if is_x030l is initial.
table_error u2018does not exist or is not activeu2019.
elseif is_x030l-tabtype ne u2018Tu2019.
table_error u2018is not selectableu2019.
endif.
endform. u201Cf_table_def
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
FORM f_create_table *
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
form f_create_table using in_tabname.
create data it_content type table of (in_tabname).
if sy-subrc = 0.
assign it_content->* to <itab>.
else.
write: u2018Error creating internal tableu2019.
stop.
endif.
endform. u201Cf_create_table
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
FORM f_select_table *
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
form f_select_table.
if w_active = 0.
select * from (p_table)
into corresponding fields of table <itab>.
else.
Selection with parameters
call function u2018FREE_SELECTIONS_EX_2_WHEREu2019
exporting
expressions = it_expr
importing
where_clauses = it_where
exceptions
expression_not_supported = 1
others = 2.
read table it_where into is_where with key tablename = p_table.
select * from (p_table)
into corresponding fields of table <itab>
where (is_where-where_tab).
endif.
if sy-dbcnt = 0.
write: u2018No record selectedu2019.
stop.
endif.
endform. u201Cf_select_table
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
FORM f_modify_table *
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
form f_modify_table.
field-symbols: <fld> type any.
loop at <itab> assigning <irec>.
if p_field is not initial.
assign component p_field of structure <irec> to <fld>.
if sy-subrc = 0.
call function u2018GENERIC_CONVERSION_EXIT_INPUTu2019
exporting
i_tabname = p_table
i_fieldname = p_field
input_text = p_value
importing
output_text = <fld>
exceptions
invalid_ddic_parameters = 1
invalid_input = 2
others = 3.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endif.
endif.
if p_systm is not initial.
Default values for system fields
loop at it_x031l into is_x031l.
if is_x031l-dtyp = u2018CLNTu2019.
fixed_val sy-mandt.
elseif is_x031l-rollname = u2018ERDATu2019
or is_x031l-rollname = u2018ERSDAu2019
or is_x031l-rollname = u2018AEDATu2019
or is_x031l-rollname = u2018LAEDAu2019.
fixed_val sy-datum.
elseif is_x031l-rollname = u2018ERTIMu2019
or is_x031l-rollname = u2018AETIMu2019.
fixed_val sy-uzeit.
elseif is_x031l-rollname = u2018ERNAMu2019
or is_x031l-rollname = u2018AENAMu2019.
fixed_val sy-uname.
endif.
endloop.
endif.
endloop.
endform. u201Cf_modify_table
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
FORM f_display_table *
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
form f_display_table using in_table.
data: ob_table type ref to cl_salv_table,
ob_event type ref to cl_salv_events_table,
cx_error type ref to cx_salv_msg.
try.
call method cl_salv_table=>factory
importing
r_salv_table = ob_table
changing
t_table = in_table.
catch cx_salv_msg into cx_error.
exit.
endtry.
if p_displ is initial and
p_field is not initial.
call method ob_table->set_screen_status
exporting
report = u2018ZBC_UPDATE_TABLEu2019
pfstatus = u2018STANDARDu2019
set_functions = ob_table->c_functions_all.
ob_event = ob_table->get_event( ).
create object ob_appl.
set handler ob_appl->on_user_command for ob_event.
else.
call method ob_table->set_screen_status
exporting
report = u2018SAPLSALVu2019
pfstatus = u2018STANDARDu2019
set_functions = ob_table->c_functions_all.
endif.
call method ob_table->display.
endform. u201Cf_display_table
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
*& Form user_command
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
form user_command using in_command type salv_de_function.
data: l_messg type string,
l_answer type c.
data: ls_expr type string.
check in_command = u2018SAVEu2019.
l_messg = u2018Overwrite field for all selected records ?u2019.
call function u2018POPUP_TO_CONFIRMu2019
exporting
titlebar = u2018Update tableu2019
text_question = l_messg
default_button = u20182u2032
display_cancel_button = u2018 u2018
popup_type = u2018@1A@u2019
importing
answer = l_answer
exceptions
text_not_found = 1
others = 2.
if l_answer = u20181u2032.
concatenate p_field u2018= u201Du2019 into ls_expr
separated by space.
concatenate ls_expr p_value u201Du201D into ls_expr.
try.
update (p_table) set (ls_expr)
where (is_where-where_tab).
catch cx_sy_dynamic_osql_error.
rollback work.
message u2018Error during update!u2019 type u2018Iu2019.
endtry.
if sy-subrc = 0.
commit work.
endif.
endif.
endform. u201Cuser_command
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
*& Include ZBC_QUERY_EVENTS
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
class lcl_handle_events definition deferred.
data: ob_appl type ref to lcl_handle_events.
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014-
CLASS lcl_handle_events DEFINITION
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014-
class lcl_handle_events definition.
public section.
methods:
on_user_command for event added_function of cl_salv_events
importing e_salv_function,
on_before_salv_function for event before_salv_function of cl_salv_events
importing e_salv_function,
on_after_salv_function for event after_salv_function of cl_salv_events
importing e_salv_function,
on_double_click for event double_click of cl_salv_events_table
importing row column,
on_link_click for event link_click of cl_salv_events_table
importing row column.
endclass. u201Clcl_handle_events DEFINITION
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014-
CLASS lcl_handle_events IMPLEMENTATION
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014-
class lcl_handle_events implementation.
method on_user_command.
perform user_command in program (sy-repid) if found
using e_salv_function.
endmethod. u201Con_user_command
method on_before_salv_function.
perform before_function in program (sy-repid) if found
using e_salv_function.
endmethod. u201Con_before_salv_function
method on_after_salv_function.
perform after_function in program (sy-repid) if found
using e_salv_function.
endmethod. u201Con_after_salv_function
method on_double_click.
perform double_click in program (sy-repid) if found
using row column.
endmethod. u201Con_double_click
method on_link_click.
perform link_click in program (sy-repid) if found
using row column.
endmethod. u201Con_single_click
endclass. u201Clcl_handle_events IMPLEMENTATION
thanks
karthik -
Can I have multiple hotspots on the same ALV grid?
Hi,
I have a simple ALV grid report with a hotspot. I can't seem to find any examples or information on whether I can have 2 hotspots on the same ALV grid line.
Is this possible and is there an example somewhere that I can look at?
Thanks for your help!
AndyCheck the code below
METHODS:set_hotspot_ebeln CHANGING pc_alv TYPE REF TO cl_salv_table
pc_report TYPE REF TO lcl_report.
*--Event Handlers for alv
METHODS:on_link_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING row column .
METHOD set_hotspot_ebeln.
DATA: lf_cols_tab TYPE REF TO cl_salv_columns_table,
lf_col_tab TYPE REF TO cl_salv_column_table.
DATA: lf_events TYPE REF TO cl_salv_events_table.
lf_cols_tab = pc_alv->get_columns( ).
TRY.
lf_col_tab ?= lf_cols_tab->get_column( 'VGBEL' ).
CATCH cx_salv_not_found.
ENDTRY.
TRY.
CALL METHOD lf_col_tab->set_cell_type
EXPORTING
value = if_salv_c_cell_type=>hotspot. "5-stands for hot spot
CATCH cx_salv_data_error .
ENDTRY.
TRY.
lf_col_tab ?= lf_cols_tab->get_column( 'VBELN' ).
CATCH cx_salv_not_found.
ENDTRY.
TRY.
CALL METHOD lf_col_tab->set_cell_type
EXPORTING
value = if_salv_c_cell_type=>hotspot. "5-stands for hot spot
CATCH cx_salv_data_error .
ENDTRY.
lf_events = pc_alv->get_event( ).
*--Set event handler for click on cell
SET HANDLER lf_report->on_link_click FOR lf_events.
ENDMETHOD. "set_hotspot_ebeln
METHOD on_link_click.
DATA:la_put TYPE type_put.
READ TABLE lf_report->i_put INTO la_put INDEX row.
CHECK sy-subrc = 0.
if column = 'VGBEL'.
SET PARAMETER ID 'BES' FIELD la_put-vgbel.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
elseif column = 'VBELN'
"<----
endif.
ENDMETHOD. "on_link_click -
ABAP OO: traffic lights in ALV
Hello,
Instead of going the easy way, I decided to practise a bit of ABAP OO (which I am still quite unfamiliar with), and do ALV list to my new report by using CL_SALV_TABLE class.
This seems to be quite clear if I just follow Rich's great instructions:
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/eac1fa0b-0e01-0010-0990-8530de4908a6
The only thing that is not so clear is that how can I add traffic (or led) lights to my ALV list when using class CL_SALV_TABLE. Does someone has an example?
Another bonus question: Do I always have to define the field catalog (with CL_SALV_TABLE) when using internal table of my own type?Hello
Have a look at the sample report
SALV_DEMO_TABLE_COLUMNS.Following is the in-line documentation of the report:
*& Report SALV_DEMO_TABLE_COLUMNS
report salv_demo_table_columns no standard page heading.
*... This report demonstrates the settings for the columns.
* The demonstration uses the new ALV API
* - cl_salv_table (Fullscreen Grid, Fullscreen List, Grid)
* - cl_salv_hierseq_table (hierseq. lists)
* If the table ALV_T_T2 is empty, please create data for the demo
* by running report BCALV_GENERATE_ALV_T_T2
* §1 select data into global output table
* §2 create ALV Table
* create instance of cl_salv_table for displaying a list of your
* output table
* §2.1 create a ALV List by setting the parameter LIST_DISPLAY of the
* constructor cl_salv_table to 'X'
* §2.2 create a ALV Fullscreen Grid by not setting the parameter
* LIST_DISPLAY of the constructor cl_salv_table to 'X'
* §2.3 create a Grid by creating a Dynpro with a container in it. In
* PBO check if the container has been instantiated. If the
* container has not yet been instantiated then this is the first
* call:
* (1) create the container
* (2) create an instance of cl_salv_table
* §3 Functions
* §3.1 activate ALV generic Functions
* §3.2 include own functions
* §4 Cell Types
* §4.1 Exception Column
* §4.2 Icon Column
* §4.3 Symbol Column
* §4.4 Checkbox Column
* §4.5 Hotspot Column
* §4.6 Button Column
* §4.7 Hyperlink Column
* §4.8 Dropdown Column
* §4.9 Tooltip Information for Exceptions, Icons and Symbols
* §5 Color
* §5.1 set the color of a complete column by calling the method
* set_color of cl_salv_column of the column
* §5.2 set the color of a complete row
* note: by setting the columnname information the same
* technique can be used for setting the color of cells
* (1) register the column in which the color information
* for the row is held
* (2) set the color information to the row in the output
* table
* note: do not fill the parameter FNAME for setting the
* color of the complete row
* fill the parameter FNAME for setting the color
* of a cell (Row and Column are definied)
* §6 Event Handler
* define a handler for the events of cl_salv_table
* §6.1 define a local class for handling events of cl_salv_table
* define methods for the events which are to be handled
* §6.2 implement the defined methods for handling the events of
* cl_salv_table
* §7 Events
* register to events of cl_salv_table
* §7.1 register to the event USER_COMMAND of cl_salv_table
* for receiving information when own functions has been selected
* §7.2 register to the event DOUBLE_CLICK of cl_salv table
* for receiving information when user has double clicked on a line
* §7.3 register to the event LINK_CLICK of cl_salv_table
* for receiving information when user has initiated a hotspot click
* §8 Display
* display the configurated ALV Table by calling the method
* display of cl_salv_table.
Regards
Uwe -
Display Traffic Lights in ALV TREE
Hi,
I have to display traffic light in ALV tree but i am not able to find out what parameter i should pass like in ALV grid where we can set is_layout (BCALV_GRID_04).
Thanks in advance.
Regards,
HarshHi,
Please take a look at my code below. Hope it suits your requirement.
P.S. Please award points if it helps...
*& Report ZMM_R_PO_TO_IPURCH_XI
*& PROGRAM TYPE : Report
*& RICEF ID :
*& TITLE : ZMM_R_PO_TO_IPURCH_XI
*& SAP Module : MM
*& CREATION DATE : 02/06/2008
*& AUTHOR : Aris Hidalgo
*& DESIGNER : Aris Hidalgo
*& DESCRIPTION :
*$**********************************************************************
*$ CHANGE HISTORY
*$----------------------------------------------------------------------
*$ DATE | T-Num | Description | Reference
** | | |
*$**********************************************************************
REPORT zmm_r_po_to_ipurch_xi
NO STANDARD PAGE HEADING
MESSAGE-ID zmm.
* Data Dictionary Table/s *
TABLES: edidc.
* SELECTION-SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_credat FOR edidc-credat OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: rb_sum RADIOBUTTON GROUP grp1,
rb_det RADIOBUTTON GROUP grp1.
SELECTION-SCREEN END OF BLOCK b2.
*/ CLASS DEFINITION/S /*
* CLASS lcl_data_def DEFINITION
CLASS lcl_data_def DEFINITION ABSTRACT.
PUBLIC SECTION.
TYPES: BEGIN OF t_edidc,
docnum TYPE edidc-docnum,
docrel TYPE edidc-docrel,
status TYPE edidc-status,
doctyp TYPE edidc-doctyp,
direct TYPE edidc-direct,
rcvpor TYPE edidc-rcvpor,
rcvprt TYPE edidc-rcvprt,
rcvprn TYPE edidc-rcvprn,
rcvsad TYPE edidc-rcvsad,
sndpor TYPE edidc-sndpor,
sndprt TYPE edidc-sndprt,
sndprn TYPE edidc-sndprn,
sndsad TYPE edidc-sndsad,
credat TYPE edidc-credat,
cretim TYPE edidc-cretim,
mestyp TYPE edidc-mestyp,
idoctp TYPE edidc-idoctp,
END OF t_edidc.
TYPES: BEGIN OF t_output,
exception TYPE char1,
ebeln TYPE ekko-ebeln,
lifnr TYPE lfa1-lifnr,
name1 TYPE lfa1-name1,
credat TYPE edidc-credat,
cretim TYPE edidc-cretim,
END OF t_output.
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekko-ebeln,
lifnr TYPE ekko-lifnr,
END OF t_ekko.
TYPES: BEGIN OF t_lfa1,
lifnr TYPE lfa1-lifnr,
name1 TYPE lfa1-name1,
END OF t_lfa1.
DATA: gt_edidc TYPE STANDARD TABLE OF t_edidc,
gt_output TYPE STANDARD TABLE OF t_output,
wa_output LIKE LINE OF gt_output,
gt_ekko TYPE HASHED TABLE OF t_ekko
WITH UNIQUE KEY ebeln,
gt_lfa1 TYPE HASHED TABLE OF t_lfa1
WITH UNIQUE KEY lifnr.
ENDCLASS. "lcl_data_def DEFINITION
CLASS lcl_alv_routines DEFINITION DEFERRED.
CLASS lcl_handle_events DEFINITION DEFERRED.
* CLASS lcl_get_data DEFINITION
CLASS lcl_get_data DEFINITION INHERITING FROM lcl_data_def.
PUBLIC SECTION.
METHODS: get_idocs,
read_idocs,
process_data
IMPORTING
im_docnum TYPE edidc-docnum.
PRIVATE SECTION.
CONSTANTS: lc_mestyp TYPE edidc-mestyp VALUE 'ZMARKETSITE_PURCHASE_ORDER',
lc_idoctp TYPE edidc-idoctp VALUE 'ZMARKETSITE_PURCHASE_ORDER01',
lc_segnam TYPE edid4-segnam VALUE 'ZMARKETSITE_ORDER_HEADER1'.
CONSTANTS: lc_red TYPE i VALUE 1,
lc_yellow TYPE i VALUE 2,
lc_green TYPE i VALUE 3.
DATA: lv_stat_message TYPE bdidocattr-message,
o_lcl_alv_routines TYPE REF TO lcl_alv_routines.
DATA: ls_idoc_control TYPE edidc,
lv_tot_data_recs TYPE sy-dbcnt, "#EC NEEDED
lv_tot_status_recs TYPE sy-dbcnt. "#EC NEEDED
DATA: lt_edids TYPE STANDARD TABLE OF edids,
lt_edidd TYPE STANDARD TABLE OF edidd.
ENDCLASS. "lcl_get_data DEFINITION
* CLASS lcl_alv_routines DEFINITION
CLASS lcl_alv_routines DEFINITION INHERITING FROM lcl_get_data.
PUBLIC SECTION.
DATA: lcl_table TYPE REF TO cl_salv_table,
lcl_container TYPE REF TO cl_gui_custom_container,
lcl_handle_events TYPE REF TO lcl_handle_events,
lcl_columns TYPE REF TO cl_salv_columns_table,
lcl_column TYPE REF TO cl_salv_column_table,
lcl_events2 TYPE REF TO cl_salv_events_table,
lcl_display_settings TYPE REF TO cl_salv_display_settings,
lcl_functions TYPE REF TO cl_salv_functions_list,
lcl_display TYPE REF TO cl_salv_display_settings,
lcl_aggregations TYPE REF TO cl_salv_aggregations,
lcl_sorts TYPE REF TO cl_salv_sorts,
lcl_content TYPE REF TO cl_salv_form_element,
lcl_header TYPE REF TO cl_salv_form_header_info,
ls_color TYPE lvc_s_colo.
DATA: lcl_grid TYPE REF TO cl_salv_form_layout_grid,
lcl_grid_1 TYPE REF TO cl_salv_form_layout_grid,
lcl_grid_2 TYPE REF TO cl_salv_form_layout_grid,
lcl_label TYPE REF TO cl_salv_form_label,"#EC NEEDED
lcl_text TYPE REF TO cl_salv_form_text,
gt_t247 TYPE STANDARD TABLE OF t247,
wa_t247 LIKE LINE OF gt_t247,
lv_text TYPE string.
METHODS: display_data
IMPORTING
im_output LIKE gt_output,
display_top_of_page.
PRIVATE SECTION.
DATA: lv_string TYPE string,
lv_date1 TYPE c LENGTH 10,
lv_time TYPE c LENGTH 10,
lv_title TYPE string.
ENDCLASS. "lcl_alv_routines DEFINITION
* CLASS lcl_handle_events DEFINITION
CLASS lcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS:
on_link_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING row column.
ENDCLASS. "lcl_handle_events DEFINITION
*/ IMPLEMENTATION/S /*
* CLASS lcl_get_data IMPLEMENTATION
CLASS lcl_get_data IMPLEMENTATION.
* METHOD get_idocs
METHOD get_idocs.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
* PERCENTAGE = 0
text = text-p01.
SELECT docnum docrel status doctyp
direct rcvpor rcvprt rcvprn
rcvsad sndpor sndprt sndprn
sndsad credat cretim mestyp
idoctp
FROM edidc
INTO TABLE gt_edidc
WHERE mestyp = lc_mestyp
AND idoctp = lc_idoctp
AND credat IN s_credat.
IF gt_edidc[] IS NOT INITIAL.
* Get IDOC details
CALL METHOD me->read_idocs.
ENDIF.
ENDMETHOD. "get_idocs
* METHOD read_idocs
METHOD read_idocs.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
* PERCENTAGE = 0
text = text-p02.
FIELD-SYMBOLS: <fs_edidc> LIKE LINE OF gt_edidc,
<fs_output> LIKE LINE OF gt_output,
<fs_ekko> LIKE LINE OF gt_ekko,
<fs_lfa1> LIKE LINE OF gt_lfa1.
LOOP AT gt_edidc ASSIGNING <fs_edidc>.
CLEAR ls_idoc_control.
REFRESH: lt_edids, lt_edidd.
* Get status text of IDOC
CALL FUNCTION 'IDOC_GET_MESSAGE_ATTRIBUTE'
EXPORTING
idoc_number = <fs_edidc>-docnum
IMPORTING
idoc_message = lv_stat_message.
* Get IDOC details
CALL FUNCTION 'IDOC_READ_COMPLETELY'
EXPORTING
document_number = <fs_edidc>-docnum
IMPORTING
idoc_control = ls_idoc_control
number_of_data_records = lv_tot_data_recs
number_of_status_records = lv_tot_status_recs
TABLES
int_edids = lt_edids
int_edidd = lt_edidd
EXCEPTIONS
document_not_exist = 1
document_number_invalid = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Pass data to output table
CALL METHOD me->process_data
EXPORTING
im_docnum = <fs_edidc>-docnum.
ENDLOOP.
DELETE gt_output WHERE ebeln IS INITIAL.
IF gt_output[] IS NOT INITIAL.
* Get vendor for fetched POs
SELECT ebeln lifnr
FROM ekko
INTO TABLE gt_ekko
FOR ALL ENTRIES IN gt_output
WHERE ebeln = gt_output-ebeln.
IF gt_ekko[] IS NOT INITIAL.
* Get name of vendors
SELECT lifnr name1
FROM lfa1
INTO TABLE gt_lfa1
FOR ALL ENTRIES IN gt_ekko
WHERE lifnr = gt_ekko-lifnr.
ENDIF.
* Pass vendor details to output table
LOOP AT gt_output ASSIGNING <fs_output>.
READ TABLE gt_ekko ASSIGNING <fs_ekko>
WITH TABLE KEY ebeln = <fs_output>-ebeln.
IF sy-subrc = 0.
READ TABLE gt_lfa1 ASSIGNING <fs_lfa1>
WITH TABLE KEY lifnr = <fs_ekko>-lifnr.
IF sy-subrc = 0.
<fs_output>-lifnr = <fs_lfa1>-lifnr.
<fs_output>-name1 = <fs_lfa1>-name1.
ENDIF.
ENDIF.
ENDLOOP.
CREATE OBJECT o_lcl_alv_routines.
CALL METHOD o_lcl_alv_routines->display_data
EXPORTING
im_output = gt_output[].
ENDIF.
ENDMETHOD. "read_idocs
* METHOD process_data
METHOD process_data.
FIELD-SYMBOLS: <fs_edidd> LIKE LINE OF lt_edidd.
IF lv_stat_message CP 'ok' OR
lv_stat_message CP 'positive'.
wa_output-exception = lc_green.
ELSEIF lv_stat_message CP 'error' OR
lv_stat_message CP 'negative'.
wa_output-exception = lc_red.
ELSE.
wa_output-exception = lc_yellow.
ENDIF.
READ TABLE lt_edidd ASSIGNING <fs_edidd>
WITH KEY docnum = im_docnum
segnam = lc_segnam.
IF sy-subrc = 0.
wa_output-ebeln = <fs_edidd>-sdata+0(10).
ENDIF.
wa_output-credat = ls_idoc_control-credat.
wa_output-cretim = ls_idoc_control-cretim.
APPEND wa_output TO gt_output.
CLEAR wa_output.
ENDMETHOD. "process_data
ENDCLASS. "lcl_get_data IMPLEMENTATION
* CLASS lcl_alv_routines IMPLEMENTATION
CLASS lcl_alv_routines IMPLEMENTATION.
* METHOD display_data
METHOD display_data.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = 0
text = text-p03.
gt_output[] = im_output[].
TRY.
cl_salv_table=>factory(
EXPORTING
list_display = ''
IMPORTING
r_salv_table = lcl_table
CHANGING
t_table = gt_output ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
lcl_functions = lcl_table->get_functions( ).
* Set all standard ALV functions
lcl_functions->set_all( abap_true ).
lcl_columns = lcl_table->get_columns( ).
lcl_columns->set_optimize( '' ).
* Set display to striped pattern
lcl_display = lcl_table->get_display_settings( ).
lcl_display->set_striped_pattern( cl_salv_display_settings=>true ).
*/Sort columns
TRY.
lcl_sorts = lcl_table->get_sorts( ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
lcl_sorts->set_group_active( ).
TRY.
lcl_sorts->add_sort(
columnname = 'EBELN'
subtotal = '' ).
CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER
ENDTRY.
*/Set column names
TRY.
lcl_columns->set_exception_column( 'EXCEPTION' ).
CATCH cx_salv_data_error. "#EC NO_HANDLER
ENDTRY.
TRY.
lcl_column ?= lcl_columns->get_column( 'EXCEPTION' ).
lcl_column->set_short_text( text-h01 ).
lcl_column->set_medium_text( text-h01 ).
lcl_column->set_long_text( text-h01 ).
lcl_column->set_output_length( '6' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
TRY.
lcl_column ?= lcl_columns->get_column( 'EBELN' ).
lcl_column->set_short_text( text-h02 ).
lcl_column->set_medium_text( text-h02 ).
lcl_column->set_long_text( text-h02 ).
lcl_column->set_output_length( '9' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
TRY.
lcl_column ?= lcl_columns->get_column( 'LIFNR' ).
* lcl_column->set_short_text( text-h03 ).
lcl_column->set_medium_text( text-h03 ).
lcl_column->set_long_text( text-h03 ).
lcl_column->set_output_length( '11' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
TRY.
lcl_column ?= lcl_columns->get_column( 'NAME1' ).
* lcl_column->set_short_text( text-h04 ).
* lcl_column->set_medium_text( text-h04 ).
lcl_column->set_long_text( text-h04 ).
lcl_column->set_output_length( '30' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
TRY.
lcl_column ?= lcl_columns->get_column( 'CREDAT' ).
* lcl_column->set_short_text( text-h05 ).
* lcl_column->set_medium_text( text-h05 ).
lcl_column->set_long_text( text-h05 ).
lcl_column->set_output_length( '13' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
TRY.
lcl_column ?= lcl_columns->get_column( 'CRETIM' ).
* lcl_column->set_short_text( text-h06 ).
* lcl_column->set_medium_text( text-h06 ).
lcl_column->set_long_text( text-h06 ).
lcl_column->set_output_length( '13' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
*/Set aggregations
* TRY.
* lcl_aggregations = lcl_table->get_aggregations( ).
* CATCH cx_salv_not_found. "#EC NO_HANDLER
* ENDTRY.
* TRY.
* lcl_aggregations->add_aggregation( '' ).
* CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER
* ENDTRY.
*/Hide columns
* TRY.
* lcl_column ?= lcl_columns->get_column( 'DESCRIPT' ).
* lcl_column->set_visible( if_salv_c_bool_sap=>false ).
* CATCH cx_salv_not_found. "#EC NO_HANDLER
* ENDTRY.
*/Display top of page
CALL METHOD me->display_top_of_page.
lcl_table->set_top_of_list( lcl_content ).
*/Handle ALV events
lcl_events2 = lcl_table->get_event( ).
CREATE OBJECT lcl_handle_events.
SET HANDLER lcl_handle_events->on_link_click FOR lcl_events2.
lcl_display_settings = lcl_table->get_display_settings( ).
lcl_table->display( ).
ENDMETHOD. "display_data
* METHOD display_top_of_page
METHOD display_top_of_page.
CREATE OBJECT lcl_grid.
lv_title = text-t01.
lcl_grid->create_header_information(
row = 1
column = 1
text = lv_title
tooltip = lv_title ).
lcl_grid->add_row( ).
lcl_grid_1 = lcl_grid->create_grid(
row = 3
column = 1 ).
CLEAR lv_string.
CONCATENATE: sy-datum+4(2) '/' sy-datum+6(2) '/' sy-datum+0(4)
INTO lv_date1.
CONCATENATE: text-t02 lv_date1
INTO lv_string
SEPARATED BY space.
lcl_label = lcl_grid_1->create_label(
row = 1
column = 1
text = lv_string
tooltip = lv_string ).
CLEAR lv_string.
CONCATENATE: sy-uzeit+0(2) ':' sy-uzeit+2(2) ':' sy-uzeit+4(2)
INTO lv_time.
CONCATENATE: text-t03 lv_time
INTO lv_string
SEPARATED BY space.
lcl_label = lcl_grid_1->create_label(
row = 2
column = 1
text = lv_string
tooltip = lv_string ).
lcl_content = lcl_grid.
ENDMETHOD. "display_top_of_page
ENDCLASS. "lcl_alv_routines IMPLEMENTATION
* CLASS lcl_handle_events IMPLEMENTATION
CLASS lcl_handle_events IMPLEMENTATION.
* METHOD on_link_click
METHOD on_link_click.
ENDMETHOD. "on_link_click
ENDCLASS. "lcl_handle_events IMPLEMENTATION
* START-OF-SELECTION *
START-OF-SELECTION.
DATA: o_lcl_get_data TYPE REF TO lcl_get_data.
CREATE OBJECT o_lcl_get_data.
CALL METHOD o_lcl_get_data->get_idocs. -
Multiple traffic lights in ALV
Hi friends,
is it possible to have more than one traffic lights colomn in ALV OO ?
i displayed the first one, but i need to display 3 traffic lights in 3 different colomns in my ALV (wich has 10 columns)
Thanks in advance,
SoufianeCopy this and paste in your test program. execute it and see
REPORT ysam_test5 MESSAGE-ID zsummit.
TYPE-POOLS: icon.
DATA: marc TYPE marc.
TYPES: BEGIN OF t_marc,
matnr TYPE matnr,
werks TYPE werks_d,
mmsta TYPE mmsta,
maabc TYPE maabc,
action(4) TYPE c,
action1(4) type c,
action2(4) type c,
END OF t_marc.
DATA: it_marc TYPE TABLE OF t_marc,
wa_marc TYPE t_marc.
FIELD-SYMBOLS: .
DATA: w_recipient TYPE swc_object,
w_recipient_obj TYPE swotobjid.
*container macro
swc_container w_swc_container.
*batch job information
INCLUDE lbtchdef.
DATA: w_job TYPE tbtcjob.
*constants
CONSTANTS: c_on VALUE 'X',
c_off VALUE space,
c_int(11) VALUE ' 0123456789'.
Objects for handling the events
CLASS lcl_handle_events DEFINITION DEFERRED.
DATA: w_events_grid TYPE REF TO lcl_handle_events.
CLASS lcl_handle_events DEFINITION
CLASS lcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS:
on_link_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING row column.
ENDCLASS. "lcl_handle_events DEFINITION
CLASS lcl_handle_events IMPLEMENTATION
CLASS lcl_handle_events IMPLEMENTATION.
METHOD on_link_click.
IF column = 'ACTION'.
READ TABLE it_marc ASSIGNING refresh.
ENDIF.
ENDMETHOD. "on_single_click
ENDCLASS. "lcl_handle_events IMPLEMENTATION
SELECTION-SCREEN BEGIN OF BLOCK main WITH FRAME.
SELECT-OPTIONS: s_matnr FOR marc-matnr,
s_werks FOR marc-werks.
SELECTION-SCREEN BEGIN OF BLOCK back WITH FRAME TITLE text-ss2.
PARAMETERS: p_fore RADIOBUTTON GROUP proc DEFAULT 'X', "foreground
p_ball RADIOBUTTON GROUP proc,
p_berr RADIOBUTTON GROUP proc.
SELECTION-SCREEN END OF BLOCK back.
SELECTION-SCREEN BEGIN OF BLOCK mail WITH FRAME TITLE text-ss3.
PARAMETERS: p_print RADIOBUTTON GROUP mail DEFAULT 'X',
p_email RADIOBUTTON GROUP mail.
SELECTION-SCREEN END OF BLOCK mail.
SELECTION-SCREEN END OF BLOCK main.
START-OF-SELECTION.
PERFORM select_data.
END-OF-SELECTION.
PERFORM salv_grid.
*& Form salv_grid
text
FORM salv_grid .
DATA: lref TYPE REF TO cx_root .
DATA: lr_layout TYPE REF TO cl_salv_layout,
ls_key TYPE salv_s_layout_key.
Icon
DATA: l_columns TYPE REF TO cl_salv_columns,
l_column TYPE REF TO cl_salv_column_table.
DATA: l_icon TYPE REF TO cl_salv_column_list.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = it_marc ).
CATCH cx_salv_msg INTO lref.
ENDTRY.
***Sub Total
PERFORM sub_total.
***Layout
lr_layout = gr_table->get_layout( ).
ls_key-report = sy-cprog.
lr_layout->set_key( ls_key ).
lr_layout->set_default( 'X' ).
lr_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
***toolbar
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( 'X' ).
icon
l_columns = gr_table->get_columns( ).
TRY.
l_column ?= l_columns->get_column( 'ACTION' ).
l_column->set_short_text( 'Execute' ).
l_column->set_icon( IF_SALV_C_BOOL_SAP=>FALSE ).
CATCH cx_salv_not_found.
ENDTRY.
TRY.
l_column ?= l_columns->get_column( 'ACTION' ).
l_column->set_icon( if_salv_c_bool_sap=>true ).
CATCH cx_salv_not_found.
ENDTRY.
TRY.
l_column ?= l_columns->get_column( 'ACTION' ).
l_column->set_cell_type( if_salv_c_cell_type=>hotspot ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
*... §6.5 register to the event LINK_CLICK
DATA: lr_events TYPE REF TO cl_salv_events_table.
lr_events = gr_table->get_event( ).
CREATE OBJECT w_events_grid.
SET HANDLER w_events_grid->on_link_click FOR lr_events.
*final display
gr_table->display( ).
ENDFORM. " salv
*& Form sub_total
FORM sub_total .
DATA: lr_aggregations TYPE REF TO cl_salv_aggregations.
lr_aggregations = gr_table->get_aggregations( ).
lr_aggregations->clear( ).
TRY.
lr_aggregations->add_aggregation( columnname = 'Z_BALANCE_REM' ).
CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing.
ENDTRY.
TRY.
lr_aggregations->add_aggregation( columnname = 'Z_PAY_AMT' ).
CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing.
ENDTRY.
ENDFORM. " sub_total
*& Form select_data
FORM select_data .
SELECT matnr werks mmsta maabc
INTO CORRESPONDING FIELDS OF TABLE it_marc
FROM marc
WHERE matnr IN s_matnr
AND werks IN s_werks.
IF sy-subrc = 0.
LOOP AT it_marc ASSIGNING -action = icon_execute_object.
ENDLOOP.
ENDIF.
ENDFORM. " select_data
enter material number and press execute icon - just come back from mm02 and it will display three lights. -
Display document from Content Server
Hello Expert,
I need to display document in CE portal, that are stored on ECC content server.
Does anyone know how to do this?
Thank you in advance.
Francois
Edited by: François BECKER on Oct 13, 2011 9:39 AMHi,
Try using this sample code
class lcl_handle_events definition.
public section.
methods:
on_double_click for event double_click of cl_salv_events_table
importing row column.
endclass. "lcl_handle_events DEFINITION
class lcl_handle_events implementation.
method on_double_click.
if column = 'INSTID'.
clear gv_usrnme.
*Reading the ALV table to get the purchase order number
read table gt_usrnme into gv_usrnme index row.
if sy-subrc = 0.
*Passing the value of the PO number to ME23N Transaction
set parameter id 'BES' field gv_usrnme-instid.
*Calling ME23N
call transaction 'ME23N'.
endif.
endif.
endmethod.
data gv_event type ref to lcl_handle_events. "events object
gv_events = gs_table->get_event( ).
create object gv_event.
*... §6.4 register to the event Link_CLICK
set handler gv_event->on_double_click for gv_events.
Hope this helps you. Here i was calling a different transaction code based on each line selection..
Regards
Ansari -
Which 'Values' need to Export in START-OF-SELECTION for Hotspot
I develop a small Test Report for Hotspot, and it's working fine.
Actually, Here - Error is at START-OF-SELECTION.
I tried many combinations for passing the Parameters but It's Not Working.
Which 'Values' I need to Export ?
START-OF-SELECTION.
CREATE OBJECT lr_details.
lr_details->data_gathering( ).
IF gi_final IS NOT INITIAL.
lr_details->display_alv( ).
lr_details->on_double_click( EXPORTING row = ? column = '?' ). " ?
lr_details->on_link_click( EXPORTING row = ? column = '?' ). " ?
ELSE.
MESSAGE 'No Data for the Selection Critaria' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
Here row & column are obligatory fileds - I need to pass the Values
(I am already passing the Values with Form get_aufnr_info.)
I try with Hard Coding row = 1 & column = 'AUFNR'
lr_details->on_double_click( EXPORTING row = 1 column = 'AUFNR' ).
lr_details->on_link_click( EXPORTING row = 1 column = 'AUFNR' ).
One may find it Silly, But in this Case - Hotspot is not working & when I go for 'BACK' it's showing IW33 (req. Tcode).
The Complete code for HOTSPOT is as follow.
METHODS: data_gathering,
display_alv,
on_double_click FOR EVENT double_click OF cl_salv_events_table IMPORTING row column,
on_link_click FOR EVENT link_click OF cl_salv_events_table IMPORTING row column.
METHOD on_double_click.
PERFORM get_aufnr_info USING row column.
ENDMETHOD.
METHOD on_link_click.
PERFORM get_aufnr_info USING row column.
ENDMETHOD.
FORM get_aufnr_info USING row TYPE salv_de_row
column TYPE salv_de_column.
IF column = 'AUFNR'.
CLEAR: gwa_final.
READ TABLE gi_final INTO gwa_final INDEX row.
IF sy-subrc EQ 0.
SET PARAMETER ID 'ANR' FIELD gwa_final-aufnr.
CALL TRANSACTION 'IW33' AND SKIP FIRST SCREEN.
ENDIF.
ENDIF.
ENDFORM.Thanks Clemens & Lakshmi,
But Here I am not taking a FieldCat and
cl_gui_custom_container, "Detail container
cl_gui_alv_grid , "Detail ALV instance
I am taking display as -->code
DATA: lr_table TYPE REF TO cl_salv_table,
lr_layout TYPE REF TO cl_salv_layout,
lr_functions TYPE REF TO cl_salv_functions_list,
lr_columns TYPE REF TO cl_salv_columns_table,
lr_column1 TYPE REF TO cl_salv_column_table,
lr_column TYPE REF TO cl_salv_column,
lr_events TYPE REF TO cl_salv_events_table .
DATA : gr_events TYPE REF TO get_details.
DATA: ls_layout TYPE salv_s_layout_key.
ls_layout-report = sy-repid.
TRY.
CALL METHOD cl_salv_table=>factory " call factory method of alv
* EXPORTING
IMPORTING
r_salv_table = lr_table
CHANGING
t_table = gi_final.
CATCH cx_salv_not_found .
ENDTRY.
lr_functions = lr_table->get_functions( ). " activate the alv funcationality
lr_layout = lr_table->get_layout( ).
lr_table->display( ).
TRY.
CALL METHOD pr_columns->get_column
EXPORTING
columnname = 'AUFNR'
RECEIVING
value = lr_column.
CATCH cx_salv_not_found.
ENDTRY.
lr_column->set_long_text( text-006 ).
I already developed Reports With FIELDCAT(set_table_for_first_display) with double_click
And also created a small Test Report where I am taking double_click in CLASS DEF.
Both are working.
But when I am using double_click in Reports with START-OF-SELECTION it's not working. -
If I need not Use double_click in START-OF-SELECTION, THEN HOW I SHOULD CALL IT ?? -
Alv using class In list format
Hi,
I am using a method set_table_for_first_display in class cl_gui_alv_grid to display ALV. but by default the output appears in grid format, I want to change the output in LIST format.
What can I do to change the output in list format.
Kind Regards,
Abhishek.try this.... this is an example code.... don't use set_table_for_first_display rather use CL_SALV_TABLE and execute the below code
*& Report ZAMIT_TEST
REPORT zamit_test MESSAGE-ID z_zzz_ca_messages.
* constants for icons
TYPE-POOLS: icon, col.
* type for internal table
TYPES: BEGIN OF x_sflight.
* selfld TYPE char1.
INCLUDE STRUCTURE sflight.
TYPES: seatsfree TYPE sflight-seatsocc,
usage TYPE n, " exception
icon_future TYPE icon-id, " icon for future / past
line_counter TYPE i, " line counter
it_colors TYPE lvc_t_scol, " internal tab for cell color info
END OF x_sflight.
* Internal table
DATA: i_sflight TYPE STANDARD TABLE OF x_sflight,
wa_sflight TYPE x_sflight,
wa_colors TYPE lvc_s_scol,
list_display TYPE sap_bool,
vref_cont TYPE REF TO cl_gui_custom_container,
vref_alv TYPE REF TO cl_salv_table, " ALV instance
oref_error TYPE REF TO cx_salv_error, " Error instance
l_text_alv_e TYPE string,
ok_code TYPE syucomm.
SELECT-OPTIONS: so_car FOR wa_sflight-carrid MEMORY ID car,
so_con FOR wa_sflight-connid.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK alv WITH FRAME TITLE text-alv.
PARAMETERS: pa_full RADIOBUTTON GROUP alvd DEFAULT 'X',
pa_cont RADIOBUTTON GROUP alvd,
pa_list RADIOBUTTON GROUP alvd.
SELECTION-SCREEN END OF BLOCK alv.
PARAMETERS: p_layout TYPE slis_vari.
* CLASS lcl_handler DEFINITION
CLASS lcl_handler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
on_added_function FOR EVENT added_function OF cl_salv_events_table
IMPORTING e_salv_function, " type salv_de_function
on_double_click FOR EVENT double_click OF cl_salv_events_table
IMPORTING row, " type salv_de_row = int4
on_link_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING row " type salv_de_row = int4
column." type salv_de_column = char(30)
ENDCLASS. "lcl_handler definition
* CLASS lcl_handler IMPLEMENTATION
CLASS lcl_handler IMPLEMENTATION.
METHOD on_added_function.
DATA: l_oref_columns TYPE REF TO cl_salv_columns_table,
l_oref_column TYPE REF TO cl_salv_column_table,
l_oref_column1 TYPE REF TO cl_salv_column,
l_except1 TYPE REF TO cx_salv_not_found, "Exception
l_text1 TYPE string, "Exception msg
l_lvc_s_colo TYPE lvc_s_colo.
CASE e_salv_function.
WHEN 'REORDER'.
* get the COLUMNS object
l_oref_columns = vref_alv->get_columns( ).
* positions: (MANDT column + 3 key colums)
l_oref_columns->set_column_position( columnname = 'SEATSOCC'
position = 5 ).
l_oref_columns->set_column_position( columnname = 'SEATSOCC_B'
position = 6 ).
l_oref_columns->set_column_position( columnname = 'SEATSOCC_F'
position = 7 ).
* prepare color info
* column SEATSOCC
TRY.
CALL METHOD l_oref_columns->get_column
EXPORTING
columnname = 'SEATSOCC'
RECEIVING
value = l_oref_column1.
CATCH cx_salv_not_found INTO l_except1.
l_text1 = l_except1->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
ENDTRY.
l_oref_column ?= l_oref_column1.
l_oref_column->set_color( value = l_lvc_s_colo ).
* column SEATSOCC_B
TRY.
CALL METHOD l_oref_columns->get_column
EXPORTING
columnname = 'SEATSOCC_B'
RECEIVING
value = l_oref_column1.
CATCH cx_salv_not_found INTO l_except1.
l_text1 = l_except1->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
ENDTRY.
l_oref_column ?= l_oref_column1.
l_oref_column->set_color( value = l_lvc_s_colo ).
* column SEATSOCC_F
TRY.
CALL METHOD l_oref_columns->get_column
EXPORTING
columnname = 'SEATSOCC_F'
RECEIVING
value = l_oref_column1.
CATCH cx_salv_not_found INTO l_except1.
l_text1 = l_except1->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
ENDTRY.
l_oref_column ?= l_oref_column1.
l_oref_column->set_color( value = l_lvc_s_colo ).
ENDCASE.
ENDMETHOD. "on_added_function
METHOD on_double_click.
DATA: message_text(70),
lc_seatsfree_e(10),
lc_seatsfree_b(10),
lc_seatsfree_f(10).
READ TABLE i_sflight INTO wa_sflight INDEX row.
CHECK sy-subrc EQ 0.
lc_seatsfree_e = wa_sflight-seatsmax - wa_sflight-seatsocc.
lc_seatsfree_b = wa_sflight-seatsmax_b - wa_sflight-seatsocc_b.
lc_seatsfree_f = wa_sflight-seatsmax_f - wa_sflight-seatsocc_f.
CONCATENATE 'FREE SEATS:'(frs) 'ECONOMY:'(eco) lc_seatsfree_e
'BUSINESS'(bus) lc_seatsfree_b 'FIRST'(fst) lc_seatsfree_f
INTO message_text SEPARATED BY space.
MESSAGE message_text TYPE 'I'.
ENDMETHOD. "on_double_click
METHOD on_link_click.
DATA: lc_carrname TYPE scarr-carrname,
lc_currcode TYPE scarr-currcode,
message_text(70).
READ TABLE i_sflight INTO wa_sflight INDEX row.
CHECK sy-subrc EQ 0.
CASE column.
WHEN 'CARRID'.
SELECT SINGLE carrname currcode
INTO (lc_carrname, lc_currcode)
FROM scarr
WHERE carrid = wa_sflight-carrid.
IF sy-subrc EQ 0.
CONCATENATE 'AIRLINE:'(air) wa_sflight-carrid
'NAME:'(nme) lc_carrname
'CURRENCY:' lc_currcode
INTO message_text
SEPARATED BY space.
MESSAGE message_text TYPE 'I'.
ENDIF.
WHEN 'SELFLD'.
MESSAGE i000 with 'Checkbox Clicked'.
ENDCASE.
ENDMETHOD. "on_link_click
ENDCLASS. "lcl_handler IMPLEMENTATION
START-OF-SELECTION.
* retrieve data into internal table
SELECT * FROM sflight
INTO CORRESPONDING FIELDS OF TABLE i_sflight
WHERE carrid IN so_car
AND connid IN so_con.
END-OF-SELECTION.
* fill additional data fields
LOOP AT i_sflight INTO wa_sflight.
* seats free
wa_sflight-seatsfree =
wa_sflight-seatsmax + wa_sflight-seatsmax_b
+ wa_sflight-seatsmax_f
- wa_sflight-seatsocc - wa_sflight-seatsocc_b
- wa_sflight-seatsocc_f.
* usage (exception light)
IF wa_sflight-seatsfree = 0.
wa_sflight-usage = '1'.
ELSEIF wa_sflight-seatsfree <= 20.
wa_sflight-usage = '2'.
ELSE.
wa_sflight-usage = '3'.
ENDIF.
* icon "in the future/not in the future"
IF wa_sflight-fldate > sy-datum.
wa_sflight-icon_future = icon_positive.
ELSE.
wa_sflight-icon_future = icon_negative.
ENDIF.
* cell colors
* single cell if planetype is 747-400
IF wa_sflight-planetype = '747-400'.
CLEAR wa_colors.
wa_colors-fname = 'PLANETYPE'.
wa_colors-color-col = col_positive.
wa_colors-color-int = 1.
APPEND wa_colors TO wa_sflight-it_colors.
ENDIF.
* whole line if seatsfree gt 200
IF wa_sflight-seatsfree >= 200.
CLEAR wa_colors.
wa_colors-color-col = col_heading.
wa_colors-color-int = 1.
APPEND wa_colors TO wa_sflight-it_colors.
ENDIF.
MODIFY i_sflight
FROM wa_sflight
TRANSPORTING
seatsfree
usage
icon_future
it_colors.
ENDLOOP.
CASE 'X'.
WHEN pa_full OR pa_list.
IF pa_list IS NOT INITIAL.
list_display = if_salv_c_bool_sap=>true.
ELSE.
list_display = if_salv_c_bool_sap=>false.
ENDIF.
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
list_display = list_display
IMPORTING
r_salv_table = vref_alv
CHANGING
t_table = i_sflight.
CATCH cx_salv_msg INTO oref_error.
l_text_alv_e = oref_error->get_text( ).
MESSAGE i000 WITH l_text_alv_e.
LEAVE LIST-PROCESSING.
ENDTRY.
* define settings
PERFORM define_settings USING vref_alv.
* display ALV
vref_alv->display( ).
WHEN pa_cont.
CALL SCREEN 100.
ENDCASE.
*& Form define_settings
* text
* -->P_ALV ALV object
FORM define_settings USING p_alv TYPE REF TO cl_salv_table.
PERFORM: sub_set_display USING p_alv,
sub_set_columns USING p_alv,
sub_set_sorts USING p_alv,
sub_set_aggregs USING p_alv,
sub_set_selections USING p_alv,
sub_set_layout USING p_alv,
sub_set_functions USING p_alv,
sub_set_events USING p_alv,
sub_set_header USING p_alv.
ENDFORM. " define_settings
*& Form sub_set_display
* set general display attributs
* -->P_ALV ALV object
FORM sub_set_display USING p_alv TYPE REF TO cl_salv_table.
DATA: lr_display TYPE REF TO cl_salv_display_settings,
l_title TYPE lvc_title.
* get display settings object
lr_display = p_alv->get_display_settings( ).
* set header
l_title = text-ttl.
lr_display->set_list_header( value = text-ttl ).
* set horizontal lines off
lr_display->set_horizontal_lines( value = ' ' ).
* set striped pattern
lr_display->set_striped_pattern( value = 'X' ).
ENDFORM. " sub_set_display
*& Form sub_set_columns
* text
* -->P_ALV text
FORM sub_set_columns USING p_alv TYPE REF TO cl_salv_table.
DATA: l_oref_columns TYPE REF TO cl_salv_columns_table,
l_oref_column TYPE REF TO cl_salv_column_table,
l_oref_column1 TYPE REF TO cl_salv_column,
l_except1 TYPE REF TO cx_salv_not_found, "Exception
l_except2 TYPE REF TO cx_salv_data_error, "Exception
l_text1 TYPE string, "Exception msg
l_scrtext_s TYPE scrtext_s,
l_scrtext_m TYPE scrtext_m,
l_scrtext_l TYPE scrtext_l,
l_lvc_tip TYPE lvc_tip, " for tooltip
l_pos TYPE i, " column position
l_lvc_s_colo TYPE lvc_s_colo. " column color
l_oref_columns = p_alv->get_columns( ). " get columns object
* set exception column
TRY.
CALL METHOD l_oref_columns->set_exception_column
EXPORTING
value = 'USAGE'.
CATCH cx_salv_data_error INTO l_except2.
l_text1 = l_except2->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
ENDTRY.
* set count column
TRY.
CALL METHOD l_oref_columns->set_count_column
EXPORTING
value = 'LINE_COUNTER'.
CATCH cx_salv_data_error INTO l_except2.
l_text1 = l_except2->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
ENDTRY.
* set cell colors / line colors column
TRY.
CALL METHOD l_oref_columns->set_color_column
EXPORTING
value = 'IT_COLORS'.
CATCH cx_salv_data_error INTO l_except2.
l_text1 = l_except2->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
ENDTRY.
* column ICON_FUTURE
TRY.
CALL METHOD l_oref_columns->get_column
EXPORTING
columnname = 'ICON_FUTURE'
RECEIVING
value = l_oref_column1.
CATCH cx_salv_not_found INTO l_except1.
l_text1 = l_except1->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
ENDTRY.
l_oref_column ?= l_oref_column1.
l_oref_column->set_icon( ).
l_scrtext_s = text-fut.
l_oref_column->set_short_text( value = l_scrtext_s ).
l_oref_column->set_row( value = 2 ).
* Column SEATSFREE
TRY.
CALL METHOD l_oref_columns->get_column
EXPORTING
columnname = 'SEATSFREE'
RECEIVING
value = l_oref_column1.
CATCH cx_salv_not_found INTO l_except1.
l_text1 = l_except1->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
ENDTRY.
l_oref_column ?= l_oref_column1.
* set color to COL_GROUP
l_lvc_s_colo-col = col_group.
l_lvc_s_colo-int = 1.
l_oref_column->set_color( value = l_lvc_s_colo ).
** Column SELFLD
* TRY.
* CALL METHOD l_oref_columns->get_column
* EXPORTING
* columnname = 'SELFLD'
* RECEIVING
* value = l_oref_column1.
* CATCH cx_salv_not_found INTO l_except1.
* l_text1 = l_except1->get_text( ).
* MESSAGE i000 WITH l_text1.
* LEAVE LIST-PROCESSING.
* ENDTRY.
* l_oref_column ?= l_oref_column1.
** set color to COL_GROUP
* if pa_list = 'X'.
* l_oref_column->set_cell_type( value =
* if_salv_c_cell_type=>CHECKBOX ).
* ELSEIF pa_full = 'X'.
* l_oref_column->set_cell_type( value =
* if_salv_c_cell_type=>CHECKBOX_HOTSPOT ).
* endif.
ENDFORM. "sub_set_columns
*& Form sub_set_sorts
* -->P_ALV text
FORM sub_set_sorts USING p_alv TYPE REF TO cl_salv_table.
DATA: l_oref_sorts TYPE REF TO cl_salv_sorts,
l_except1 TYPE REF TO cx_salv_not_found, "Exception
l_except2 TYPE REF TO cx_salv_existing, "Exception
l_except3 TYPE REF TO cx_salv_data_error, "Exception
l_text1 TYPE string. "Exception msg
* get the SORTS object
l_oref_sorts = p_alv->get_sorts( ).
* add sorts
TRY.
CALL METHOD l_oref_sorts->add_sort
EXPORTING
columnname = 'CARRID'
position = 1.
CATCH cx_salv_not_found INTO l_except1.
l_text1 = l_except1->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
CATCH cx_salv_existing INTO l_except2.
l_text1 = l_except2->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
CATCH cx_salv_data_error INTO l_except3.
l_text1 = l_except3->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
ENDTRY.
TRY.
CALL METHOD l_oref_sorts->add_sort
EXPORTING
columnname = 'CONNID'
position = 2
subtotal = if_salv_c_bool_sap=>true.
CATCH cx_salv_not_found INTO l_except1.
l_text1 = l_except1->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
CATCH cx_salv_existing INTO l_except2.
l_text1 = l_except2->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
CATCH cx_salv_data_error INTO l_except3.
l_text1 = l_except3->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
ENDTRY.
TRY.
CALL METHOD l_oref_sorts->add_sort
EXPORTING
columnname = 'FLDATE'
position = 3.
CATCH cx_salv_not_found INTO l_except1.
l_text1 = l_except1->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
CATCH cx_salv_existing INTO l_except2.
l_text1 = l_except2->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
CATCH cx_salv_data_error INTO l_except3.
l_text1 = l_except3->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
ENDTRY.
ENDFORM. " sub_set_sorts
*& Form sub_set_aggregs
* -->P_ALV text
FORM sub_set_aggregs USING p_alv TYPE REF TO cl_salv_table.
DATA: l_oref_aggregs TYPE REF TO cl_salv_aggregations,
l_except1 TYPE REF TO cx_salv_data_error, "Exception
l_except2 TYPE REF TO cx_salv_not_found, "Exception
l_except3 TYPE REF TO cx_salv_existing, "Exception
l_text1 TYPE string. "Exception msg
l_oref_aggregs = p_alv->get_aggregations( ).
TRY.
CALL METHOD l_oref_aggregs->add_aggregation
EXPORTING
columnname = 'SEATSFREE'
aggregation = if_salv_c_aggregation=>total.
CATCH cx_salv_data_error INTO l_except1.
l_text1 = l_except1->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
CATCH cx_salv_not_found INTO l_except2.
l_text1 = l_except2->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
CATCH cx_salv_existing INTO l_except3.
l_text1 = l_except3->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
ENDTRY.
ENDFORM. " sub_set_aggregs
*& Form sub_set_selections
* -->P_ALV text
FORM sub_set_selections USING p_alv TYPE REF TO cl_salv_table.
DATA: lr_selections TYPE REF TO cl_salv_selections.
* get the SELECTIONS object
lr_selections = p_alv->get_selections( ).
* set the selection mode
lr_selections->set_selection_mode(
value = if_salv_c_selection_mode=>cell ).
ENDFORM. " sub_set_selections
*& Form sub_set_layout
* -->P_ALV text
FORM sub_set_layout USING p_alv TYPE REF TO cl_salv_table.
DATA: lr_layout TYPE REF TO cl_salv_layout,
ls_key TYPE salv_s_layout_key.
* get the LAYOUT object
lr_layout = p_alv->get_layout( ).
* set the layout key
ls_key-report = sy-cprog.
lr_layout->set_key( value = ls_key ).
* set save restriction
* (restriction "none" is intended,
* so we may use the default)
lr_layout->set_save_restriction(
* VALUE = IF_SALV_C_LAYOUT=>RESTRICT_NONE
* allow setting a default layout
lr_layout->set_default( value = 'X' ).
* set initial layout
lr_layout->set_initial_layout( value = p_layout ).
ENDFORM. " sub_set_layout
*& Form sub_set_functions
* -->P_ALV text
FORM sub_set_functions USING p_alv TYPE REF TO cl_salv_table.
DATA: lr_functions TYPE REF TO cl_salv_functions_list,
l_except1 TYPE REF TO cx_salv_existing,
l_except2 TYPE REF TO cx_salv_wrong_call,
l_text1 TYPE string,
* help variables for method call ADD_FUNCTION
l_icon TYPE string,
l_text TYPE string,
l_tooltip TYPE string.
IF pa_full = 'X' or pa_list = 'X'.
p_alv->set_screen_status( pfstatus = 'SALV_TABLE_STANDARD'
report = sy-repid
set_functions = p_alv->c_functions_all ).
ENDIF.
* get the FUNCTIONS object
lr_functions = p_alv->get_functions( ).
* offer all generic functions
lr_functions->set_all( value = if_salv_c_bool_sap=>true ).
* subtract average
lr_functions->set_aggregation_average(
value = if_salv_c_bool_sap=>false ).
* subtract all export functions
lr_functions->set_group_export(
value = if_salv_c_bool_sap=>false ).
* enable exort to local file
lr_functions->set_export_localfile(
value = if_salv_c_bool_sap=>true ).
* subtract transfer to lotus
lr_functions->set_view_lotus(
value = if_salv_c_bool_sap=>false ).
* customer defined function:
* display occupied seats columns most left
* and highlight them
* IF pa_cont = 'X'.
* l_icon = icon_insert_row.
* l_text = text-tot.
* l_tooltip = text-ttt.
* TRY.
* CALL METHOD lr_functions->add_function
* EXPORTING
* name = 'REORDER'
* icon = l_icon
* text = l_text
* tooltip = l_tooltip
* position = if_salv_c_function_position=>right_of_salv_functions.
* CATCH cx_salv_existing INTO l_except1.
* l_text1 = l_except1->get_text( ).
* MESSAGE i000 WITH l_text1.
* LEAVE LIST-PROCESSING.
* CATCH cx_salv_wrong_call INTO l_except2.
* l_text1 = l_except2->get_text( ).
* MESSAGE i000 WITH l_text1.
* LEAVE LIST-PROCESSING.
* ENDTRY.
* ENDIF.
ENDFORM. " sub_set_functions
*& Form sub_set_events
* text
* -->P_ALV text
FORM sub_set_events USING p_alv TYPE REF TO cl_salv_table.
DATA: lr_event TYPE REF TO cl_salv_events_table.
* get the EVENT object
lr_event = p_alv->get_event( ).
SET HANDLER :
lcl_handler=>on_added_function FOR lr_event,
lcl_handler=>on_double_click FOR lr_event,
lcl_handler=>on_link_click FOR lr_event.
ENDFORM. " sub_set_events
*& Form sub_set_header
* -->P_ALV text
FORM sub_set_header
USING p_alv TYPE REF TO cl_salv_table.
DATA: lr_grid TYPE REF TO cl_salv_form_layout_grid.
* 1st step: create the grid object
CREATE OBJECT lr_grid.
* 2nd step: add some text items
lr_grid->create_header_information( row = 1 column = 1
text = 'Flight List Grp ##'(fll) ).
lr_grid->create_text( row = 2 column = 1
text = 'Please check utilization'(uti) ).
* 3rd step: declare grid as header of list
p_alv->set_top_of_list( value = lr_grid ).
ENDFORM. " sub_set_header
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'SALV_TABLE_STANDARD'.
SET TITLEBAR 'T100'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module create_control OUTPUT
* text
MODULE create_control OUTPUT.
IF vref_cont IS NOT BOUND.
* create container control
* and link it to the dynpro
CREATE OBJECT vref_cont
EXPORTING
container_name = 'MY_CONTAINER'
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Error when creating the container object'.
ENDIF.
* create ALV and
* link it to the container control
TRY.
cl_salv_table=>factory(
EXPORTING
r_container = vref_cont
IMPORTING
r_salv_table = vref_alv
CHANGING
t_table = i_sflight ).
CATCH cx_salv_msg INTO oref_error.
l_text_alv_e = oref_error->get_text( ).
MESSAGE i000 WITH l_text_alv_e.
LEAVE LIST-PROCESSING.
ENDTRY.
* display ALV
vref_alv->display( ).
ENDIF.
ENDMODULE. " create_control OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
SET SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Module exit INPUT
* text
MODULE exit INPUT.
SET SCREEN 0.
ENDMODULE. " exit INPUT -
Creating a Report for the following Query u0096 Kindly help
Hi,
Using selection options we have to give the name of
1) Sales Organization -- VBAK -VKORG
2) Distribution Channel -- VBAK - VTWEG
3) Division -- VBAK -- SPART
4) Created Date -- VBAK -- ERDAT.
Once we select this the following list should be displayed.
1) Order no. -- VBAK - VBELN.
2) Created date -- VBAK - ERDAT
3) Sold To Party -- VBAK - KUNNR
4) Shipped to party -- VBPA -- KUNNR.
5) Item no -- VBAP -- POSNR
6) Material no. -- VBAP -- MATNR
7) Material Discription -- VBAP - ARKTX.
The out put should be like this
Sales Org : **********
Dist chan : **************
Division : *********
Created Date : ********
Orderno credate soltopar shiptopar itemno materiano materdes
and so.
Also When we click on the order no we should ge the transaction VA03.
With Select options i was able to get the sales organization distribution channel and division and the when we give the values it is showing Run time errors.
Kindly help me to proceed further.
Even if I am able to generate the order list it will be fine. Going on to VA03 I will manage some how If possible give the syntax for this also).
Regard,
SurjithHi,
Check the below code :
REPORT yvic_test_sales.
TABLES vbak.
TYPES:
BEGIN OF ty_sales_data,
vbeln TYPE vbeln_va,
erdat TYPE erdat,
kunnr TYPE kunag,
oid_ship TYPE kunwe,
posnr TYPE posnr_va,
matnr TYPE matnr,
END OF ty_sales_data.
DATA : gt_data TYPE STANDARD TABLE OF ty_sales_data.
CLASS gcl_handle_events DEFINITION
CLASS gcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS:
on_link_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING row column.
ENDCLASS. "gcl_handle_events DEFINITION
SELECTION-SCREEN BEGIN OF BLOCK b1.
SELECT-OPTIONS:
s_vkorg FOR vbak-vkorg,
s_vtweg FOR vbak-vtweg,
s_spart FOR vbak-spart,
s_erdat FOR vbak-erdat.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
SELECT d1~vbeln
d1~erdat
d1~kunnr
d2~oid_ship
d2~posnr
d2~matnr
INTO TABLE gt_data
FROM vbak AS d1
JOIN vbap AS d2
ON d1vbeln = d2vbeln
WHERE d1~vkorg IN s_vkorg[]
AND d1~vtweg IN s_vtweg[]
AND d1~spart IN s_spart[]
AND d1~erdat IN s_erdat[].
CLASS gcl_handle_events IMPLEMENTATION
Subroutine call_transaction will get called
when user clicks on BELNR (Acounting document) or EBELN(PO)
CLASS gcl_handle_events IMPLEMENTATION.
METHOD on_link_click.
PERFORM call_transaction USING row column.
ENDMETHOD. "on_link_click
ENDCLASS. "gcl_handle_events IMPLEMENTATION
END-OF-SELECTION.
PERFORM display_data.
*& Form DISPLAY_DATA
text
--> p1 text
<-- p2 text
FORM display_data .
DATA:
lo_table TYPE REF TO cl_salv_table,"table object
lo_function TYPE REF TO cl_salv_functions,
lo_layout TYPE REF TO cl_salv_layout,
lo_columns TYPE REF TO cl_salv_columns_table,
lo_hotspot TYPE REF TO cl_salv_column_table,
lo_events_name TYPE REF TO cl_salv_events_table,
lo_click TYPE REF TO gcl_handle_events,
ls_key TYPE salv_s_layout_key,
lo_sorts TYPE REF TO cl_salv_sorts,
lo_aggregation TYPE REF TO cl_salv_aggregations,
lo_exception TYPE REF TO cx_root,"exception object
l_text TYPE string." to hold exception message
create a table object to display result table
TRY.
cl_salv_table=>factory( IMPORTING r_salv_table = lo_table
CHANGING t_table = gt_data ).
catch exception
CATCH cx_salv_msg INTO lo_exception.
get exception text and display it in message
l_text = lo_exception->get_text( ).
Message: & & & &
MESSAGE i000(zzz) WITH l_text.
ENDTRY.
get column object of the table created
lo_columns = lo_table->get_columns( ).
FOR HOTSPOT on Doc no
TRY.
lo_hotspot ?= lo_columns->get_column( 'VBELN' ).
lo_hotspot->set_cell_type( if_salv_c_cell_type=>hotspot ).
CATCH cx_salv_not_found INTO lo_exception.
get exception text and display it in message
l_text = lo_exception->get_text( ).
Message: & & & &
MESSAGE i000(zzz) WITH l_text.
ENDTRY.
lo_events_name = lo_table->get_event( ).
CREATE OBJECT lo_click.
SET HANDLER lo_click->on_link_click FOR lo_events_name.
lo_table->display( ).
ENDFORM. " DISPLAY_DATA
*& Form CALL_TRANSACTION
text
-->P_ROW text
-->P_COLUMN text
FORM call_transaction USING pa_row
pa_column.
DATA ls_final_data TYPE ty_sales_data.
IF pa_column = 'VBELN'.
CLEAR ls_final_data.
READ TABLE gt_data INTO ls_final_data INDEX pa_row.
IF NOT ls_final_data-vbeln IS INITIAL.
SET PARAMETER ID 'AUN' FIELD ls_final_data-vbeln.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
ENDIF.
ENDIF.
ENDFORM. " CALL_TRANSACTION
Reward if helpful..
Thanks
Maybe you are looking for
-
IN FRANCE WHAT DO I PLUG INTO, a converter or just plug?
I'm going to France, Do I need a converter or just a plug adapter?
-
BCS validation at document Level
Hi all SEM-BCS experts We are adopting a matrix consolidation (company & profit center) design. We would like to have a validation at the manual posting document (posting level 10) where all line items can only be posted with the SAME company code on
-
Tell me about the details of ROWID...
Hi, Is anybody there to tell me the answer to the following questions : 1. Internal structure and working of ROWID. 2. diffrence between the ROWIDs of different Oracle versions. Thanks
-
SSMS Tools with SQL Express 2014
Hi Need to know whether SSMS Tools that come along with SQL Express 2014 require client license? Please let me know the details
-
My Computer keeps freezing while downloading songs to ipod
It varies. sometimes I get 5 songs on..sometimes 250 songs sometimes 2500 songs but it keeps freezing up. I have a 2.0 usb port that is brand new and has been checked out. why is this happening and what do i do to stop it?...please help me? I'm at th