Tree structured Report programming
Hi,
I have a requirement of a Report which has to have a Tree structure similar to SE09 Transaction. When we give the User id in the SE09 and hit on Display button the next screen lists all the Transport requests under the user in a Tree structure which can be exploded or collapsed.
I want to know how complicated is this to code, is there any Function module that can help acheive this. Also let me if there is a sample program.
Appreciate your help on this.
Thanks and Regards,
Saleem.
Hi Saleem,
Check this sample code,
REPORT Z_AZAZ_TEST_TREE_1 .
TYPE-POOLS : FIBS,STREE.
DATA : T_NODE TYPE SNODETEXT.
DATA : NODE_TAB LIKE T_NODE OCCURS 0 WITH HEADER LINE.
CLEAR : NODE_TAB, NODE_TAB[].
NODE_TAB-TYPE = 'T'.
NODE_TAB-NAME = 'Earth'.
NODE_TAB-TLEVEL = '01'.
NODE_TAB-NLENGTH = '5'.
NODE_TAB-COLOR = '4'.
NODE_TAB-TEXT = 'Hello'.
NODE_TAB-TLENGTH ='5'.
NODE_TAB-TCOLOR = 3.
APPEND NODE_TAB.
CLEAR NODE_TAB.
NODE_TAB-TYPE = 'P'.
NODE_TAB-NAME = 'Europe'.
NODE_TAB-TLEVEL = '02'.
NODE_TAB-NLENGTH = '6'.
NODE_TAB-COLOR = '1'.
NODE_TAB-TEXT = 'Hello'.
NODE_TAB-TLENGTH ='5'.
NODE_TAB-TCOLOR = 4.
APPEND NODE_TAB.
CLEAR NODE_TAB.
NODE_TAB-TYPE = 'P'.
NODE_TAB-NAME = 'Germany'.
NODE_TAB-TLEVEL = '03'.
NODE_TAB-NLENGTH = '7'.
NODE_TAB-COLOR = '4'.
NODE_TAB-TEXT = 'Hello'.
NODE_TAB-TLENGTH ='5'.
NODE_TAB-TCOLOR = 4.
APPEND NODE_TAB.
CLEAR NODE_TAB.
NODE_TAB-TYPE = 'P'.
NODE_TAB-NAME = 'Berlin'.
NODE_TAB-TLEVEL = '04'.
NODE_TAB-NLENGTH = '6'.
NODE_TAB-COLOR = '4'.
NODE_TAB-TEXT = 'Hello'.
NODE_TAB-TLENGTH ='5'.
NODE_TAB-TCOLOR = 3.
APPEND NODE_TAB.
CLEAR NODE_TAB.
NODE_TAB-TYPE = 'P'.
NODE_TAB-NAME = 'Asia'.
NODE_TAB-TLEVEL = '02'.
NODE_TAB-NLENGTH = '4'.
NODE_TAB-COLOR = '1'.
NODE_TAB-TEXT = 'Hello'.
NODE_TAB-TLENGTH ='5'.
NODE_TAB-TCOLOR = 3.
APPEND NODE_TAB.
CLEAR NODE_TAB.
NODE_TAB-TYPE = 'P'.
NODE_TAB-NAME = 'India'.
NODE_TAB-TLEVEL = '03-'.
NODE_TAB-NLENGTH = '5'.
NODE_TAB-COLOR = '1'.
NODE_TAB-TEXT = 'Hello'.
NODE_TAB-TLENGTH ='5'.
NODE_TAB-TCOLOR = 3.
APPEND NODE_TAB.
CLEAR NODE_TAB.
NODE_TAB-TYPE = 'P'.
NODE_TAB-NAME = 'Bombay'.
NODE_TAB-TLEVEL = '04-'.
NODE_TAB-NLENGTH = '6'.
NODE_TAB-COLOR = '1'.
NODE_TAB-TEXT = 'Hello'.
NODE_TAB-TLENGTH ='5'.
NODE_TAB-TCOLOR = 3.
APPEND NODE_TAB.
CLEAR NODE_TAB.
CALL FUNCTION 'RS_TREE_CONSTRUCT'
EXPORTING
INSERT_ID = '000000'
RELATIONSHIP = ' '
LOG =
TABLES
NODETAB = NODE_TAB
EXCEPTIONS
TREE_FAILURE = 1
ID_NOT_FOUND = 2
WRONG_RELATIONSHIP = 3
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.
DATA: TYPE_MAPPING TYPE STREE_CTL_TYPE_MAPPING_TAB.
DATA: WA_TYPE TYPE STREE_CTL_TYPE_MAPPING.
CLEAR: TYPE_MAPPING[].
WA_TYPE-TYPE = 'A'.
WA_TYPE-ICON = '@BL@'.
APPEND WA_TYPE TO TYPE_MAPPING.
*CALL FUNCTION 'RS_TREE_CONTROL_PREPARE'
EXPORTING
CONTROL_PATTERN = STREE_CTL_GENERIC
CONTROL_PATTERN = 'PH'
HIERARCHY_HEADER =
INITIAL_HEADER_WIDTH =
LIST_ITEM_HEADER =
MULTIPLE_SELECTION = 'X'
ITEM_SELECTION = STREE_FALSE
SUPPRESS_NODE_ICON = STREE_FALSE
SUPPRESS_FOLDER_ICON = STREE_FALSE
CALLBACK_PROGRAM =
CALLBACK_ITEM_DISPLAY =
COLOR_MAPPING =
TYPE_MAPPING = type_mapping
IMPORTING
SUBSCREEN_PROGRAM =
SUBSCREEN_DYNNR =
EXCEPTIONS
NOT_AVAILABLE = 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 FUNCTION 'RS_TREE_SET_CURRENT_LAYOUT'
EXPORTING
CURSOR_COLUMN = 3
CURSOR_LINE = 2
FIRST_NODE = 1
FIRST_NODE_TYPE = ' '
LIST_COLUMN = 1
LIST_LINE = 1
LAYOUT_MODE = STREE_LAYOUT_NORMAL
IMPORTING
INCONSISTENT_LAYOUT =
TABLES
LAYOUT =
CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
EXPORTING
CALLBACK_PROGRAM =
CALLBACK_USER_COMMAND =
CALLBACK_TEXT_DISPLAY =
CALLBACK_MOREINFO_DISPLAY =
CALLBACK_COLOR_DISPLAY =
CALLBACK_TOP_OF_PAGE =
CALLBACK_GUI_STATUS =
CALLBACK_CONTEXT_MENU =
STATUS = 'IMPLICIT'
CHECK_DUPLICATE_NAME = '1'
COLOR_OF_NODE = '4'
COLOR_OF_MARK = '3'
COLOR_OF_LINK = '1'
COLOR_OF_MATCH = '5'
LOWER_CASE_SENSITIVE = ' '
MODIFICATION_LOG = ' '
NODE_LENGTH = 30
TEXT_LENGTH = 75
TEXT_LENGTH1 = 0
TEXT_LENGTH2 = 0
RETURN_MARKED_SUBTREE = ' '
SCREEN_START_COLUMN = 0
SCREEN_START_LINE = 0
SCREEN_END_COLUMN = 0
SCREEN_END_LINE = 0
SUPPRESS_NODE_OUTPUT = ' '
LAYOUT_MODE = ' '
USE_CONTROL = STREE_USE_LIST
USE_CONTROL = 'L'.
IMPORTING
F15 =
Regards,
Azaz Ali.
Similar Messages
-
Organization/Tree structure report in BOBJ
Hello All,
Recently received a requirement for a "report" which to me initially did not look like a report, but rather a model of an organization chart/tree. I am trying to figure out if something like this is possible to do in any of the BOBJ tools (WEBI/Crystal/Dashboards). The Level0, Level1 and Level2 objects are all dynamic and there would be multiple Overall Processes - Level 0s (let's say 15). Each process is then broken down into the respective Level1 and then further into Level 2. All these levels are dynamic (there could be 2 level1s, 5, etc) and would come from a database (I'm not sure exactly what the data structure would look like, but it can be modeled specifically for this reason). I see it as a type of hierarchy (but vertical) , but I am having trouble reproducing it in WEBI / Crystal. I tried a CrossTable report in WEBI, and it almost gets me there but it shows all the Level 2s for each level 1 - can't do that type of breakdown where it compresses the rows dynamically. What it looks like we are trying to do here is create a horizontal table for Level 0 and Level 1, but then a vertical table for Level 2. I'm just looking for any ideas on how this may be possible as this is not your typical report.The issue we seem to be having is the fact that we need to create multiple vertical tables (level 2s) for each column (Level1).
The data looks as such
Level 0 Level 1 System
Overall Process Create System1
Overall Process Create System2
Overall Process Create System3
Overall Process Create System4
Overall Process Create System5
Overall Process Create System6
Overall Process Create System7
Overall Process Create System8
Overall Process Develop System1
Overall Process Develop System2
Overall Process Develop System3
Overall Process Develop System4
Overall Process Develop System5
Overall Process Develop System6
Overall Process Develop System7
Overall Process Award System7
Overall Process Award System1
Overall Process Award System2
So the Level 1s (Create/Develop/Award...) are rows and have a relation to the systems. But the systems are required to be shown as columns, each related to level 1. But the level 0/1s are dynamic..there could be 1 to 15 Level 0s and 1 to 16 Level 1s. I can make this relationship show as a cross table, but having a hard time (without doing some Excel Magic in Dasboards) to make it show as a "chart" -
How to Display Heading for TREE Structure (report)
hi,
tell me how display the heading for the TREE Report.
With Regards,
Shakthi Raj N.Hi,
If you are using object oriented approach for developing the Tree report, then you can use below shown example for creating header for the report.
first create tree control
CREATE OBJECT TREE1
EXPORTING
PARENT = G_CONTAINER_OBJECT
NODE_SELECTION_MODE = CL_GUI_COLUMN_TREE=>NODE_SEL_MODE_SINGLE
ITEM_SELECTION = ''
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.
CLEAR GT_HEADER.
GT_HEADER-TYP = 'H'.
GT_HEADER-INFO = 'Output'.
APPEND GT_HEADER.
CLEAR GT_HEADER.
GT_HEADER-TYP = 'S'.
GT_HEADER-KEY = 'Display'.
GT_HEADER-INFO = 'Report'.
APPEND GT_HEADER.
then create empty tree-control
CALL METHOD TREE1->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_HIERARCHY_HEADER = G_HIERARCHY_HEADER
I_BACKGROUND_ID = 'ALV_BACKGROUND'
IT_LIST_COMMENTARY = GT_HEADER[]
CHANGING
IT_OUTTAB = GT_SPFLI[] "empty table
IT_FIELDCATALOG = GT_FIELDCAT_LVC[].
In this way header can be given for Tree report.
Hope this answers your query.
Regards,
Brajvir -
How to get Text for nodes in Tree Structure
Hi Friends,
How to get Text for nodes in Tree Structure
REPORT YFIIN_REP_TREE_STRUCTURE no standard page heading.
I N I T I A L I Z A T I O N
INITIALIZATION.
AUTHORITY-CHECK OBJECT 'ZPRCHK_NEW' :
ID 'YFIINICD' FIELD SY-TCODE.
IF SY-SUBRC NE 0.
MESSAGE I000(yFI02) with SY-TCODE .
LEAVE PROGRAM.
ENDIF.
class screen_init definition create private.
Public section
public section.
class-methods init_screen.
methods constructor.
Private section
private section.
data: container1 type ref to cl_gui_custom_container,
container2 type ref to cl_gui_custom_container,
tree type ref to cl_gui_simple_tree.
methods: fill_tree.
endclass.
Class for Handling Events
class screen_handler definition.
Public section
public section.
methods: constructor importing container
type ref to cl_gui_custom_container,
handle_node_double_click
for event node_double_click
of cl_gui_simple_tree
importing node_key .
Private section
private section.
endclass.
*& Classes implementation
class screen_init implementation.
*& Method INIT_SCREEN
method init_screen.
data screen type ref to screen_init.
create object screen.
endmethod.
*& Method CONSTRUCTOR
method constructor.
data: events type cntl_simple_events,
event like line of events,
event_handler type ref to screen_handler.
create object: container1 exporting container_name = 'CUSTOM_1',
tree exporting parent = container1
node_selection_mode =
cl_gui_simple_tree=>node_sel_mode_multiple.
create object: container2 exporting container_name = 'CUSTOM_2',
event_handler exporting container = container2.
event-eventid = cl_gui_simple_tree=>eventid_node_double_click.
event-appl_event = ' '. "system event, does not trigger PAI
append event to events.
call method tree->set_registered_events
exporting events = events.
set handler event_handler->handle_node_double_click for tree.
call method: me->fill_tree.
endmethod.
*& Method FILL_TREE
method fill_tree.
data: node_table type table of abdemonode,
node type abdemonode.
types: begin of tree_node,
folder(50) type c,
tcode(60) type c,
tcode1(60) type c,
tcode2(60) type c,
text(60) type c,
text1(60) type c,
text2(60) type c,
end of tree_node.
data: wa_tree_node type tree_node,
t_tree_node type table of tree_node.
wa_tree_node-folder = text-001.
wa_tree_node-tcode = text-002.
wa_tree_node-text = 'Creditors ageing'.
wa_tree_node-tcode1 = text-003.
wa_tree_node-text1 = 'GR/IR aging'.
wa_tree_node-tcode2 = text-004.
wa_tree_node-text2 = 'Bank Balance'.
append wa_tree_node to t_tree_node.
clear wa_tree_node .
wa_tree_node-folder = text-005.
wa_tree_node-tcode = text-006.
wa_tree_node-text = 'Creditors ageing'.
wa_tree_node-tcode1 = text-007.
wa_tree_node-text1 = 'Creditors ageing'.
wa_tree_node-tcode2 = text-008.
wa_tree_node-text2 = 'Creditors ageing'.
append wa_tree_node to t_tree_node.
clear wa_tree_node .
wa_tree_node-folder = text-009.
wa_tree_node-tcode = text-010.
wa_tree_node-text = 'Creditors ageing'.
wa_tree_node-tcode1 = text-011.
wa_tree_node-text1 = 'Creditors ageing'.
wa_tree_node-tcode2 = text-012.
wa_tree_node-text2 = 'Creditors ageing'.
append wa_tree_node to t_tree_node.
clear wa_tree_node .
node-hidden = ' '. " All nodes are visible,
node-disabled = ' '. " selectable,
node-isfolder = 'X'. " a folder,
node-expander = ' '. " have no '+' sign forexpansion.
loop at t_tree_node into wa_tree_node.
at new folder.
node-isfolder = 'X'. " a folder,
node-node_key = wa_tree_node-folder.
clear node-relatkey.
clear node-relatship.
node-text = wa_tree_node-folder.
node-n_image = ' '.
node-exp_image = ' '.
append node to node_table.
endat.
at new tcode .
node-isfolder = ' '. " a folder,
node-n_image = '@CS@'. "AV is the internal code
node-exp_image = '@CS@'. "for an airplane icon
node-node_key = wa_tree_node-tcode.
node-text = wa_tree_node-text .
node-relatkey = wa_tree_node-folder.
node-relatship = cl_gui_simple_tree=>relat_last_child.
endat.
append node to node_table.
at new tcode1 .
node-isfolder = ' '. " a folder,
node-n_image = '@CS@'. "AV is the internal code
node-exp_image = '@CS@'. "for an airplane icon
node-node_key = wa_tree_node-tcode1.
node-relatkey = wa_tree_node-folder.
node-relatship = cl_gui_simple_tree=>relat_last_child.
node-text = wa_tree_node-text1.
endat.
append node to node_table.
at new tcode2 .
node-isfolder = ' '. " a folder,
node-n_image = '@CS@'. "AV is the internal code
node-exp_image = '@CS@'. "for an airplane icon
node-node_key = wa_tree_node-tcode2.
node-relatkey = wa_tree_node-folder.
node-relatship = cl_gui_simple_tree=>relat_last_child.
node-text = wa_tree_node-text2.
endat.
append node to node_table.
endloop.
call method tree->add_nodes
exporting table_structure_name = 'ABDEMONODE'
node_table = node_table.
endmethod.
endclass.
*& Class implementation
class screen_handler implementation.
*& Method CONSTRUCTOR
method constructor.
create object: HTML_VIEWER exporting PARENT = CONTAINER,
LIST_VIEWER exporting I_PARENT = CONTAINER.
endmethod.
*& Method HANDLE_NODE_DOUBLE_CLICK
method handle_node_double_click.
case node_key(12).
when 'Creditors'.
submit YFIIN_REP_CREADITORS_AGING via selection-screen and return.
when 'Vendor'.
submit YFIIN_REP_VENDOR_OUTSTANDING via selection-screen and return.
when 'Customer'.
submit YFIIN_REP_CUSTOMER_OUTSTANDING via selection-screen and
return.
when 'GR/IR'.
submit YFIIN_REP_GRIR_AGING via selection-screen and return.
when 'Acc_Doc_List'.
submit YFIIN_REP_ACCOUNTINGDOCLIST via selection-screen and return.
when 'Bank Bal'.
submit YFIIN_REP_BANKBALANCE via selection-screen and return.
when 'Ven_Cus_Dtl'.
submit YFIIN_REP_VENDORCUST_DETAIL via selection-screen and return.
when 'G/L_Open_Bal'.
submit YFIIN_REP_OPENINGBALANCE via selection-screen and return.
when 'Usr_Authn'.
submit YFIIN_REP_USERAUTHRIZATION via selection-screen and return.
endcase.
endmethod.
endclass.
Program execution ************************************************
load-of-program.
call screen 9001.
at selection-screen.
Dialog Modules PBO
*& Module STATUS_9001 OUTPUT
text
module status_9001 output.
set pf-status 'SCREEN_9001'.
set titlebar 'TIT_9001'.
call method screen_init=>init_screen.
endmodule. " STATUS_9001 OUTPUT
Dialog Modules PAI
*& Module USER_COMMAND_9001 INPUT
text
module user_command_9001 input.
endmodule. " USER_COMMAND_9001 INPUT
*& Module exit_9001 INPUT
text
module exit_9001 input.
case sy-ucomm.
when 'EXIT'.
set screen 0.
endcase.
endmodule.
exit_9001 INPUTyou can read the table node_table with nody key value which imports when docubble click the the tree node (Double clifk event).
Regards,
Gopi .
Reward points if helpfull. -
Tree structure format in report.
Hi all,
I have got a report to develop where in i have to display the ouptut of the report
in a tree structure.Can anybody tell me how to proceed with this ?? This is
basically an interactive report where clicking on one of the node will take us to
another page.
Thanks and Regards.
syed.HI
Refer this code.
REPORT YMS_ALVTREEDEMO .
*Data Declaration
TABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
it_ekpo TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
it_emptytab TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko,
wa_ekpo TYPE t_ekko.
DATA: ok_code like sy-ucomm, "OK-Code
save_ok like sy-ucomm.
*ALV data declarations
DATA: fieldcatalog TYPE lvc_t_fcat WITH HEADER LINE.
DATA: gd_fieldcat TYPE lvc_t_fcat,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv.
*ALVtree data declarations
CLASS cl_gui_column_tree DEFINITION LOAD.
CLASS cl_gui_cfw DEFINITION LOAD.
DATA: gd_tree TYPE REF TO cl_gui_alv_tree,
gd_hierarchy_header TYPE treev_hhdr,
gd_report_title TYPE slis_t_listheader,
gd_logo TYPE sdydo_value,
gd_variant TYPE disvariant.
*Create container for alv-tree
DATA: l_tree_container_name(30) TYPE c,
l_custom_container TYPE REF TO cl_gui_custom_container.
*Includes
*INCLUDE ZDEMO_ALVTREEO01. "Screen PBO Modules
*INCLUDE ZDEMO_ALVTREEI01. "Screen PAI Modules
*INCLUDE ZDEMO_ALVTREEF01. "ABAP Subroutines(FORMS)
*Start-of-selection.
START-OF-SELECTION.
ALVtree setup data
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM build_hierarchy_header CHANGING gd_hierarchy_header.
PERFORM build_report_title USING gd_report_title gd_logo.
PERFORM build_variant.
Display ALVtree report
call screen 100.
*& Form DATA_RETRIEVAL
Retrieve data into Internal tables
FORM data_retrieval.
SELECT ebeln
UP TO 10 ROWS
FROM ekko
INTO corresponding fields of TABLE it_ekko.
loop at it_ekko into wa_ekko.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
FROM ekpo
appending TABLE it_ekpo
where ebeln eq wa_ekko-ebeln.
endloop.
ENDFORM. " DATA_RETRIEVAL
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
Please not there are a number of differences between the structure of
ALVtree fieldcatalogs and ALVgrid fieldcatalogs.
For example the field seltext_m is replace by scrtext_m in ALVtree.
fieldcatalog-fieldname = 'EBELN'. "Field name in itab
fieldcatalog-scrtext_m = 'Purchase Order'. "Column text
fieldcatalog-col_pos = 0. "Column position
fieldcatalog-outputlen = 15. "Column width
fieldcatalog-emphasize = 'X'. "Emphasize (X or SPACE)
fieldcatalog-key = 'X'. "Key Field? (X or SPACE)
fieldcatalog-do_sum = 'X'. "Sum Column?
fieldcatalog-no_zero = 'X'. "Don't display if zero
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-scrtext_m = 'PO Iten'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-scrtext_m = 'Status'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = 2.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-scrtext_m = 'Item change date'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-scrtext_m = 'Material Number'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-scrtext_m = 'PO quantity'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-scrtext_m = 'Order Unit'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-scrtext_m = 'Net Price'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = 7.
fieldcatalog-datatype = 'CURR'.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-scrtext_m = 'Price Unit'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
ENDFORM. " BUILD_LAYOUT
*& Form build_hierarchy_header
build hierarchy-header-information
-->P_L_HIERARCHY_HEADER structure for hierarchy-header
FORM build_hierarchy_header CHANGING
p_hierarchy_header TYPE treev_hhdr.
p_hierarchy_header-heading = 'Hierarchy Header'(013).
p_hierarchy_header-tooltip = 'This is the Hierarchy Header !'(014).
p_hierarchy_header-width = 30.
p_hierarchy_header-width_pix = ''.
ENDFORM. " build_hierarchy_header
*& Form BUILD_REPORT_TITLE
Build table for ALVtree header
<-> p1 Header details
<-> p2 Logo value
FORM build_report_title CHANGING
pt_report_title TYPE slis_t_listheader
pa_logo TYPE sdydo_value.
DATA: ls_line TYPE slis_listheader,
ld_date(10) TYPE c.
List Heading Line(TYPE H)
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-key "Not Used For This Type(H)
ls_line-info = 'PO ALVTree Display'.
APPEND ls_line TO pt_report_title.
Status Line(TYPE S)
ld_date(2) = sy-datum+6(2).
ld_date+2(1) = '/'.
ld_date3(2) = sy-datum4(2).
ld_date+5(1) = '/'.
ld_date+6(4) = sy-datum(4).
ls_line-typ = 'S'.
ls_line-key = 'Date'.
ls_line-info = ld_date.
APPEND ls_line TO pt_report_title.
Action Line(TYPE A)
CLEAR ls_line.
ls_line-typ = 'A'.
CONCATENATE 'Report: ' sy-repid INTO ls_line-info SEPARATED BY space.
APPEND ls_line TO pt_report_title.
ENDFORM.
*& Form BUILD_VARIANT
Build variant
form build_variant.
Set repid for storing variants
gd_variant-report = sy-repid.
endform. " BUILD_VARIANT
Check these programs.
e.g
BCALV_TREE_01 ALV tree control: build up the hierarchy tree
BCALV_TREE_02 ALV tree control: event handling
BCALV_TREE_03 ALV tree control: use an own context menu
BCALV_TREE_04 ALV tree control: add a button to the toolbar
BCALV_TREE_05 ALV tree control: add a menu to the toolbar
BCALV_TREE_06 ALV tree control: Icon column and icon for nodes/items
BCALV_TREE_DEMO Demo for ALV tree control
BCALV_TREE_DND ALV tree control: Drag & Drop within a hierarchy tree
BCALV_TREE_DND_MULTIPLE ALV tree control: Drag & Drop within a hierarchy tree
RSDEMO_DRAG_DROP_TREE_MULTI
BCALV_TREE_EVENT_RECEIVER Include BCALV_TREE_EVENT_RECEIVER
BCALV_TREE_EVENT_RECEIVER01
BCALV_TREE_ITEMLAYOUT ALV Tree: Change Item Layouts at Runtime
BCALV_TREE_MOVE_NODE_TEST Demo for ALV tree control
BCALV_TREE_SIMPLE_DEMO Program BCALV_TREE_SIMPLE_DEMO
BCALV_TREE_VERIFY Verifier for ALV Tree and Simple ALV Tree
Reward all helpfull answers.
Regards.
Jay -
How to show alv report in tree structure
hi all,
how to show data or create a alv report in tree structure.
thanks in advance.
HarshaHi Harsha,
Its done using FM 'RS_TREE_CONSTRUCT'
and FM for displaying the tree: 'RS_TREE_LIST_DISPLAY'
Thanks
Shrila -
How to get tree structure navigation in module pool program
please send me a sample code for getting tree structure navigation in a screen in module pool program.
ex.
masters
itemsdo a chain and endchain on the fields.Then insert the fields in to the required database.
-
How to Link Organizational Structure to a report program
Hi All,
Can anyone pls help me out with my requirement. How can we link a organizational structure created in transaction PPOMW to a report program. Basically i want to send the report output as an XLS attachment to an external email id. For that i need to link Organizational Structure to the report program.
There are many ways of doing it but i want it to be done by linking Organization structure to the report program. Pls help me as soon as possible as its a bit urgent for me.Hi,
Please follow the below function modules and the paramters for reading archived data:
CALL FUNCTION 'ARCHIVE_OPEN_FOR_READ'
EXPORTING
OBJECT = archiving object name
IMPORTING
ARCHIVE_HANDLE = archive read handle
Then in the loop(DO-ENDDO), use this FM:
DO.
CALL FUNCTION 'ARCHIVE_GET_NEXT_OBJECT'
EXPORTING
archive_handle = archive read handle
Then records from the data objects using this FM:
CALL FUNCTION 'ARCHIVE_GET_TABLE'
EXPORTING
archive_handle = archive read handle
record_structure = 'TABLENAME'
all_records_of_object = 'X'
automatic_conversion = 'X'
TABLES
table = internal table for which you want to retrieve records.
ENDDO.
Then close the archive file using this FM:
CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
EXPORTING
archive_handle = archive read handle
This will help u in reading archived data from archive file.
may give some idea also on how to code the read prgram.
Thanks,
Shamim -
How to create tree structure in abap
hi,
I am mohan. Please send the how to create the tree structure. how to insert the child nodes in root node. actually our requirement is we have list transaction codes. We are planning to put all transaction codes in tree level.
please tell me how to do the program in tree structure.Hi Mohan,
Check the following program on ALV tree.
REPORT zalvtree.
CLASS cl_gui_column_tree DEFINITION LOAD.
CLASS cl_gui_cfw DEFINITION LOAD.
DATA: go_grid TYPE REF TO cl_gui_alv_grid.
DATA: ro_grid TYPE REF TO cl_gui_alv_grid.
DATA tree1 TYPE REF TO cl_gui_alv_tree.
DATA mr_toolbar TYPE REF TO cl_gui_toolbar.
DATA : gt_checked TYPE lvc_t_chit,
gs_checked LIKE LINE OF gt_checked,
l_part_key TYPE lvc_nkey,
gt_node TYPE lvc_s_chit-nodekey.
INCLUDE <icon>.
INCLUDE zamit_alv_tree_toolbar_event.
INCLUDE zbcalv_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.
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.
else.
CALL METHOD me->refresh_table_display
EXCEPTIONS
PROGRAM_ERROR = 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.
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.
*mrk
WHEN 'MOVE'.
PERFORM check_selection.
WHEN 'MBAK'.
PERFORM another_selection.
WHEN 'ALL'.
PERFORM select_all.
WHEN 'CLEAR'.
PERFORM clear_all.
WHEN 'DELETE'.
PERFORM delete_all.
WHEN 'EXPAND'.
PERFORM expand_all.
WHEN 'COLLAPSE'.
PERFORM collapse_all.
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.
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 check_selection
text
--> p1 text
<-- p2 text
FORM check_selection .
create container for alv-tree
DATA: l_tree_container_name(30) TYPE c,
l_custom_container2 TYPE REF TO cl_gui_custom_container.
l_tree_container_name = 'TREE2'.
IF sy-batch IS INITIAL.
CREATE OBJECT l_custom_container2
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 OBJECT go_grid
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
i_parent = l_custom_container2
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
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.
PERFORM load_data_into_grid.
*data: lt_nodes type LVC_T_NKEY,
ls_nodes like line of lt_nodes,
ls_checked like line of gt_checked.
*loop at gt_checked into ls_checked.
ls_nodes = ls_checked-nodekey.
append ls_nodes to lt_nodes.
*endloop.
*CALL METHOD tree1->unselect_nodes
EXPORTING
it_node_key = lt_nodes
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
DP_ERROR = 2
MULTIPLE_NODE_SELECTION_ONLY = 3
ERROR_IN_NODE_KEY_TABLE = 4
FAILED = 5
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.
ENDFORM. " check_selection
*& Form another_selection
text
--> p1 text
<-- p2 text
FORM another_selection .
create container for alv-tree
DATA: l_tree_container_name(30) TYPE c,
l_custom_container2 TYPE REF TO cl_gui_custom_container.
l_tree_container_name = 'TREE2'.
IF sy-batch IS INITIAL.
CREATE OBJECT l_custom_container2
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 OBJECT ro_grid
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
i_parent = l_custom_container2
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
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.
PERFORM load_data_into_grid1.
DATA: lt_unsel TYPE lvc_t_nkey,
ls_unsel LIKE LINE OF lt_unsel.
LOOP AT gt_checked INTO gs_checked.
ls_unsel = gs_checked-nodekey.
APPEND ls_unsel TO lt_unsel.
ENDLOOP.
CALL METHOD tree1->unselect_nodes
EXPORTING
it_node_key = lt_unsel
EXCEPTIONS
cntl_system_error = 1
dp_error = 2
multiple_node_selection_only = 3
error_in_node_key_table = 4
failed = 5
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.
*CALL METHOD tree1->unselect_all
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
FAILED = 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.
DATA: text TYPE lvc_value,
item TYPE lvc_t_layi,
node TYPE lvc_s_layn,
inode TYPE lvc_nkey.
FIELD-SYMBOLS: <wa> TYPE ANY.
DATA: l_dref_wa LIKE LINE OF gt_sflight.
ASSIGN l_dref_wa TO <wa>.
READ TABLE gt_checked INTO gs_checked WITH KEY nodekey = 3.
inode = gs_checked-nodekey.
CALL METHOD tree1->get_outtab_line
EXPORTING
i_node_key = inode
IMPORTING
e_outtab_line = <wa>
e_node_text = text
et_item_layout = item
es_node_layout = node
EXCEPTIONS
node_not_found = 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.
DATA: lt_layout TYPE lvc_t_laci,
layout LIKE LINE OF lt_layout.
layout-chosen = 'X'.
layout-fieldname = tree1->c_hierarchy_column_name.
ls_item_layout-chosen = 'X'. "To give default checkbox value checked
layout-class = cl_gui_column_tree=>item_class_checkbox.
layout-editable = 'X'.
LAYOUT-U_CHOSEN = 'X'.
APPEND layout TO lt_layout.
CALL METHOD tree1->change_node
EXPORTING
i_node_key = inode
i_outtab_line = <wa>
IS_NODE_LAYOUT =
it_item_layout = lt_layout
I_NODE_TEXT =
I_U_NODE_TEXT =
EXCEPTIONS
node_not_found = 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->change_item
EXPORTING
i_node_key = inode
i_fieldname = gs_checked-FIELDNAME
i_data = <wa>
I_U_DATA = ''
IS_ITEM_LAYOUT = layout
EXCEPTIONS
NODE_NOT_FOUND = 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.
*loop at lt_unsel into ls_unsel.
*CALL METHOD tree1->update_checked_items
EXPORTING
i_node_key = ls_unsel
i_fieldname = ''
i_checked = ''
EXCEPTIONS
PROGRAM_ERROR = 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.
*endif.
ENDFORM. " another_selection
*& Form select_all
text
--> p1 text
<-- p2 text
FORM select_all .
CONSTANTS: c_x(1) TYPE c VALUE 'X'.
*********Check box modifications.
CALL METHOD tree1->delete_all_nodes
EXCEPTIONS
failed = 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.
clear l_part_key.
create hierarchy
PERFORM create_hierarchy USING c_x.
CALL METHOD tree1->expand_node
EXPORTING
i_node_key = gt_node
I_LEVEL_COUNT = 1
i_expand_subtree = 'X'
EXCEPTIONS
failed = 1
illegal_level_count = 2
cntl_system_error = 3
node_not_found = 4
cannot_expand_leaf = 5
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.
add own functioncodes to the toolbar
perform change_toolbar.
register events
perform register_events.
adjust column_width
call method tree1->COLUMN_OPTIMIZE.
ENDFORM. " select_all
*& Form clear_all
text
--> p1 text
<-- p2 text
FORM clear_all .
CONSTANTS: c_x(1) TYPE c VALUE space.
*********Check box modifications.
CALL METHOD tree1->delete_all_nodes
EXCEPTIONS
failed = 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.
create hierarchy
PERFORM create_hierarchy USING c_x.
CALL METHOD tree1->expand_node
EXPORTING
i_node_key = gt_node
I_LEVEL_COUNT = 1
i_expand_subtree = 'X'
EXCEPTIONS
failed = 1
illegal_level_count = 2
cntl_system_error = 3
node_not_found = 4
cannot_expand_leaf = 5
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.
ENDFORM. " clear_all
*& Form delete_all
text
--> p1 text
<-- p2 text
FORM delete_all .
*********Check box modifications.
CALL METHOD tree1->delete_all_nodes
EXCEPTIONS
failed = 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.
ENDFORM. " delete_all
*& Form expand_all
text
--> p1 text
<-- p2 text
FORM expand_all .
CALL METHOD tree1->expand_node
EXPORTING
i_node_key = gt_node
I_LEVEL_COUNT = 1
i_expand_subtree = 'X'
EXCEPTIONS
failed = 1
illegal_level_count = 2
cntl_system_error = 3
node_not_found = 4
cannot_expand_leaf = 5
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.
ENDFORM. " expand_all
*& Form collapse_all
text
--> p1 text
<-- p2 text
FORM collapse_all .
CALL METHOD tree1->collapse_all_nodes
EXCEPTIONS
failed = 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.
ENDFORM. " collapse_all
*& Form load_data_into_grid
text
--> p1 text
<-- p2 text
FORM load_data_into_grid .
DATA:
For parameter IS_VARIANT
l_layout TYPE disvariant,
gs_layout TYPE lvc_s_layo.
DATA gi_sflight TYPE TABLE OF zsflight.
Load data into the grid and display them
l_layout-report = sy-repid.
gs_layout-grid_title = 'Amits Test Program'.
gs_layout-sel_mode = 'A'.
SELECT *
FROM zsflight
INTO TABLE gi_sflight.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
is_layout = gs_layout
is_variant = l_layout
i_save = 'A'
CHANGING
it_outtab = gi_sflight.
ENDFORM. " load_data_into_grid
*& Form load_data_into_grid
text
--> p1 text
<-- p2 text
FORM load_data_into_grid1.
DATA:
For parameter IS_VARIANT
l_layout TYPE disvariant,
gs_layout TYPE lvc_s_layo.
DATA gi_sflight TYPE TABLE OF zapempl.
Load data into the grid and display them
l_layout-report = sy-repid.
gs_layout-grid_title = 'Rams Test Program'.
gs_layout-sel_mode = 'A'.
SELECT *
FROM zapempl
INTO TABLE gi_sflight.
CALL METHOD ro_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'ZAPEMPL'
is_layout = gs_layout
is_variant = l_layout
i_save = 'A'
CHANGING
it_outtab = gi_sflight.
ENDFORM. " load_data_into_grid1
*& 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 USING p_x.
DATA: ls_sflight TYPE sflight,
lt_sflight TYPE sflight OCCURS 0.
get data
SELECT * FROM sflight INTO TABLE lt_sflight
UP TO 200 ROWS .
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.
l_part_key TYPE lvc_nkey
PERFORM add_carrid_line USING ls_sflight
CHANGING l_part_key.
gt_node = l_part_key.
LOOP AT lt_sflight INTO ls_sflight.
ON CHANGE OF ls_sflight-carrid.
PERFORM add_carrid_line USING ls_sflight
l_part_key
CHANGING l_carrid_key.
PERFORM add_connid_line USING ls_sflight
l_carrid_key
CHANGING l_connid_key.
PERFORM add_complete_line USING ls_sflight
l_connid_key
p_x
CHANGING l_last_key.
CONTINUE.
ENDON.
ON CHANGE OF ls_sflight-connid.
PERFORM add_connid_line USING ls_sflight
l_carrid_key
CHANGING l_connid_key.
PERFORM add_complete_line USING ls_sflight
l_connid_key
p_x
CHANGING l_last_key.
CONTINUE.
ENDON.
PERFORM add_complete_line USING ls_sflight
l_connid_key
p_x
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.
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 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
p_x
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-chosen = p_x. "To give default checkbox value checked
ls_item_layout-class = cl_gui_column_tree=>item_class_checkbox.
ls_item_layout-editable = 'X'.
APPEND ls_item_layout TO lt_item_layout.
l_node_text = ps_sflight-fldate.
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.
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.
SET HANDLER l_event_receiver->handle_checkbox_change FOR tree1.
ENDFORM. " register_events
*& Form change_toolbar
text
--> p1 text
<-- p2 text
FORM change_toolbar.
DATA: toolbar_event_receiver TYPE REF TO lcl_toolbar_event_receiver.
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
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 = l_custom_container
node_selection_mode = cl_gui_column_tree=>node_sel_mode_multiple "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.
CONSTANTS: c_s(1) TYPE c VALUE space.
create hierarchy
PERFORM create_hierarchy USING c_s.
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
Award points if found useful.
Regards
Indrajit -
Hi experts,
can any one give me sample code for providing tree structure in f4help. like object part field have in iw21 transaction
Regards
reddyHi Muttukundu,
SAP has provided a lot of sample programs for developing tree structures. Just go to SE38, type BCALVTREE and hit F4. You'll get different sample programs with a range of operations on trees
Go through the link,
http://www.sapdevelopment.co.uk/reporting/alv/alvtree.htm
Slowly check this code..you will get idea of how to develop tree structure.
REPORT y_hierarchies_in_tables
NO STANDARD PAGE HEADING.
PARAMETER: g_group TYPE grpname. " DEFAULT 'Z_GLAB0000'.
DATA:
g_setid TYPE setid,
g_class TYPE setclass.
DATA: lt_hier TYPE STANDARD TABLE OF sethier,
lt_val TYPE STANDARD TABLE OF setvalues.
DATA: hier LIKE sethier OCCURS 0 WITH HEADER LINE,
val LIKE setvalues OCCURS 0 WITH HEADER LINE,
setinfo LIKE setinfo OCCURS 0 WITH HEADER LINE.
DATA: zaccbas(20) TYPE c OCCURS 0 WITH HEADER LINE.
DATA: miss_val LIKE setvalues-from OCCURS 0 WITH HEADER LINE.
DATA: table_name TYPE tabname,
field_name TYPE setfld.
DATA: ambiguity_flag TYPE c.
Ambiguity check
PERFORM ambiguity_check.
Display Records
PERFORM display_records.
*& Form AMBIGUITY_CHECK
Ambiguity check
FORM ambiguity_check .
DATA: it_abaplist LIKE abaplist OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF it_ascilist OCCURS 0,
zeile(256) TYPE c,
END OF it_ascilist.
DATA: flag.
SUBMIT rgsovl00 "VIA SELECTION-SCREEN
WITH p_shrtn = g_group
WITH path = 'X'
EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = it_abaplist
EXCEPTIONS
not_found = 1
OTHERS = 2.
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = it_ascilist
listobject = it_abaplist
EXCEPTIONS
empty_list = 1
list_index_invalid = 2
OTHERS = 3 .
LOOP AT it_ascilist.
IF it_ascilist-zeile = text-001.
flag = 'X'.
ENDIF.
IF flag = 'X' AND
it_ascilist-zeile = text-002.
ambiguity_flag = 'X'.
CLEAR flag.
ENDIF.
ENDLOOP.
FREE MEMORY.
ENDFORM. " AMBIGUITY_CHECK
*& Form DISPLAY_RECORDS
Display the Records
FORM display_records .
PERFORM get_records.
PERFORM header_data.
PERFORM item_data.
ENDFORM. " DISPLAY_RECORDS
*& Form GET_RECORDS
Get all the Node values
FORM get_records .
Get the ID name for the Hierarchy
CALL FUNCTION 'G_SET_GET_ID_FROM_NAME'
EXPORTING
shortname = g_group
setclass = g_class
old_setid = g_setid
IMPORTING
new_setid = g_setid.
Get the Table and Field name for the Top Node
CALL FUNCTION 'G_SET_GET_INFO'
EXPORTING
setname = g_setid
no_set_title = 'X'
use_table_buffer = 'X'
IMPORTING
info = setinfo.
table_name = setinfo-tabname.
field_name = setinfo-fld.
Get all the Nodes for the Hierarchy
CALL FUNCTION 'G_SET_TREE_IMPORT'
EXPORTING
no_descriptions = ' '
no_rw_info = 'X'
setid = g_setid
TABLES
set_hierarchy = lt_hier
set_values = lt_val.
hier[] = lt_hier.
val[] = lt_val.
SELECT (field_name) FROM (table_name) INTO TABLE zaccbas.
LOOP AT zaccbas.
READ TABLE val WITH KEY FROM = zaccbas.
IF sy-subrc = 0.
DELETE zaccbas.
CLEAR zaccbas.
DELETE val INDEX sy-tabix.
CLEAR val.
ENDIF.
ENDLOOP.
ENDFORM. " GET_RECORDS
*& Form HEADER_DATA
Header Data
FORM header_data .
DATA: desc TYPE settext.
READ TABLE hier WITH KEY fieldname = field_name
shortname = g_group.
IF sy-subrc = 0.
desc = hier-descript.
ENDIF.
SKIP.
WRITE: 'Node :',g_group.
WRITE:75 'User name :', sy-uname.
WRITE:/ 'Description :', desc.
WRITE:75 'Date:', sy-datum.
WRITE:/ 'Table Name :' , table_name.
WRITE:75 'Time:', sy-timlo.
WRITE:/ 'Field Name :', field_name.
write:75 'Client:', SY-MANDT.
skip.
IF ambiguity_flag = 'X'.
WRITE:/ 'Ambiguity Check :'. WRITE: 'Success' COLOR 5.
ELSE.
WRITE:/ 'Ambiguity Check :'. WRITE: 'Failed' COLOR 6 .
ENDIF.
WRITE:/ sy-uline.
WRITE:/37 'Validation for Hierarchy'.
WRITE:/ sy-uline.
ENDFORM. " HEADER_DATA
*& Form ITEM_DATA
Output Report for Nodes
FORM item_data .
IF NOT zaccbas[] IS INITIAL.
WRITE:/ 'Missing Records from Hierarchy' COLOR 3.
LOOP AT zaccbas.
WRITE:/ zaccbas.
ENDLOOP.
ENDIF.
IF NOT val[] IS INITIAL.
SKIP 1.
WRITE:/ 'Additional Records in Hierarchy' COLOR 3.
LOOP AT val.
WRITE:/ val-from. ", 28 val-DESCRIPT.
ENDLOOP.
ELSEIF ZACCBAS[] IS INITIAL.
WRITE:/ 'No Missing Records Found' COLOR 3.
ENDIF.
ENDFORM. " ITEM_DATA
Reward if found helpfull,
Cheers,
Chaitanya. -
SE80 : Source for the tree structure display for any type of Object
Hi Experts ,
I have developed a report which takes in a TR .Given a TR , I get the list of objects under it from table e071 table .
Now , I need all the objects (includes,screen,status,etc) related each of this object . SE80 perfectly does this in the form of a tree structure but now sure how.
Is there any Standard Table in which this information is stored or any FM/Method using which these details can be retrieved ?Hi,
You may use this tool : [SDN wiki: ABAP program to read where-used lists|http://wiki.sdn.sap.com/wiki/display/ABAP/ABAPprogramtoreadwhere-used+lists ]
Sandra -
Hi All,
Is there any Function module to display the output in a ALV tree structure( like parent node --> child nodes)
Thanx in advance,
Regards,
RaviHi kranthi,
1. Its quite simple.
2. Basically there are TWO FMs,
which do the job.
3. just copy paste in new program
and u will know the whole logic.
4.
REPORT abc.
DATA : tr LIKE TABLE OF snodetext WITH HEADER LINE.
data
tr-id = '1'.
tr-tlevel = 1.
tr-name = 'amit'.
APPEND tr.
tr-id = '2'.
tr-tlevel = 2.
tr-name = 'mittal'.
APPEND tr.
display
CALL FUNCTION 'RS_TREE_CONSTRUCT'
TABLES
nodetab = tr
EXCEPTIONS
tree_failure = 1
OTHERS = 4.
CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
regards,
amit m. -
Hi
I am having Data in one internal table
BEGIN OF ty_box,
vbeln LIKE vbak-vbeln, "Sales Order Document Number
exidv LIKE vekp-exidv, "External Handling Unit Identification
vegr4 LIKE vekp-vegr4, "Integration required if the value is INTR
matnr LIKE lips-matnr, "Delivery Item-Material Number
arktx LIKE lips-arktx, "Delivery Item-Short text for Material
END OF ty_box.
I want to Display output like tree structure
integration required?
() Sales order
() HU -
checkbox
Mat A Description of A
Mat B Description of B
Please give sample program for this type. '-' indicate sapce
Message was edited by:
sudhakara reddy
Message was edited by:
sudhakara reddyhi,
use ALV TREE
check these links.
http://www.erpgenie.com/sap/abap/SalesOrderFlow.htm
http://www.sapdevelopment.co.uk/reporting/alv/alvtree/alvtree_basic.htm
Check these programs.
BCALV_TREE_01 ALV tree control: build up the hierarchy tree
BCALV_TREE_02 ALV tree control: event handling
BCALV_TREE_03 ALV tree control: use an own context menu
BCALV_TREE_04 ALV tree control: add a button to the toolbar
BCALV_TREE_05 ALV tree control: add a menu to the toolbar
BCALV_TREE_06 ALV tree control: Icon column and icon for nodes/items
BCALV_TREE_DEMO Demo for ALV tree control
BCALV_TREE_DND ALV tree control: Drag & Drop within a hierarchy tree
BCALV_TREE_DND_MULTIPLE ALV tree control: Drag & Drop within a hierarchy tree
RSDEMO_DRAG_DROP_TREE_MULTI
BCALV_TREE_EVENT_RECEIVER Include BCALV_TREE_EVENT_RECEIVER
BCALV_TREE_EVENT_RECEIVER01
BCALV_TREE_ITEMLAYOUT ALV Tree: Change Item Layouts at Runtime
BCALV_TREE_MOVE_NODE_TEST Demo for ALV tree control
BCALV_TREE_SIMPLE_DEMO Program BCALV_TREE_SIMPLE_DEMO
BCALV_TREE_VERIFY Verifier for ALV Tree and Simple ALV Tree
Also please check the transaction DWDM This will give info also on trees.
Check the links -
drag drop required for alv column!
drag and drop in a tree
Drag&Drop within the Tree
Drag&Drop within a tree
Drag and drop in ALV tree -
Hi all,
Can anyone give sample code for TREE TYPE REPORT(simple code), like for example: The list should contain 2 main items (parent item) and when i expand each item i should have 1 item(child item) .and when i double click on that it should perform some action say it should go to new list.
like :
+ food
+ tools
(this is in first list , 2 main items) when i expand this
- food
noodles
- tools
hammer
(this sub item , when i click on this it should go to new list)
thanks in advance.
kumaran.cHI Kumaran,
Have a look at the following code of simple tree control ...Its in module pool style.. will copy each include as well..
*& Module Pool ZKM_SIMPLETREE_CONTROL
REPORT ZKM_SIMPLETREE_CONTROL.
INCLUDE ZKM_TOP.
INCLUDE ZKM_CL.
INCLUDE ZKM_PBO_100O01.
INCLUDE ZKM_FORM01.
INCLUDE ZKM_PAI_100I01.
START-OF-SELECTION.
create the application object
this object is needed to handle the ABAP Objects Events of
Controls
CREATE OBJECT G_APPLICATION.
SET SCREEN 1000.
*& Include ZKM_TOP
*REPORT ZKM_SIMPLETREE_CONTROL MESSAGE-ID TREE_CONTROL_MSG.
CLASS lcl_application DEFINITION DEFERRED.
CLASS cl_gui_cfw DEFINITION LOAD.
TYPES: node_table_type LIKE STANDARD TABLE OF zkm_treesnode
WITH DEFAULT KEY.
CAUTION: MTREESNODE is the name of the node structure which must
be defined by the programmer. DO NOT USE MTREESNODE!
*internal table and work area for storing all the nodes that are created
DATA: gt_nodetable TYPE node_table_type,
gw_nodetable TYPE zkm_treesnode.
*objects refering to the classes used.
DATA: g_application TYPE REF TO lcl_application,
g_custom_container TYPE REF TO cl_gui_custom_container,
g_tree TYPE REF TO cl_gui_simple_tree.
Fields on Dynpro 1000
DATA: g_event(30),
g_key TYPE i,
g_node_key TYPE tv_nodekey.
Fields on Dynpro 2000
DATA: g_relatship TYPE i,
g_cb_sub,
g_cb_same,
g_cb_under VALUE 'X',
g_nodename(30).
Structure for preserving the skeleton
TYPES: BEGIN OF ty_flag,
relatkey TYPE tv_nodekey,
node_key TYPE tv_nodekey,
flag TYPE i, "1 = skeleton
"2 = service line
"3 = levels
END OF ty_flag.
DATA: gt_flag TYPE TABLE OF ty_flag,
gw_flag TYPE ty_flag.
*structure storing the hierarchy and the nodes under them.
***INCLUDE ZKM_PBO_100O01 .
*& Module PBO_1000 OUTPUT
text
MODULE pbo_1000 OUTPUT.
SET PF-STATUS 'ZMAIN'.
SET TITLEBAR 'ZTITLE'.
IF g_tree IS INITIAL.
" The Tree Control has not been created yet.
" Create a Tree Control and insert nodes into it.
PERFORM create_and_init_tree.
ENDIF.
*registering keys which can trigger the event
PERFORM register_key_strokes.
*checking status of the actions performed
CASE sy-ucomm.
WHEN 'ADD'. "node successfully added
MESSAGE s002(zkm_class).
WHEN 'YES'. "node successfully deleted
MESSAGE s003(zkm_class).
WHEN 'NO' OR 'CANCEL'. "action cancelled
MESSAGE s007(zkm_class).
ENDCASE.
ENDMODULE. " PBO_1000 OUTPUT
*& Module PBO_2000 OUTPUT
text
MODULE pbo_2000 OUTPUT.
SET PF-STATUS 'ZDIALOG'.
SET TITLEBAR 'ZADD'.
*setting the attributes of the screen field depending on node attributes
READ TABLE gt_flag INTO gw_flag WITH KEY node_key = g_node_key.
IF gw_flag-flag = 3.
LOOP AT SCREEN.
IF screen-name = 'BRANCH'.
screen-invisible = '1'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
ENDMODULE. " PBO_2000 OUTPUT
*& Module PBO_3000 OUTPUT
text
MODULE pbo_3000 OUTPUT.
SET PF-STATUS 'ZDIALOG'.
SET TITLEBAR 'ZCONFIRM'.
ENDMODULE. " PBO_3000 OUTPUT
***INCLUDE ZKM_PAI_100I01 .
*& Module PAI_1000 INPUT
text
MODULE pai_1000 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.
EXIT.
ENDIF.
CASE sy-ucomm.
WHEN 'ADDND'.
*check whether node has been selected or not
IF g_event NE 'NODE_DOUBLE_CLICK'. "AND g_node_key EQ ' '.
MESSAGE e000(zkm_class).
ELSE.
*whether selected node can have sub-branches or not
READ TABLE gt_nodetable INTO gw_nodetable WITH KEY node_key = g_node_key.
IF gw_nodetable-isfolder = ' '.
MESSAGE e006(zkm_class).
ELSE.
*call screen for adding the node.
CALL SCREEN 2000 STARTING AT 20 10.
ENDIF.
ENDIF.
CLEAR g_event.
WHEN 'DELND'.
*check whether node has been selected or not
IF g_event NE 'NODE_DOUBLE_CLICK'.
MESSAGE e000(zkm_class).
ELSE.
*skeleton should not be deleted.
IF g_node_key EQ 'Capgemini' OR
g_node_key EQ 'TSP-SAP-CRM' OR
g_node_key EQ 'MANAGERS' OR
g_node_key EQ 'TEAM LEAD'.
MESSAGE e004(zkm_class).
ENDIF.
*call screen for confirmation
CALL SCREEN 3000 STARTING AT 20 10.
ENDIF.
CLEAR g_event.
WHEN 'TEST'.
CALL METHOD g_tree->expand_node
EXPORTING
node_key = 'New1'.
WHEN 'BACK'. " Finish program
IF NOT g_custom_container IS INITIAL.
destroy tree container (detroys contained tree control, too)
CALL METHOD g_custom_container->free
EXCEPTIONS
cntl_system_error = 1
cntl_error = 2.
IF sy-subrc <> 0.
MESSAGE a000.
ENDIF.
CLEAR g_custom_container.
CLEAR g_tree.
ENDIF.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " PAI_1000 INPUT
*& Module pai_2000 INPUT
text
MODULE pai_2000 INPUT.
DATA: node_table TYPE node_table_type,
node LIKE zkm_treesnode.
CASE sy-ucomm.
WHEN 'BACK'.
CALL SCREEN 1000.
WHEN 'ADD'.
IF g_nodename IS INITIAL. "Has to enter the Node name
MESSAGE s005(zkm_class).
CALL SCREEN 2000 STARTING AT 20 10.
ELSE.
*Checking whether specified node already exists or not
READ TABLE gt_nodetable INTO gw_nodetable WITH KEY node_key = g_nodename.
IF sy-subrc EQ 0.
CLEAR gw_flag.
MESSAGE s008(zkm_class).
CALL SCREEN 2000 STARTING AT 20 10.
ENDIF.
*assigning attributes to the node
CLEAR node.
CLEAR node_table.
node-node_key = g_nodename. "Key of the Node.
node-relatkey = g_node_key. "Relationship with the selected node
node-relatship = cl_gui_simple_tree=>relat_last_child.
*checking whether the node would be a folder or a leaf
READ TABLE gt_flag INTO gw_flag WITH KEY node_key = g_node_key.
IF gw_flag-flag = 1 OR gw_flag-flag = 2.
node-hidden = ' '.
node-disabled = ' '.
node-isfolder = 'X'.
CLEAR node-n_image.
CLEAR node-exp_image.
CLEAR node-expander.
IF gw_flag-flag EQ 1.
gw_flag-flag = 2.
ELSE.
gw_flag-flag = 3.
ENDIF.
ELSEIF gw_flag-flag = 3.
node-n_image = '@XY@'.
node-isfolder = ' '.
node-expander = ' '.
gw_flag-flag = 3.
ENDIF.
CLEAR node-exp_image.
node-text = g_nodename.
APPEND node TO node_table.
*keeping records of all the nodes added in the tree
gw_nodetable = node.
APPEND gw_nodetable TO gt_nodetable.
CLEAR gw_nodetable.
*append structure 'FLAG' to group the added node according to position
gw_flag-relatkey = g_node_key.
gw_flag-node_key = g_nodename.
APPEND gw_flag TO gt_flag.
CLEAR gw_flag.
*adding nodes in the tree
CALL METHOD g_tree->add_nodes
EXPORTING
table_structure_name = 'ZKM_TREESNODE'
node_table = node_table
EXCEPTIONS
error_in_node_table = 1
failed = 2
dp_error = 3
table_structure_name_not_found = 4
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.
CLEAR g_nodename. "clearing screen field
CALL SCREEN 1000.
ENDIF.
WHEN 'CANCEL'.
CALL SCREEN 1000.
ENDCASE.
ENDMODULE. " pai_2000 INPUT
*& Module PAI_3000 INPUT
text
MODULE pai_3000 INPUT.
CASE sy-ucomm.
WHEN 'YES'. "user agrees to delete the node
CALL METHOD g_tree->delete_node
EXPORTING
node_key = g_node_key
EXCEPTIONS
failed = 1
node_not_found = 2
cntl_system_error = 3
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.
ELSE.
gw_nodetable-node_key = g_node_key.
gw_flag-node_key = g_node_key.
READ TABLE gt_nodetable INTO gw_nodetable WITH KEY node_key = g_node_key.
IF sy-subrc EQ 0.
DELETE gt_nodetable INDEX sy-tabix.
ENDIF.
READ TABLE gt_flag INTO gw_flag WITH KEY node_key = g_node_key.
IF sy-subrc EQ 0.
DELETE gt_flag INDEX sy-tabix.
ENDIF.
CLEAR gw_flag.
CLEAR gw_nodetable.
CALL SCREEN 1000.
ENDIF.
WHEN 'NO'. "user clicks the cancel button
CALL SCREEN 1000.
ENDCASE.
ENDMODULE. " PAI_3000 INPUT
***INCLUDE ZKM_FORM01 .
*& Form create_and_init_tree
text
--> p1 text
<-- p2 text
FORM create_and_init_tree .
DATA: node_table TYPE node_table_type,
events TYPE cntl_simple_events,
event TYPE cntl_simple_event.
*create a container for the tree control.
CREATE OBJECT g_custom_container
EXPORTING
" the container is linked to the custom control with the
" name 'TREE_CONTAINER' on the dynpro
container_name = 'TREE_CONTAINER'
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 ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*create tree control.
CREATE OBJECT g_tree
EXPORTING
parent = g_custom_container
node_selection_mode = cl_gui_simple_tree=>node_sel_mode_single
EXCEPTIONS
lifetime_error = 1
cntl_system_error = 2
create_error = 3
failed = 4
illegal_node_selection_mode = 5
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.
*define events which will be passed to the backend.
"node double click.
event-eventid = cl_gui_simple_tree=>eventid_node_double_click.
event-appl_event = 'X'. "process PAI if event occurs.
APPEND event TO events.
"expand no children.
event-eventid = cl_gui_simple_tree=>eventid_expand_no_children.
event-appl_event = 'X'.
APPEND event TO events.
"node key press
event-eventid = cl_gui_simple_tree=>eventid_node_keypress.
event-appl_event = 'X'.
APPEND event TO events.
"NODE_CONTEXT_MENU_REQUEST
event-eventid = cl_gui_simple_tree=>eventid_node_context_menu_req.
event-appl_event = 'X'.
APPEND event TO events.
"event node_context_menu_select is automatically registered on registering
" the event NODE_CONTEXT_MENU_REQUEST
" process PAI if context menu select event occurs
CALL METHOD g_tree->set_ctx_menu_select_event_appl
EXPORTING
appl_event = 'X'.
CALL METHOD g_tree->set_registered_events
EXPORTING
events = events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3
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.
*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_expand_no_children FOR g_tree.
SET HANDLER g_application->handle_node_keypress FOR g_tree.
SET HANDLER g_application->handle_node_context_menu_req FOR g_tree.
SET HANDLER g_application->handle_node_context_menu_sel 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_table USING node_table.
CALL METHOD g_tree->add_nodes
EXPORTING
table_structure_name = 'ZKM_TREESNODE'
node_table = node_table
EXCEPTIONS
error_in_node_table = 1
failed = 2
dp_error = 3
table_structure_name_not_found = 4
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.
ENDFORM. " create_and_init_tree
*& Form BUILD_NODE_TABLE
text
-->P_NODE_TABLE text
FORM build_node_table
USING node_table TYPE node_table_type.
DATA: node LIKE zkm_treesnode.
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
occur in the node table before its parent node.
*Node with key 'Capgemini'.
node-node_key = 'Capgemini'. "Key of the node.
CLEAR node-relatkey. "Special case.. A root node has no parent node.
CLEAR node-relatship.
node-hidden = ' '. "Node is visible.
node-disabled = ' '. "Selectable.
node-isfolder = 'X'. "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.
node-text = 'Capgemini'.
APPEND node TO node_table.
gw_nodetable = node.
APPEND gw_nodetable TO gt_nodetable.
CLEAR gw_nodetable.
CLEAR gw_flag-relatkey.
gw_flag-node_key = 'Capgemini'.
gw_flag-flag = 1. "Skeleton
APPEND gw_flag TO gt_flag.
CLEAR gw_flag.
CLEAR node.
*Node with key 'TSP-SAP-CRM'.
node-node_key = 'TSP-SAP-CRM'. "Key of the Node.
"Node is inserted as child of the node with key 'Root'.
node-relatkey = 'Capgemini'.
node-relatship = cl_gui_simple_tree=>relat_last_child.
node-hidden = ' '. "Node is visible.
node-disabled = ' '. "Selectable.
node-isfolder = 'X'. "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.
node-text = 'TSP-SAP-CRM'.
APPEND node TO node_table.
gw_nodetable = node.
APPEND gw_nodetable TO gt_nodetable.
CLEAR gw_nodetable.
*adding the node for corresponding relatkey
gw_flag-relatkey = 'Capgemini'.
gw_flag-node_key = 'TSP-SAP-CRM'.
gw_flag-flag = 2. "Service line
APPEND gw_flag TO gt_flag.
CLEAR gw_flag.
*creating new relatkey in gt_flag
gw_flag-relatkey = 'TSP-SAP-CRM'.
gw_flag-node_key = ' '.
gw_flag-flag = '2'.
APPEND gw_flag TO gt_flag.
*Node with key 'Managers'
node-node_key = 'MANAGERS'.
node-relatkey = 'TSP-SAP-CRM'.
node-relatship = cl_gui_simple_tree=>relat_last_child.
CLEAR node-n_image.
CLEAR node-exp_image.
CLEAR node-expander. " = ' '.
node-isfolder = 'X'.
node-text = 'Managers'.
APPEND node TO node_table.
gw_nodetable = node.
APPEND gw_nodetable TO gt_nodetable.
CLEAR gw_nodetable.
gw_flag-relatkey = 'TSP-SAP-CRM'.
gw_flag-node_key = 'MANAGERS'.
gw_flag-flag = 3. "Levels
APPEND gw_flag TO gt_flag.
CLEAR gw_flag.
gw_flag-relatkey = 'MANAGERS'.
gw_flag-node_key = ' '.
gw_flag-flag = '2'.
APPEND gw_flag TO gt_flag.
*Node with key 'Team Lead'.
node-node_key = 'TEAM LEAD'.
node-relatkey = 'TSP-SAP-CRM'.
node-relatship = cl_gui_simple_tree=>relat_last_child.
CLEAR node-n_image.
CLEAR node-exp_image.
CLEAR node-expander. " = ' '.
node-isfolder = 'X'.
node-text = 'TEAM LEAD'.
APPEND node TO node_table.
gw_nodetable = node.
APPEND gw_nodetable TO gt_nodetable.
CLEAR gw_nodetable.
gw_flag-relatkey = 'TSP-SAP-CRM'.
gw_flag-node_key = 'Team_Lead'.
gw_flag-flag = 3. "Levels
APPEND gw_flag TO gt_flag.
CLEAR gw_flag.
gw_flag-relatkey = 'TEAM LEAD'.
gw_flag-node_key = ' '.
gw_flag-flag = '2'.
APPEND gw_flag TO gt_flag.
ENDFORM. " BUILD_NODE_TABLE
*& Form register_key_strokes
text
--> p1 text
<-- p2 text
FORM register_key_strokes .
g_key = cl_tree_control_base=>key_delete.
"process PAI if node key press occurs
CALL METHOD g_tree->add_key_stroke
EXPORTING
key = g_key
EXCEPTIONS
failed = 1
illegal_key = 2
cntl_system_error = 3
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.
g_key = cl_tree_control_base=>key_enter.
"process PAI if node key press occurs
CALL METHOD g_tree->add_key_stroke
EXPORTING
key = g_key
EXCEPTIONS
failed = 1
illegal_key = 2
cntl_system_error = 3
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.
g_key = cl_tree_control_base=>key_insert.
CALL METHOD g_tree->add_key_stroke
EXPORTING
key = g_key
EXCEPTIONS
failed = 1
illegal_key = 2
cntl_system_error = 3
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.
ENDFORM. " register_key_strokes
***INCLUDE ZKM_CL .
*& Class LCL_APPLICATION
Text
CLASS lcl_application DEFINITION.
PUBLIC SECTION.
METHODS:
handle_node_double_click
FOR EVENT node_double_click
OF cl_gui_simple_tree
IMPORTING node_key,
handle_expand_no_children
FOR EVENT expand_no_children
OF cl_gui_simple_tree
IMPORTING node_key,
handle_node_keypress
FOR EVENT node_keypress
OF cl_gui_simple_tree
IMPORTING node_key key,
handle_node_context_menu_req
FOR EVENT node_context_menu_request
OF cl_gui_simple_tree
IMPORTING node_key menu,
handle_node_context_menu_sel
FOR EVENT node_context_menu_select
OF cl_gui_simple_tree
IMPORTING node_key fcode.
ENDCLASS. "LCL_APPLICATION
*& Class (Implementation) LCL_APPLICATION
Text
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_expand_no_children.
" this method handles the expand no children event of the tree
" control instance
DATA: node_table TYPE node_table_type,
node TYPE zkm_treesnode.
"show the key of the double clicked node on the dynpro field.
g_event = 'EXPAND_NO_CHILDREN'.
g_node_key = node_key.
IF node_key = 'TSP-SAP-CRM'.
*add two nodes to the tree control (The children of Child1).
*Node with key 'New1'.
CLEAR node.
node-node_key = 'Managers'.
node-relatkey = 'TSP-SAP-CRM'.
node-relatship = cl_gui_simple_tree=>relat_last_child.
node-n_image = '@XY@'.
CLEAR node-exp_image.
node-expander = ' '.
node-isfolder = ' '.
node-text = 'Managers'.
APPEND node TO node_table.
*Node with key 'New2'.
CLEAR node.
node-node_key = 'Team_Lead'.
node-relatkey = 'TSP-SAP-CRM'.
node-relatship = cl_gui_simple_tree=>relat_last_child.
node-n_image = '10'.
CLEAR node-exp_image.
node-expander = ' '.
node-isfolder = ' '.
node-text = 'Team Lead'.
APPEND node TO node_table.
ENDIF.
CALL METHOD g_tree->add_nodes
EXPORTING
table_structure_name = 'MTREESNODE'
node_table = node_table
EXCEPTIONS
error_in_node_table = 1
failed = 2
dp_error = 3
table_structure_name_not_found = 4
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.
ENDMETHOD. "HANDLE_EXPAND_NO_CHILDREN
METHOD handle_node_keypress.
g_node_key = node_key.
CASE key.
WHEN 2.
g_event = 'DELETE KEY PRESSED'.
READ TABLE gt_flag INTO gw_flag WITH KEY node_key = g_node_key.
IF gw_flag-flag EQ 1.
MESSAGE e004(zkm_class).
ENDIF.
CALL SCREEN 3000 STARTING AT 20 10.
CLEAR g_event.
WHEN 3.
g_event = 'INSERT KEY PRESSED'.
READ TABLE gt_nodetable INTO gw_nodetable WITH KEY node_key = g_node_key.
IF gw_nodetable-isfolder = ' '.
MESSAGE e006(zkm_class).
ELSE.
CALL SCREEN 2000 STARTING AT 20 10.
MESSAGE s001(zkm_class).
ENDIF.
CLEAR g_event.
WHEN 5.
g_event = 'ENTER KEY PRESSED'.
READ TABLE gt_nodetable INTO gw_nodetable WITH KEY node_key = node_key.
IF gw_nodetable-isfolder = ' '.
MESSAGE e009(zkm_class).
ELSE.
CALL METHOD g_tree->expand_node
EXPORTING
node_key = node_key
EXCEPTIONS
failed = 1
illegal_level_count = 2
cntl_system_error = 3
node_not_found = 4
cannot_expand_leaf = 5
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.
ENDIF.
ENDCASE.
CALL METHOD g_tree->remove_all_key_strokes
EXCEPTIONS
failed = 1
cntl_system_error = 2.
ENDMETHOD. "HANDLE_NODE_KEYPRESS.
METHOD handle_node_context_menu_req.
g_event = 'NODE_CONTEXT_MENU_REQ'.
g_node_key = node_key.
CALL METHOD menu->add_function
EXPORTING
fcode = 'ADD'
text = 'Add Node'.
CALL METHOD menu->add_function
EXPORTING
fcode = 'DELETE'
text = 'Delete Node'.
ENDMETHOD. "handle_node_context_menu_req
METHOD handle_node_context_menu_sel.
g_event = 'NODE_CONTEXT_MENU_SELECT'.
CASE fcode.
WHEN 'ADD'.
READ TABLE gt_nodetable INTO gw_nodetable WITH KEY node_key = g_node_key.
IF gw_nodetable-isfolder = ' '.
MESSAGE e006(zkm_class).
ELSE.
CALL SCREEN 2000 STARTING AT 20 10.
MESSAGE s001(zkm_class).
ENDIF.
CLEAR g_event.
WHEN 'DELETE'.
IF g_node_key EQ 'Capgemini' OR
g_node_key EQ 'TSP-SAP-CRM' OR
g_node_key EQ 'MANAGERS' OR
g_node_key EQ 'TEAM LEAD'.
MESSAGE e004(zkm_class).
ENDIF.
CALL SCREEN 3000 STARTING AT 20 10.
CLEAR g_event.
ENDCASE.
ENDMETHOD. "handle_node_context_menu_sel
ENDCLASS. "LCL_APPLICATION
This is a complete tree control application.. I am sure it will solve all your problems.
Pls pls reward points if useful.
Regards,
Karan -
What is difference between report programming and dialog programming?
hi,
what is difference between report programming and dialog programming? plz provide some example code
byeABAP programming
Basically reports are used to read database and represent the results in lists.
Reports are collections of processing blocks that the system calls depending on events.
We can use reports to evaluate data from database tables.
Reports are stand alone programs and controlled by events.
A report itself never creates events
steps in report:
Processing the selection screen
Reading the database
Evaluating the data and creating lists
Outputting a list.
1st u write simple logics, after that u can enhance the code as step by step.
http://venus.imp.mx/hilario/Libros/TeachYrslfAbap4/index.htm
http://help.sap.com/saphelp_47x200/helpdata/en/d1/802cfc454211d189710000e8322d00/frameset.htm
http://www.sapdev.co.uk/reporting/reportinghome.htm
Dialog Programming
Structure of a Dialog Program
A dialog program consists of the following basic components:
Screens (dynpros)
Each dialog in an SAP system is controlled by dynpros. A dynpro (DYnamic PROgram) consists of a screen and its flow logic and controls exactly one dialog step. The flow logic determines which processing takes place before displaying the screen (PBO-Process Before Output) and after receiving the entries the user made on the screen (PAI-Process After Input).
The screen layout fixed in the Screen Painter determines the positions of input/output fields, text fields, and graphical elements such as radio buttons and checkboxes. In addition, the Menu Painter allows to store menus, icons, pushbuttons, and function keys in one or more GUI statuses. Dynpros and GUI statuses refer to the ABAP/4 program that control the sequence of the dynpros and GUI statuses at runtime.
ABAP/4 module pool
Each dynpro refers to exactly one ABAP/4 dialog program. Such a dialog program is also called a module pool, since it consists of interactive modules. The flow logic of a dynpro contains calls of modules from the corresponding module pool. Interactive modules called at the PBO event are used to prepare the screen template in accordance to the context, for example by setting field contents or by suppressing fields from the display that are not needed. Interactive modules called at the PAI event are used to check the user input and to trigger appropriate dialog steps, such as the update task.
All dynpros to be called from within one transaction refer to a common module pool. The dynpros of a module pool are numbered. By default, the system stores for each dynpro the dynpro to be displayed next. This dynpro sequence or chain can be linear as well as cyclic. From within a dynpro chain, you can even call another dynpro chain and, after processing it, return to the original chain.
Check this link for basics.
http://sap.mis.cmich.edu/sap-abap/abap09/index.htm
Check this link for Dialog Programming/Table Control
http://www.planetsap.com/Tips_and_Tricks.htm#dialog
Check this SAP Help for Dialog Program doc.
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9cdc35c111d1829f0000e829fbfe/content.htm
Check this SAP Help link for Subscreens.
http://help.sap.com/saphelp_nw70/helpdata/en/9f/dbabfe35c111d1829f0000e829fbfe/content.htm
Check this link for subscreen demo program.
http://abapcode.blogspot.com/2007/05/demo-program-to-create-subscreen-in.html
Also check this link too.
http://abapcode.blogspot.com/2007/06/dialog-programming-faq.html
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9cdc35c111d1829f0000e829fbfe/frameset.htm
http://sap.mis.cmich.edu/sap-abap/abap09/sld004.htm
http://help.sap.com/saphelp_nw04/helpdata/en/52/670ba2439b11d1896f0000e8322d00/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/52/670c17439b11d1896f0000e8322d00/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/52/670c17439b11d1896f0000e8322d00/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9ccf35c111d1829f0000e829fbfe/frameset.htm
http://abapprogramming.blogspot.com/
Maybe you are looking for
-
We setup iPads for a mobile lab and students change the settings or set up a pass code on the iPad. Is there a way to lock the settings folder or an app to revert any changes back to the original set up like the program cornerstone (for a pc)?
-
Not able to use external library DC in NW 7.0
Also refer steps in http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/60d99678-1a29-2d10-94b4-9d9a67b7199b?QuickLink=index&overridelayout=true
-
Why is the System Prefs dialog so **** big?
Not really a problem, rather just a nuisance. But the System Preferences dialog in Mavericks annoyed me from day 1. The icons are a lot bigger than they used to be and there seems to be no way of resizing. And the window gets even bigger once you ins
-
How to enhance Standard View in Webdynpro
Hi Techies, I AM NEW TO WEBDYNPRO CONCEPTS. I have requirement that, I need incorporate a new UI element "THRESHOLD SLIDER" instead of Radio Button Group, These Radio Button Group represents "Profieciency Scale of Candidate". this is dynamic, i.e, so
-
Hi, I am developing under Windows XP, SP2, all updates installed. When I run the program below, the modeless dialog disappears after a few seconds when I click into the parent frame. Obviously the frame repaints and ignores the dialog. But the dialog