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

DropDown Handler in ALV Grid

Former Member
0 Likes
1,701

Hi All,

I have set a drop down for a cell of my ALVGrid.

I have used DropDown Alias table...

Unfortunatly data are not well transported to my internal table

do you have any ideo of the problem:

In field catalog:

      WHEN 'STATUSTXT'.
* Set the status as dropdown
        ls_fcat-drdn_hndl = '1'.
        ls_fcat-drdn_alias = 'X'.
        ls_fcat-outputlen = 7.
      WHEN 'ERRORTXT'.
** set the ERROR as Dropdown without change possible
        ls_fcat-drdn_hndl = '2'.
        ls_fcat-drdn_alias = 'X'.
        ls_fcat-outputlen = 7.

In abap:


*&---------------------------------------------------------------------*
*&      Form  set_drdn_table
*&---------------------------------------------------------------------*
FORM set_drdn_table.
*§1.Define a dropdown table and pass it to ALV.
*   One listbox is referenced by a handle, e.g., '1'.
*   For each entry that shall appear in this listbox
*   you have to append a line to the dropdown table
*   with handle '1'.
*   This handle can be assigned to several columns
*   of the output table using the field catalog.
*
  DATA: li_alias TYPE lvc_t_dral,
        lw_alias LIKE LINE OF li_alias .

*1/ set the possible values for the status
  DATA : li_status TYPE zttmdi_status_list,
** list of all the status
         lw_status LIKE LINE OF li_status.
  PERFORM get_allowed_status(saplzvmdi_wf)
              USING
                  c_role
                  'X'
              CHANGING
                  li_status.
** fill li_alias with
** diff codes and text for the dropdown of the status!
  LOOP AT li_status INTO lw_status.
    lw_alias-handle = '1'.
    lw_alias-value = lw_status-zzmdistattxt.
    lw_alias-int_value = lw_status-zzmdistat.
    IF lw_alias-value IS INITIAL.
      lw_alias-value = lw_alias-int_value .
    ENDIF.
    APPEND lw_alias TO li_alias.
  ENDLOOP.

*2/ set the possible values for the error
  DATA : li_error TYPE zttmdi_error_list,
         lw_error LIKE LINE OF li_error .
  PERFORM get_error(saplzvmdi_wf)
              CHANGING
                 li_error.
** fill li_alias with
** diff codes and text for the dropdown of the status!
  LOOP AT li_error INTO lw_error.
    lw_alias-handle = '2'.
    lw_alias-value = lw_error-errortxt.
    lw_alias-int_value = lw_error-error.
    IF lw_alias-value IS INITIAL.
      lw_alias-value = lw_alias-int_value .
    ENDIF.
    APPEND lw_alias TO li_alias.
  ENDLOOP.



  CALL METHOD go_handler->ato_grid->set_drop_down_table
    EXPORTING
      it_drop_down_alias = li_alias.
ENDFORM.                    "set_drdn_table

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
836

Hi,

1.definition

    HANDLE_DATA_CHANGED FOR EVENT DATA_CHANGED
                         OF CL_GUI_ALV_GRID
                         IMPORTING ER_DATA_CHANGED
                                   E_ONF4
                                   E_ONF4_BEFORE
                                   E_ONF4_AFTER.

2.implementation

METHOD HANDLE_DATA_CHANGED.
    DATA: X_CHANGE TYPE LVC_S_MODI,
          X_FINAL TYPE T_FINAL,
          X_OCRC LIKE LINE OF IT_OCRC,
          L_FLAG.

LOOP AT ER_DATA_CHANGED->MT_GOOD_CELLS INTO X_CHANGE.
      IF X_CHANGE-FIELDNAME = 'ZZOCHOLDRC'.
    READ TABLE IT_FINAL INTO X_FINAL 
                         INDEX X_CHANGE-ROW_ID.
        IF SY-SUBRC = 0.
      READ TABLE IT_OCRC INTO X_OCRC WITH 
                      KEY  ZZOCHOLDRC = X_CHANGE-VALUE
                                 TRANSPORTING ZZRCDESC.

          IF SY-SUBRC = 0.
            X_FINAL-ZZRCDESC = X_OCRC-ZZRCDESC.
  MODIFY IT_FINAL FROM X_FINAL INDEX X_CHANGE-ROW_ID
                                  TRANSPORTING ZZRCDESC.
          ENDIF.
        ENDIF.
      ENDIF.
ENDLOOP.
ENDMETHOD.

in this data changed method modify your itab, from changed content.

regards

vijay

1 REPLY 1
Read only

Former Member
0 Likes
837

Hi,

1.definition

    HANDLE_DATA_CHANGED FOR EVENT DATA_CHANGED
                         OF CL_GUI_ALV_GRID
                         IMPORTING ER_DATA_CHANGED
                                   E_ONF4
                                   E_ONF4_BEFORE
                                   E_ONF4_AFTER.

2.implementation

METHOD HANDLE_DATA_CHANGED.
    DATA: X_CHANGE TYPE LVC_S_MODI,
          X_FINAL TYPE T_FINAL,
          X_OCRC LIKE LINE OF IT_OCRC,
          L_FLAG.

LOOP AT ER_DATA_CHANGED->MT_GOOD_CELLS INTO X_CHANGE.
      IF X_CHANGE-FIELDNAME = 'ZZOCHOLDRC'.
    READ TABLE IT_FINAL INTO X_FINAL 
                         INDEX X_CHANGE-ROW_ID.
        IF SY-SUBRC = 0.
      READ TABLE IT_OCRC INTO X_OCRC WITH 
                      KEY  ZZOCHOLDRC = X_CHANGE-VALUE
                                 TRANSPORTING ZZRCDESC.

          IF SY-SUBRC = 0.
            X_FINAL-ZZRCDESC = X_OCRC-ZZRCDESC.
  MODIFY IT_FINAL FROM X_FINAL INDEX X_CHANGE-ROW_ID
                                  TRANSPORTING ZZRCDESC.
          ENDIF.
        ENDIF.
      ENDIF.
ENDLOOP.
ENDMETHOD.

in this data changed method modify your itab, from changed content.

regards

vijay