Skip to Content
author's profile photo Former Member
Former Member

Add check box before each line

Hi All,

I am using alv grid to print the out put. It is comming correct. I want to add check box before each line of out put. How can I do it?

And in the selection screen I want delivery block p_lifsk as '01' fixed, so that user cannot change the value.

Please help me.

Thanks

Veni.

PERFORM get_data.
  PERFORM PROCESS_data.
  perform sub_alv_routines.
  perform comment_build  using t_list_top_of_page[].
  g_repid = sy-repid.
  perform alv_build_fieldcat using 'IT_OUTPUT' g_repid.
  perform sub_call_alv_grid tables it_output.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

13 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 13, 2006 at 02:08 AM

    Hi,

    By pressing the Control button you can select more than rows...

    Also it will be easy for you to handle if you are going to have additional buttons on the application toolbar..

    For the selected rows..You can just use the following statements..

    LOOP AT IT_OUTPUT WHERE CHECK = 'X'.

    ENDLOOP.

    If you are having a check box in the screen..And if you have additional buttons..It is not properly capturing the rows that are selected...I checked it..

    Let me know if you have any questions..

    Thanks,

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 11, 2006 at 09:43 PM

    add a field for the check box in the internal table and in the field catalog add a check box.

    eg:

    fcat_wa-col_pos = col_pos.

    fcat_wa-fieldname = field.

    fcat_wa-datatype = rtable.

    fcat_wa-inttype = rinttype.

    fcat_wa-outputlen = routputlength.

    fcat_wa-decimals_out = rdecimal.

    fcat_wa-seltext_l = rseltext.

    fcat_wa-ref_tabname = rtable.

    fcat_wa-key = key.

    fcat_wa-checkbox = checkbox.

    if you are updating the check box after the grid is created then dont forget to refresh the selected line

    rs-refresh = 'X'

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi KE,

      My field cat looks like this. where do you want me to add check box.

      and also how should I declare it in the internal table.

      Thanks

      Veni

      form alv_build_fieldcat using lt_output l_repid.

      call function 'REUSE_ALV_FIELDCATALOG_MERGE'

      exporting

      i_program_name = l_repid

      i_internal_tabname = lt_output

      i_inclname = l_repid

      changing

      ct_fieldcat = it_alv_field_cat[]

      exceptions

      inconsistent_interface = 1

      program_error = 2

      others = 3.

      if sy-subrc <> 0. "something went wrong...

      message id sy-msgid type sy-msgty number sy-msgno

      with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

      exit.

      endif.

      endform. " ALV_BUILD_FIELDCAT

  • author's profile photo Former Member
    Former Member
    Posted on Oct 11, 2006 at 10:43 PM

    what does your it_alv_field_cat[] have? it should be the catalog where you can include the check box. and in the above internal table it_output include a field with 1 char

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 11, 2006 at 10:43 PM

    Are you using ABAP OO or FM to display the ALV..

    Thanks,

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      Data: it_alv_field_cat type slis_fieldcat_alv occurs 0 with header line,

      I declared

      CBOX AS CHECKBOX in it_output.

      I am getting this error.

      "Unable to interpret "AS". Possible causes of error: Incorrect spelling or comma error."

      I am using FM only.

      Thanks

      Veni.

  • author's profile photo Former Member
    Former Member
    Posted on Oct 11, 2006 at 11:09 PM

    Hi,

    In the internal table it_output have a field for the check box..

    CHECK TYPE CHAR1,

    After calling the FIELDCATALOG_MERGE function module..Modify the fieldcatalog internal table..

    DATA: S_FIELDCATALOG type SLIS_T_FIELDCAT_ALV.

    s_fieldcatalog-checkbox = 'X'.

    MODIFY it_alv_field_cat from s_fieldcatalog

    transporting checkbox

    where fieldname = 'CHECK'.

    Thanks,

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Naren,

      I declared CBOX in it_output.

      I made the following changes, please look at it.

      Thanks

      Veni.

      <u>This is my previous code.</u>

      Data: it_alv_field_cat type slis_fieldcat_alv occurs 0 with header line,

      form alv_build_fieldcat using lt_output l_repid.

      call function 'REUSE_ALV_FIELDCATALOG_MERGE'

      exporting

      i_program_name = l_repid

      i_internal_tabname = lt_output

      i_inclname = l_repid

      changing

      ct_fieldcat = it_alv_field_cat[]

      exceptions

      inconsistent_interface = 1

      program_error = 2

      others = 3.

      if sy-subrc <> 0. "something went wrong...

      message id sy-msgid type sy-msgty number sy-msgno

      with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

      exit.

      endif.

      endform. " ALV_BUILD_FIELDCAT

      <u>I changed it to,</u>

      DATA: S_FIELDCATALOG type SLIS_T_FIELDCAT_ALV.

      form alv_build_fieldcat using lt_output l_repid.

      s_fieldcatalog-checkbox = 'X'.

      call function 'REUSE_ALV_FIELDCATALOG_MERGE'

      exporting

      i_program_name = l_repid

      i_internal_tabname = lt_output

      i_inclname = l_repid

      changing

      ct_fieldcat = s_fieldcatalog[]

      exceptions

      inconsistent_interface = 1

      program_error = 2

      others = 3.

      if sy-subrc <> 0. "something went wrong...

      message id sy-msgid type sy-msgty number sy-msgno

      with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

      exit.

      endif.

      endform. " ALV_BUILD_FIELDCAT

  • author's profile photo Former Member
    Former Member
    Posted on Oct 12, 2006 at 02:46 AM

    Hi,

    The changes are marked in bold..

    form alv_build_fieldcat using lt_output l_repid.

    <b>DATA: S_FIELDCATALOG type SLIS_T_FIELDCAT_ALV.</b>

    call function 'REUSE_ALV_FIELDCATALOG_MERGE'

    exporting

    i_program_name = l_repid

    i_internal_tabname = lt_output

    i_inclname = l_repid

    changing

    ct_fieldcat = s_fieldcatalog[]

    exceptions

    inconsistent_interface = 1

    program_error = 2

    others = 3.

    if sy-subrc <> 0. "something went wrong...

    message id sy-msgid type sy-msgty number sy-msgno

    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    exit.

    endif.

    <b>s_fieldcatalog-checkbox = 'X'.

    MODIFY it_alv_field_cat from s_fieldcatalog

    transporting checkbox

    where fieldname = 'CBOX'.</b>

    endform. " ALV_BUILD_FIELDCAT

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thank you Naren,

      I tried it with the changes. It is now giving me the error saying '"S_FIELDCATALOG" is a table without a header line and therefore has no component called "BOX_FIELDNAME". '

      it is comming at

      s_fieldcatalog-checkbox = 'X'.

      Thank you

      Veni.

  • author's profile photo Former Member
    Former Member
    Posted on Oct 12, 2006 at 05:21 PM

    Hi,

    Declare the s_fieldcatalog..

    DATA: S_FIELDCATALOG type slis_fieldcat_alv..

    Thanks,

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 12, 2006 at 06:17 PM

    Hi,

    Did you do the modify statement as I mentioned above..

    MODIFY it_alv_field_cat from s_fieldcatalog

    transporting checkbox

    where fieldname = 'CBOX'.

    THanks,

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 12, 2006 at 06:26 PM

    Hi,

    Check this sample program..

    TYPE-POOLS: slis.

    DATA: BEGIN OF itab1 OCCURS 0,

    check TYPE c,

    vbeln LIKE vbep-vbeln,

    posnr LIKE vbep-posnr,

    END OF itab1.

    DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.

    DATA: v_repid TYPE syrepid.

    v_repid = sy-repid.

    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

    i_program_name = v_repid

    i_internal_tabname = 'ITAB1'

    i_inclname = v_repid

    CHANGING

    ct_fieldcat = t_fieldcatalog.

    DATA: s_fieldcatalog TYPE slis_fieldcat_alv.

    s_fieldcatalog-checkbox = 'X'.

    s_fieldcatalog-edit = 'X'.

    MODIFY t_fieldcatalog FROM s_fieldcatalog

    TRANSPORTING checkbox edit

    WHERE fieldname = 'CHECK'.

    DATA: s_layout TYPE slis_layout_alv.

    SELECT vbeln posnr UP TO 10 ROWS

    FROM vbep

    INTO CORRESPONDING FIELDS OF TABLE itab1.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_callback_program = v_repid

    it_fieldcat = t_fieldcatalog

    is_layout = s_layout

    TABLES

    t_outtab = itab1

    EXCEPTIONS

    program_error = 1

    OTHERS = 2.

    Thanks,

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Naren,

      I checked the sample program. I did not see much difference. I just added s_fieldcatalog-edit = 'X'.

      Then I ran the program, no luck, no check box in out put.

      I am sending my program and include, can you please check it.

      Thanks

      Veni.

      REPORT ZSDR_DELIBLOCK
             no standard page heading line-size 255.
      
      *TYPE-POOLS: slis.
      TABLES: LIKP, TVLS.
      
      include zfri_alv_grid_db.
      
      data: g_repid like sy-repid.
      
      DATA: Begin of IT_LIKP occurs 0,
            VBELN like LIKP-VBELN,
            LFDAT like LIKP-LFDAT,
            KUNNR like LIKP-KUNNR,
            KNKLI LIKE LIKP-KNKLI,
            NETWR like LIKP-NETWR,
            End of IT_LIKP.
      
      DATA: Begin of IT_OUTPUT occurs 0,
            CHECK TYPE CHAR1,
            VBELN like LIKP-VBELN,
            LFDAT like LIKP-LFDAT,
            KUNNR like LIKP-KUNNR,
            KNKLI LIKE LIKP-KNKLI,
            NETWR like LIKP-NETWR,
            End of IT_OUTPUT.
      
      SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
      SELECT-OPTIONS: S_LFDAT FOR LIKP-LFDAT,
                      S_LIFSK FOR LIKP-LIFSK,
                      S_KUNNR FOR LIKP-KUNNR.
      PARAMETERS: P_LIFSK TYPE LIKP-LIFSK DEFAULT '01'.
      
      SELECTION-SCREEN END OF BLOCK b1.
      
      at selection-screen output.
      
        loop at screen.
          if screen-name = 'P_LIFSK'.
            screen-input = 0.
            modify screen.
          endif.
        endloop.
      
      start-of-selection.
        PERFORM get_data.
        PERFORM PROCESS_data.
        perform sub_alv_routines.
        perform comment_build  using t_list_top_of_page[].
        g_repid = sy-repid.
        perform alv_build_fieldcat using 'IT_OUTPUT' g_repid.
        perform sub_call_alv_grid tables it_output.
      
      FORM get_data.
        SELECT VBELN LFDAT KUNNR KNKLI NETWR
                      FROM LIKP
                      INTO TABLE IT_LIKP
                      WHERE LFDAT IN S_LFDAT
                        AND LIFSK IN S_LIFSK
                        AND KUNNR IN S_KUNNR
                        AND LIFSK = P_LIFSK.
      ENDFORM.                    " get_data
      
      FORM process_data.
      
        loop at it_LIKP.
          if sy-subrc = 0.
            move-corresponding it_LIKP to it_output.
            append it_output.
            clear it_output.
          endif.
        endloop.
      
      ENDFORM.                    " process_data
      
      
      form top_of_page .
        call function 'REUSE_ALV_COMMENTARY_WRITE'
                 exporting
                   i_logo             = 'HTMLCNTL_TESTHTM2_SAPLOGO'
      *              i_logo             = 'ENJOYSAP_LOGO'
                      it_list_commentary = t_list_top_of_page.
      
      endform.                    "top_of_page
      
      form comment_build using lt_top_of_page type slis_t_listheader.
        data:
            ls_line type slis_listheader.
      *  Company code
        clear ls_line.
        ls_line-typ  = 'S'.
        ls_line-key  = 'customer'.
        ls_line-info = s_kunnr.
        append ls_line to lt_top_of_page.
      endform.                    " comment_build
      

      -


      
      data:
        g_variant              like  disvariant.          "variants
      
      type-pools:  slis.                                "Global types
      
      data: s_alv_layout_cat          type slis_layout_alv.
      data: s_alv_print_cat           type slis_print_alv.
      
      data: it_alv_field_cat type slis_fieldcat_alv occurs 0 with header line,
            S_FIELDCATALOG type slis_fieldcat_alv occurs 0 with header line,
            i_fieldcat type slis_fieldcat_alv occurs 0 with header line,
            w_fieldcat like line of i_fieldcat.        "ALV FieldCat WorkArea
      * ALV sort catalog
      data: it_alv_sort_cat type slis_sortinfo_alv occurs 0 with header line.
      * ALV event catalog
      data: it_alv_event_cat type slis_alv_event occurs 0 with header line.
      data: t_list_top_of_page type slis_t_listheader.
      
      form sub_alv_routines.
      * Populate the layout catalog for alv
        perform alv_layout.
      * Populate the event catalog for alv
        perform alv_events.
      * Populate the print catalog for alv
        perform alv_print.
      endform.                 "sub_alv_routines
      
      form sub_call_alv_grid tables lt_output.
      
      * Call ALV display
        call function 'REUSE_ALV_GRID_DISPLAY'
             exporting
                  i_callback_program      = sy-cprog
                  is_layout               = s_alv_layout_cat
                  i_callback_user_command = 'USER_COMMAND'
                  it_fieldcat             = it_alv_field_cat[]
      *           it_sort                 = it_alv_sort_cat[]
                  i_save                  = 'A'
                  is_variant              = g_variant
                  it_events               = it_alv_event_cat[]
                  is_print                = s_alv_print_cat
                  i_grid_title            = text-t01
             tables
                  t_outtab                = lt_output
             exceptions
                  program_error           = 1
                  others                  = 2.
      
      
      *  if sy-subrc <> 0.
      *    message e048. "Error executing func. module REUSE_ALV_LIST_DISPLAY
      *  endif.
      
      
      endform.                    " sub_call_alv_grid
      
      form alv_layout.
      
      * Enable striped output display if user wants
        s_alv_layout_cat-zebra                = 'X'.
      * Optimize column width if user wants
        s_alv_layout_cat-colwidth_optimize    = 'X'.
        s_alv_layout_cat-box_fieldname        = space.
        s_alv_layout_cat-no_input             = 'X'.
      *  if p_lines = 'X'.
      *    s_alv_layout_cat-no_vline           = ' '.
      *  else.
      *    s_alv_layout_cat-no_vline           = 'X'.
      *  endif.
        s_alv_layout_cat-no_colhead           = ' '.
        s_alv_layout_cat-lights_condense      = 'X'.
        s_alv_layout_cat-info_fieldname       = 'ALV_COLOR'.
        s_alv_layout_cat-confirmation_prompt  = 'X'.
        s_alv_layout_cat-detail_popup         = 'X'.
        s_alv_layout_cat-detail_initial_lines = 'X'.
      
      endform.                    " alv_layout
      
      form alv_events.
      * Declare event catalog for page headers
        clear it_alv_event_cat.
        it_alv_event_cat-name = 'TOP_OF_PAGE'.
        it_alv_event_cat-form = 'TOP_OF_PAGE'.
        append it_alv_event_cat.
      
      * Declare event catalog for report footers
        clear it_alv_event_cat.
        it_alv_event_cat-name = 'END_OF_LIST'.
        it_alv_event_cat-form = 'END_OF_LIST'.
      *  append it_alv_event_cat.
      
      
      endform.                    " alv_events
      
      form alv_print.
      * Declare print catalog for statistics page
        s_alv_print_cat-no_print_listinfos = 'X'.
      
      endform.                    " alv_print
      
      
      form alv_build_fieldcat  using lt_output  l_repid.
      * This function module will build the bulk of the field catalog,
      * but apparently there is still need for some changes...
      * cannot use sy-repid for i_program_name
      * i_inclname must be hardcoded for this to work
      * i_internal_tabname must be in capital letters
      
      *DATA: S_FIELDCATALOG type SLIS_T_FIELDCAT_ALV occurs 0.
      
        call function 'REUSE_ALV_FIELDCATALOG_MERGE'
             exporting
                i_program_name         = l_repid
                i_internal_tabname     = lt_output
      *         I_CLIENT_NEVER_DISPLAY = 'X'
                i_inclname             = l_repid
             changing
                ct_fieldcat            = it_alv_field_cat[]
            exceptions
                 inconsistent_interface = 1
                 program_error          = 2
                 others                 = 3.
      
        if sy-subrc <> 0.                    "something went wrong...
          message id sy-msgid type sy-msgty number sy-msgno
                  with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          exit.
        endif.
      
        s_fieldcatalog-checkbox = 'X'.
        s_fieldcatalog-edit = 'X'.
      
        MODIFY it_alv_field_cat from s_fieldcatalog
        transporting checkbox
        where fieldname = 'CHECK'.
      
      endform.                    " ALV_BUILD_FIELDCAT
      

  • author's profile photo Former Member
    Former Member
    Posted on Oct 12, 2006 at 10:16 PM

    Hi,

    In the internal table it_output use type c instead of type char1 for the field check..

    DATA: Begin of IT_OUTPUT occurs 0,

    <b> CHECK TYPE C,</b>

    VBELN like LIKP-VBELN,

    LFDAT like LIKP-LFDAT,

    KUNNR like LIKP-KUNNR,

    KNKLI LIKE LIKP-KNKLI,

    NETWR like LIKP-NETWR,

    End of IT_OUTPUT.

    THanks,

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thank you very much Naren.

      I dont know how I ignored that. Now I have the check boxes in column1. But these are disabled. How can I make these enable, so that I can check the required deliveries for processing.

      Thanks

      Veni.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.