Skip to Content
0
Former Member
Jun 11, 2009 at 06:38 AM

control problem in trees using class

46 Views

Hi all i am creating tree structure using class method in that when i am creating only one node it is working properly but when i try to crate multiple nodes it is giving me dump my program is as follow.

I search these on sdn and try the things but it still giving me same error.

*&---------------------------------------------------------------------*
*& Report  ZIRPT_HR_TEST_SPLITTER_01
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

report  zirpt_hr_test_splitter_01.


tables : pa0001,t582s.

select-options : p_pernr for pa0001-pernr no intervals.



*----------------------------------------------------------------------*
*       CLASS screen_init DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class screen_init definition create private.
  public section.
    class-methods init_screen.
    methods constructor.
  private section.
    data: splitter_h type ref to cl_gui_splitter_container,
    splitter_v type ref to cl_gui_splitter_container,
    picture type ref to cl_gui_picture,
    tree type ref to cl_gui_simple_tree,
     it_pa0001 type table of pa0001,
     it_pa0000 type table of pa0000.

    methods: fill_tree,
    fill_picture.
endclass.                    "screen_init DEFINITION


*----------------------------------------------------------------------*
*       CLASS screen_handler DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class screen_handler definition.
  public section.
    methods: constructor importing container
    type ref to cl_gui_container,
    handle_node_double_click
    for event node_double_click
    of cl_gui_simple_tree
    importing node_key.
  private section.
    data: html_viewer type ref to cl_gui_html_viewer,
           it_pa0001 type table of pa0001,
           it_pa0000 type table of pa0000,
    list_viewer type ref to cl_gui_alv_grid.
    methods:
    fill_list importing pernr type pa0001-pernr
                       infty type t582s-infty.
endclass.                    "screen_handler DEFINITION



*----------------------------------------------------------------------*
*       CLASS screen_init IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class screen_init implementation.

  method init_screen.
    data screen type ref to screen_init.
    create object screen.
  endmethod.                    "init_screen

  method constructor.
    data: events type cntl_simple_events,
    event like line of events,
    event_handler type ref to screen_handler,
    container_left type ref to cl_gui_container,
    container_right type ref to cl_gui_container,
    container_top type ref to cl_gui_container,
    container_bottom type ref to cl_gui_container.
    create object splitter_h
    exporting
    parent = cl_gui_container=>screen0
    rows = 1
    columns = 2.
    call method splitter_h->set_border
      exporting
        border = cl_gui_cfw=>false.

    call method splitter_h->set_column_mode
      exporting
        mode = splitter_h->mode_absolute.

    call method splitter_h->set_column_width
      exporting
        id    = 1
        width = 110.
    container_left = splitter_h->get_container( row = 1 column = 1 ).
    container_right = splitter_h->get_container( row = 1 column = 2 ).

    create object splitter_v
    exporting
    parent = container_left
    rows = 2
    columns = 1.

    call method splitter_v->set_border
      exporting
        border = cl_gui_cfw=>false.

    call method splitter_v->set_row_mode
      exporting
        mode = splitter_v->mode_absolute.

    call method splitter_v->set_row_height
      exporting
        id     = 1
        height = 160.
    container_top = splitter_v->get_container( row = 1 column = 1 ).
    container_bottom = splitter_v->get_container( row = 2 column = 1 ).

    create object picture
    exporting parent = container_top.

    create object tree
    exporting parent = container_bottom
    node_selection_mode =
    cl_gui_simple_tree=>node_sel_mode_single.

    create object event_handler
    exporting container = container_right.
    event-eventid = cl_gui_simple_tree=>eventid_node_double_click.
    event-appl_event = ' '.
    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,
                 me->fill_picture.

     call method cl_gui_cfw=>flush.

  endmethod.                    "constructor
*
  method fill_picture.
    types pict_line(256) type c.
    data pict_tab type table of pict_line.
    data url(255) type c.
    data : file type rlgrap-filename value 'C:\Documents and Settings\sapgroup.NITCOWRL\My Documents\nitco.gif'.

    translate file to upper case.

*CALL FUNCTION 'WS_UPLOAD'
*EXPORTING
*filename = file
*filetype = 'BIN'
*TABLES
*data_tab = pict_tab.
    data query_table_wa type w3query.
    data query_table type table of w3query." OF like w3query occurs 1 with header line.
    data html_table type table of w3html."  like w3html occurs 1.
    data return_code type  w3param-ret_code.
    data content_type type  w3param-cont_type.
    data content_length type  w3param-cont_len.
    data pic_data type table of w3mime."  like w3mime occurs 0.
    data pic_size type i.

    refresh query_table.
    query_table_wa-name = '_OBJECT_ID'.
    query_table_wa-value = 'ENJOYSAP_LOGO'.
    append query_table_wa to query_table.

    call function 'WWW_GET_MIME_OBJECT'
      tables
        query_string        = query_table
        html                = html_table
        mime                = pic_data
      changing
        return_code         = return_code
        content_type        = content_type
        content_length      = content_length
      exceptions
        object_not_found    = 1
        parameter_not_found = 2
        others              = 3.
    if sy-subrc = 0.
      pic_size = content_length.
    endif.

    call function 'DP_CREATE_URL'
      exporting
        type     = 'image'
        subtype  = cndp_sap_tab_unknown
        size     = pic_size
        lifetime = cndp_lifetime_transaction
      tables
        data     = pic_data
      changing
        url      = url
      exceptions
        others   = 1.

*IMPORT pict_tab = pict_tab FROM DATABASE abtree(pi) ID 'FLIGHTS'.
*CALL FUNCTION 'DP_CREATE_URL'
*EXPORTING
*type = 'IMAGE'
*subtype = 'GIF'
*TABLES
*data = pict_tab
*CHANGING
*url = url.
    call method picture->load_picture_from_url
      exporting
        url = url.
    call method picture->set_display_mode
      exporting
        display_mode = picture->display_mode_fit_center.

*     CALL METHOD cl_gui_cfw=>flush.
  endmethod.                    "fill_picture

  method fill_tree.
    data: node_table type table of abdemonode,
    node type abdemonode.

*data : it_pa0001 TYPE TABLE OF p0001,
    data :wa_pa0001 type pa0001,

          wa_pa0000 type pa0000,
          it_t582s type table of t582s,
          wa_t582s type t582s.

    types : begin of ttab,
             itext type t582s-itext,
             infty type t582s-infty,
             pernr type p0001-pernr,
             end of ttab.

    data : itab type table of ttab,
           wa_tab type ttab.


      field-symbols : <fs> like p_pernr.
      data : text1 type c.

    node-hidden = ' '.
    node-disabled = ' '.
    node-isfolder = 'X'.
    node-expander = ' '.



    select * from t582s
             into corresponding fields of table it_t582s
             where sprsl = sy-langu
               and infty in ('0001','0000')."'0002','0006',
*                         '0008','0015','0019').

    loop at it_t582s into wa_t582s .
      move-corresponding wa_t582s to wa_tab.

      node-node_key = wa_t582s-infty.
      clear node-relatkey.
      clear node-relatship.
      node-text = wa_t582s-itext.
      node-n_image = ' '.
      node-exp_image = ' '.
      append node to node_table.




      loop at p_pernr assigning <fs>.

        wa_tab-pernr = <fs>-low.
        append wa_tab to itab.
        clear p_pernr-low.

        node-node_key = <fs>-low.
        node-relatkey = wa_tab-infty.
        node-relatship = cl_gui_simple_tree=>relat_last_child.
        node-text = <fs>-low.
        node-n_image = '@AV@'.
        append node to node_table.

      endloop.

*        SELECT SINGLE * FROM pa0001 INTO wa_pa0001 WHERE pernr in p_pernr.



*     WHEN '0000'.
*        SELECT SINGLE * FROM pa0000 INTO wa_pa0000 WHERE pernr = p_pernr.
*    wa_tab-pernr = wa_pa0000-pernr.
*
*    endcase.

      clear : wa_tab,wa_pa0001,wa_pa0000.
    endloop.
*node-hidden = ' '.
*node-disabled = ' '.
*node-isfolder = 'X'.
*node-expander = ' '.


*LOOP AT itab INTO wa_tab.
*AT NEW infty.
*node-node_key = wa_tab-infty.
*CLEAR node-relatkey.
*CLEAR node-relatship.
*node-text = wa_tab-itext.
*node-n_image = ' '.
*node-exp_image = ' '.
*APPEND node TO node_table.
*ENDAT.
*AT NEW pernr.
* node-node_key = wa_tab-pernr.
*node-relatkey = wa_tab-infty.
*node-relatship = cl_gui_simple_tree=>relat_last_child.
*node-text = wa_tab-pernr.
*node-n_image = '@AV@'.
*node-exp_image = '@AV@'.
*ENDAT.
*APPEND node TO node_table.
*ENDLOOP.
    call method tree->add_nodes
      exporting
        table_structure_name = 'ABDEMONODE'
        node_table           = node_table.

*    CALL METHOD cl_gui_cfw=>flush.

  endmethod.                    "fill_tree

endclass.                    "screen_init IMPLEMENTATION





*----------------------------------------------------------------------*
*       CLASS screen_handler IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class screen_handler implementation.


  method constructor.
    create object: html_viewer exporting parent = container,
    list_viewer exporting i_parent = container.
  endmethod.                    "constructor

  method handle_node_double_click.
    data: infty type t582s-infty,
          pernr type pa0001-pernr.
    infty = node_key(4).
    pernr = node_key+4(8).
*IF pernr IS INITIAL.
*CALL METHOD: fill_html EXPORTING infty = infty,
*html_viewer->set_visible EXPORTING visible = 'X',
*list_viewer->set_visible EXPORTING visible = ' '.
*ELSE.
    call method: fill_list exporting infty = infty
                                     pernr = pernr,
    list_viewer->set_visible exporting visible = 'X',
    html_viewer->set_visible exporting visible = ' '.
*ENDIF.
*    CALL METHOD cl_gui_cfw=>flush.
  endmethod.                    "handle_node_double_click

*METHOD fill_html.
*DATA url TYPE scarr-url.
*SELECT SINGLE url
*FROM scarr
*INTO url
*WHERE infty = infty.
*CALL METHOD html_viewer->show_url EXPORTING url = url.
*ENDMETHOD.


  method fill_list.
    data: flight_tab type table of demofli,
    begin of flight_title,
    carrname type scarr-carrname,
    cityfrom type spfli-cityfrom,
    cityto type spfli-cityto,
    end of flight_title,
    list_layout type lvc_s_layo.

*DATA : it_pa0001 TYPE TABLE OF p0001.
    if infty = '0001'.
      select * from pa0001 into table it_pa0001 where pernr = pernr.
    elseif infty = '0000'.
      select * from pa0001 into table it_pa0001 where pernr = pernr.
    endif.
*SELECT SINGLE c~carrname p~cityfrom p~cityto
*INTO CORRESPONDING FIELDS OF flight_title
*FROM ( scarr AS c
*INNER JOIN spfli AS p ON c~carrid = p~carrid )
*WHERE p~carrid = carrid AND
*p~connid = connid.
*SELECT fldate seatsmax seatsocc
*INTO CORRESPONDING FIELDS OF TABLE flight_tab
*FROM sflight
*WHERE carrid = carrid AND connid = connid
*  ORDER BY fldate.
*CONCATENATE flight_title-carrname
*connid
*flight_title-cityfrom
*flight_title-cityto
    list_layout-grid_title = 'TEST'.
    list_layout-smalltitle = 'X'.
    list_layout-cwidth_opt = 'X'.
    list_layout-no_toolbar = 'X'.
*if infty = '0001'.
    call method list_viewer->set_table_for_first_display
      exporting
        i_structure_name = 'PA0001'
        is_layout        = list_layout
      changing
        it_outtab        = it_pa0001.

* CALL METHOD cl_gui_cfw=>flush.
*ELSEIF infty = '0001'.
*CALL METHOD list_viewer->set_table_for_first_display
*EXPORTING i_structure_name = 'PA0000'
*is_layout = list_layout
*CHANGING it_outtab = it_pa0000.
*endif.

  endmethod.                    "fill_list



endclass.                    "screen_handler IMPLEMENTATION







start-of-selection.
  data : it_pa0001 type table of p0001.
  call screen 100.
*----------------------------------------------------------------------*
*  MODULE status_0100 OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
module status_0100 output.
  set pf-status 'SCREEN_100'.
  set titlebar 'TIT_100'.
  call method screen_init=>init_screen.
*   CALL METHOD cl_gui_cfw=>flush.
endmodule.                    "status_0100 OUTPUT
*----------------------------------------------------------------------*
*  MODULE cancel INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
module cancel input.
  set screen 0.
  leave program.
endmodule.                    "cancel INPUT

Plz Suggest ,

Regards ,

Paresh G.