Application Development 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: 

radiobutton or checkbox in alv

Former Member
0 Kudos

Hy! I want to put a checkbox button or a radiobutton inside an alv showed using the function alv grid display. is it possible? thanx.

14 REPLIES 14

Former Member
0 Kudos

Hi fer,

1. CHeckbox is possible (radio button not)

2. For that u declare ONE EXTRA FIELD

OF TYPE C (1 CHARACTER)

IN THE INTERNAL TABLE.

3. Then in layout ,

use layout-box_fieldname = 'FLAG'

(where flag is the field name of the extra field)

4. This will display checkboxes.

regards,

amit m.

Former Member
0 Kudos

First of all define a fieldname of type c char1 and for that fieldname in the fieldcatalog<b> LVC_S_FCAT</b>

there is a field called <b>CHECKBOX</b>, u can make that as 'X'.

Hope thsi helps u to solve ur problem.

Former Member
0 Kudos

HI fer

ya , it is possible. you can radio button and check button.

for radio button the button type should be 4

for check box button it should be 5.

regards

kishore

0 Kudos

Eg:

data: fieldcatalog type lvc_s_fcat with header line.
  fieldcatalog-fieldname   = 'CBOX'.
  fieldcatalog-seltext_m   = 'Select'.
  fieldcatalog-col_pos     = 1.
  fieldcatalog-checkbox    = 'X'.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.

Former Member
0 Kudos

Hi fer,

1. sample program.

REPORT abc.

TYPE-POOLS : slis.

*----


Data

DATA : BEGIN OF itab OCCURS 0,

flag TYPE c.

INCLUDE STRUCTURE t001.

DATA : END OF itab.

DATA : alvfc TYPE slis_t_fieldcat_alv.

DATA : alvly TYPE slis_layout_alv.

*----


Select

SELECT * FROM t001 INTO TABLE itab.

*------- Field Catalogue

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = sy-repid

i_internal_tabname = 'ITAB'

i_inclname = sy-repid

CHANGING

ct_fieldcat = alvfc

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

*----


Display

alvly-box_fieldname = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

it_fieldcat = alvfc

is_layout = alvly

TABLES

t_outtab = itab

EXCEPTIONS

program_error = 1

OTHERS = 2.

regards,

amit m.

Former Member
0 Kudos

Create a variable checkbox(1) in your internal table and set ...

layout-box_fieldname = 'CHECKBOX'.

layout-box_tabname = 'I_OUTPUT'.

former_member188685
Active Contributor
0 Kudos

Hi,

you can do it,

declare one field of one char.

while filling filed cat for one char field

give the following

<b>fieldcat-checkbox = 'X'.</b> "for check box

regards

vijay

former_member188685
Active Contributor
0 Kudos
REPORT  Z_TEST7                                 .
*Table declaration
tables: vbak,vbap.

*internal table
data: begin of i_sales occurs 0,

      vbeln like vbak-vbeln,
      erdat like vbak-erdat,
      audat like vbak-audat,
      kunnr like vbak-kunnr,
      vkorg like vbak-vkorg,
      matnr like vbap-matnr,
      netpr like vbap-netpr,
      check type c,  "checkbox
      end of i_sales.

type-pools: slis.
data: v_fieldcat type slis_fieldcat_alv,
      gt_fieldcat type slis_t_fieldcat_alv,
      gt_layout type slis_layout_alv,
      gt_sort type slis_sortinfo_alv,
      fieldcat like line of gt_fieldcat.


*Selection screen
parameters: p_vkorg like vbak-vkorg.
select-options: s_vbeln for vbak-vbeln.

*start of selection.
start-of-selection.
  perform get_data.
  perform fill_fieldcatalog.
  perform write_data.
*&---------------------------------------------------------------------*
*&      Form  get_data
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_data .
  select a~vbeln a~erdat a~audat a~kunnr a~vkorg b~matnr b~netpr into

  corresponding fields of table i_sales from vbak
  as a inner join vbap as b on a~vbeln = b~vbeln
                    where  a~vkorg = p_vkorg and
                           a~vbeln in s_vbeln.

ENDFORM.                    " get_data
*&---------------------------------------------------------------------*
*&      Form  write_data
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM write_data .
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
     I_CALLBACK_PROGRAM                = sy-repid
*     IS_LAYOUT                         = gt_layout
     IT_FIELDCAT                       = gt_fieldcat
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
*     I_SAVE                            = 'X'
*   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_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   I_HTML_HEIGHT_TOP                 =
*   I_HTML_HEIGHT_END                 =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
    TABLES
      T_OUTTAB                          = i_sales
   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.

ENDFORM.                    " write_data
*&---------------------------------------------------------------------*
*&      Form  fill_fieldcatalog
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM fill_fieldcatalog .
  sort i_sales by vbeln.
  clear v_fieldcat.
"for check box
  v_fieldcat-col_pos = 1.
  v_fieldcat-fieldname = 'CHECK'.
  v_fieldcat-seltext_m = 'chek'.
  v_fieldcat-checkbox = 'X'.
  v_fieldcat-input = 'X'.
  v_fieldcat-edit = 'X'.
  append v_fieldcat to  gt_fieldcat.
  clear v_fieldcat.
  v_fieldcat-col_pos = 2.
  v_fieldcat-fieldname = 'VBELN'.
  v_fieldcat-seltext_m = 'Sales Document'.
  append v_fieldcat to  gt_fieldcat.
  clear v_fieldcat.
  v_fieldcat-col_pos = 3.
  v_fieldcat-fieldname = 'ERDAT'.
  v_fieldcat-seltext_m = 'Creation Date'.
  append v_fieldcat to  gt_fieldcat.
clear v_fieldcat.
  v_fieldcat-col_pos = 4.
  v_fieldcat-fieldname = 'AUDAT'.
  v_fieldcat-seltext_m = 'Document Date'.
  append v_fieldcat to  gt_fieldcat.
clear v_fieldcat.
  v_fieldcat-col_pos = 5.
  v_fieldcat-fieldname = 'KUNNR'.
  v_fieldcat-seltext_m = 'Customer'.
  append v_fieldcat to  gt_fieldcat.
clear v_fieldcat.
  v_fieldcat-col_pos = 6.
  v_fieldcat-fieldname = 'VKORG'.
  v_fieldcat-seltext_m = 'Sales Organization'.
  append v_fieldcat to  gt_fieldcat.
clear v_fieldcat.
  v_fieldcat-col_pos = 7.
  v_fieldcat-fieldname = 'MATNR'.
  v_fieldcat-seltext_m = 'Material'.
  append v_fieldcat to  gt_fieldcat.
clear v_fieldcat.
  v_fieldcat-col_pos = 8.
  v_fieldcat-fieldname = 'NETPR'.
  v_fieldcat-seltext_m = 'Net Value'.
  append v_fieldcat to  gt_fieldcat.
  clear v_fieldcat.
endform.

Regards

vijay

Former Member
0 Kudos

I am trying to use the function REUSE_ALV_POPUP_TO_SELECT

and it hasnt any item like layout, what can I do?

thanx!

0 Kudos

Hi fer,

1. For this FM, it has a parameter,

I_CHECKBOX_FIELDNAME = 'fieldname'

utilise this paramteer

2.

report abc.

data : t001 like table of t001 with header line.

SELECT * FROM T001 INTO TABLE T001.

CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'

EXPORTING

I_TITLE = 'abc'

I_SELECTION = 'X'

  • I_ALLOW_NO_SELECTION =

  • I_ZEBRA = ' '

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

I_CHECKBOX_FIELDNAME = 'KOKFI'

  • I_LINEMARK_FIELDNAME =

  • I_SCROLL_TO_SEL_LINE = 'X'

i_tabname = 'T001'

I_STRUCTURE_NAME = 'T001'

  • IT_FIELDCAT =

  • IT_EXCLUDING =

  • I_CALLBACK_PROGRAM =

  • I_CALLBACK_USER_COMMAND =

  • IS_PRIVATE =

  • IMPORTING

  • ES_SELFIELD =

  • E_EXIT =

tables

t_outtab = T001

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.

BREAK-POINT.

regards,

amit m.

0 Kudos

Hi,

its not a problem...

declare a field CHECK(1) in your internal table of type c. then fill fieldcat for rest of them..

 CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
           EXPORTING
              I_TITLE         = 'Test create IDoc'(012)
               I_SCREEN_START_COLUMN   = 30
               I_SCREEN_START_LINE     = 01
               I_SCREEN_END_COLUMN     = 100
               I_SCREEN_END_LINE       = 25
              <b> I_CHECKBOX_FIELDNAME    = 'CHECK'</b>
                I_TABNAME               = 'IT_VBAP'
               IT_FIELDCAT             = IT_FIELDCAT
          IMPORTING
               ES_SELFIELD              = WA_SELFIELD
           TABLES
                T_OUTTAB                = IT_VBAP
          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.

observe the bold one

Regards

vijay

0 Kudos

Hi Fer,

if you don't have a CHECK field in your internal table, it is difficult to capture the record. so you should have a field of type c with one char. that you need to mention while calling the FM .

Regards

vijay

0 Kudos

Hi,

I have created the check box, but i am not able to create Radio button in the popup. Is it possible to create a Radio button in the popup? If so can you suggest how we can get?

Regards,

Satheesh.

Former Member
0 Kudos

Hi Fer,

See this code ALV popup with checkbox

type-pools :slis.

DATA: begin of i_tab occurs 0.
       include structure sflight.
data:    w_chk type c.
data:       end of i_tab.

DATA: i_private TYPE slis_data_caller_exit,
      i_selfield TYPE slis_selfield,
      w_exit(1) TYPE c.

DATA: p_title TYPE sy-title VALUE 'Popup with Checkbox'.

START-OF-SELECTION.

  SELECT * FROM sflight INTO TABLE i_tab.

CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
  EXPORTING
   I_TITLE                       = P_TITLE
   I_CHECKBOX_FIELDNAME          = 'W_CHK'
    I_TABNAME                     = 'I_TAB'
   I_STRUCTURE_NAME              = 'SFLIGHT'
  TABLES
    T_OUTTAB                      = I_TAB
 EXCEPTIONS
   PROGRAM_ERROR                 = 1
   OTHERS                        = 2
          .
  LOOP AT i_tab WHERE w_chk = 'X'.
    WRITE: /  i_tab-carrid, i_tab-price.
  ENDLOOP.