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

ALV TREE USING OOPS

Former Member
0 Likes
1,450

Hello every one,

I am doing program  on tree alv using oops. My program activated without syntactical error. while exciting it generating some short-dump. I am getting short-dump while calling set_table_for_first_display method in CL_GUI_ALV_TREE_Simple calss.Please help me on this issue.  Below code am using .

PFA for short-dump screenshot.

*&---------------------------------------------------------------------*
*& Report  ZOOPS_ALV_TREE1
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zoops_alv_tree1.
TYPES :BEGIN OF ty_mara ,
       matnr TYPE matnr,
       mtart TYPE mtart,
       mbrsh TYPE mbrsh,
       MEINS TYPE MEINS,
       END OF ty_mara.
DATA:wa_mara TYPE ty_mara,
       v_matnr TYPE matnr,
       it_mara TYPE STANDARD TABLE OF ty_mara INITIAL SIZE 1,
       it_fcat TYPE STANDARD TABLE OF lvc_s_fcat INITIAL SIZE 1,
       gc_cont TYPE REF TO cl_gui_custom_container,
       gt_tree TYPE REF TO cl_gui_alv_tree_simple,
       it_sort TYPE STANDARD TABLE OF lvc_s_sort.
SELECT-OPTIONS s_matnr FOR v_matnr.

START-OF-SELECTION.
   CALL SCREEN 101.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0101  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0101 OUTPUT.
   IF gt_tree IS INITIAL.

     PERFORM tree.

   ENDIF.
   SET PF-STATUS 'ZTREEPF'.
ENDMODULE.                 " STATUS_0101  OUTPUT
*&---------------------------------------------------------------------*
*&      Form  TREE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM tree .
   PERFORM out_tab.
   PERFORM fillcatlog.
   PERFORM sort_table.
   PERFORM display.
ENDFORM.                    " TREE
*&---------------------------------------------------------------------*
*&      Form  OUT_TAB
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM out_tab .
   SELECT matnr
          mtart
          mbrsh
          meins FROM mara INTO TABLE it_mara
          WHERE matnr IN s_matnr.
ENDFORM.                    " OUT_TAB
*&---------------------------------------------------------------------*
*&      Form  FILLCATLOG
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM fillcatlog .
   PERFORM:fcat USING 'MATNR' 'Material no',
           fcat USING 'MTART' 'Material Type',
           fcat USING 'MBRSH' 'Industry Sector',
           fcat USING 'MEINS' 'Unit of Measurment'.
ENDFORM.                    " FILLCATLOG
*&---------------------------------------------------------------------*
*&      Form  FCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0130   text
*      -->P_0131   text
*----------------------------------------------------------------------*
FORM fcat  USING    p_name
                     p_desc.
   DATA wa_fcat TYPE lvc_s_fcat.
   wa_fcat-fieldname = p_name.
   wa_fcat-seltext = p_desc.
   APPEND wa_fcat TO it_fcat.
   CLEAR  wa_fcat.
ENDFORM.                    " FCAT
*&---------------------------------------------------------------------*
*&      Form  SORT_TABLE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM sort_table .
   DATA ls_sort_wa TYPE lvc_s_sort.
*  ls_sort_wa-spos = 1.
   ls_sort_wa-fieldname = 'MATNR'.
   ls_sort_wa-up = 'X'.
   ls_sort_wa-subtot = 'X'.
   APPEND ls_sort_wa TO it_sort.
ENDFORM.                    " SORT_TABLE
*&---------------------------------------------------------------------*
*&      Form  DISPLAY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM display .
   CREATE OBJECT gc_cont
     EXPORTING
       container_name = 'CONT'.
   CREATE OBJECT gt_tree
     EXPORTING
       i_parent = gc_cont.
   CALL METHOD gt_tree->set_table_for_first_display
   EXPORTING
     i_structure_name     = 'MARA'
*    is_variant           =
*    i_save               =
*    i_default            = 'X'
*    is_layout            =
*    it_special_groups    =
*    it_list_commentary   =
*    i_logo               =
*    i_background_id      =
*    it_toolbar_excluding =
*    it_grouplevel_layout =
*    it_except_qinfo      =
     CHANGING
       it_outtab            = it_mara
*      it_fieldcatalog      = it_fcat
*    it_filter            =
       it_sort              = it_sort
       .
   CALL METHOD gt_tree->expand_tree
     EXPORTING
       i_level                 = 1
*  EXCEPTIONS
*    failed                  = 1
*    cntl_system_error       = 2
*    error_in_node_key_table = 3
*    dp_error                = 4
*    node_not_found          = 5
*    others                  = 6
           .
   IF sy-subrc <> 0.
* Implement suitable error handling here
   ENDIF.


ENDFORM.                    " DISPLAY
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0101  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0101 INPUT.
   CASE sy-ucomm.
     WHEN  'BACK'.
       LEAVE TO SCREEN 0.
     WHEN 'EXIT'.
       LEAVE PROGRAM.
   ENDCASE.
ENDMODULE.                 " USER_COMMAND_0101  INPUT



8 REPLIES 8
Read only

Former Member
0 Likes
1,349

HI Ramesh,

There is no field catalog.

Can you add it and try again.

Read only

0 Likes
1,349

Hi Abdul,

I tried by passing field-catalog also still it showing same error.

Read only

0 Likes
1,349

Hi Ramesh,

Please give latest source and error screen shot.

Read only

Former Member
0 Likes
1,349

Hi,

Could you please uncomment the Exceptions while calling the method EXPAND_TREE and check if you get the same error again.

Let me know.

Read only

0 Likes
1,349

Hi,

I am  posting my recent code what i tried along with short-dump screen shot.  I am getting error in

set_table_for_first-display area itself.

*&---------------------------------------------------------------------*
*& Report  ZOOPS_ALV_TREE1
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zoops_alv_tree1.
TYPES :BEGIN OF ty_mara ,
       matnr TYPE matnr,
       mtart TYPE mtart,
       mbrsh TYPE mbrsh,
       MEINS TYPE MEINS,
       END OF ty_mara.
DATA:wa_mara TYPE ty_mara,
       v_matnr TYPE matnr,
       it_mara TYPE STANDARD TABLE OF ty_mara INITIAL SIZE 1,
       it_fcat TYPE STANDARD TABLE OF lvc_s_fcat INITIAL SIZE 1,
       gc_cont TYPE REF TO cl_gui_custom_container,
       gt_tree TYPE REF TO cl_gui_alv_tree_simple,
       it_sort TYPE STANDARD TABLE OF lvc_s_sort.
SELECT-OPTIONS s_matnr FOR v_matnr.

START-OF-SELECTION.
   CALL SCREEN 101.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0101  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0101 OUTPUT.
   IF gt_tree IS INITIAL.

     PERFORM tree.

   ENDIF.
   SET PF-STATUS 'ZTREEPF'.
ENDMODULE.                 " STATUS_0101  OUTPUT
*&---------------------------------------------------------------------*
*&      Form  TREE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM tree .
   PERFORM out_tab.
   PERFORM fillcatlog.
   PERFORM sort_table.
   PERFORM display.
ENDFORM.                    " TREE
*&---------------------------------------------------------------------*
*&      Form  OUT_TAB
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM out_tab .
   SELECT matnr
          mtart
          mbrsh
          meins FROM mara INTO TABLE it_mara
          WHERE matnr IN s_matnr.
ENDFORM.                    " OUT_TAB
*&---------------------------------------------------------------------*
*&      Form  FILLCATLOG
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM fillcatlog .
   PERFORM:fcat USING 'MATNR' 'Material no',
           fcat USING 'MTART' 'Material Type',
           fcat USING 'MBRSH' 'Industry Sector',
           fcat USING 'MEINS' 'Unit of Measurment'.
ENDFORM.                    " FILLCATLOG
*&---------------------------------------------------------------------*
*&      Form  FCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0130   text
*      -->P_0131   text
*----------------------------------------------------------------------*
FORM fcat  USING    p_name
                     p_desc.
   DATA wa_fcat TYPE lvc_s_fcat.
   wa_fcat-fieldname = p_name.
   wa_fcat-seltext = p_desc.
   APPEND wa_fcat TO it_fcat.
   CLEAR  wa_fcat.
ENDFORM.                    " FCAT
*&---------------------------------------------------------------------*
*&      Form  SORT_TABLE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM sort_table .
   DATA ls_sort_wa TYPE lvc_s_sort.
*  ls_sort_wa-spos = 1.
   ls_sort_wa-fieldname = 'MATNR'.
   ls_sort_wa-up = 'X'.
   ls_sort_wa-subtot = 'X'.
   APPEND ls_sort_wa TO it_sort.
ENDFORM.                    " SORT_TABLE
*&---------------------------------------------------------------------*
*&      Form  DISPLAY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM display .
   CREATE OBJECT gc_cont
     EXPORTING
       container_name = 'CONT'.
   CREATE OBJECT gt_tree
     EXPORTING
       i_parent = gc_cont.
   CALL METHOD gt_tree->set_table_for_first_display     <-----------------------error getting areaa
*  EXPORTING
*    i_structure_name     = 'MARA'
*    is_variant           =
*    i_save               =
*    i_default            = 'X'
*    is_layout            =
*    it_special_groups    =
*    it_list_commentary   =
*    i_logo               =
*    i_background_id      =
*    it_toolbar_excluding =
*    it_grouplevel_layout =
*    it_except_qinfo      =
     CHANGING
       it_outtab            = it_mara
       it_fieldcatalog      = it_fcat
*    it_filter            =
       it_sort              = it_sort
       .
   CALL METHOD gt_tree->expand_tree
     EXPORTING
       i_level                 = 1
   EXCEPTIONS
     failed                  = 1
     cntl_system_error       = 2
     error_in_node_key_table = 3
     dp_error                = 4
     node_not_found          = 5
     others                  = 6
           .
   IF sy-subrc <> 0.
* Implement suitable error handling here
   ENDIF.


ENDFORM.                    " DISPLAY
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0101  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0101 INPUT.
   CASE sy-ucomm.
     WHEN  'BACK'.
       LEAVE TO SCREEN 0.
     WHEN 'EXIT'.
       LEAVE PROGRAM.
   ENDCASE.
ENDMODULE.                 " USER_COMMAND_0101  INPUT


Read only

0 Likes
1,349

I think the problem is in it_sort table.


Try doing the following:-

1. Declare it_sort as:

     it_sort TYPE LVC_T_SORT.

2. Uncomment the line:

     *  ls_sort_wa-spos = 1.


Let me know.

Read only

0 Likes
1,349

Hi,

gt_tree->expand_tree

you don't have nodes... check please

let me know,

AI

Read only

0 Likes
1,349

Hi Ramesh,

You have defined the custom type declaration for output table IT_MARA.

Then why are you massing structure name as 'MARA' into the method SET_TABLE_FOR_FIRST_DISPLAY. If you want to use the same define internal table of type mara. Create field catalog with FM 'LVC_FIELDCATALOG_MERGE' and use that.

If you want to use your custom type declaration then do not pass 'MARA' as structure name.

Create z structure in database dictionary and pass it. Even it is not required to pass.

Santosh