Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SUBMIT inside a method & the automation queue

Former Member
0 Likes
1,536

Hi,

I call a method via a tree toolbar button in that calls a standard SAP report using the SUBMIT AND RETURN command. This is done within a screen with several docking containers and split screens attached.

The problem is that when I press the toolbar button, the report (which also has docking container) is presented partially inside my screen.

When I put a BREAK-POINT on the SUBMIT statement it is good and I can see SAP's report with no issues and I do not see my screen. When I take the break point off it is back to the original problem.

This leaves me to think that it is an automation queue problem or something like that.

How can I get over this?

Thanks,

Itay

6 REPLIES 6
Read only

Former Member
0 Likes
984

Perhaps, new session help: create your own transaction which was called report and change your method on CALL TRANSACTION.

Read only

uwe_schieferstein
Active Contributor
0 Likes
984

Hello Itay

I assume that call the SAP report within the event handler method dealing with the toolbar events.

You could try to "shift" the timepoint where the SUBMIT is executed from the event handler method (note: toolbar events do NOT trigger PAI of the displaying dynpro) to the <b>PAI </b>of your dynpro.

Use the following method call within your event handler method:

  CALL METHOD cl_gui_cfw=>set_new_ok_code( 'SUBMIT' ).

At the end of the event handler method this will trigger PAI where you can submit the report.

MODULE user_command_0100 PAI.

  CASE gd_okcode.
    WHEN 'BACK'  or
               'EXIT'    or
               'CANC'.
      set screen 0. leave screen

    WHEN 'SUBMIT'.
      SUBMIT <SAP standard report>
        AND RETURN.


    WHEN others.
    ENDCASE.
ENDMODULE.

Regards

Uwe

Read only

0 Likes
984

Hi Uwe,

It sounds like the correct answer.

I put the code in place but it doesn't seem to call the PAI again.

Am I missing something?

Thanks,

Itay

Read only

0 Likes
984

I read the RC for the event and I got 102- and not 0.

why is that?

how can I check that?

Thanks.

Read only

0 Likes
984

I tried to do the call function ans I got exactly as if I use the set_new_ok_code:

return code = cl_gui_cfw=>rc_wrong_state

I use CALL METHOD cl_gui_cfw=>set_new_ok_code inside the toolbar event receiver.

from the help on this method:

"You may only use this method in the handler method of a system event. It sets an OK_CODE that triggers PAI processing. This means that data is transferred from the screen to the program, and you can take control of the program in your PAI modules.

what is that "system event"?

any ideas?

Read only

uwe_schieferstein
Active Contributor
0 Likes
984

Hello Itay

I tried to simulate your situation. Perhaps you get from this sample report (which was copied from BCALV_TREE_DEMO and the adjusted) some ideas how to solve your problem. In my report all controls are displayed properly.

[code]&----


*& Report ZUS_SDN_BCALV_TREE_DEMO_8 *

*& *

&----


*& Based on: BCALV_TREE_DEMO *

*& *

&----


REPORT zus_sdn_bcalv_tree_demo.

DATA:

gd_okcode TYPE ui_func,

*

go_docking TYPE REF TO cl_gui_docking_container,

go_splitter TYPE REF TO cl_gui_splitter_container,

go_cell_left TYPE REF TO cl_gui_container,

go_cell_right TYPE REF TO cl_gui_container,

go_grid TYPE REF TO cl_gui_alv_grid.

data:

gt_knb1 type standard table of knb1. " dummy

*$Comment: begin

DATA:

gd_delete_nkey TYPE lvc_nkey.

*$Comment: end

CLASS cl_gui_column_tree DEFINITION LOAD.

CLASS cl_gui_cfw DEFINITION LOAD.

DATA tree1 TYPE REF TO cl_gui_alv_tree.

DATA mr_toolbar TYPE REF TO cl_gui_toolbar.

INCLUDE <icon>.

INCLUDE ZUS_SDN_BCALV_TB_EVENT_RCVR8.

*INCLUDE zus_sdn_bcalv_tb_event_rcvr.

*include bcalv_toolbar_event_receiver.

INCLUDE ZUS_SDN_BCALV_TREE_EVENT_RCVR8.

*INCLUDE zus_sdn_bcalv_tree_event_rcvr.

*include bcalv_tree_event_receiver.

DATA: toolbar_event_receiver TYPE REF TO lcl_toolbar_event_receiver.

DATA: gt_sflight TYPE sflight OCCURS 0, "Output-Table

gt_fieldcatalog TYPE lvc_t_fcat, "Fieldcatalog

ok_code LIKE sy-ucomm. "OK-Code

START-OF-SELECTION.

  • Create docking container

CREATE OBJECT go_docking

EXPORTING

parent = cl_gui_container=>screen0

ratio = 90

EXCEPTIONS

OTHERS = 6.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • Create splitter container

CREATE OBJECT go_splitter

EXPORTING

parent = go_docking

rows = 1

columns = 2

  • NO_AUTODEF_PROGID_DYNNR =

  • NAME =

EXCEPTIONS

cntl_error = 1

cntl_system_error = 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.

  • Get cell container

CALL METHOD go_splitter->get_container

EXPORTING

row = 1

column = 1

RECEIVING

container = go_cell_left.

CALL METHOD go_splitter->get_container

EXPORTING

row = 1

column = 2

RECEIVING

container = go_cell_right.

  • Create ALV grid

CREATE OBJECT go_grid

EXPORTING

i_parent = go_cell_right

EXCEPTIONS

OTHERS = 5.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL METHOD go_grid->set_table_for_first_display

EXPORTING

i_structure_name = 'KNB1'

CHANGING

it_outtab = gt_knb1

EXCEPTIONS

OTHERS = 4.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • Link the docking container to the target dynpro

CALL METHOD go_docking->link

EXPORTING

repid = syst-repid

dynnr = '0100'

  • CONTAINER =

EXCEPTIONS

OTHERS = 4.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL SCREEN 100.

END-OF-SELECTION.

&----


*& 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.

translate ok_code to upper case.

CASE ok_code.

WHEN 'EXIT' OR 'BACK' OR 'CANC'.

PERFORM exit_program.

*$Comment: begin

WHEN 'DELETE'.

CALL METHOD tree1->delete_subtree

EXPORTING

i_node_key = gd_delete_nkey " = folder 'AA'

  • I_UPDATE_PARENTS_EXPANDER = SPACE

  • I_UPDATE_PARENTS_FOLDER = SPACE

EXCEPTIONS

node_key_not_in_model = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL METHOD tree1->update_calculations

EXPORTING

no_frontend_update = ' '. " do frontend update

*$Comment: end

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.

  • get fieldcatalog

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = 'SFLIGHT'

CHANGING

ct_fieldcat = gt_fieldcatalog.

SORT gt_fieldcatalog BY scrtext_l.

  • change fieldcatalog

DATA: ls_fieldcatalog TYPE lvc_s_fcat.

LOOP AT gt_fieldcatalog INTO ls_fieldcatalog.

CASE ls_fieldcatalog-fieldname.

WHEN 'CARRID' OR 'CONNID' OR 'FLDATE'.

ls_fieldcatalog-no_out = 'X'.

ls_fieldcatalog-key = ''.

WHEN 'PRICE' OR 'SEATSOCC' OR 'SEATSMAX' OR 'PAYMENTSUM'.

ls_fieldcatalog-do_sum = 'X'.

ENDCASE.

MODIFY gt_fieldcatalog FROM ls_fieldcatalog.

ENDLOOP.

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 Header'. "#EC NOTEXT

p_hierarchy_header-tooltip =

'This is the Hierarchy Header !'. "#EC NOTEXT

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.

*

  • LIST HEADING LINE: TYPE H

CLEAR ls_line.

ls_line-typ = 'H'.

  • LS_LINE-KEY: NOT USED FOR THIS TYPE

ls_line-info = 'ALV-tree-demo: flight-overview'. "#EC NOTEXT

APPEND ls_line TO pt_list_commentary.

  • STATUS LINE: TYPE S

CLEAR ls_line.

ls_line-typ = 'S'.

ls_line-key = 'valid until'. "#EC NOTEXT

ls_line-info = 'January 29 1999'. "#EC NOTEXT

APPEND ls_line TO pt_list_commentary.

ls_line-key = 'time'.

ls_line-info = '2.00 pm'. "#EC NOTEXT

APPEND ls_line TO pt_list_commentary.

  • ACTION LINE: TYPE A

CLEAR ls_line.

ls_line-typ = 'A'.

  • LS_LINE-KEY: NOT USED FOR THIS TYPE

ls_line-info = 'actual data'. "#EC NOTEXT

APPEND ls_line TO pt_list_commentary.

p_logo = 'ENJOYSAP_LOGO'.

ENDFORM. "build_comment

&----


*& Form create_hierarchy

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM create_hierarchy.

DATA: ls_sflight TYPE sflight,

lt_sflight TYPE sflight OCCURS 0.

  • get data

SELECT * FROM sflight INTO TABLE lt_sflight

UP TO 200 ROWS . "#EC CI_NOWHERE

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-carrid.

PERFORM add_carrid_line USING ls_sflight

''

CHANGING l_carrid_key.

ENDON.

*$Comment: begin

IF ( ls_sflight-carrid = 'AA' ).

gd_delete_nkey = l_carrid_key.

ENDIF.

*$Comment: end

ON CHANGE OF ls_sflight-connid.

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 sflight

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 = '@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-carrid.

DATA: ls_node TYPE lvc_s_layn.

ls_node-n_image = space.

ls_node-exp_image = space.

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

is_node_layout = ls_node

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 sflight

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-connid.

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 sflight

p_relat_key TYPE lvc_nkey

CHANGING p_node_key TYPE lvc_nkey.

DATA: l_node_text TYPE lvc_value.

  • set item-layout

DATA: lt_item_layout TYPE lvc_t_layi,

ls_item_layout TYPE lvc_s_layi.

ls_item_layout-fieldname = tree1->c_hierarchy_column_name.

ls_item_layout-class = cl_gui_column_tree=>item_class_checkbox.

ls_item_layout-editable = 'X'.

APPEND ls_item_layout TO lt_item_layout.

CLEAR ls_item_layout.

ls_item_layout-fieldname = 'PLANETYPE'.

ls_item_layout-alignment = cl_gui_column_tree=>align_right.

APPEND ls_item_layout TO lt_item_layout.

l_node_text = ps_sflight-fldate.

DATA: ls_node TYPE lvc_s_layn.

ls_node-n_image = space.

ls_node-exp_image = space.

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

is_node_layout = ls_node

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.

  • define the events which will be passed to the backend

DATA: lt_events TYPE cntl_simple_events,

l_event TYPE cntl_simple_event.

  • define the events which will be passed to the backend

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_checkbox_change.

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.

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.

  • set Handler

DATA: l_event_receiver TYPE REF TO lcl_tree_event_receiver.

CREATE OBJECT l_event_receiver.

SET HANDLER l_event_receiver->handle_node_ctmenu_request

FOR tree1.

SET HANDLER l_event_receiver->handle_node_ctmenu_selected

FOR tree1.

SET HANDLER l_event_receiver->handle_item_ctmenu_request

FOR tree1.

SET HANDLER l_event_receiver->handle_item_ctmenu_selected

FOR tree1.

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

  • Add SUBMIT-Button

CALL METHOD mr_toolbar->add_button

EXPORTING

fcode = 'SUBMIT'

icon = '@15@'

butn_type = cntb_btype_button

text = ''

quickinfo = 'SUBMIT report'. "#EC NOTEXT

  • set event-handler for toolbar-control

CREATE OBJECT toolbar_event_receiver.

SET HANDLER toolbar_event_receiver->on_function_selected

FOR mr_toolbar.

SET HANDLER toolbar_event_receiver->on_toolbar_dropdown

FOR mr_toolbar.

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 = go_cell_left

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

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_tree[/code]

<b>INCLUDE ZUS_SDN_BCALV_TB_EVENT_RCVR8.</b>

[code]----


  • INCLUDE ZUS_SDN_BCALV_TB_EVENT_RCVR8 *

----


CLASS lcl_toolbar_event_receiver DEFINITION.

PUBLIC SECTION.

METHODS: on_function_selected

FOR EVENT function_selected OF cl_gui_toolbar

IMPORTING fcode,

on_toolbar_dropdown

FOR EVENT dropdown_clicked OF cl_gui_toolbar

IMPORTING fcode

posx

posy.

ENDCLASS. "lcl_toolbar_event_receiver DEFINITION

----


  • CLASS lcl_toolbar_event_receiver IMPLEMENTATION

----


  • ........ *

----


CLASS lcl_toolbar_event_receiver IMPLEMENTATION.

METHOD on_function_selected.

DATA: ls_sflight TYPE sflight.

CASE fcode.

WHEN 'SUBMIT'.

SUBMIT zus_sdn_two_alv_grids AND RETURN.

WHEN 'DELETE'.

  • get selected node

DATA: lt_selected_node TYPE lvc_t_nkey.

CALL METHOD tree1->get_selected_nodes

CHANGING

ct_selected_nodes = lt_selected_node.

CALL METHOD cl_gui_cfw=>flush.

DATA l_selected_node TYPE lvc_nkey.

READ TABLE lt_selected_node INTO l_selected_node INDEX 1.

  • delete subtree

IF NOT l_selected_node IS INITIAL.

CALL METHOD tree1->delete_subtree

EXPORTING

i_node_key = l_selected_node

i_update_parents_expander = ''

i_update_parents_folder = 'X'.

ELSE.

MESSAGE i227(0h).

ENDIF.

WHEN 'INSERT_LC'.

  • get selected node

CALL METHOD tree1->get_selected_nodes

CHANGING

ct_selected_nodes = lt_selected_node.

CALL METHOD cl_gui_cfw=>flush.

READ TABLE lt_selected_node INTO l_selected_node INDEX 1.

  • get current Line

IF NOT l_selected_node IS INITIAL.

CALL METHOD tree1->get_outtab_line

EXPORTING

i_node_key = l_selected_node

IMPORTING

e_outtab_line = ls_sflight.

ls_sflight-seatsmax = ls_sflight-price + 99.

ls_sflight-price = ls_sflight-seatsmax + '99.99'.

CALL METHOD tree1->add_node

EXPORTING

i_relat_node_key = l_selected_node

i_relationship = cl_tree_control_base=>relat_last_child

is_outtab_line = ls_sflight

  • is_node_layout

  • it_item_layout

i_node_text = 'Last Child'. "#EC NOTEXT

  • importing

  • e_new_node_key

ELSE.

MESSAGE i227(0h).

ENDIF.

WHEN 'INSERT_FC'.

  • get selected node

CALL METHOD tree1->get_selected_nodes

CHANGING

ct_selected_nodes = lt_selected_node.

CALL METHOD cl_gui_cfw=>flush.

READ TABLE lt_selected_node INTO l_selected_node INDEX 1.

  • get current Line

IF NOT l_selected_node IS INITIAL.

CALL METHOD tree1->get_outtab_line

EXPORTING

i_node_key = l_selected_node

IMPORTING

e_outtab_line = ls_sflight.

ls_sflight-seatsmax = ls_sflight-price + 99.

ls_sflight-price = ls_sflight-seatsmax + '99.99'.

CALL METHOD tree1->add_node

EXPORTING

i_relat_node_key = l_selected_node

i_relationship = cl_tree_control_base=>relat_first_child

is_outtab_line = ls_sflight

  • is_node_layout

  • it_item_layout

i_node_text = 'First Child'. "#EC NOTEXT

  • importing

  • e_new_node_key

ELSE.

MESSAGE i227(0h).

ENDIF.

WHEN 'INSERT_FS'.

  • get selected node

CALL METHOD tree1->get_selected_nodes

CHANGING

ct_selected_nodes = lt_selected_node.

CALL METHOD cl_gui_cfw=>flush.

READ TABLE lt_selected_node INTO l_selected_node INDEX 1.

  • get current Line

IF NOT l_selected_node IS INITIAL.

CALL METHOD tree1->get_outtab_line

EXPORTING

i_node_key = l_selected_node

IMPORTING

e_outtab_line = ls_sflight.

ls_sflight-seatsmax = ls_sflight-price + 99.

ls_sflight-price = ls_sflight-seatsmax + '99.99'.

CALL METHOD tree1->add_node

EXPORTING

i_relat_node_key = l_selected_node

i_relationship =

cl_tree_control_base=>relat_first_sibling

is_outtab_line = ls_sflight

  • is_node_layout

  • it_item_layout

i_node_text = 'First Sibling'. "#EC NOTEXT

  • importing

  • e_new_node_key

ELSE.

MESSAGE i227(0h).

ENDIF.

WHEN 'INSERT_LS'.

  • get selected node

CALL METHOD tree1->get_selected_nodes

CHANGING

ct_selected_nodes = lt_selected_node.

CALL METHOD cl_gui_cfw=>flush.

READ TABLE lt_selected_node INTO l_selected_node INDEX 1.

  • get current Line

IF NOT l_selected_node IS INITIAL.

CALL METHOD tree1->get_outtab_line

EXPORTING

i_node_key = l_selected_node

IMPORTING

e_outtab_line = ls_sflight.

ls_sflight-seatsmax = ls_sflight-price + 99.

ls_sflight-price = ls_sflight-seatsmax + '99.99'.

CALL METHOD tree1->add_node

EXPORTING

i_relat_node_key = l_selected_node

i_relationship =

cl_tree_control_base=>relat_last_sibling

is_outtab_line = ls_sflight

  • is_node_layout

  • it_item_layout

i_node_text = 'Last Sibling'. "#EC NOTEXT

  • importing

  • e_new_node_key

ELSE.

MESSAGE i227(0h).

ENDIF.

WHEN 'INSERT_NS'.

  • get selected node

CALL METHOD tree1->get_selected_nodes

CHANGING

ct_selected_nodes = lt_selected_node.

CALL METHOD cl_gui_cfw=>flush.

READ TABLE lt_selected_node INTO l_selected_node INDEX 1.

  • get current Line

IF NOT l_selected_node IS INITIAL.

CALL METHOD tree1->get_outtab_line

EXPORTING

i_node_key = l_selected_node

IMPORTING

e_outtab_line = ls_sflight.

ls_sflight-seatsmax = ls_sflight-price + 99.

ls_sflight-price = ls_sflight-seatsmax + '99.99'.

CALL METHOD tree1->add_node

EXPORTING

i_relat_node_key = l_selected_node

i_relationship =

cl_tree_control_base=>relat_next_sibling

is_outtab_line = ls_sflight

  • is_node_layout

  • it_item_layout

i_node_text = 'Next Sibling'. "#EC NOTEXT

  • importing

  • e_new_node_key

ELSE.

MESSAGE i227(0h).

ENDIF.

ENDCASE.

  • update frontend

CALL METHOD tree1->frontend_update.

ENDMETHOD. "on_function_selected

METHOD on_toolbar_dropdown.

  • create contextmenu

DATA: l_menu TYPE REF TO cl_ctmenu,

l_fc_handled TYPE as4flag.

CREATE OBJECT l_menu.

CLEAR l_fc_handled.

CASE fcode.

WHEN 'INSERT_LC'.

l_fc_handled = 'X'.

  • insert as last child

CALL METHOD l_menu->add_function

EXPORTING

fcode = 'INSERT_LC'

text = 'Insert New Line as Last Child'. "#EC NOTEXT

  • insert as first child

CALL METHOD l_menu->add_function

EXPORTING

fcode = 'INSERT_FC'

text = 'Insert New Line as First Child'. "#EC NOTEXT

  • insert as next sibling

CALL METHOD l_menu->add_function

EXPORTING

fcode = 'INSERT_NS'

text = 'Insert New Line as Next Sibling'. "#EC NOTEXT

  • insert as last sibling

CALL METHOD l_menu->add_function

EXPORTING

fcode = 'INSERT_LS'

text = 'Insert New Line as Last Sibling'. "#EC NOTEXT

  • insert as first sibling

CALL METHOD l_menu->add_function

EXPORTING

fcode = 'INSERT_FS'

text = 'Insert New Line as First Sibling'. "#EC NOTEXT

ENDCASE.

  • show dropdownbox

IF l_fc_handled = 'X'.

CALL METHOD mr_toolbar->track_context_menu

EXPORTING

context_menu = l_menu

posx = posx

posy = posy.

ENDIF.

ENDMETHOD. "on_toolbar_dropdown

ENDCLASS. "lcl_toolbar_event_receiver IMPLEMENTATION[/code]

<b>INCLUDE ZUS_SDN_BCALV_TREE_EVENT_RCVR8.</b>

[code]----


  • INCLUDE ZUS_SDN_BCALV_TREE_EVENT_RCVR8 *

----


class lcl_tree_event_receiver definition.

public section.

methods handle_node_ctmenu_request

for event node_context_menu_request of cl_gui_alv_tree

importing node_key

menu.

methods handle_node_ctmenu_selected

for event node_context_menu_selected of cl_gui_alv_tree

importing node_key

fcode.

methods handle_item_ctmenu_request

for event item_context_menu_request of cl_gui_alv_tree

importing node_key

fieldname

menu.

methods handle_item_ctmenu_selected

for event item_context_menu_selected of cl_gui_alv_tree

importing node_key

fieldname

fcode.

methods handle_item_double_click

for event item_double_click of cl_gui_alv_tree

importing node_key

fieldname.

methods handle_button_click

for event button_click of cl_gui_alv_tree

importing node_key

fieldname.

methods handle_link_click

for event link_click of cl_gui_alv_tree

importing node_key

fieldname.

methods handle_header_click

for event header_click of cl_gui_alv_tree

importing fieldname.

endclass.

class lcl_tree_event_receiver implementation.

method handle_node_ctmenu_request.

  • append own functions

call method menu->add_function

exporting fcode = 'USER1'

text = 'Usercmd 1'. "#EC NOTEXT

call method menu->add_function

exporting fcode = 'USER2'

text = 'Usercmd 2'. "#EC NOTEXT

call method menu->add_function

exporting fcode = 'USER3'

text = 'Usercmd 3'. "#EC NOTEXT

endmethod.

method handle_node_ctmenu_selected.

case fcode.

when 'USER1' or 'USER2' or 'USER3'.

message i000(0h) with 'Node-Context-Menu on Node ' node_key

'fcode : ' fcode. "#EC NOTEXT

endcase.

endmethod.

method handle_item_ctmenu_request .

  • append own functions

call method menu->add_function

exporting fcode = 'USER1'

text = 'Usercmd 1'.

call method menu->add_function

exporting fcode = 'USER2'

text = 'Usercmd 2'.

call method menu->add_function

exporting fcode = 'USER3'

text = 'Usercmd 3'.

endmethod.

method handle_item_ctmenu_selected.

case fcode.

when 'USER1' or 'USER2' or 'USER3'.

message i000(0h) with 'Item-Context-Menu on Node ' node_key

'Fieldname : ' fieldname. "#EC NOTEXT

endcase.

endmethod.

method handle_item_double_click.

endmethod.

method handle_button_click.

endmethod.

method handle_link_click.

endmethod.

method handle_header_click.

endmethod.

endclass.[/code]