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

Tree List using screen and a check box

Former Member
0 Kudos

Hi Friends,

I need to create a TREE REPORT with CHECK BOX against each row. when the user selects a row and clicks on a custom button then those should get populated into an internal table. This is HIGH priority one and I have tried my best but couldnt find any solution. Please advise me some sol.

thanks in advance for your valuable time and help.

<b>I am unable to find the right class for this purpose though I can see many in sap help.</b> Please advise the right class for this.

thanks in advance.

srithan

Message was edited by: srithan

Reddy

6 REPLIES 6

Former Member
0 Kudos

Use the CL_GUI_TREE_MODEL, and when creating the object set the selection mode to cl_list_tree_model=>node_sel_mode_multiple.

Albert

Former Member
0 Kudos

Hi

CL_GUI_ALV_TREE (ALV Tree Control)

CL_GUI_ALV_TREE_SIMPLE (Simple ALV Tree)

you can look into BCALV_TEST_SIMPLE_TREE or if you are newer release of SAP, you can also look into SALV_DEMO_TREE_SIMPLE.

Please try program 'SAPSIMPLE_TREE_CONTROL_DEMO', sample program of tree controls.

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

BCALV_GRID_DND_TREE ALV Grid: Drag and Drop with ALV Tree

BCALV_GRID_DND_TREE_SIMPLE ALV GRID: Drag and drop with ALV tree (simple)

here's a piece of code:

add 1 to childnr.

concatenate 'child' childnr into childname.

NODE-NODE_KEY = childname.

NODE-ISFOLDER = 'X'.

NODE-EXPANDER = 'X'.

ITEM-NODE_KEY = childname.

move childname to vtab-childname.

add 1 to dateinr.

NODE-NODE_KEY = dateinr.

ITEM-NODE_KEY = node-node_key.

move dateinr to vtab-childname.

modify vtab from wa.

APPEND ITEM TO ITEM_TABLE.

APPEND NODE TO NODE_TABLE.

*Datum

clear item.

ITEM-NODE_KEY = NODE-NODE_KEY.

ITEM-ITEM_NAME = '2'.

ITEM-CLASS = CL_GUI_LIST_TREE=>ITEM_CLASS_TEXT.

ITEM-LENGTH = 10.

ITEM-USEBGCOLOR = 'X'.

ITEM-TEXT = vtab-datum.

APPEND ITEM TO ITEM_TABLE.

*Größe

clear item.

ITEM-NODE_KEY = NODE-NODE_KEY.

ITEM-ITEM_NAME = '3'.

ITEM-CLASS = CL_GUI_LIST_TREE=>ITEM_CLASS_TEXT.

ITEM-LENGTH = 10.

ITEM-USEBGCOLOR = 'X'.

ITEM-TEXT = vtab-len.

APPEND ITEM TO ITEM_TABLE.

*und los

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.

IF SY-SUBRC <> 0.

MESSAGE A000.

ENDIF.

Check this link

http://www.sap-img.com/abap/a-sample-tree-programming.htm

http://www.sapdevelopment.co.uk/reporting/alv/alvtree.htm

Reward all helpfull answers

If you are trying for a tree structure in report check this report

*&----


*

*& Report ZTREE *

*& *

*&----


*

*& *

*& *

*&----


*

REPORT ZTREE .

DATA: BEGIN OF ITEMS OCCURS 100,

ID(10),

PARENT_ID(10),

TEXT(20),

SYMBOL,

END OF ITEMS,

TABIX_STACK LIKE SY-TABIX OCCURS 10 WITH HEADER LINE,

ITEMS_SHOW LIKE ITEMS OCCURS 100 WITH HEADER LINE.

INCLUDE .

  • append sample items (mixed order)

PERFORM APPEND_ITEM USING:

'1' '' 'Food',

'2' '' 'Drinks',

'12' '9' 'Pavan Praveen',

'17' '11' 'company',

'3' '' 'Tools',

'4' '1' 'Dairy milk',

'16' '11' 'Music',

'5' '1' 'Chocolate',

'6' '2' 'Alcoholic',

'8' '4' 'Megastar',

'10' '5' 'Milk',

'11' '3' 'Boost',

'13' '9' 'Sachin ',

'7' '4' 'Cricket',

'14' '2' 'Non-alcholic',

'35' '31' 'Pepsi',

'9' '6' 'Thumsup',

'15' '14' 'Coca-cola',

'18' '6' 'Win',

'28' '18' 'Ganguly ',

'33' '28' 'INDIA',

'34' '28' 'Gujarat',

'29' '18' 'State',

'30' '29' 'congrats',

'19' '33' 'chiranjeevi',

'20' '33' 'kalyan',

'22' '19' 'here comes',

'23' '19' 'Chandra',

'24' '20' 'chat',

'32' '31' 'Marvelous',

'25' '20' 'Memorable',

'31' '34' 'guess'.

  • show initial list (items with level 0 - parentless items)

LOOP AT ITEMS WHERE PARENT_ID = ''.

MOVE-CORRESPONDING ITEMS TO ITEMS_SHOW.

ITEMS_SHOW-SYMBOL = '+'.

APPEND ITEMS_SHOW.

ENDLOOP.

PERFORM PRINT_TREE TABLES ITEMS_SHOW.

  • at line-selection - when the node is opened/closed or item double-clk

AT LINE-SELECTION.

READ TABLE ITEMS WITH KEY PARENT_ID = ITEMS_SHOW-ID. "see 'hide'

IF SY-SUBRC = 0. "item has children - expand or collapse

SY-LSIND = 0.

PERFORM EXPAND_COLLAPSE USING ITEMS_SHOW-ID.

PERFORM PRINT_TREE TABLES ITEMS_SHOW.

ELSE. "item has NO children - perform some action

READ TABLE ITEMS WITH KEY ID = ITEMS_SHOW-ID.

WRITE: 'Action performed on item "' NO-GAP, ITEMS-TEXT NO-GAP,

'", id.', ITEMS-ID.

ENDIF.

  • form print_tree

FORM PRINT_TREE TABLES ITEMS STRUCTURE ITEMS.

DATA: V_TABIX LIKE SY-TABIX,

START_TABIX LIKE SY-TABIX,

V_LEVEL LIKE SY-TFILL,

V_OFFSET TYPE I,

V_ID LIKE ITEMS-ID,

V_PARENT_ID LIKE ITEMS-PARENT_ID,

V_PARENT_ID_FOR_VLINE LIKE ITEMS-PARENT_ID,

V_PREV_LEVEL TYPE I,

V_ITEMS_COUNT LIKE SY-TFILL,

V_VLINES_STRING(200).

CHECK NOT ITEMS[] IS INITIAL.

SORT ITEMS BY PARENT_ID ID.

READ TABLE ITEMS INDEX 1.

V_PARENT_ID = ITEMS-PARENT_ID.

START_TABIX = 1.

REFRESH TABIX_STACK.

DO.

LOOP AT ITEMS FROM START_TABIX.

V_TABIX = START_TABIX = SY-TABIX."remember current index

V_ID = ITEMS-ID.

V_PARENT_ID_FOR_VLINE = ITEMS-PARENT_ID.

  • decrease level and exit loop if parent not the same as previous

IF ITEMS-PARENT_ID NE V_PARENT_ID.

PERFORM READ_FROM_STACK CHANGING START_TABIX. "level = NoOfRecs

READ TABLE ITEMS INDEX START_TABIX.

V_PARENT_ID = ITEMS-PARENT_ID.

ADD 1 TO START_TABIX. "next loop starts from parent index + 1

  • clear vline

IF V_LEVEL > 1.

V_OFFSET = 2 + ( V_LEVEL - 2 ) * 3.

IF V_LEVEL = 1. V_OFFSET = 1. ENDIF.

V_VLINES_STRING+V_OFFSET = ' '.

ENDIF.

EXIT.

ENDIF.

V_PARENT_ID = ITEMS-PARENT_ID.

  • write item

FORMAT COLOR OFF.

DESCRIBE TABLE TABIX_STACK LINES V_LEVEL."level is no of StackRecs

WRITE: / V_VLINES_STRING.

V_OFFSET = V_LEVEL * 3.

IF V_LEVEL NE 0.

IF V_PREV_LEVEL < V_LEVEL.

WRITE: AT V_OFFSET '|', / ''.

WRITE: / V_VLINES_STRING.

ENDIF.

V_OFFSET = V_LEVEL * 3.

WRITE AT V_OFFSET '|--'.

ENDIF.

V_OFFSET = V_OFFSET + 3.

CASE ITEMS-SYMBOL.

WHEN '+'.

WRITE AT V_OFFSET SYM_PLUS_FOLDER AS SYMBOL

COLOR 4 INTENSIFIED HOTSPOT.

WHEN '-'.

WRITE AT V_OFFSET SYM_MINUS_FOLDER AS SYMBOL

COLOR 4 INTENSIFIED HOTSPOT.

WHEN OTHERS. FORMAT COLOR 5.

ENDCASE.

WRITE: ITEMS-TEXT.

V_PREV_LEVEL = V_LEVEL.

HIDE: ITEMS-ID.

ADD 1 TO V_ITEMS_COUNT.

READ TABLE ITEMS WITH KEY PARENT_ID = ITEMS-ID.

  • increase level and exit loop if item has children

IF SY-SUBRC = 0.

START_TABIX = SY-TABIX.

APPEND V_TABIX TO TABIX_STACK. "level is no of recs in stack

V_PARENT_ID = ITEMS-PARENT_ID.

  • set vline

V_TABIX = V_TABIX + 1.

READ TABLE ITEMS INDEX V_TABIX.

V_OFFSET = 2 + ( V_LEVEL - 1 ) * 3.

IF V_LEVEL > 0.

IF ITEMS-PARENT_ID = V_PARENT_ID_FOR_VLINE AND SY-SUBRC = 0.

V_VLINES_STRING+V_OFFSET = '|'.

ELSE.

V_VLINES_STRING+V_OFFSET = ' '.

ENDIF.

ENDIF.

EXIT.

ENDIF.

  • at last - decrease level

AT LAST.

  • clear vline

IF V_LEVEL > 1.

V_OFFSET = 2 + ( V_LEVEL - 2 ) * 3.

IF V_LEVEL = 1. V_OFFSET = 1. ENDIF.

V_VLINES_STRING+V_OFFSET = ' '.

ENDIF.

" next loop starts from parent index, not parent index + 1

" because of different parents level will decrease anyway

PERFORM READ_FROM_STACK CHANGING START_TABIX.

APPEND START_TABIX TO TABIX_STACK. "must return index to stack

ENDAT.

ENDLOOP.

DESCRIBE TABLE ITEMS.

IF START_TABIX > SY-TFILL OR V_ITEMS_COUNT >= SY-TFILL.

EXIT.

ENDIF.

ENDDO.

ENDFORM.

  • form expand_collapse

FORM EXPAND_COLLAPSE USING VALUE(V_ID).

DATA: V_NO_MORE_ORPHANS,

ITEMS_TEMP LIKE ITEMS OCCURS 100 WITH HEADER LINE.

DELETE ITEMS_SHOW WHERE PARENT_ID = V_ID. "try to collapse

IF SY-SUBRC = 0. "succesfull first collapse

DO. "cascade collapse - delete 'orphans' that are left

REFRESH ITEMS_TEMP.

MOVE ITEMS_SHOW[] TO ITEMS_TEMP[].

SORT ITEMS_TEMP BY ID.

V_NO_MORE_ORPHANS = 'X'.

LOOP AT ITEMS_SHOW WHERE PARENT_ID NE ''.

READ TABLE ITEMS_TEMP WITH KEY ID = ITEMS_SHOW-PARENT_ID

BINARY SEARCH TRANSPORTING NO FIELDS.

IF SY-SUBRC NE 0. "no parent - it's an orphan

CLEAR V_NO_MORE_ORPHANS.

DELETE ITEMS_SHOW.

ENDIF.

ENDLOOP.

IF V_NO_MORE_ORPHANS = 'X'. EXIT. ENDIF.

ENDDO.

ITEMS_SHOW-SYMBOL = '+'.

MODIFY ITEMS_SHOW TRANSPORTING SYMBOL WHERE ID = V_ID.

ELSE. "unsuccessfull collapse - expand

ITEMS_SHOW-SYMBOL = '-'.

MODIFY ITEMS_SHOW TRANSPORTING SYMBOL WHERE ID = V_ID.

LOOP AT ITEMS WHERE PARENT_ID = V_ID. "show children

APPEND ITEMS TO ITEMS_SHOW.

ENDLOOP.

LOOP AT ITEMS_SHOW WHERE PARENT_ID = V_ID. "check grandchildren

READ TABLE ITEMS WITH KEY PARENT_ID = ITEMS_SHOW-ID.

IF SY-SUBRC = 0.

ITEMS_SHOW-SYMBOL = '+'.

ELSE.

ITEMS_SHOW-SYMBOL = ''.

ENDIF.

MODIFY ITEMS_SHOW.

ENDLOOP.

ENDIF.

ENDFORM.

  • form append_item

FORM APPEND_ITEM USING VALUE(ID) VALUE(PARENT_ID) VALUE(TEXT).

ITEMS-ID = ID.

ITEMS-PARENT_ID = PARENT_ID.

ITEMS-TEXT = TEXT.

APPEND ITEMS.

ENDFORM.

  • form read_from_stack

FORM READ_FROM_STACK CHANGING TABIX LIKE SY-TABIX.

DESCRIBE TABLE TABIX_STACK.

CHECK SY-TFILL NE 0.

READ TABLE TABIX_STACK INDEX SY-TFILL.

TABIX = TABIX_STACK.

DELETE TABIX_STACK INDEX SY-TFILL.

ENDFORM.

Or use this FM RS_TREE_SET_CURRENT_LAYOUT

*&----


*

*& Report ZTREESTRUC *

*& *

*&----


*

*& *

*& *

*&----


*

REPORT ZTREESTRUC .

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 =

**********end of program .

For Tree structure in alv

Check this

*&----


*

*& Report ZALVTREE *

*& *

*&----


*

*& *

*& *

*&----


*

REPORT ZALVTREE .

*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

Regards

Pavan

0 Kudos

Hi Pavan,

Thanks for your reply.

But I am looking for a report or anything to display a TREE list with checkbox. I am able to get the normal tree but not the check box. can you plz provide something which is related to this ?

Thanks

srithan

Former Member
0 Kudos

There a number of ways to get a "tree" look in SAP (e.g. function group SEUT for the older style hierarchies)... and have you checked out the SAPCOLUMN_TREE_CONTROL_DEMO demo program which includes a checkbox and checkbox_change event?

Jonathan

Former Member
0 Kudos

Thank you for all resps

0 Kudos

I achieved this using

SAPCOLUMN_TREE_CONTROL_DEMO demo program and rhinte20 program which includes a checkbox and checkbox_change event

thanks once again.

Srithan