Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Update Itab flag using ALV Grid

hi experts,

can you help me with this. i created a report that generates data from pa2006 using alv grid display then i added checkbox on the display. what i want is when i tick the checkbox it should modify the itab-flag field = 'X'. So that when i call the Delete command only data with flag='X' should be deleted in the itab and in pa2006.

here my source sode.

TYPE-POOLS: slis.

TABLES: pa0000, pa2006.

TYPES: BEGIN OF t_pa2006,
  pernr LIKE pa2006-pernr,
  begda LIKE pa2006-begda,
  endda LIKE pa2006-endda,
  subty LIKE pa2006-subty,
  anzhl LIKE pa2006-anzhl,
  flag(1) TYPE c,
  END OF t_pa2006.
DATA: it_pa2006 TYPE TABLE OF t_pa2006,
      gs_pa2006 TYPE t_pa2006.

DATA: gt_pa2006 TYPE TABLE OF pa2006.

* alv display
DATA: t_fieldcat TYPE slis_t_fieldcat_alv,
      l_fieldcat TYPE slis_fieldcat_alv,
      t_layout   TYPE slis_layout_alv.

DATA: answer(5).
DATA: lt_rows TYPE lvc_t_row.
DATA: lt_index LIKE LINE OF lt_rows.
DATA: g_grid TYPE REF TO cl_gui_alv_grid.

SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text-001.
SELECT-OPTIONS: pernr FOR pa2006-pernr NO INTERVALS,
                begda FOR pa2006-begda,
                endda FOR pa2006-endda,
                subty FOR pa2006-subty NO INTERVALS.

SELECTION-SCREEN END OF  BLOCK blk.
START-OF-SELECTION.
  SET PF-STATUS 'ZSTANDARD'.
  PERFORM get_pa2006.

END-OF-SELECTION.
  PERFORM display.
*----------------------------------------------------------------------*
* Form Set_pf_status
* Notes: Called by FM REUSE_ALV_GRID_DISPLAY
*----------------------------------------------------------------------*
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
  SET PF-STATUS 'ZSTANDARD'.
ENDFORM. "Set_pf_status
*&---------------------------------------------------------------------*
*&      Form  GET_PA2006
*&---------------------------------------------------------------------*
FORM get_pa2006 .
  DATA: wa_pa2006 TYPE pa2006.
  SELECT * FROM pa2006 INTO TABLE gt_pa2006 WHERE pernr IN pernr
                                        AND begda IN begda
                                        AND endda IN endda
                                        AND subty IN subty.
  IF gt_pa2006[] IS NOT INITIAL.
    LOOP AT gt_pa2006 INTO wa_pa2006.
      gs_pa2006-pernr = wa_pa2006-pernr.
      gs_pa2006-begda = wa_pa2006-begda.
      gs_pa2006-endda = wa_pa2006-endda.
      gs_pa2006-subty = wa_pa2006-subty.
      gs_pa2006-anzhl = wa_pa2006-anzhl.
      APPEND gs_pa2006 TO it_pa2006.
    ENDLOOP.
  ELSE.
    MESSAGE i001(00) WITH 'No data found!'.
    LEAVE LIST-PROCESSING.

  ENDIF.
ENDFORM.                    " GET_PA2006
*&---------------------------------------------------------------------*
*&      Form  DISPLAY
*&---------------------------------------------------------------------*
*       ALV Grid display
*----------------------------------------------------------------------*
FORM display .
  PERFORM t_field_cat.
  PERFORM alv_grid.
ENDFORM.                    " DISPLAY
*&---------------------------------------------------------------------*
*&      Form  T_FIELD_CAT
*&---------------------------------------------------------------------*
FORM t_field_cat .
  PERFORM fill_field USING 'CHECK'  'Chk' 'X' 'X' 'X'.
  PERFORM fill_field USING 'PERNR'  'Employee #' '' '' ''.
  PERFORM fill_field USING 'BEGDA'  'Begin Date' '' '' ''.
  PERFORM fill_field USING 'ENDDA'  'End Date' '' '' ''.
  PERFORM fill_field USING 'SUBTY'  'Subtype' '' '' ''.
  PERFORM fill_field USING 'ANZHL'  'Quota ' '' '' ''.

ENDFORM.                    " T_FIELD_CAT
*&---------------------------------------------------------------------*
*&      Form  FILL_FIELD
*&---------------------------------------------------------------------*
FORM fill_field  USING    p_fieldname
                          p_seltext
                          p_edit
                          p_chk
                          p_in.

  l_fieldcat-fieldname    = p_fieldname.
  l_fieldcat-tabname      = 'IT_PA2006'.
  l_fieldcat-seltext_l    = p_seltext.
  l_fieldcat-edit = p_edit.
  l_fieldcat-checkbox = p_chk.
  l_fieldcat-input = p_in.

  APPEND l_fieldcat TO t_fieldcat.
  CLEAR l_fieldcat.
ENDFORM.                    " FILL_FIELD

Former Member
replied

Sorry, I overlooked that I also removed the following line of code, as it caused problems:

l_fieldcat-checkbox = p_chk.

l_fieldcat-checkbox should not be filled.

Hope this helps.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question