Skip to Content

Dear All,

Kindly look on this document…

We can make tree structure in sap which will make our GUI interface more attractive and easy to interact with transactions with authorization security in it.


Advantage:

1.      Don’t need to remember the TCODES

2.      Attractive GUI

3.      All things are in same pool

4.      Same type of thing is under common folder.

5.      Authorization security is also possible.

And many more advantages to use this.

     1.      Define the data instances of classes which will come in use to develop the tree pool.


****DATA DECELERATION FOR TREE AND DOCKET***********
CLASS lcl_application DEFINITION DEFERRED.
CLASS cl_gui_cfw DEFINITION LOAD.

* CAUTION: MTREEITM is the name of the item structure which must
* be defined by the programmer. DO NOT USE MTREEITM!
TYPES: item_table_type LIKE STANDARD TABLE OF mtreeitm
WITH DEFAULT KEY.

CONSTANTS:
BEGIN OF c_nodekey,
root  
TYPE tv_nodekey VALUE ‘Root’,                    “#EC NOTEXT
child1
TYPE tv_nodekey VALUE ‘Child1’,                  “#EC NOTEXT
child2
TYPE tv_nodekey VALUE ‘Child2’,                  “#EC NOTEXT
child3
TYPE tv_nodekey VALUE ‘Child3’,                  “#EC NOTEXT
new1  
TYPE tv_nodekey VALUE ‘New1’,                    “#EC NOTEXT
new2  
TYPE tv_nodekey VALUE ‘New2’,                    “#EC NOTEXT
new3  
TYPE tv_nodekey VALUE ‘New3’,                    “#EC NOTEXT
new4  
TYPE tv_nodekey VALUE ‘New4’,                    “#EC NOTEXT
new5  
TYPE tv_nodekey VALUE ‘New5’,                    “#EC NOTEXT
new6  
TYPE tv_nodekey VALUE ‘New6’,                    “#EC NOTEXT
new7  
TYPE tv_nodekey VALUE ‘New7’,                    “#EC NOTEXT
END OF c_nodekey.

******data deceleration for custom container, docket containers and alv display and chooose****
DATA  init.
DATA: docking
TYPE REF TO cl_gui_docking_container,     “class for docket container
splitter
TYPE REF TO cl_gui_splitter_container,   “class for container splitter
lt_exclude 
TYPE ui_functions.                    “to exclude icons from tool baar
DATA picture TYPE REF TO cl_gui_picture.                “class for picture display
DATA: cont1
TYPE REF TO cl_gui_container,
cont2
TYPE REF TO cl_gui_container,
cont3
TYPE REF TO cl_gui_container,
cont4
TYPE REF TO cl_gui_container,
cont5
TYPE REF TO cl_gui_container.
DATA : it_layo   TYPE lvc_s_fcat OCCURS 0,
wa_layo  
LIKE LINE OF it_layo,
wa_layout
TYPE lvc_s_layo.
******end of custom container, docket containers and alv display and chooose deceleration *****

* Fields on Dynpro 100
DATA: g_event(30),
g_node_key
TYPE tv_nodekey,
g_item_name
TYPE tv_itmname.

DATA : g_custom_container TYPE REF TO cl_gui_custom_container,
edit_mod 
TYPE REF TO cl_gui_textedit,
g_tree
TYPE REF TO cl_gui_list_tree.

          2.   Make a sub screen in module pool in se80 and give the name as ‘SCRN’.

img1.JPG

3.          Define the classes which will use to link transaction in tree structure folder, handle double click event on files, node double click, button click, link click, and check box click.

CLASS lcl_application DEFINITION.
PUBLIC SECTION.
METHODS:
handle_node_double_click
FOR EVENT node_double_click
OF cl_gui_list_tree
IMPORTING node_key,
handle_expand_no_children
FOR EVENT expand_no_children
OF cl_gui_list_tree
IMPORTING node_key,
handle_item_double_click
FOR EVENT item_double_click
OF cl_gui_list_tree
IMPORTING node_key item_name,
handle_button_click
FOR EVENT button_click
OF cl_gui_list_tree
IMPORTING node_key item_name,
handle_link_click
FOR EVENT link_click
OF cl_gui_list_tree
IMPORTING node_key item_name,
handle_checkbox_change
FOR EVENT checkbox_change
OF cl_gui_list_tree
IMPORTING node_key item_name checked.
ENDCLASS.                   
“LCL_APPLICATION DEFINITION
*———————————————————————-*
*       CLASS LCL_APPLICATION IMPLEMENTATION
*———————————————————————-*
*
*———————————————————————-*
CLASS lcl_application IMPLEMENTATION.

METHOD  handle_node_double_click.
” this method handles the node double click event of the tree
” control instance

” show the key of the double clicked node in a dynpro field
g_event =
‘NODE_DOUBLE_CLICK’.
g_node_key = node_key.
ENDMETHOD.                   
“HANDLE_NODE_DOUBLE_CLICK

METHOD  handle_item_double_click.
” this method handles the item double click event of the tree
” control instance

” show the key of the node and the name of the item
” of the double clicked item in a dynpro field
g_event =
‘ITEM_DOUBLE_CLICK’.
g_node_key = node_key.
g_item_name = item_name.
ENDMETHOD.                   
“HANDLE_ITEM_DOUBLE_CLICK

METHOD  handle_link_click.
” this method handles the link click event of the tree
” control instance

” show the key of the node and the name of the item
” of the clicked link in a dynpro field
g_event =
‘LINK_CLICK’.
g_node_key = node_key.
g_item_name = item_name.
ENDMETHOD.                   
“HANDLE_LINK_CLICK

METHOD  handle_button_click.
” this method handles the button click event of the tree
” control instance

” show the key of the node and the name of the item
” of the clicked button in a dynpro field
g_event =
‘BUTTON_CLICK’.
g_node_key = node_key.
g_item_name = item_name.
ENDMETHOD.                   
“HANDLE_BUTTON_CLICK

METHOD  handle_checkbox_change.
” this method handles the checkbox_change event of the tree
” control instance

” show the key of the node and the name of the item
” of the clicked checkbox in a dynpro field
g_event =
‘CHECKBOX_CHANGE’.
g_node_key = node_key.
g_item_name = item_name.
ENDMETHOD.                   
“HANDLE_CHECKBOX_CHANGE

************method which is used to define the transaction and programs are

*****used to link from folder here is one way to link items and we can also

***link it directly in coding of PBO
METHOD handle_expand_no_children.
DATA: node_table
TYPE treev_ntab,
node
TYPE treev_node,
item_table
TYPE item_table_type,
item
TYPE mtreeitm.

* show the key of the expanded node in a dynpro field
g_event =
‘EXPAND_NO_CHILDREN’.
g_node_key = node_key.

IF node_key = c_nodekey-child2.
* add the children for node with key ‘Child2’
* Node with key ‘New3’
CLEAR node.
node-node_key = c_nodekey-new3.
node-relatkey = c_nodekey-child2.
node-relatship = cl_gui_list_tree=>relat_last_child.
APPEND node TO node_table.

* Node with key ‘New4’
CLEAR node.
node-node_key = c_nodekey-new4.
node-relatkey = c_nodekey-child2.
node-relatship = cl_gui_list_tree=>relat_last_child.
APPEND node TO node_table.

* Items of node with key ‘New3’
CLEAR item.
item-node_key = c_nodekey-new3.
item-item_name =
‘1’.
item-class = cl_gui_list_tree=>item_class_text.
item-length =
16.
item-usebgcolor =
‘X’.
item-text =
‘Atd Entry Screen’.
APPEND item TO item_table.

CLEAR item.
item-node_key = c_nodekey-new3.
item-item_name =
‘2’.
item-class = cl_gui_list_tree=>item_class_text.
item-alignment = cl_gui_list_tree=>align_auto.
item-font = cl_gui_list_tree=>item_font_prop.
item-text =
‘Attendance Entry Screen’.
APPEND item TO item_table.

* Items of node with key ‘New4’
CLEAR item.
item-node_key = c_nodekey-new4.
item-item_name =
‘1’.
item-class = cl_gui_list_tree=>item_class_text.
item-length =
16.
item-usebgcolor =
‘X’.
item-text =
‘Atd Transfer’.
APPEND item TO item_table.

CLEAR item.
item-node_key = c_nodekey-new4.
item-item_name =
‘2’.
item-class = cl_gui_list_tree=>item_class_text.
item-alignment = cl_gui_list_tree=>align_auto.
item-font = cl_gui_list_tree=>item_font_prop.
item-text =
‘Attendance Entry Transfer Screen’.
APPEND item TO item_table.
ENDIF.

CALL METHOD g_tree->add_nodes_and_items
EXPORTING
node_table                     = node_table
item_table                     = item_table
item_table_structure_name      =
‘MTREEITM’
EXCEPTIONS
failed                         =
1
cntl_system_error              =
3
error_in_tables                =
4
dp_error                       =
5
table_structure_name_not_found =
6.

ENDMETHOD.                    “HANDLE_EXPAND_NO_CHILDREN

ENDCLASS.                    “LCL_APPLICATION IMPLEMENTATION

DATA: G_APPLICATION TYPE REF TO LCL_APPLICATION.


     4.      Now, in PBO of screen having module ‘status_1004’, do initial coding to generate the tree structure.

PROCESS BEFORE OUTPUT.

MODULE status_1004.

CALL SUBSCREEN scrn INCLUDING sy-repid v_dynnr1.

PROCESS AFTER INPUT.

CALL SUBSCREEN scrn.

MODULE exitprg AT EXIT-COMMAND.

MODULE user_command_1004.


     5.      In our case, I am making a docking container which will divide into two parts: one will show the logo of company and another one will contain the folders under which their related transactions will be available.

MODULE status_1004 OUTPUT.
SET PF-STATUS ‘YCMN’.
SET TITLEBAR ‘YRPTL’.

CALL FUNCTION ‘RM_SAPGUI_PROGRESS_INDICATOR’
EXPORTING
percentage =
100
text       = ‘Extracting…’.

****here if first time the transaction call the tree instances will initiated ***and will make a structre
IF init IS INITIAL.
v_repid = sy-repid.
v_dynnr = sy-dynnr.

****create the docket container
CREATE OBJECT docking
EXPORTING
repid     = v_repid
dynnr     = v_dynnr
side      = cl_gui_docking_container=>dock_at_left
extension =
269.

****split the docket container
CREATE OBJECT splitter
EXPORTING
link_dynnr        = v_dynnr
link_repid        = v_repid
*        shellstyle        =
*        left              =
*        top               =
*        width             =
*        height            =
*        metric            = cntl_metric_dynpro
*        align             = 15
parent            = docking
rows              = 2
columns           =
1
*        no_autodef_progid_dynnr =
*        name              =

.

“first set type of splitter bar
CALL METHOD splitter->set_row_sash
EXPORTING
id    = 1                                    “first conatiner (actually splitter bar)
type  = cl_gui_splitter_container=>type_movable
value = cl_gui_splitter_container=>false.

“now set its value in % of entire costum control (so here first container will occupy 80% of enitre custom control space).
splitter->set_row_height(
id = 1 height = 36 ).

CALL METHOD splitter->get_container
EXPORTING
row       =
1
column    =
1
RECEIVING
container = cont1.

CALL METHOD splitter->get_container
EXPORTING
row       =
2
column    =
1
RECEIVING
container = cont2.

* create the picture container
CREATE OBJECT picture
EXPORTING
parent = cont1.

*    CALL METHOD cont1->set_height
*      EXPORTING
*        height = ‘5’.

* Request an URL from the data provider by exporting the pic_data.
DATA url(255).
CLEAR url.
PERFORM load_pic_from_db USING ‘ZNUVOLG’ CHANGING url.

* load picture
CALL METHOD picture->load_picture_from_url
EXPORTING
url = url.

init = ‘X’.

IF g_tree IS INITIAL.
DATA: node_table
TYPE treev_ntab,
item_table
TYPE item_table_type,
events TYPE cntl_simple_events,
event TYPE cntl_simple_event.
” The Tree Control has not been created yet.
” Create a Tree Control and insert nodes into it.

* create a list tree
CREATE OBJECT g_tree
EXPORTING
parent              = cont2
node_selection_mode = cl_gui_list_tree=>node_sel_mode_single
item_selection      =
‘X’
with_headers        =
‘ ‘.

*********Here define the events which will be accessable on folders*****
* define the events which will be passed to the backend
” node double click
event-eventid = cl_gui_list_tree=>eventid_node_double_click.
event-appl_event =
‘X’.                                  
APPEND event TO events.

” item double click
event-eventid = cl_gui_list_tree=>eventid_item_double_click.
event-appl_event =
‘X’.
APPEND event TO events.

” expand no children
event-eventid = cl_gui_list_tree=>eventid_expand_no_children.
event-appl_event =
‘X’.
APPEND event TO events.

” link click
event-eventid = cl_gui_list_tree=>eventid_link_click.
event-appl_event =
‘X’.
APPEND event TO events.

” button click
event-eventid = cl_gui_list_tree=>eventid_button_click.
event-appl_event =
‘X’.
APPEND event TO events.

” checkbox change
event-eventid = cl_gui_list_tree=>eventid_checkbox_change.
event-appl_event =
‘X’.
APPEND event TO events.

CALL METHOD g_tree->set_registered_events
EXPORTING
events                    = events
EXCEPTIONS
cntl_error                =
1
cntl_system_error         =
2
illegal_event_combination =
3.

* create the application object
* this object is needed to handle the ABAP Objects Events of
* Controls
CREATE OBJECT g_application.

* assign event handlers in the application class to each desired event
SET HANDLER g_application->handle_node_double_click FOR g_tree.
SET HANDLER g_application->handle_item_double_click FOR g_tree.
SET HANDLER g_application->handle_expand_no_children FOR g_tree.
SET HANDLER g_application->handle_link_click FOR g_tree.
SET HANDLER g_application->handle_button_click FOR g_tree.
SET HANDLER g_application->handle_checkbox_change FOR g_tree.

* add some nodes to the tree control
* NOTE: the tree control does not store data at the backend. If an
* application wants to access tree data later, it must store the
* tree data itself.

PERFORM build_node_and_item_table USING node_table item_table.

CALL METHOD g_tree->add_nodes_and_items
EXPORTING
node_table                     = node_table
item_table                     = item_table
item_table_structure_name      =
‘MTREEITM’
EXCEPTIONS
failed                         =
1
cntl_system_error              =
3
error_in_tables                =
4
dp_error                       =
5
table_structure_name_not_found =
6.
ENDIF.
ENDIF.
ENDMODULE.                
” STATUS_1004  OUTPUT

*Code: to show picture above in docking container as show in figure below

FORM load_pic_from_db USING p_val
CHANGING p_url.
DATA query_table LIKE w3query OCCURS 1 WITH HEADER LINE.
DATA html_table LIKE w3html OCCURS 1.
DATA return_code LIKE  w3param-ret_code.
DATA content_type LIKE  w3param-cont_type.
DATA content_length LIKE  w3param-cont_len.
DATA pic_data LIKE w3mime OCCURS 0.
DATA pic_size TYPE i.

REFRESH query_table.
query_table-name =
‘_OBJECT_ID’.
query_table-value = p_val.
APPEND query_table.

CALL FUNCTION ‘WWW_GET_MIME_OBJECT’
TABLES
query_string        = query_table
html                = html_table
mime                = pic_data
CHANGING
return_code         = return_code
content_type        = content_type
content_length      = content_length
EXCEPTIONS
object_not_found    =
1
parameter_not_found =
2
OTHERS              = 3.
IF sy-subrc = 0.
pic_size = content_length.
ENDIF.

CALL FUNCTION ‘DP_CREATE_URL’
EXPORTING
type     = ‘image’
subtype  = cndp_sap_tab_unknown
size     = pic_size
lifetime = cndp_lifetime_transaction
TABLES
data     = pic_data
CHANGING
url      = url
EXCEPTIONS
OTHERS   = 1.


ENDFORM.                   
” LOAD_PIC_FROM_DB

img2.JPG

*********here use to link items directly from PBO code.

FORM build_node_and_item_table
USING
node_table
TYPE treev_ntab
item_table
TYPE item_table_type.

DATA: node TYPE treev_node,
item
TYPE mtreeitm.

* Build the node table.

* Caution: The nodes are inserted into the tree according to the order
* in which they occur in the table. In consequence, a node must not
* must not occur in the node table before its parent node.

* Node with key ‘Root’
node-node_key = c_nodekey-root.
” Key of the node
CLEAR node-relatkey.      ” Special case: A root node has no parent
CLEAR node-relatship.                ” node.

node-hidden = ‘ ‘.                   ” The node is visible,
node-disabled =
‘ ‘.                 ” selectable,
node-isfolder =
‘X’.                 ” a folder.
CLEAR node-n_image.       ” Folder-/ Leaf-Symbol in state “closed”:
” use default.
CLEAR node-exp_image.     ” Folder-/ Leaf-Symbol in state “open”:
” use default
CLEAR node-expander.                 ” see below.
” the width of the item is adjusted to its content (text)
APPEND node TO node_table.

* Node with key ‘Child1’
CLEAR node.
node-node_key = c_nodekey-child1.
” Key of the node
” Node is inserted as child of the node with key ‘Root’.
node-relatkey = c_nodekey-root.
node-relatship = cl_gui_list_tree=>relat_last_child.
node-isfolder =
‘X’.
APPEND node TO node_table.

* Node with key ‘New1’
CLEAR node.
node-node_key = c_nodekey-new1.
node-relatkey = c_nodekey-child1.
node-relatship = cl_gui_list_tree=>relat_last_child.
APPEND node TO node_table.

* Node with key ‘New2’
CLEAR node.
node-node_key = c_nodekey-new2.
node-relatkey = c_nodekey-child1.
node-relatship = cl_gui_list_tree=>relat_last_child.
APPEND node TO node_table.

* Node with key ‘New5’
CLEAR node.
node-node_key = c_nodekey-new5.
node-relatkey = c_nodekey-child1.
node-relatship = cl_gui_list_tree=>relat_last_child.
APPEND node TO node_table.

* Node with key ‘Child2’
CLEAR node.
node-node_key = c_nodekey-child2.
node-relatkey = c_nodekey-root.
node-relatship = cl_gui_list_tree=>relat_last_child.
node-isfolder =
‘X’.
node-expander =
‘X’. ” The node is marked with a ‘+’, although
” it has no children. When the user clicks on the
” + to open the node, the event expand_nc is
” fired. The programmerr can
” add the children of the
” node within the event handler of the expand_nc
” event  (see callback handle_expand_nc).
APPEND node TO node_table.

* The items of the nodes:

* Node with key ‘Root’
CLEAR item.
item-node_key = c_nodekey-root.
item-item_name =
‘1’.                ” Item with name ‘1’
item-class = cl_gui_list_tree=>item_class_text.
” Text Item
” the with of the item is adjusted to its content (text)
item-alignment = cl_gui_list_tree=>align_auto.
” use proportional font for the item
item-font = cl_gui_list_tree=>item_font_prop.
item-text =
‘Reports’(003).
APPEND item TO item_table.

* Node with key ‘Child1’
CLEAR item.
item-node_key = c_nodekey-child1.
item-item_name =
‘1’.
item-class = cl_gui_list_tree=>item_class_text.
item-alignment = cl_gui_list_tree=>align_auto.
item-font = cl_gui_list_tree=>item_font_prop.
item-text =
‘Employee Master Reports’(004).
APPEND item TO item_table.

* Node with key ‘Child2’
CLEAR item.
item-node_key = c_nodekey-child2.
item-item_name =
‘1’.
item-class = cl_gui_list_tree=>item_class_text.
item-alignment = cl_gui_list_tree=>align_auto.
item-font = cl_gui_list_tree=>item_font_prop.
item-text =
‘Attendance’.
APPEND item TO item_table.

* Items of node with key ‘New1’
*  CLEAR ITEM.
*  item-node_key = c_nodekey-new1.
*  ITEM-ITEM_NAME = ‘1’.
*  ITEM-CLASS = CL_GUI_LIST_TREE=>ITEM_CLASS_TEXT.
*  ITEM-LENGTH = 4. ” the width of the item is 4 characters
*  ITEM-IGNOREIMAG = ‘X’.               ” see documentation of Structure
*                                       ” TREEV_ITEM
*  ITEM-USEBGCOLOR = ‘X’.               ” item has light grey background
*  ITEM-T_IMAGE = ‘@25@’.               ” icon of the item
*  APPEND ITEM TO ITEM_TABLE.

CLEAR item.
item-node_key = c_nodekey-new1.
item-item_name =
‘1’.
item-class = cl_gui_list_tree=>item_class_text.
item-length =
20.
item-usebgcolor =
‘X’.
item-text =
‘Employee Detail’.
APPEND item TO item_table.

*  CLEAR ITEM.
*  item-node_key = c_nodekey-new1.
*  ITEM-ITEM_NAME = ‘2’.
*  ITEM-CLASS = CL_GUI_LIST_TREE=>ITEM_CLASS_TEXT.
*  ITEM-LENGTH = 11.
*  ITEM-USEBGCOLOR = ‘X’.                                    “
*  ITEM-TEXT = ‘MUELLER’.
*  APPEND ITEM TO ITEM_TABLE.

CLEAR item.
item-node_key = c_nodekey-new1.
item-item_name =
‘2’.
item-class = cl_gui_list_tree=>item_class_text.
item-alignment = cl_gui_list_tree=>align_auto.
item-font = cl_gui_list_tree=>item_font_prop.
item-text =
‘Emplyee Master Details’.
APPEND item TO item_table.

* Items of node with key ‘New2’
*  CLEAR item.
*  item-node_key = c_nodekey-new2.
*  item-item_name = ‘1’.
*  item-class = cl_gui_list_tree=>item_class_text.
*  item-length = 4. ” the width of the item is 2 characters
*  item-ignoreimag = ‘X’.               ” see documentation of Structure
*  ” TREEV_ITEM
*  item-usebgcolor = ‘X’.               ” item has light grey background
*  item-t_image = ‘@02@’.               ” icon of the item
*  APPEND item TO item_table.

CLEAR item.
item-node_key = c_nodekey-new2.
item-item_name =
‘1’.
item-class = cl_gui_list_tree=>item_class_text.
item-length =
20.
item-usebgcolor =
‘X’.
item-text =
‘Emp Dep & Cnt Dtls’.
APPEND item TO item_table.

*  CLEAR item.
*  item-node_key = c_nodekey-new2.
*  item-item_name = ‘3’.
*  item-class = cl_gui_list_tree=>item_class_text.
*  item-length = 11.
*  item-usebgcolor = ‘X’.                                    “
*  item-text = ‘HARRYHIRSCH’.
*  APPEND item TO item_table.

CLEAR item.
item-node_key = c_nodekey-new2.
item-item_name =
‘2’.
item-class = cl_gui_list_tree=>item_class_text.
item-alignment = cl_gui_list_tree=>align_auto.
item-font = cl_gui_list_tree=>item_font_prop.
item-text =
‘Employee Dependent & Contact Details’(007).
APPEND item TO item_table.

* Items of node with key ‘New3’
*  CLEAR item.
*  item-node_key = c_nodekey-new3.
*  item-item_name = ‘1’.
*  item-class = cl_gui_list_tree=>item_class_text.
*  item-length = 4. ” the width of the item is 2 characters
*  item-ignoreimag = ‘X’.               ” see documentation of Structure
*  ” TREEV_ITEM
*  item-usebgcolor = ‘X’.               ” item has light grey background
*  item-t_image = ‘@02@’.               ” icon of the item
*  APPEND item TO item_table.

CLEAR item.
item-node_key = c_nodekey-new5.
item-item_name =
‘1’.
item-class = cl_gui_list_tree=>item_class_text.
item-length =
20.
item-usebgcolor =
‘X’.
item-text =
‘Atd Recording Report’.
APPEND item TO item_table.

*  CLEAR item.
*  item-node_key = c_nodekey-new2.
*  item-item_name = ‘3’.
*  item-class = cl_gui_list_tree=>item_class_text.
*  item-length = 11.
*  item-usebgcolor = ‘X’.                                    “
*  item-text = ‘HARRYHIRSCH’.
*  APPEND item TO item_table.

CLEAR item.
item-node_key = c_nodekey-new5.
item-item_name =
‘2’.
item-class = cl_gui_list_tree=>item_class_text.
item-alignment = cl_gui_list_tree=>align_auto.
item-font = cl_gui_list_tree=>item_font_prop.
item-text =
‘Employee Attendance Recording Report’.
APPEND item TO item_table.
ENDFORM.                   
” BUILD_NODE_AND_ITEM_TABLE

     6.    Here, in PBI it is compulsory to free the docking container and tree object while exiting the program. This is called from the PBI code.

*&———————————————————————*
*&      Module  EXITPRG  INPUT
*&———————————————————————*
*       text
*———————————————————————-*
MODULE exitprg INPUT.
ok_code = sy-ucomm.
CASE ok_code.
WHEN ‘BACK’.
PERFORM clrit.
*      LEAVE PROGRAM.
WHEN ‘UP’.
PERFORM clrit.
*      LEAVE PROGRAM.
WHEN ‘EXIT’.
PERFORM clrit.
*      LEAVE PROGRAM.
ENDCASE.

IF NOT docking IS INITIAL.
” destroy tree container (detroys contained tree control, too)
CALL METHOD docking->free
EXCEPTIONS
cntl_system_error =
1
cntl_error        =
2.
CLEAR docking.
CLEAR g_tree.
ENDIF.
LEAVE PROGRAM.
ENDMODULE.                
” EXITPRG  INPUT

  1. 3.      Now to link the transaction and call the code on click event from tree node, do the below code in PBI  module function:MODULEuser_command_1004.’

MODULE user_command_1004 INPUT.
DATA: return_code
TYPE i.

* CL_GUI_CFW=>DISPATCH must be called if events are registered
* that trigger PAI
* this method calls the event handler method of an event
CALL METHOD cl_gui_cfw=>dispatch
IMPORTING
return_code = return_code.
IF return_code <> cl_gui_cfw=>rc_noevent.
” a control event occured => exit PAI
IF g_node_key = ‘New1’.
v_dynnr1 =
‘0801’.
ELSEIF g_node_key = ‘New2’.
v_dynnr1 =
‘0802’.
ELSEIF g_node_key = ‘New3’.
v_dynnr1 =
‘0803’.
ELSEIF g_node_key = ‘New4’.
PERFORM chkauth USING ‘New4’.
REFRESH : it_trnf1, it_trnf1[],
it_trnf,  it_trnf[],
it_tmp, it_tmp[],
it_sftm, it_sftm[],
it_esftm1, it_esftm1[],
it_adent, it_adent[],
it_esftm, it_esftm[].
CLEAR : v_index, yatndent-pchdt, yunitmst-untno, wa_tmp.
CALL SCREEN 1007.
*      v_dynnr1 = ‘1007’.
ELSEIF g_node_key = ‘New5’.

v_dynnr1 = ‘0805’.
ENDIF.
CLEAR ok_code.
EXIT.
ENDIF.

ok_code = sy-ucomm.
CASE ok_code.
WHEN ‘OK’.
IF g_node_key = ‘New1’.
PERFORM chkauth USING ‘New1’.
PERFORM empdtlsel.
CALL SCREEN 1005.
ELSEIF g_node_key = ‘New2’.
PERFORM chkauth USING ‘New2’.
PERFORM empcntdpt.
CALL SCREEN 1005.
ELSEIF g_node_key = ‘New3’.
PERFORM chkauth USING ‘New3’.
PERFORM atndentry.
ELSEIF g_node_key = ‘New5’.
PERFORM chkauth USING ‘New5’.
PERFORM atndrep.
CALL SCREEN 1005.
ENDIF.

WHEN ‘BACK’. ” Finish program
IF NOT docking IS INITIAL.
” destroy tree container (detroys contained tree control, too)
CALL METHOD docking->free
EXCEPTIONS
cntl_system_error =
1
cntl_error        =
2.
CLEAR docking.
CLEAR g_tree.
ENDIF.
LEAVE PROGRAM.
WHEN ‘SAVE’.
CALL SCREEN 0701 STARTING AT 10 5.
WHEN ‘VARIANT’.
PERFORM load_variant.
IF sy-ucomm EQ ‘CANC’.
MESSAGE ‘Variant operation terminated’ TYPE ‘S’ DISPLAY LIKE ‘E’.
ELSE.
MESSAGE ‘Variant selected’ TYPE ‘S’.
ENDIF.
CALL SCREEN 1004.
ENDCASE.

* CAUTION: clear ok code!
CLEAR ok_code.
ENDMODULE.                
” USER_COMMAND_1004  INPUT

img3.JPG

Here, if you find any error on doing coding for this, then you are free to contact me and I would be very happy to help you..

Many Thanks / Himanshu Gupta




To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

    1. HIMANSHU GUPTA Post author

      😉

      hmmm…

      yeah I know it’s lengthy but it requires to do it….

      and  thanks for your early response…

      Many Thanks / Himanshu Gupta

      (0) 
  1. Sam Peter

    Nice document, but lengthy..

    Dont we have a provision to attach code to this document, so that it will be helpful to read the purpose of the document in first hand, and then look at the code??

    Thanks

    Sam Peter.

    (0) 
  2. Eitan Rosenberg

    Hi,

    Thanks for sharing.

    Can you download the code and add it as attachments .

    Screens can be downloaded as well .

    This way we can have a working program in minutes….

           

    Regards .

    (0) 

Leave a Reply