Application Development and Automation 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: 
Read only

Retrieve Data from ALV without using GET_SELECTED_ROWS

achraf_smaali
Explorer
0 Likes
1,424

Hi ABAPers!!

First of all let me tell you that I'm working in ACCENTURE Casablanca(Morocco) and this is my first Job in my career.

I'm working on an ALV OO, the program concists on creating an ALV using OO, In my selection screen there's a parameter of type DBFIELD I provide the name of table and it returns the table's fields in another dynpro (screen0100), To do this I used the FM: 'DB_GET_TABLE_FIELDS' then I append the internal table returned in another one to add the field CB (CheckBox), and I add a button in the toolbar, the function of this button is to generate a MySQL script To create the table provided by the user in my parameter (Screen 1000), but the fields of this table in the generated script are only the selected ones by cheking the checkbox in the ALV.

At first I used the method GET_SELECTED_ROWS and the sel_mode = 'C' in the layout structure but it doesn't returns any thing in the lvc_t_rowid table, moreover my boss refused that I used this method and he adviced me to use the event button_click.

So could any one help me with some piece of code?!!

Regards

SMAALI Achraf

9 REPLIES 9
Read only

Kiran_Valluru
Active Contributor
0 Likes
1,247

Hi.,

Check BCALV_GRID_05 report.,

this will help u.,

Thanks & Regards

Kiran

Read only

Former Member
0 Likes
1,247

You have to implement event handler for capturing rowid

Read only

achraf_smaali
Explorer
0 Likes
1,247

Thanks kiran kumar Reddy,

In executed the program you provided but in the ALV returned there isn't any field as a checkbox, and my problem is how to link the chek of checkbox and the evnt button_click

Read only

0 Likes
1,247

Hi.,

In field catalog U add one more field Check and make it as Check box., so in ur ALV out put u will get one more column with all check boxes., and select the check box for which records u want., then when u press button ., loop the internal table and check whether the check box is selected or not., if selected append those records..!!

hope this helps u.,

Thanks & regards

Kiran

Read only

achraf_smaali
Explorer
0 Likes
1,247

Thanks brother AbdoALLAH,

Of course I did and this is the code :


*&---------------------------------------------------------------------*
*&  Include           ZCLTABLES_METADATA_OO
*&---------------------------------------------------------------------*
CONSTANTS c_10_ic  TYPE iconname  VALUE '@0Q@'.
DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid .
DATA: gt_list type standard table of dbfield WITH HEADER LINE,
      wa_list TYPE dbfield.
DATA gt_listalv TYPE STANDARD TABLE OF zstr_dbfcb WITH HEADER LINE.



**************************Classes
CLASS lcl_event_receiver DEFINITION.

  PUBLIC SECTION.
    METHODS :
*To add new functional buttons to the ALV toolbar
       handle_toolbar
       FOR EVENT toolbar OF cl_gui_alv_grid
                         IMPORTING e_object,
*To implement user commands
       handle_user_command
       FOR EVENT user_command OF cl_gui_alv_grid
                         IMPORTING e_ucomm,
*To control menu buttons
       handle_menu_button
       FOR EVENT menu_button OF cl_gui_alv_grid
                         IMPORTING e_object e_ucomm .
  PRIVATE SECTION.

ENDCLASS.               "LCL_EVENT_RECEIVER
*&---------------------------------------------------------------------*
*&       Class (Implementation)  LCL_EVENT_RECEIVER
*&---------------------------------------------------------------------*
*        Implémentation de la méthode
*----------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
  METHOD handle_toolbar.
    DATA ls_toolbar TYPE stb_button.
    MOVE 3 TO ls_toolbar-butn_type.
    INSERT ls_toolbar INTO e_object->mt_toolbar INDEX 25.
    CLEAR ls_toolbar.
    ls_toolbar-function  = 'SCR'.
    ls_toolbar-icon      = c_10_ic.
    ls_toolbar-quickinfo = text-013.
    ls_toolbar-butn_type = 0.
    ls_toolbar-checked   = space.
    INSERT ls_toolbar INTO e_object->mt_toolbar INDEX 26.
    CLEAR ls_toolbar.

  ENDMETHOD.                    "handle_toolbar
*Handle User Command
  METHOD handle_user_command.
    DATA ls_selected_row TYPE lvc_s_roid .
    Data : l_valid type c,
           ls_listalv type ZSTR_DBFCB,
           lt_selected_rows type lvc_t_roid.
    call method gr_alvgrid->check_changed_data
          importing
            e_valid = l_valid.
    if l_valid = 'X'.
      call method gr_alvgrid->get_selected_rows
          importing
            et_row_no = lt_selected_rows[].
      loop at lt_selected_rows into ls_selected_row.
        read table gt_listalv into ls_listalv
              index ls_selected_row-row_id.
***********************************
              ls_listalv-cb = 'X'.
              MESSAGE text-014 TYPE 'S' DISPLAY LIKE 'E'.
***********************************
        modify gt_listalv from ls_listalv index ls_selected_row-row_id.
      endloop.
      call method gr_alvgrid->refresh_table_display.
    endif.
  ENDMETHOD.                    "handle_user_command
*Handle Menu Buttons
  METHOD handle_menu_button .
    CASE e_ucomm .
      WHEN 'SCR' .
        CALL METHOD e_object->add_function
          EXPORTING
            fcode = 'SCR'
            text  = 'Script'.
    ENDCASE .
  ENDMETHOD .                    "handle_menu_button

ENDCLASS. 

Read only

achraf_smaali
Explorer
0 Likes
1,247

Thanks kiran kumar Reddy for your time,

The fieldcatalog u adviced me to add is the first step I did when I start building my program, But when I want to press the button after checking the checkbox field, my program dumped which due to the incompatibility between the table returned by the FM 'DB_GET_TABLE_FIELDS' and the fieldcatalog because of the added field 'Check'. that's why I've created another internal table which includes the structure DBFIELD and another field called 'CB' to be handled as a chekbox and this is the it which I provide as it_outtab to my CL_GUI_ALVGRID.

But as you told there is another way which I'll try is to loop at the internal table and I'll check if the CB field = 'X' then I append this line to another it which I'll base on to generate my script

Read only

achraf_smaali
Explorer
0 Likes
1,247

Thank you very much kiran kumar Reddy!!

I try it and it works fine with me, one little thing pllllz, the Internal table which I filled to generate my script it is appended after I push the button in the toolbar but I want to fill it while I'm checking my chekboxes plz tell me which event should I use? I don't really know what to do?!! __

Read only

0 Likes
1,247

Hi.,

I dont think it is possible..!! if it is Web Dynpro., there are events like onSelect., but here., on double click we can do., but we are jus selecting check box., try to put hotspot for that column..

n my suggestion is once selecting all records and pressing button is gud option., bcoz when u use hotspot also u need to check whether it is checked or not instead of blindly appending..

hope this helps u.,

Thanks & regards

Kiran

Read only

achraf_smaali
Explorer
0 Likes
1,247

Problem solved, Assigning points is disactivated