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 and set_table_for_first_display problem

Former Member
0 Likes
1,271

I am trying to create an alv tree. I have some sample code that uses the sflight table and this works fine however when i replace sflight with my internal structure and table it crashes at set_table_for_first_display with a "Field symbol has not been assigned" error.

This is part of the original code that works. *This isn't all the code just the relevant parts.

DATA: gt_sflight      TYPE sflight OCCURS 0,   " Output-Table
           gt_fieldcatalog TYPE lvc_t_fcat,            " Field Catalog

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.

SELECT * FROM sflight INTO TABLE gt_sflight.

create hierarchy
  CALL METHOD tree1->set_table_for_first_display
    EXPORTING
      it_list_commentary = lt_list_commentary
      i_logo             = l_logo
      i_background_id    = 'ALV_BACKGROUND'
      i_save             = 'A'
      is_variant         = ls_variant
    CHANGING
      it_sort            = gt_sort
      it_outtab          = gt_sflight
      it_fieldcatalog    = gt_fieldcatalog.

Here is the code when I replace gt_sflight with my internal table.

DATA: gt_detailed      TYPE ZDT_REPORT1_DETAIL_STRUC occurs 0 ,   " Output-Table
           gt_fieldcatalog TYPE lvc_t_fcat,         " Field Catalog

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name = 'ZDT_REPORT1_DETAIL_STRUC'
    CHANGING
      ct_fieldcat      = gt_fieldcatalog
    EXCEPTIONS
      inconsistent_interface = 1
      program_error = 2
      OTHERS = 3.
    IF sy-subrc <> 0.
*--Exception handling
    ENDIF.


"* change fieldcatalog
  DATA: ls_fieldcatalog TYPE lvc_s_fcat.
  LOOP AT gt_fieldcatalog INTO ls_fieldcatalog.
    CASE ls_fieldcatalog-fieldname.
      WHEN 'COMP_DESC' OR 'SUBC_DESC'.
        ls_fieldcatalog-no_out = 'X'.
        ls_fieldcatalog-key    = ''.
      WHEN 'DOWNTIME'.
        ls_fieldcatalog-do_sum = 'X'.
    ENDCASE.
    MODIFY gt_fieldcatalog FROM ls_fieldcatalog.
  ENDLOOP.

" Select statement to fill gt_detailed

* create hierarchy
  CALL METHOD tree1->set_table_for_first_display
    EXPORTING
      it_list_commentary = lt_list_commentary
      i_logo             = l_logo
      i_background_id    = 'ALV_BACKGROUND'
      i_save             = 'A'
      is_variant         = ls_variant
    CHANGING
      it_sort            = gt_sort
      it_outtab          = gt_detailed
      it_fieldcatalog    = gt_fieldcatalog.

When it runs like this it crashes at set_table_for_first_display

I am trying to create an alv tree. I have some sample code that uses the sflight table and this works fine however when i replace sflight with my internal structure and table it crashes at set_table_for_first_display with a "Field symbol has not been assigned" error.

This is part of the original code that works. *This isn't all the code just the relevant parts.

DATA: gt_sflight      TYPE sflight OCCURS 0,   " Output-Table
           gt_fieldcatalog TYPE lvc_t_fcat,            " Field Catalog

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.

SELECT * FROM sflight INTO TABLE gt_sflight.

create hierarchy
  CALL METHOD tree1->set_table_for_first_display
    EXPORTING
      it_list_commentary = lt_list_commentary
      i_logo             = l_logo
      i_background_id    = 'ALV_BACKGROUND'
      i_save             = 'A'
      is_variant         = ls_variant
    CHANGING
      it_sort            = gt_sort
      it_outtab          = gt_sflight
      it_fieldcatalog    = gt_fieldcatalog.

Here is the code when I replace gt_sflight with my internal table.

DATA: gt_detailed      TYPE ZDT_REPORT1_DETAIL_STRUC occurs 0 ,   " Output-Table
           gt_fieldcatalog TYPE lvc_t_fcat,         " Field Catalog

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name = 'ZDT_REPORT1_DETAIL_STRUC'
    CHANGING
      ct_fieldcat      = gt_fieldcatalog
    EXCEPTIONS
      inconsistent_interface = 1
      program_error = 2
      OTHERS = 3.
    IF sy-subrc <> 0.
*--Exception handling
    ENDIF.


"* change fieldcatalog
  DATA: ls_fieldcatalog TYPE lvc_s_fcat.
  LOOP AT gt_fieldcatalog INTO ls_fieldcatalog.
    CASE ls_fieldcatalog-fieldname.
      WHEN 'COMP_DESC' OR 'SUBC_DESC'.
        ls_fieldcatalog-no_out = 'X'.
        ls_fieldcatalog-key    = ''.
      WHEN 'DOWNTIME'.
        ls_fieldcatalog-do_sum = 'X'.
    ENDCASE.
    MODIFY gt_fieldcatalog FROM ls_fieldcatalog.
  ENDLOOP.

" Select statement to fill gt_detailed

* create hierarchy
  CALL METHOD tree1->set_table_for_first_display
    EXPORTING
      it_list_commentary = lt_list_commentary
      i_logo             = l_logo
      i_background_id    = 'ALV_BACKGROUND'
      i_save             = 'A'
      is_variant         = ls_variant
    CHANGING
      it_sort            = gt_sort
      it_outtab          = gt_detailed
      it_fieldcatalog    = gt_fieldcatalog.

When it runs like this it crashes at set_table_for_first_display

3 REPLIES 3
Read only

Former Member
0 Likes
859

Hi,

Have a look at this program it will be pretty much clearer then,

BCALV_TREE_01

Hope it helps you,

Regards,

Abhijit G. Borkar

Read only

0 Likes
859

The code I am using as an example is BCALV_TREE_SIMPLE_DEMO. If I have no data in my table it doesn't error when I call set_table_for_first_display.

But it looks like I might have to use that one instead because from what I understand you can use cl_gui_alv_tree_simple when the input table has all the required columns such as sflight but you use cl_gui_alv_tree when you need an internal table.

Read only

Former Member
0 Likes
859

I needed to use cl_gui_alv_tree instead of cl_gui_alv_tree_simple. BCALV_TREE_01 is a good example.