Skip to Content
avatar image
Former Member

Editable Tree ALV

Hi friends,

How can I edit ALV tree .please give me inputs

correct Inputs are rewarded

Regards

Rasheed

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Oct 16, 2008 at 09:36 AM

    SAP does not support editable ALV trees. What you can do is that if user double click on the line, the program displays pop up window where user can change values and then transfer these changes back to ALV tree.

    Cheers

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      You can implement it as below:

      FORM frm_assign_budget.

      DATA: lt_selected_nodes TYPE lvc_t_nkey,

      ls_selected_node LIKE LINE OF lt_selected_nodes.

      DATA: ls_tree LIKE LINE OF gt_tree.

      ======================================================================

      *先取得选中的预算行

      ======================================================================

      CALL METHOD g_tree->get_selected_nodes

      CHANGING

      ct_selected_nodes = lt_selected_nodes

      EXCEPTIONS

      cntl_system_error = 1

      dp_error = 2

      failed = 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.

      READ TABLE lt_selected_nodes INTO ls_selected_node INDEX 1.

      IF sy-subrc NE 0.

      MESSAGE 'You have not select any row'(011) TYPE 'I'.

      RETURN.

      ENDIF.

      CALL METHOD g_tree->get_outtab_line

      EXPORTING

      i_node_key = ls_selected_node

      IMPORTING

      e_outtab_line = ls_tree

      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.

      ======================================================================

      *检测选择的数据是否可进行预算分配

      ======================================================================

      IF ls_tree IS INITIAL.

      MESSAGE 'You have not select any row'(011) TYPE 'I'.

      RETURN.

      ENDIF.

      IF ls_tree-asset_class EQ ''.

      MESSAGE 'You have not select any row'(011) TYPE 'I'.

      RETURN.

      ENDIF.

      IF ls_tree-aufnr NE ''.

      MESSAGE 'The budget had been assigned cannot be edited'(012) TYPE 'I'.

      RETURN.

      ENDIF.

      ======================================================================

      *弹出输入框让用户输入预算

      ======================================================================

      DATA: lt_sval TYPE STANDARD TABLE OF sval INITIAL SIZE 0,

      ls_sval TYPE sval,

      l_returncode TYPE c,

      l_budget TYPE z01fis4111-budget.

      MOVE 'Z01FIS4111' TO ls_sval-tabname.

      MOVE 'WAERS' TO ls_sval-fieldname.

      MOVE g_waers TO ls_sval-value.

      MOVE '02' TO ls_sval-field_attr.

      APPEND ls_sval TO lt_sval.

      CLEAR ls_sval.

      MOVE 'Z01FIS4111' TO ls_sval-tabname.

      MOVE 'BUDGET' TO ls_sval-fieldname.

      APPEND ls_sval TO lt_sval.

      CALL FUNCTION 'POPUP_GET_VALUES'

      EXPORTING

      popup_title = 'Asset Budget Assignment'(008)

      IMPORTING

      returncode = l_returncode

      TABLES

      fields = lt_sval

      EXCEPTIONS

      error_in_fields = 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.

      CHECK l_returncode EQ ''.

      READ TABLE lt_sval INTO ls_sval INDEX 2.

      CHECK sy-subrc EQ 0.

      MOVE ls_sval-value TO l_budget.

      CHECK l_budget GT 0.

      CALL METHOD g_tree->change_item

      EXPORTING

      i_node_key = ls_selected_node

      i_fieldname = 'BUDGET'

      i_data = l_budget

      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 g_tree->update_calculations.

      CALL METHOD g_tree->frontend_update .

      ENDFORM.