Skip to Content

ALV - selecting row

Hi guys

I have a problem with adding row select option to my ALV.

Here's my code:

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

   I_STRUCTURE_NAME  = 'ZDEF_INTRASTAT'

CHANGING

    CT_FIELDCAT  = lt_fcat[]

EXCEPTIONS

   INCONSISTENT_INTERFACE = 1

   PROGRAM_ERROR  = 2

   OTHERS   = 3.

  DATA: g_variant TYPE disvariant,

        g_layo TYPE slis_layout_alv.

        g_layo-info_fieldname = 'COLOR'.

        g_variant-report  = sy-repid.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

   EXPORTING

    i_callback_program = sy-repid

    i_callback_user_command  = 'USER_COMMAND'

    i_callback_pf_status_set   = 'SUB_PF_STATUS'

    is_layout    = g_layo

    it_fieldcat   = lt_fcat

    i_save   = 'A'

    is_variant   = g_variant

    TABLES

      t_outtab   = gt_dane

EXCEPTIONS

   PROGRAM_ERROR = 1

   OTHERS   = 2.

FORM sub_pf_status USING rt_extab TYPE slis_t_extab..

  SET PF-STATUS 'ZSTANDARD'.

ENDFORM.

FORM user_command USING r_ucomm     LIKE sy-ucomm

                        rs_selfield TYPE slis_selfield.

     IF r_ucomm EQ 'CTR'.

       call TRANSACTION 'SM30'. "calling transaction sm30 with by button called CTR

     ENDIF.

ENDFORM.

and my table look like this:

If I add: "g_layo-box_fieldname = 'SELECT'." it looks like I would like it to be (select squares, marked red):

But if I press any button I some big error (I copied text to dump.txt file).

Can anyone help me with this error?

Best regards,

Bartlomiej

dump.txt.zip (1.5 kB)
ALV_1.PNG (41.8 kB)
ALV_2.PNG (51.5 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    Sep 09, 2014 at 08:11 PM

    So maybe I'll ask another question. What is the easiest way to get those select squares (like on second image)?

    If I click on any cell in table from first image the whole row is highlighted, does it mean that it is also selected? I am asking, because I want to call transaction with my button and pass some values (or I will read a little about batch input).

    Regards.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 10, 2014 at 05:19 AM

    Hi, Bartlomiej!

    What is the easiest way to get those select squares (like on second image)?

    One option for you is using checkboxes in a 1st field (as Mahesh suggested) so that user can select the necessary records. But I don't like that style because if you have 50 records on screen and you need to select 30 of them it's much easier to use a "built-in" solution instead of ticking every row. Just add the next line for your layout:

    g_layo-sel_mode = 'A'.
    And you'll get standard selection buttons to the left of your ALV table.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Bartlomiej Borucki

      Ah, sorry, I didn't notice you are using 'REUSE_ALV_GRID_DISPLAY'. I guess, in that case you'll have to add SELECT column in your outtab as Max suggested.

      But you can try to use 'REUSE_ALV_GRID_DISPLAY_LVC' instead. Then you'll be able to set g_layo-sel_mode (it's of type LVC_S_LAYO there).

  • avatar image
    Former Member
    Sep 10, 2014 at 05:54 AM

    Hi Bartlomiej,

    Refer this link...

    Regards

    Sreekanth

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 10, 2014 at 07:43 AM

    Hi Bartlomiej,

    lf ur layout g_layo is define as following

    DATA: g_layo TYPE lvc_s_layo.

    Then you can easily achieve your requirement of selection of records from the alv grid display just by adding the one line in your code.

    g_layo-sel_mode   =  'A'.

    With the above line you can solve your issue.

    Regards,

    Chakradhar.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 09, 2014 at 03:01 PM

    Hi

    ZDEF_INTRASTAT has a field called SELECT?


    Max

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Bartlomiej Borucki

      Hi

      You've add this code line:

      g_layo-box_fieldname = 'SELECT'.

      That means the internal table (GT_DANE) used to show the data by ALV has to have a field called SELECT, this field will be used to save the selection.

      I suppose the dump occur because your table hasn't that field

      If you want to use it, you need to insert that field in your internal table.(GT_DANE)

      So you need to decide how to add that field in GT_DANE, because I suppose it's defined as dictionary table (ZDEF_INTRASTAT), and I don't believe it's a good solution to change it.


      Probably you can define a dictionary structure includes ZDEF_INTRASTAT and here you can add SELECT field


      Of course if ZDEF_INTRASTAT is a structure you can try to change it

      Max

  • Sep 10, 2014 at 01:31 PM

    I have next question, but it doesn't have to be solved. Here's my code:

         PERFORM bdc_dynpro USING 'SAPMSVMA' '0100'.

         PERFORM bdc_field USING 'BDC_CURSOR' 'VIMDYNFLDS-LTD_DTA_AR'.

         PERFORM bdc_field USING 'BDC_OKCODE' '=UPD'.

         PERFORM bdc_field USING 'VIEWNAME' 'VEIAV'.

         PERFORM bdc_field USING 'VIMDYNFLDS-LTD_DTA_NO' ''.

         PERFORM bdc_field USING 'VIMDYNFLDS-LTD_DTA_AR' 'X'.

         PERFORM bdc_dynpro USING 'SAPLSVIX' '0210'.

         PERFORM bdc_field USING 'BDC_CURSOR' 'MARK_CHECKBOX(11)'.

         PERFORM bdc_field USING 'BDC_OKCODE' '=OKAY'.

         PERFORM bdc_field USING 'MARK_CHECKBOX(01)' 'X'.

         PERFORM bdc_field USING 'MARK_CHECKBOX(11)' 'X'.

         PERFORM bdc_dynpro USING 'SAPLSVIX' '0100'.

         PERFORM bdc_field USING 'BDC_CURSOR' 'D0100_FIELD_TAB-LOWER_LIMIT(02)'.

         PERFORM bdc_field USING 'BDC_OKCODE' '=OKAY'.

         PERFORM bdc_field USING 'D0100_FIELD_TAB-LOWER_LIMIT(01)' lv_datumjahr.

         PERFORM bdc_field USING 'D0100_FIELD_TAB-LOWER_LIMIT(02)' lv_belegnumr.

         PERFORM bdc_dynpro USING 'SAPLVINT' '0150'.

         PERFORM bdc_field USING 'BDC_CURSOR' 'VEIAV-BELEGIDEN'.

    In my program I choose a row from table, press my buton and it takes me to wanted edit mode.

    Let's say that screen with my table is number 1, "edit mode" is 4th, two screens are ommited (selection screen for view VEIAV and the result of this selection screen).

    Is there any possibilty to press back or exit button (esc, F3, whatever) and take user from screen 4 directly to screen 1?

    Regards.

    Add comment
    10|10000 characters needed characters exceeded