cancel
Showing results for 
Search instead for 
Did you mean: 

how to add editable check box in alv

Former Member
0 Kudos

hai,

1)How to add editable checkbox in normal alv with out using class and method.

thanks in advance

kiran

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

Here is the entire code...paste it and execute it.


REPORT zsomalv3 NO STANDARD PAGE HEADING.

TYPE-POOLS: slis.

DATA: BEGIN OF i_data OCCURS 0,
        qmnum      LIKE qmel-qmnum,
        qmart      LIKE qmel-qmart,
        qmtxt      LIKE qmel-qmtxt,
        ws_row     TYPE i,
        ws_char(5) TYPE c,
        chk,
      END OF i_data.

DATA: report_id  LIKE sy-repid.
DATA: ws_title   TYPE lvc_title VALUE 'An ALV Report'.
DATA: i_layout   TYPE slis_layout_alv.
DATA: i_fieldcat TYPE slis_t_fieldcat_alv.

SELECT qmnum
       qmart
       qmtxt
       INTO TABLE i_data
       FROM qmel
       WHERE qmnum <= '00030000010'.


LOOP AT i_data.
  i_data-ws_row = sy-tabix.
  i_data-ws_char = 'AAAAA'.
  MODIFY i_data.
ENDLOOP.

report_id = sy-repid.
PERFORM f1000_layout_init CHANGING i_layout.
PERFORM f2000_fieldcat_init CHANGING i_fieldcat.


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
 EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                =
*   I_BUFFER_ACTIVE                   = ' '
   i_callback_program                = report_id
*   I_CALLBACK_PF_STATUS_SET          = ' '
*   I_CALLBACK_USER_COMMAND           = ' '
*   I_CALLBACK_TOP_OF_PAGE            = ' '
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   i_structure_name                  = ' '
*   I_BACKGROUND_ID                   = ' '
   i_grid_title                      = ws_title
*   I_GRID_SETTINGS                   =
   is_layout                         = i_layout
   it_fieldcat                       = i_fieldcat
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
   i_save                            = 'A'
*   IS_VARIANT                        =
*   IT_EVENTS                         =
*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_ADD_FIELDCAT                   =
*   IT_HYPERLINK                      =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
  TABLES
    t_outtab                          = i_data
 EXCEPTIONS
   program_error                     = 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.

*&---------------------------------------------------------------------*
*&      Form  F1000_Layout_Init
*&---------------------------------------------------------------------*

FORM f1000_layout_init USING i_layout TYPE slis_layout_alv.

  CLEAR i_layout.
  i_layout-colwidth_optimize = 'X'.
  i_layout-edit = 'X'.

ENDFORM.                    " F1000_Layout_Init
*&---------------------------------------------------------------------*
*&      Form  f2000_fieldcat_init
*&---------------------------------------------------------------------*
FORM f2000_fieldcat_init CHANGING i_fieldcat TYPE slis_t_fieldcat_alv.

  DATA: line_fieldcat TYPE slis_fieldcat_alv.

  CLEAR line_fieldcat.
  line_fieldcat-fieldname = 'QMNUM'.     " The field name and the table
  line_fieldcat-tabname   = 'I_DATA'.    " name are the two minimum req.
  line_fieldcat-key       = 'X'.  " Specifies the column as a key (Blue)
  line_fieldcat-seltext_m = 'Notification No.'. " Column Header
  APPEND line_fieldcat TO i_fieldcat.

  CLEAR line_fieldcat.
  line_fieldcat-fieldname = 'QMART'.
  line_fieldcat-ref_tabname = 'I_DATA'.
  line_fieldcat-hotspot = 'X'.           " Shows the field as a hotspot.
  line_fieldcat-seltext_m = 'Notif Type'.
  APPEND line_fieldcat TO i_fieldcat.

  CLEAR line_fieldcat.
  line_fieldcat-fieldname = 'QMTXT'.
  line_fieldcat-tabname   = 'I_DATA'.
  line_fieldcat-seltext_m = 'Description'.
  APPEND line_fieldcat TO i_fieldcat.

  CLEAR line_fieldcat.
  line_fieldcat-fieldname = 'WS_ROW'.
  line_fieldcat-tabname   = 'I_DATA'.
  line_fieldcat-seltext_m = 'Row Number'.
  APPEND line_fieldcat TO i_fieldcat.

  CLEAR line_fieldcat.
  line_fieldcat-fieldname = 'WS_CHAR'.
  line_fieldcat-tabname   = 'I_DATA'.
  line_fieldcat-seltext_l = 'Test Character Field'.
  line_fieldcat-datatype  = 'CHAR'.
  line_fieldcat-outputlen = '15'.     " You can specify the width of a
  APPEND line_fieldcat TO i_fieldcat. " column.

  CLEAR line_fieldcat.
  line_fieldcat-fieldname = 'CHK'.
  line_fieldcat-tabname   = 'I_DATA'.
  line_fieldcat-seltext_l = 'Checkbox'.
  line_fieldcat-checkbox  = 'X'.      " Display this field as a checkbox
  line_fieldcat-edit      = 'X'.      " This option ensures that you can
  " edit the checkbox. Else it will
  " be protected.
  APPEND line_fieldcat TO i_fieldcat.

ENDFORM.                    " f2000_fieldcat_init

Regs,

Venkat

Former Member
0 Kudos

Hi Venkat or anyone else,

Using the FM ALV grid, what event do you use to have the internal table (in your sample, i_data) updated with the new checkbox value after it has been updated from the ALV grid?

I tried using event MODIFY_LIST, but I could need get it to be executed.

Thanks!

Former Member
0 Kudos

I found out how the internal table updated with the new value of the edited field.

When calling function module REUSE_ALV_GRID_DISPLAY, you need to pass into I_GRID_SETTINGS with field EDT_CLL_CB set to 'X'.

The table is automatically updated with the new value.

Mike V.

Former Member
0 Kudos

Hi,

Add this piece of code in FIELD CATALOG form. U will get it.

CLEAR line_fieldcat.

line_fieldcat-fieldname = 'CHK'.

line_fieldcat-tabname = 'I_DATA'.

line_fieldcat-seltext_l = 'Checkbox'.

line_fieldcat-checkbox = 'X'.

line_fieldcat-edit = 'X'.

APPEND line_fieldcat TO i_fieldcat.

If you want the entire program let me know. Will give you.

Regs,

Venkat Ramanan

Former Member
0 Kudos

hi venkat,

i want the entire program.could you send me.

kiran

Former Member
0 Kudos

Hello

Do you have always your problem to add editable chechbox in normal alv? I have the same problem... Maybe you have already a solution? Sorry for my bad english...

Greetings from Switzerland.

Erich

Former Member
0 Kudos

Hi kiran,

You have to fill the loyout structure to have check box in alv.

Interaction

box_fieldname type slis_fieldname, " fieldname for checkbox

box_tabname type slis_tabname," tabname for checkbox

box_rollname like dd03p-rollname," rollname for checkbox

for interaction in checkbox see the example program

BALVST02_GRID

Regards,

vijay.

Former Member
0 Kudos

Kiran,

I don't why you are using the function modules for the editable ALV's. My suggestion go for Grid control and it will be very easy.

All you have to do is in the field catalog make that field editable by putting in the value 'X' in the field EDIT. Also check the field CHECKBOX so that it is displayed as a checkbox. This will be of the type LVC_T_FCAT.

If you are bent upon using the function module in the table IT_FIELDCATALOG also there is a field called CHECKBOX. So, just fill it and should display the checkbox.

However, I don't think you can have an editable ALV with function modules. Correct me if I am wrong.

You don't need to fill the layout struture

Ravi

Former Member
0 Kudos

hai ravi.

Actually we are doing enhacement of a report,in that they have used the function module.Now can i use classes along with function module.could you send some example sample.is gridcontrol and class are same.

thanks in advance

kiran

Former Member
0 Kudos

Kiran,

For one single report you cannot use a function module as well as class.

Yes, the grid control and the class that I mentioned are one and the same.

Look at this weblog of mine.

/people/ravikumar.allampallam/blog/2005/06/01/alv-reporting-using-controls--part-i

or

/people/ravikumar.allampallam/blog/2005/06/01/alv-reporting-using-controls-control-layouts--part-ii

Here is the easy ref. guide to the grid control.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/e8a1d690-0201...

Regards,

Ravi

Former Member
0 Kudos

Ravi,

Thanks for what you have given.But the problem is that we already used REUSE_ALV_GRID_DISPLAY so can i make any changes using this one.

regards

kiran