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

Dynamic checkboxes generation based on table

Hello masters,

I'm new in ABAP and I'm hardly trying to generate dynamically checkboxes based on X number of rows in a table.

Example:

table_field1 --> checkbox 1

table_field2 --> checkbox 2

table_field3 --> checkbox 3

I really need help cause I'm lost... 😔

Regards,

Arthur

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    Posted on Apr 25, 2016 at 12:58 PM

    Hi,

    Do you want to create no of check boxes based on number of rows.??

    if yes then create a new internal table (similar to table which holds the data )with a additional fields CHECKBOX and pass the data of your another internal table in this new internal table.. in each row you will get new field of checkbox.

    LOOP AT itab1. " table which holds data

    MOVE-CORRESPONDING itab1 TO itab2.

    APPEND itab2. " table which have addition checkbox field.

    ENDLOOP.

    in field catalog made the corresponding declaration so it can appear as checkbox in the output, if you want to display any output.

    fieldcat-checkbox = 'X'.

    fieldcat-input = 'X'.

    fieldcat-edit = 'X'.

    and if you are having one table from which you are fetching data then you can use the following way.

    types: begin of ty_vbak,

    checkbox type c.

    include structure vbak,

    types: end of ty_vbak.

    data: wavbak type ty_vbak

    select single * from vbak into corresponding fields of wavbak where vbeln = p_vbeln.

    thanks!!

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 25, 2016 at 01:16 PM

    Dear Arthur ,

    as per my understand , requirement is to generate 'X' no of times = db records.

    need to gather the records based on query and pass it into final output internal table.

    in the field catalog need to write the below code.

    wa_fieldcat-fieldname = 'CHECKBOX'.

    ADD 1 TO wf_pos.

    wa_fieldcat-col_pos = wf_pos.

    wa_fieldcat-datatype = 'C'.

    wa_fieldcat-outputlen = '6'.

    wa_fieldcat-reptext = 'Select'.

    wa_fieldcat-coltext = 'Select'.

    wa_fieldcat-seltext = 'Select'.

    wa_fieldcat-tooltip = 'Select'.

    wa_fieldcat-checkbox = 'X'.

    wa_fieldcat-edit = 'X'.

    wa_fieldcat-key = ''.

    wa_fieldcat-icon = ''.

    APPEND wa_fieldcat TO it_fieldcat.

    and call nmethod.

    CALL METHOD alv_grid->set_table_for_first_display

    EXPORTING

    is_layout = gs_layout

    it_toolbar_excluding = lt_exclude

    CHANGING

    it_outtab = it_output

    it_fieldcatalog = it_fieldcat..

    I hope it would be useful to you .

    Regards,

    sudheer.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 25, 2016 at 06:26 PM

    If you know the maximum number of rows in the table, you can create checkboxes for all of them and then LOOP AT SCREEN to hide the ones you don't need.

    Rob

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 25, 2016 at 01:37 PM

    Thanks guys for your quick answer.

    But the checkboxes I have to generate are supposed to be on the selection screen and not in an ALV (sorry for the mistake).

    But may I could integrate an ALV on the selscreen ?

    Arthur

    Add a comment
    10|10000 characters needed characters exceeded

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.