ALV HANDLE_DATA_CHANGED_FINISHED
Hi ,
I have to capture change on ALV cells , I am using HANDLE_DATA_CHANGED_FINISHED but this event gets triggered only after hitting ENTER or other user commands.
I wan to avoid Hitting ENTER and other user commands to trigger HANDLE_DATA_CHANGED_FINISHED/HANDLE_DATA_CHANGED . Any Ideas how to achieve this ?
-Raj
Hi Arshad & Marcin ,
Thanks for your replies.
i have already registered edit event with attribute
i_event_id = cl_gui_alv_grid=>mc_evt_modifies. tried i_event_id = cl_gui_alv_grid=>cl_gui_alv_grid=>mc_evt_enter too .
As Marcin said the event is getting triggered when the user changes and focus the cursor on next field , but I have many editable drop down fields on the ALV
After entering a value in one of the editable ALV then instead of focusing on the other field , if I try to select/click on the menu icon on the drop down (editable field ) then it triggers the HANDLE_DATA_CHANGED_FINISHED event and the drop down
flashes and disapears i have to reselect dorp down to select the value which is annoying .
Everything works fine when I enter a value in one of the editable field then hit " enter key " . So I am trying to programaticaly trigger enter soon after user changes/enteres some value in the editable cell . Is this possible ?
-Raj
Similar Messages
-
Drop Down in ALV Flashes and Disappears.
Hi All,
I have a strange issue going on. In an ALV (built on CL_GUI_ALV_GRID) I have got an editable field with a drop down option.Now lets say I have 10 rows in an ALV. I chose an entry from the drop down in one of the rows (this happens OK) and immediately after that I go on a click on drop down for any other row. What happens is that the drop down for the new row that I am in flashes and disappears. Now if I click for the drop down again the drop down appears. Basically whenever an entry is selected in one of the rows, drop down function immediately after that does not work. I have a feeling that it has something to do with the data _changed event but I am not sure how to handle that event.
I saw a similar thread [ALV Menu Flash|ALV HANDLE_DATA_CHANGED_FINISHED; but could not figure it out.
Any suggestions ?
Thanks
AnujHi,
Let us see the code and check it
Make the necessary changes at the fieldcatalog
clear ls_fcat.
ls_fcat-fieldname = 'COURSE'.
ls_fcat-col_pos = 5.
ls_fcat-coltext = 'Course'.
ls_fcat-outputlen = 10.
ls_fcat-DRDN_HNDL = 25.
ls_fcat-edit = 'X'.
APPEND ls_fcat to lt_fcat.
and in the class cl_gui_alv_grid we have one method SET_DROP_DOWN_TABLE
and it is having one parameter called iT_DROPDOWN of type LVC_T_DROP
generate the internal table and call the method set_drop_down_table
clear ls_drop.
ls_drop-handle = '25'.
ls_drop-value = 'ABAP'.
append ls_drop to lt_drop.
clear ls_drop.
ls_drop-handle = '25'.
ls_drop-value = 'CRM'.
append ls_drop to lt_drop.
clear ls_drop.
ls_drop-handle = '25'.
ls_drop-value = 'WEBDYNPRO'.
append ls_drop to lt_drop.
CALL METHOD o_grid->set_drop_down_table
EXPORTING
it_drop_down = lt_drop.
Thanks & Regards.
Raghunadh.K -
ALV OM - keep filter while deleting lines from ALV
Dear all,
I'm using an ALV (cl_salv_table) to get a proposallist of materials and substances to be linked. When a material is linked to a substance, all lines for this material are deleted from the ALV. So far, so good.
When a user sets a filter on a certain column and links a material, the filter icon on top of the column is shown while the records are not filtered accordingly. When the user selects the column again en pushes the filter button, the value that was set in the first place, is shown.
edit : I've "solved" this problem myself by getting a list of all filters, clearing lr_filters and filling lr_filters up again from this list.I don't think this is a very clean sollution to the problem, but it works.
How can I resolve this problem in a better way? Thanks in advance.
Cheers.
Luk
Edited by: Luk Declerck on Dec 16, 2009 4:28 PMU can do all validations in the event data_changed_finished.
****----EVENT HANDLING.....*****
*------Class definition
CLASS lcl_event_handler DEFINITION .
PUBLIC SECTION.
METHODS handle_data_changed_finished FOR EVENT data_changed_finished
OF cl_gui_alv_grid IMPORTING e_modified ET_GOOD_CELLS.
ENDCLASS. "lcl_event_handler DEFINITION
*-----Class implementation
CLASS lcl_event_handler IMPLEMENTATION.
"handle_usercom
**----DATA changed
METHOD handle_data_changed_finished.
PERFORM handle_data_changed_finished USING e_modified
et_good_cells
ENDMETHOD.
ENDCLASS. "lcl_event_handler IMPLEMENTATION
FORM handle_data_changed_finished using i_modified type char01
i_good_cells type LVC_t_MODI.
data: wa_good_cells type lvc_s_modi.
// Perform ur validation here
endform. -
Editable and non editable issue in ALV OOPS
Hi All,
After giving the input in selection screen when i execute the report program will display the output in ALV OOOps.
Here i need few fields in Editable and some fields are non editbale mode. I can't use Edit ='X" in fieldcatalog.
I refered few threads in SDN at last i found the method cl_gui_alv_grid=>mc_style_enabled. using this method also i am not getting. PLz see below sample code.
gs_celltab-fieldname = 'Z_MESSAGEID'.
gs_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
INSERT gs_celltab INTO TABLE gt_celltab.
gs_final-celltab = gt_celltab.
APPEND gs_final TO gt_final.
I am passing GT_FINAL to below mthiod.
CALL METHOD grid->set_table_for_first_display
EXPORTING
i_save = 'A'
i_default = 'X'
is_layout = gs_layout
is_variant = gs_variant
it_toolbar_excluding = gt_exclud
CHANGING
it_fieldcatalog = gt_fieldcat[]
it_outtab = gt_final[].
still inut all fields are in disply mode. Any body can suggest me how to approach.
Regards,
MaheedharHere is the sample code.
DATA :PT_CELLTAB Type LVC_T_STYL,
LS_CELLTAB TYPE LVC_S_STYL,
L_MODE type RAW4.
LS_CELLTAB-fieldname = 'KUNRG'.
LS_CELLTAB-style = cl_gui_alv_grid=>mc_style_disabled.
Insert LS_CELLTAB Into Table PT_CELLTAB.
LS_CELLTAB-fieldname = 'KUNNR_AG'.
LS_CELLTAB-style = cl_gui_alv_grid=>mc_style_enabled.
Insert LS_CELLTAB Into Table PT_CELLTAB.
Append X_OUTTAB to TB_OUTTAB.
*---Switch edit mode 0 for No-edit 1 for Edit
CALL METHOD g_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
its recommended to use the below events for editable mode to handle changed data
example
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING e_onf4
e_onf4_before
e_onf4_after
er_data_changed,
Handle data Change Finished
handle_data_changed_finished
FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING. ...
Edited by: Ashwin Kumar Chitram on Oct 3, 2011 8:06 PM -
For all users having probs with OO ALV Grid
I wanted to put this in the WIKI but it keeps bombing out when I try and save so I've put this here -- Maybe a MOD can move it for me.
This generic class should give you far more insite into using an EDITABLE ALV table than the standard documentation.
If you follow the steps you should be able to code very quickly a decent useable ALV OO program which can retrieve and manipulate data very easily. The events are (hopefully) well documented as are all the steps.
Once you understand the basics you can add more functionality like colouring Cells, adding hyperlinks etc etc.
I've always found that stupid SEAT / AIRLINE application SAP uses for its examples far too overblown and in reality who would ever use a SAP system for Airline reservations anyway.
The class here describes a much simpler application which CLEARLY (I hope) explains how the whole thing works.
Jimbo's generic class for using the OO ALV GRID Class CL_GUI_ALV_GRID
from an application program to display and manipulate ANY table
with minimal coding needed in the Calling application program.
Handles the following EVENTS
1) TOOLBAR BUTTONS
(you can add more to the toolbar method
if you need even more functionality).
2) DOUBLE CLICK
3) ENTER KEY PRESSED
4) DATA CHANGED
5) DATA CHANGED FINISHED
Methods available
PUBLIC METHODS ( Can be called directly from the application program).
1) display_grid displays grid with toolbar
Table and FCAT are built dynamically - user only needs to
define the table structure (can be DDIC or User fields)
2) change_title - changes title at the top of the Grid
3) refresh_grid - refreshes grid after table updated etc.
4) build_dynamic_structures - this method creates a dynamic table and a dynamic FCAT
using the structure defined in the calling application program
PRIVATE METHODS (Internal Methods used within the class)
1) verwerk - returns to FORM VERWERK in calling application program
(Via Toolbar). The application program can then do any special processing
at this point e.g update SAP tables etc.
2) download_to_excel (via Toolbar). This creates an EXCEL spreadsheet
directly which can be downloaded / saved to a file if required,
3) return_structure - internal method returns the structure
of the table defined in the calling application program. This is needed in order
to build the dynamic table and Field Catalog.
4) create_dynamic_table - creates a dynamic table from the structure defined in
the calling application program
5) create_dynamic_fcat - creates the dynamic field catalog from the structure
defined in the application program.
6) dubbleklik entered when user double clicks a cell
activated by EVENT DOUBLE_CLICK.
returns to FORM DUBBELKLIK in the
calling application program
COOKBOOK STEP BY STEP instructions on how to use this class
in your application program.
In the application program :
1) define a blank screen 100 - SE51 with a custom container
on it called CCONTAINER1.
you need the following logic in the screen
The PAI is only used if you have defined a STATUS with SE41 and you exit the
application program via the standard SAP buttons on the
top of the Screen (NOT the GRID toolbar).
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
2) (optional) define a STATUS with a titlebar - SE41
you only need this if you want the standard EXIT and menu buttons on the
top line of the screen
3) If you want to have your OWN colum names on the grid
add the following macro to the start of your program
DEFINE col_name.
read table it_fldcat into wa_it_fldcat index &1.
wa_it_fldcat-coltext = &2.
modify it_fldcat from wa_it_fldcat index &1.
END-OF-DEFINITION.
4) Define the following Field symbols
<fs1> TYPE ANY,
<fs2> TYPE STANDARD TABLE,
<fs3> TYPE ANY,
<field_catalog> TYPE STANDARD TABLE,
<dyn_table> TYPE STANDARD TABLE,
<orig_table> TYPE STANDARD TABLE,
<dyn_field>,
<dyn_wa>.
5) After the field-symbols add the code in this class
as an INCLUDE
e.g INCLUDE ZZJIMBOXX_INCL.
6) define your Internal table as follows
TYPES: BEGIN OF s_elements,
Your structure
your structure etc.
END OF s_elements.
For example
INCLUDE <icon>.
TABLES: VAPMA.
*TYPES: BEGIN OF s_elements,
vbeln TYPE vapma-vbeln,
posnr TYPE vapma-posnr,
matnr TYPE vapma-matnr,
kunnr TYPE vapma-kunnr,
werks TYPE vapma-werks,
vkorg TYPE vapma-vkorg,
vkbur TYPE vapma-vkbur,
status TYPE c,
*END OF s_elements.
7) Define the following data IN YOUR APPLICATION PROGRAM
(note here only data is described
that relates to using THIS CLASS. Data purely used internally
in the application program is NOT shown here).
DATA: z_object TYPE REF TO zcl_dog, "Instantiate our class
grid_container1 TYPE REF TO cl_gui_custom_container,
t_elements TYPE TABLE OF s_elements, "refers to our ITAB
wa_elements TYPE s_elements,
wa_dyn_table_line TYPE REF TO DATA,
it_fldcat TYPE lvc_t_fcat,
i_gridtitle TYPE lvc_title,
wa_it_fldcat TYPE lvc_s_fcat,
new_table TYPE REF TO DATA,
dy_table TYPE REF TO data,
dy_line TYPE REF TO data,
row_id TYPE sy-index.
8) insert the following code at the start of the application program.
*START-OF-SELECTION.
*CALL SCREEN 100.
*END-OF-SELECTION.
*MODULE status_0100 OUTPUT.
*ASSIGN wa_elements TO <fs1>.
*CREATE OBJECT z_object EXPORTING z_object = z_object. "Instantiate the class
*CALL METHOD z_object->build_dynamic_structures
CHANGING it_fldcat = it_fldcat.
9) if you inserted the macro in step 3) then
define your own column names as follws
col_name 1 'Name1'.
col_name 2 'Name2'.
etc. The number is the colum number you want and the name is
the name you want to assign to the column.
for example using the table shown above
col_name 1 'Order Nr'.
col_name 2 'Item'.
col_name 3 'Material'.
col_name 4 'Customer'.
col_name 5 'Plant'.
col_name 6 'Sales Org'.
col_name 7 'Sales Office'.
col_name 8 'Status'.
10) perform a routine that fills your dynamic table and
display the GRID. If you created a status with SE41 you can set
a title etc. Further processing is dependent on the users action
after the GRID is displayed for example if a Cell is double clicked,
dat is entered, a toolbar button is pressed or a SAP ICON on top of the screen is pressed.
PERFORM populate_dynamic_itab.
CALL METHOD z_object->display_grid
CHANGING it_fldcat = it_fldcat.
SET PF-STATUS '0001'.
SET TITLEBAR '000'.
ENDMODULE.
11) If you added a STATUS via SE41 you can exit the program via the
standard SAP buttons at the top of the screen
otherwise exit via the exit button on the toolbar.
You only need this piece of code if you defined a STATUS in the application program
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'RETURN'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
12) to populate the dynamic table you only need to code something like this
remember the class has already created and structured the field-symbol <dyn_table>
so you don't have to do anything other than just select the fields you want
filled and from what data source(es).
*FORM populate_dynamic_itab.
*SELECT vbeln posnr matnr kunnr werks vkorg vkbur
UP TO 200 rows
FROM vapma
INTO CORRESPONDING FIELDS OF TABLE <dyn_table>.
if you want to keep the original table before making any changes etc code
the following
create 2nd Dyn table to hold original data. We can use
the same field catalog as for the original table
as we are just creating an identical copy here.
*CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fldcat
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO <orig_table>.
CREATE DATA dy_line LIKE LINE OF <orig_table>.
ASSIGN dy_line->* TO <dyn_wa>.
<orig_table> = <dyn_table>.
ENDFORM.
13) you need these 2 processing routines in your application program.
FORM VERWERK. "Entered from VERW on toolbar
*break-point 1.
Orig table is in dynamic table <orig_table>
ALV GRID changed table is in <dyn_table>.
*Loop at <orig_table> into <dyn_wa>.
Do what you want here
end
endloop.
ENDFORM.
*form dubbleklik using "Entered when a cell is double clicked
e_row type LVC_S_ROW
e_column type LVC_S_col
es_row_no type lvc_s_roid.
break-point 1.
Get Row id into a variable for this program.
row_id = e_row.
SET TITLEBAR '001'. "If you defined a status in SE41
i_gridtitle = 'Grid Title Changed'.
CALL METHOD z_object->change_title
EXPORTING i_gridtitle = i_gridtitle.
PERFORM refresh.
endform.
The REFRESH routine is optional but after a double click I assume
you want to do some processing
and re-display the data
so as a sample code something like
*FORM refresh.
data: ord_nr TYPE vapma-vbeln. "Your data
*READ TABLE <dyn_table> index row_id into wa_elements.
ord_nr = wa_elements-vbeln.
You've now got the Row double clicked so pick out the data element(s)
you wnat to process and do your processing
*set parameter id 'AUN' field ord_nr.
*CALL TRANSACTION 'VA02' AND SKIP FIRST SCREEN.
You can update the dynamic table for example
*wa_elements-status = 'C'.
*modify <dyn_table> from wa_elements index row_id.
now redisplay the updated grid.
*CALL METHOD z_object->refresh_grid.
*ENDFORM.
*************Class ZCL_DOG*************
CLASS zcl_dog DEFINITION.
PUBLIC SECTION.
METHODS:
constructor
IMPORTING
z_object TYPE REF TO zcl_dog,
display_grid
CHANGING
it_fldcat TYPE lvc_t_fcat,
build_dynamic_structures
CHANGING it_fldcat TYPE lvc_t_fcat,
change_title
IMPORTING
i_gridtitle TYPE lvc_title,
refresh_grid.
PRIVATE SECTION.
METHODS:
on_user_command FOR EVENT before_user_command OF cl_gui_alv_grid
IMPORTING e_ucomm
sender,
on_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object
e_interactive,
on_dubbelklik FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row
e_column
es_row_no,
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed,
handle_data_changed_finished
FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING e_modified
et_good_cells,
verwerk
IMPORTING program TYPE sy-repid,
download_to_excel,
dubbleklik
IMPORTING
e_row type LVC_S_ROW
e_column TYPE LVC_S_COL
es_row_no type lvc_s_ROID
program type sy-repid,
return_structure,
create_dynamic_fcat
EXPORTING it_fldcat TYPE lvc_t_fcat,
create_dynamic_table
IMPORTING it_fldcat TYPE lvc_t_fcat
EXPORTING dy_table TYPE REF TO DATA.
DATA:
lr_rtti_struc TYPE REF TO cl_abap_structdescr, "RTTI
zog LIKE LINE OF lr_rtti_struc->components, "RTTI
wa_it_fldcat TYPE lvc_s_fcat,
it_fldcat TYPE lvc_t_fcat,
dy_table TYPE REF TO data,
dy_line TYPE REF TO data,
struct_grid_lset TYPE lvc_s_layo,
e_row TYPE LVC_S_ROW,
e_column TYPE lvc_s_col,
es_rowid TYPE lvc_s_roid,
grid_container1 TYPE REF TO cl_gui_custom_container,
grid1 TYPE REF TO cl_gui_alv_grid,
ls_layout TYPE kkblo_layout,
lt_fieldcat_wa TYPE kkblo_fieldcat,
l_mode TYPE raw4,
celltab TYPE LVC_T_STYL,
wa_celltab TYPE lvc_s_styl,
lt_fieldcat TYPE kkblo_t_fieldcat,
l_tabname TYPE slis_tabname.
TYPES:
struc LIKE zog.
DATA:
zogt TYPE TABLE OF struc.
ENDCLASS.
CLASS zcl_dog IMPLEMENTATION.
METHOD constructor.
CREATE OBJECT grid_container1
EXPORTING
container_name = 'CCONTAINER1'.
CREATE OBJECT grid1
EXPORTING
i_parent = grid_container1.
SET HANDLER z_object->on_user_command for grid1.
SET HANDLER z_object->on_toolbar for grid1.
SET HANDLER Z_OBJECT->handle_data_changed_finished FOR grid1.
SET HANDLER Z_OBJECT->on_dubbelklik FOR grid1.
CALL METHOD grid1->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
ENDMETHOD.
METHOD refresh_grid.
CALL METHOD cl_gui_cfw=>flush.
CALL METHOD grid1->refresh_table_display.
ENDMETHOD.
METHOD on_dubbelklik.
CALL METHOD me->dubbleklik
EXPORTING
e_row = e_row
e_column = e_column
es_row_no = es_row_no
program = sy-repid.
break-point 1.
ENDMETHOD.
METHOD handle_data_changed.
Insert user code here if required
this method is entered if user ENTERS DATA.
ENDMETHOD.
METHOD handle_data_changed_finished.
Insert user code here if required
Method entered here after data entry has finished.
ENDMETHOD.
METHOD return_structure.
lr_rtti_struc ?= cl_abap_structdescr=>DESCRIBE_BY_DATA( <fs1> ).
zogt[] = lr_rtti_struc->components.
ASSIGN zogt[] TO <fs2>.
ENDMETHOD.
METHOD create_dynamic_fcat.
LOOP AT <fs2> INTO zog.
CLEAR wa_it_fldcat.
wa_it_fldcat-fieldname = zog-name .
wa_it_fldcat-datatype = zog-type_kind.
wa_it_fldcat-inttype = zog-type_kind.
wa_it_fldcat-intlen = zog-length.
wa_it_fldcat-decimals = zog-decimals.
wa_it_fldcat-coltext = zog-name.
wa_it_fldcat-lowercase = 'X'.
APPEND wa_it_fldcat TO it_fldcat .
ASSIGN it_fldcat[] TO <field_catalog>.
ENDLOOP.
ASSIGN it_fldcat[] TO <field_catalog>.
ENDMETHOD.
METHOD download_to_excel.
break-point 5.
CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO'
EXPORTING
it_fieldcat_lvc = <field_catalog>
is_layout_lvc = m_cl_variant->ms_layout
is_tech_complete = ' '
IMPORTING
es_layout_kkblo = ls_layout
et_fieldcat_kkblo = lt_fieldcat.
LOOP AT lt_fieldcat INTO lt_fieldcat_wa.
CLEAR lt_fieldcat_wa-tech_complete.
IF lt_fieldcat_wa-tabname IS initial.
lt_fieldcat_wa-tabname = '1'.
MODIFY lt_fieldcat FROM lt_fieldcat_wa.
ENDIF.
l_tabname = lt_fieldcat_wa-tabname.
ENDLOOP.
CALL FUNCTION 'ALV_XXL_CALL'
EXPORTING
i_tabname = l_tabname
is_layout = ls_layout
it_fieldcat = lt_fieldcat
i_title = sy-title
TABLES
it_outtab = <dyn_table>
EXCEPTIONS
fatal_error = 1
no_display_possible = 2
others = 3.
IF sy-subrc <> 0.
message id sy-msgid type 'S' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDMETHOD.
METHOD create_dynamic_table.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fldcat
IMPORTING
ep_table = dy_table.
ENDMETHOD.
METHOD build_dynamic_structures.
CALL METHOD me->return_structure.
CALL METHOD me->create_dynamic_fcat
IMPORTING
it_fldcat = it_fldcat.
CALL METHOD me->create_dynamic_table
EXPORTING
it_fldcat = it_fldcat
IMPORTING
dy_table = dy_table.
ASSIGN dy_table->* TO <dyn_table>.
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
ENDMETHOD.
METHOD display_grid.
struct_grid_lset-edit = 'X'. "To enable editing in ALV
struct_grid_lset-grid_title = 'Bulkwijzigingen inkoopprijzen'.
struct_grid_lset-ctab_fname = 'T_CELLCOLORS'.
struct_grid_lset-stylefname = 'CELLTAB'.
CALL METHOD grid1->set_ready_for_input
EXPORTING
i_ready_for_input = '1'.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
is_layout = struct_grid_lset
CHANGING
it_outtab = <dyn_table>
it_fieldcatalog = it_fldcat.
ENDMETHOD.
METHOD change_title.
CALL METHOD grid1->set_gridtitle
EXPORTING
i_gridtitle = i_gridtitle.
ENDMETHOD.
METHOD on_user_command.
CASE e_ucomm.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'EXCEL'.
CALL METHOD me->download_to_excel.
WHEN 'SAVE'.
WHEN 'VERW'.
CALL METHOD me->verwerk
EXPORTING
PROGRAM = SY-REPID.
ENDCASE.
ENDMETHOD. "on_user_command
METHOD on_toolbar.
User can add extra functionality by adding extra
buttons if required. Functionality can also be simplified by removing buttons.
DATA: ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'EXIT' TO ls_toolbar-function.
MOVE SPACE TO ls_toolbar-disabled.
MOVE icon_system_end TO ls_toolbar-icon.
MOVE 'Click2Exit' TO ls_toolbar-quickinfo.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'SAVE' TO ls_toolbar-function.
MOVE SPACE TO ls_toolbar-disabled.
MOVE icon_system_save TO ls_toolbar-icon.
MOVE 'Save data' TO ls_toolbar-quickinfo.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'EDIT' TO ls_toolbar-function.
MOVE SPACE TO ls_toolbar-disabled.
MOVE icon_toggle_display_change TO ls_toolbar-icon.
MOVE 'Edit data' TO ls_toolbar-quickinfo.
MOVE 'EDIT' TO ls_toolbar-text.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'VERW' TO ls_toolbar-function.
MOVE SPACE TO ls_toolbar-disabled.
MOVE icon_businav_process to ls_toolbar-icon.
MOVE 'Verw.' TO ls_toolbar-quickinfo.
MOVE 'VERW' TO ls_toolbar-text.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'EXCEL' TO ls_toolbar-function.
MOVE SPACE TO ls_toolbar-disabled.
MOVE icon_xxl TO ls_toolbar-icon.
MOVE 'Excel' TO ls_toolbar-quickinfo.
MOVE 'EXCEL' TO ls_toolbar-text.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD.
METHOD verwerk.
PERFORM verwerk IN PROGRAM (program).
LEAVE PROGRAM.
ENDMETHOD.
METHOD dubbleklik.
PERFORM dubbleklik IN PROGRAM (program)
USING
e_row
e_column
es_row_no.
ENDMETHOD.
ENDCLASS.
Cheers
JimboHi Dinu,
Before analysing ALV, please cross check the behaviour of the calling program.
Is the control really going to the application server when you do all the above process?
If so, when user makes some changes are they saved in the data base / affected the internal table which you are using for ALV?
Regards
Surya. -
Editable ALV, how to capture changed data
Hi All,
I have created an editable ALV. User can make some changes in the displayed record and press "Submit" button (custom button on application toolbar), the program should validate the data and write the file on application server if validations are successful otherwise controls stay on the same screen.
I am handling this validation and writing file part in PAI of the screen.
Problem: The program is capturing the data when user changes it for the first, but program is failing to capture the subsequent changes (user makes after the validation fails). Program processes always the first time changed data only. Please help me in getting this problem resolved.
Step1 : Program shows output.
Step2: User changes Company Code.
Step3: User clicks on Submit Button.
Step3.1: Program reads the new data and performs validation.
Step3.2: New Company code is not valid, error displayed.
Step4: User changes the company code again, presses submit button.
Goto step 3.1 -> Here program does not read the new data, rather first time changes company code is again read and validated, and program shows the same error again, which is not a desired resultHi Ashish,
you need a method HANDLE_DATA_CHANGED as handler for grid event DATA_CHANGED.
Use
LOOP AT er_data_changed->mt_mod_cells ASSIGNING <mod>.
to check all changed data. In this event, add the error messages to ER_DATA_CHANGED object.
set all required handlers, i.e.
SET HANDLER:
handle_data_changed FOR ro_grid,
handle_data_changed_finished FOR ro_grid,
handle_toolbar_set FOR ro_grid,
handle_user_command FOR ro_grid,
handle_hotspot_click FOR ro_grid,
handle_f4 FOR ro_grid,
handle_f1 FOR ro_grid.
ro_grid->set_toolbar_interactive( ).
Register ENTER and MODIFIED events.
ro_grid->register_edit_event( cl_gui_alv_grid=>mc_evt_enter ).
ro_grid->register_edit_event( cl_gui_alv_grid=>mc_evt_modified ).
Regards,
Clemens -
Handling error messages in OOPs ALV
The question below is foolish.But I am a beginner so please excuse.
I have successfully displayed an OOPs ALV which displays the material, batch and plant.
A custom toolbar button(delete batches) has been appended to the standard toolbar.
Now when I do not select any rows from the ALV and click the button(delete batches) I have ensured that an error message flahes at the bottom of the screen.
If I repeat the same procedure without coming out of the program it exits from the program itself. i want to avoid this.
I want to flash the error message continually without coming out of the program till the user commits the mistake. Please note that I have not used any leave screen commands etc.
Can someone please help me..
Thanks in advanceI assume you have the ON TOOLBAR event regiistered and the ENTER event for example.
method constructor .
create object grid_container1
exporting
* container_name = 'CCONTAINER1'.
container_name = cfname.
create object grid1
exporting
i_parent = grid_container1.
set handler z_object->on_user_command for grid1.
set handler z_object->on_toolbar for grid1.
set handler z_object->handle_data_changed for grid1.
set handler z_object->handle_data_changed_finished for grid1.
set handler z_object->on_dubbelklik for grid1.
set handler z_object->on_hotspot for grid1.
call method grid1->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
endmethod.
So the easy way to do this is in your ON USER COMMAND routine when you can check to see if you selected any rows and the issue a popup warnimg message with the standard SAP MESSAGE statement.
For example in my TEST function here I call a method to get the selected cell.
If none are selected you can then issue your message and you will then be returned back to your GRID display after the user presses the OK button on the message popup.
the grid1 object refers to the class cl_gui_alv_grid.
in your case call a method that gets selected cells rather than selected cell. Use the standard method in cl_gui_alv_grid.
If nothing selected then issue your message.
(Note that your method ON DATA CHANGE / ON DATA CHANGED FINISHED might also be entered as well so insure that you haven't got any coding in these methods that will interfere with processing flow).
method on_user_command .
* FOR EVENT before_user_command OF cl_gui_alv_grid
* IMPORTING
* e_ucomm
* sender
case e_ucomm.
when 'EXIT'.
leave program.
when 'EXCEL'.
call method me->download_to_excel.
when 'SAVE'.
when 'PROC'.
call method me->process.
when 'REFR'.
call method me->refresh.
when 'SWITCH'.
call method me->switch.
when 'TEST'.
call method me->get_cell.
endcase.
method get_cell .
break-point 1.
call method grid1->get_current_cell
importing
e_row = ls_row
e_value = ls_value
e_col = ls_col
es_row_id = ls_row_id
es_col_id = ls_col_id
es_row_no = ls_row_no.
endmethod.
cheers
jimbo -
Dear all,
I would like to do a refresh of the ALV GRID table display in event "handle_data_changed_finished".
"refresh_table_display" is NOT working.
I obviously need to go through PAI & PBO to refresh the table display.
Is there something to syncronize the data?
There must be an easy solution...
bye
Niko
Niko Prindesis
Itelligence AGDear Andreas,
thank you!
If I call "SAPGUI_SET_FUNCTIONCODE" in "handle_data_changed_finished", I can trigger the PAI/PBO.
So this solves my problem!
But ...
... isn't there a solution without going through PAI/PBO???
I want to stay in the ALVGrid control!
bye
Niko -
ALV Grid Handle Edit Event (Lost Focus)
Hi all,
I have some problems with the ALV Grid.
Target:
I have an ALV Grid with editable Column. If the user insert, update or delete the content of the column and leave the column (column lost focus) i'd like to do somthing - this means I need a event for this action. Can anybody help me to solve this problem?
Thanks StefanUse Event data_changed and data_changed_finished of the cl_gui_alv_grid.Then all you have to do is registering your event to the ALV and fill the methods with what you want to do.In ALV Grid, There is no event to capture the lost focus of a column if you don't modify it.
CLASS lcl_event_receiver DEFINITION.
METHODS:
*$ Check the change
handle_data_changed FOR EVENT data_changed
OF cl_gui_alv_grid
IMPORTING er_data_changed
e_ucomm
e_onf4
e_onf4_before
e_onf4_after,
handle_data_changed_finished
FOR EVENT data_changed_finished
OF cl_gui_alv_grid
IMPORTING e_modified
et_good_cells
sender,
ENDCLASS. "LCL_EVENT_RECEIVER DEFINITION -
Custom Function on OO ALV Grid
I am trying to implement ALV_GRID_XT to enhance the ALV Grid toolbar by adding couple of custom funcitons.As per the SAP documentation I have created 2 methods ON_TOOLBAR - one for adding items on toolbar and the other ON_USER_COMMAND - for processing if the user clicks on the custom function.
I am unable to relate the ALV Grid instance onto the method ON_USER_COMMAND . One of the funciton is to calculate the average of column which represents percentage excluding cells with zero values. Once the user selects column(s) and clicks on the Percent button on the ALV grid my piece of code should trigger ON_USER_COMMAND and then display the average percentage on the Totals row.
Method ON_USER_COMMAND has only one parameter E_UCOMM which i am able to get in the method but I am not able to get the instance of the ALV grid so that I can play around with the data in the Grid.
I could have used a local class and then enhanced the ALV toolbar but this requirement is needed for about 20 reports and hence thought of implementing it globally.
Any ideas would be appreciated.Hi there
You need to set the handlers of course and register the events
I'm using also a Z-class using functionality from the ALV Grid
in the application program
data: z_object type ref to zcl_* "my z_class"
* Instantiate your Z class
create object z_object
exporting
z_object = z_object
cfname = 'CCONTAINER1'.
Now in your Constructor for your Z-Class have a variable
say grid1 which is defined as a type ref to cl_gui_alv_grid.
Code the methods you require --. The trick is to instantiate your OWN Z class and within YOUR CLASS instantiate the GRID1 variable as an instance of cl_gui_alv_grid - then you can use methods etc from that class in your own Z class simple via something like this
method CONSTRUCTOR.
create object grid_container1
exporting
container_name = cfname.
create object grid1
exporting
i_parent = grid_container1.
set handler z_object->on_user_command for grid1.
set handler z_object->on_toolbar for grid1.
set handler z_object->handle_data_changed for grid1.
set handler z_object->handle_data_changed_finished for grid1.
set handler z_object->on_dubbelklik for grid1.
set handler z_object->on_hotspot for grid1.
call method grid1->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
endmethod.
method display_grid .
get reference of g_outtab into g_outtab1.
get reference of g_fldcat into g_fldcat1.
struct_grid_lset-edit = i_edit. "To enable editing in ALV
struct_grid_lset-zebra = i_zebra.
struct_grid_lset-cwidth_opt = i_opt.
struct_grid_lset-grid_title = i_gridtitle.
* struct_grid_lset-ctab_fname = 'T_CELLCOLORS'.
* struct_grid_lset-stylefname = 'CELLTAB'.
struct_grid_lset-ctab_fname = style_fname.
struct_grid_lset-stylefname = style_ctab.
* export gt_outtab from gt_outtab to memory id 'gt_outtab'.
call method grid1->set_table_for_first_display
exporting
is_layout = struct_grid_lset
changing
it_outtab = gt_outtab
it_fieldcatalog = it_fldcat.
endmethod.
You need to add the buttons to the toolbar with your ON TOOLBAR method
for example
method on_toolbar .
type-pools icon.
clear ls_toolbar.
move 0 to ls_toolbar-butn_type.
move 'EXCEL' to ls_toolbar-function.
move space to ls_toolbar-disabled.
move icon_xxl to ls_toolbar-icon.
move 'Excel' to ls_toolbar-quickinfo.
move 'EXCEL' to ls_toolbar-text.
append ls_toolbar to e_object->mt_toolbar.
perform toolbar in program (caller) if found
using e_object.
endmethod.
Now the functionality should work in the ON_USER_COMMAND .
Here's my ON_USER_COMMAND method within the class
method ON_USER_COMMAND.
* FOR EVENT before_user_command OF cl_gui_alv_grid
* IMPORTING
* e_ucomm
* sender
* When defined in SE24 you don't need to code the
* FOR EVENT etc as this is already defined as an event handler
case e_ucomm.
when 'EXIT'.
leave program.
when 'EXCEL'.
call method me->download_to_excel.
when 'SAVE'.
when 'PROC'.
call method me->process.
when 'REFR'.
call method me->refresh.
when 'SWITCH'.
call method me->switch.
when 'TEST'.
call method me->get_cell.
endcase.
endmethod.
Add whatever extra functionality you want to the on_user_command so long as you've defined toolbars..
Cheers
jimbo -
Download ALV O/P to multiple XL files
Hi All,
I have a report with subtotals at the vendor level, my requirement is when the user presses a button each vendor's information with the subtotals should go to a different XL file. The user can have his own layout; how can I know in my program which fields he had picked up for his layout? Any pointers would be great. Thanks!
Regards,
AmitHi there -- the OO method for ALV GRID works from V4.6C so you should have NO problem in using ALV OO (CL_GUI_ALV_GRID).
What you could do is intercept the standard button for EXPORT
use the ON_USER_COMMAND method with the parameter e_ucomm.
The function code is &PC.
Then do your own download to your relevant files and exit back to the grid or make a new button on the toolbar EXPORT for example with your own FCODE.
In the example below I've got a download to excel but change the method to your download for your users.
standard SAP class cl_gui_frontend_services has methods gui_upload and gui_download for up / downloading files etc.
note that the layout used in any particular OO grid is normally to be found in some parameter ls_layout so reading this table at your ON_USER_COMMAND event should give you the layout the user is using.
If you don't get it directly in the ON_USER_COMMAND method you can call a method from this method like I have done . The layout is available in this method (or any other after the Grid has been displayed).
when 'EXCEL'.
call method me->download_to_excel.
method constructor .
create object grid_container1
exporting
* container_name = 'CCONTAINER1'.
container_name = cfname.
create object grid1
exporting
i_parent = grid_container1.
set handler z_object->on_user_command for grid1.
set handler z_object->on_toolbar for grid1.
set handler z_object->handle_data_changed for grid1.
set handler z_object->handle_data_changed_finished for grid1.
set handler z_object->on_dubbelklik for grid1.
set handler z_object->on_hotspot for grid1.
call method grid1->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
endmethod.
method on_toolbar .
type-pools icon.
clear ls_toolbar.
move 0 to ls_toolbar-butn_type.
move 'EXCEL' to ls_toolbar-function.
move space to ls_toolbar-disabled.
move icon_xxl to ls_toolbar-icon.
move 'Excel' to ls_toolbar-quickinfo.
move 'EXCEL' to ls_toolbar-text.
append ls_toolbar to e_object->mt_toolbar.
perform toolbar in program (caller) if found
using e_object.
endmethod.
method on_user_command .
* FOR EVENT before_user_command OF cl_gui_alv_grid
* IMPORTING
* e_ucomm
* sender
case e_ucomm.
when 'EXIT'.
leave program.
when 'EXCEL'.
call method me->download_to_excel.
when 'SAVE'.
when 'PROC'.
call method me->process.
when 'REFR'.
call method me->refresh.
when 'SWITCH'.
call method me->switch.
when 'TEST'.
call method me->get_cell.
endcase.
endmethod.
method download_to_excel.
field-symbols:
<fs0> type standard table,
<fs1> type standard table.
assign g_outtab1->* to <fs0>.
assign g_fldcat1->* to <fs1>.
call function 'LVC_TRANSFER_TO_KKBLO'
exporting
it_fieldcat_lvc = <fs1>
* is_layout_lvc = m_cl_variant->ms_layout
is_tech_complete = ' '
importing
es_layout_kkblo = ls_layout
et_fieldcat_kkblo = lt_fieldcat.
loop at lt_fieldcat into lt_fieldcat_wa.
clear lt_fieldcat_wa-tech_complete.
if lt_fieldcat_wa-tabname is initial.
lt_fieldcat_wa-tabname = '1'.
modify lt_fieldcat from lt_fieldcat_wa.
endif.
l_tabname = lt_fieldcat_wa-tabname.
endloop.
call function 'ALV_XXL_CALL'
exporting
i_tabname = l_tabname
is_layout = ls_layout
it_fieldcat = lt_fieldcat
i_title = sy-title
tables
it_outtab = <fs0>
exceptions
fatal_error = 1
no_display_possible = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type 'S' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endmethod.
Cheers
jimbo -
Hello Experts!
I've created a screen with an alv_grid and a custom pf_status, I have a custome button defined in the pf_status, I need to pass the command executed from the pf_status to the alv_grid.
Is this possible?
My user refuses to use the alv_grid toolbar.Hi there
Do the following
1) separate off the functions you want the standard SAP GUI (SE41) to do - I usually choose the standard 3 buttons BACK, EXIT, CANCEL and just use these in your PAI. ( You set the status in the PBO)
2) Now for the Grid toolbars you need to define event handlers for ON TOOLBAR, and ON USER COMMAND and have methods for these. You need to register the events as well.
I'm using my own ALV GRID class but it refrences CL_GUI_ALV_GRID so you could code something like this..
in the constructor
the variable z_object is simply a refrence to type cl_gui_alv_grid. GRID1 is also defined as a reference to cl_gui_alv_grid.
As an import parameter to the constructor I also pass the name of the program - which is quite useful as I can then in various methods of the class do a Perfom (XXXX) in program (yyyy) if found.
method constructor .
create object grid_container1
exporting
* container_name = 'CCONTAINER1'.
container_name = cfname.
create object grid1
exporting
i_parent = grid_container1.
set handler z_object->on_user_command for grid1.
set handler z_object->on_toolbar for grid1.
set handler z_object->handle_data_changed for grid1.
set handler z_object->handle_data_changed_finished for grid1.
set handler z_object->on_dubbelklik for grid1.
set handler z_object->on_hotspot for grid1.
call method grid1->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
endmethod.
Now for the on_toolbar and on_user_command methods.
method on_toolbar .
type-pools icon.
clear ls_toolbar.
move 0 to ls_toolbar-butn_type.
move 'EXCEL' to ls_toolbar-function.
move space to ls_toolbar-disabled.
move icon_xxl to ls_toolbar-icon.
move 'Excel' to ls_toolbar-quickinfo.
move 'EXCEL' to ls_toolbar-text.
append ls_toolbar to e_object->mt_toolbar.
perform toolbar in program (caller) if found
using e_object.
endmethod.
method on_user_command .
* FOR EVENT before_user_command OF cl_gui_alv_grid
* IMPORTING
* e_ucomm
* sender
case e_ucomm.
when 'EXIT'.
leave program.
when 'EXCEL'.
call method me->download_to_excel.
when 'SAVE'.
when 'PROC'.
call method me->process.
when 'REFR'.
call method me->refresh.
when 'SWITCH'.
call method me->switch.
when 'TEST'.
call method me->get_cell.
endcase.
endmethod.
The toolbar event is particularly useful if you want to add / remove standard functionality to the standard toolbar.
As I've definedined my class with SE24 rather than inline code then I don't need the FOR EVENT statement in the method -- if your class is ïn line "i.e part of the abap" then you'll need those statements..
When you now press one of the grid toolbar buttons your ON_USER_COMMAND Method will be executed with the FCODE assigned to the button passed as a parameter e_ucomm.
You can also intercept the Standard SAP ALV toolbars as well as the on user command event gets handled BEFORE the SAP code.
For example as I previously posted you can intercept say the standard sort ascending button (code &SORT_ASC) issue a popup and carry on.
Cheers
jimbo -
ALV Grid - Display/change Problem
Hi Guys,
I have a peculiar problem. I have developed a Module pool application containing two screens. In the first screen I have a input field and 2 buttons for display and change. When I enter the value and press Displaythe second screen is called which shows an ALV grid in the respective display mode. But If I come back and press change I could not get the change mode for the ALV grid still it remains in the Display mode. Again if rerun the transaction and press change it shows the ALV grid in change mode but if we press back and choose display then it is not getting changed still remains as such. In all at the first run what ever the mode is chosen it remains stationery. I am using OOALV and i have tried flushing the container, grid and also refreshing the ALV. But could not trace the problem. If you guys have worked or can put some inputs please reply back.
Jagath.Please find the attached code...
from the first screen 100 i am assigning the flag w_display or w_change based on the okcode. in the second screen 200 PBO i have the following code:
MODULE status_0200 OUTPUT.
SET PF-STATUS 'STAT200'.
SET TITLEBAR 'TIT200'.
if w_display eq 'X'.
perform grid_display.
else.
perform grid_change.
endif.
ENDMODULE. " STATUS_0200 OUTPUT
Now in perform display I have the following code:
form grid_display .
Set the Fieldcatalog.
REFRESH t_fieldcat.
PERFORM get_field_catalog.
set the Layout.
CLEAR wa_layout.
wa_layout-cwidth_opt = 'X'.
wa_layout-stylefname = 'CELLTAB'.
set the Variant
w_variant-report = sy-repid.
Create the Instance for container
IF lcl_custom_disp IS INITIAL.
CREATE OBJECT lcl_custom_disp
EXPORTING
PARENT =
container_name = 'CONTAINER1'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
create the object for ALV grid
CREATE OBJECT lcl_grid_disp
EXPORTING
i_parent = lcl_custom_disp
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Create the object for events
CREATE OBJECT lcl_events.
SET HANDLER lcl_events->handle_top_of_list FOR lcl_grid_disp.
Display the ALV.
CALL METHOD lcl_grid_disp->set_table_for_first_display
EXPORTING
is_variant = w_variant
i_save = ' '
is_layout = wa_layout
CHANGING
it_outtab = t_final[]
it_fieldcatalog = t_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ELSE.
Refresh the ALV grid
CALL METHOD lcl_grid_disp->refresh_table_display
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
EXCEPTIONS
finished = 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.
ENDIF.
endform. " grid_display
In the perform change the same code is followed for different object with the fieldcatalog is changed to edit based on flag.
Set the Fieldcatalog.
REFRESH t_fieldcat.
PERFORM get_field_catalog.
set the Layout.
CLEAR wa_layout.
wa_layout-cwidth_opt = 'X'.
wa_layout-stylefname = 'CELLTAB'.
set the Variant
w_variant-report = sy-repid.
Create the Instance for container
IF lcl_custom_chng IS INITIAL.
CREATE OBJECT lcl_custom_chng
EXPORTING
PARENT =
container_name = 'CONTAINER1'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
create the object for ALV grid
CREATE OBJECT lcl_grid_chng
EXPORTING
i_parent = lcl_custom_chng
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Create the object for events
CREATE OBJECT lcl_events.
SET HANDLER lcl_events->handle_top_of_list FOR lcl_grid_chng.
SET HANDLER lcl_events->handle_data_changed FOR lcl_grid_chng.
SET HANDLER lcl_events->handle_data_changed_finished FOR lcl_grid_chng.
Display the ALV.
CALL METHOD lcl_grid_chng->set_table_for_first_display
EXPORTING
is_variant = w_variant
i_save = ' '
is_layout = wa_layout
CHANGING
it_outtab = t_final[]
it_fieldcatalog = t_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ELSE.
Refresh the ALV grid
CALL METHOD lcl_grid_chng->refresh_table_display
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
EXCEPTIONS
finished = 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.
ENDIF.
Please let me know if you require some more inputs?
Jagath -
Example of creating ALV double click event that can be used in ANY Program
Once you get the hang of OO you can really create useful generalized code that can be used in a huge number of situtations.
Double click on ALV is often wanted
Right here goes to implement a generalized double click action that returns the row, column and column name back to the caller.
In your CLASS in the DEFINITION part code as follows.
CLASS zcl_dog DEFINITION.
PUBLIC SECTION.
METHODS:
constructor
IMPORTING z_object type ref to zcl_dog,
i_parent type ref to cl_gui_custom_container,
PRIVATE SECTION.
on_dubbelklik FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row
e_column
es_row_no,
dubbleklik
IMPORTING
e_row type LVC_S_ROW
e_column TYPE LVC_S_COL
es_row_no type lvc_s_ROID
program type sy-repid.
code here any extra any methods you need.
In the CONSTRUCTOR method of the implementation
CLASS zcl_dog IMPLEMENTATION.
METHOD constructor.
CREATE OBJECT grid_container1
EXPORTING
container_name = 'CCONTAINER1'.
CREATE OBJECT grid1
EXPORTING
i_parent = grid_container1.
SET HANDLER z_object->on_user_command for grid1.
SET HANDLER z_object->on_toolbar for grid1.
SET HANDLER Z_OBJECT->handle_data_changed_finished FOR grid1.
SET HANDLER Z_OBJECT->on_dubbelklik FOR grid1.
endmethod.
METHOD on_dubbelklik.
CALL METHOD me->dubbleklik
exporting
e_row = e_row
e_column = e_column
es_row_no = es_row_no
program = sy-repid.
break-point 1.
method dubbleklik.
perform dubbleklik IN PROGRAM (program)
using
e_row
e_column
es_row_no.
ENDMETHOD.
endclass.
This will now perform a routine called dubbleklik in your application program whenever you double click a cell in the grid.
In the application program just code the following
DATA: z_object type ref to zcl_dog, "Instantiate our class
grid_container1 type ref to cl_gui_custom_container,
CREATE OBJECT z_object EXPORTING z_object = z_object.
call ANY method in the class which eventually displays the grid
CALL METHOD z_object->build_dynamic_structures
CHANGING it_fldcat = it_fldcat.
form dubbleklik using
e_row type LVC_S_ROW
e_column type LVC_S_col
es_row_no type lvc_s_roid.
break-point 1.
endform.
When you double click a cell you'should be at the break point in your routine in the application program.
You've got the cell that was clicked so by reading your table you can examine the data and take the appropriate action.
Cheers
JimboI suggest you purchase a case and have a dedicated support engineer work with you directly:
http://www.sdn.sap.com/irj/boc/gettingstarted
Or
http://store.businessobjects.com/store/bobjects/Content/pbPage.CSC_map_countyselector/pgm.67024400?resid=jFmmLgoBAlcAAALO-iYAAAAP&rests=1278687224728
If this is a bug you'll get a refund, if not post your enhancement request in the Idea Place. Or the Rep will suggest a better way to create your report. -
Hi Experts,
I know this topic is discussed several times but I still have a confusion.
I have created one ALV report using custom container like the usual way. As per my understanding this report shouldn't execute in background
but when I execute the report in background in development system, it's not throwing any error and I am able to get the spool.
Why is this happening? Is there a possibility that if I transport the object to other system I may get error?
Please share your thoughts.
Thanks,
TikiThis is my "common code" i use to manage CL_GUI_GRID in background without touching the output screen to define a container
CLASS lcl_event_handler DEFINITION DEFERRED.
DATA: gr_event_handler TYPE REF TO lcl_event_handler.
*---- ALV Grid instance reference
DATA: gr_alvgrid TYPE REF TO cl_gui_alv_grid.
*---- Custom container instance reference
DATA: gr_splitter_container TYPE REF TO cl_gui_splitter_container,
gr_container TYPE REF TO cl_gui_container.
*---- Header container
DATA: gr_docking_container TYPE REF TO cl_gui_docking_container,
gr_document TYPE REF TO cl_dd_document.
IN PBO
IF sy-batch = 'X'.
*---- Creating ALV grid within a docking container
CREATE OBJECT gr_alvgrid
EXPORTING
i_parent = gr_docking_container.
ELSE.
*---- Creating Splitted Containers
CREATE OBJECT gr_splitter_container
EXPORTING
parent = cl_gui_container=>screen0
rows = 1
columns = 1.
CALL METHOD gr_splitter_container->set_border
EXPORTING
border = cl_gui_cfw=>false.
CALL METHOD gr_splitter_container->set_row_mode
EXPORTING
mode = gr_splitter_container->mode_relative.
gr_container =
gr_splitter_container->get_container( row = 1 column = 1 ).
*---- Creating ALV Grid instance
CREATE OBJECT gr_alvgrid
EXPORTING
i_parent = gr_container.
*---- Preparing document header
PERFORM prepare_header.
ENDIF.
*-- Creating an instance for the event handler
CREATE OBJECT gr_event_handler.
*-- Registering handler methods to handle ALV Grid events
* NOTA: Qua vanno registrati eventuali metodi aggiunti per gestire
* altri eventi della classe CL_GUI_ALV_GRID.
SET HANDLER gr_event_handler->handle_double_click FOR gr_alvgrid.
SET HANDLER gr_event_handler->handle_hotspot_click FOR gr_alvgrid.
SET HANDLER gr_event_handler->handle_data_changed FOR gr_alvgrid.
SET HANDLER gr_event_handler->handle_data_changed_finished
FOR gr_alvgrid.
SET HANDLER gr_event_handler->handle_toolbar FOR gr_alvgrid.
SET HANDLER gr_event_handler->handle_user_command FOR gr_alvgrid.
*-- Preparing layout structure
PERFORM prepare_layout.
*-- Preparing print structure
PERFORM prepare_print.
*-- Preparing field catalog
PERFORM prepare_field_catalog.
*-- Preparing sort criteria table
PERFORM prepare_sort_criteria.
*-- Prepating filter criteria table
PERFORM prepare_filter_criteria.
*-- Preparing function codes to exclude from the toolbar
PERFORM prepare_toolbar_exclude.
*-- Preparing the output for the ALV grid list
*-- NOTE: set I_BUFFER_ACTIVE = 'X' to speed to the list display
*-- if the ALV grid uses statically always the same field catalog
CALL METHOD gr_alvgrid->set_table_for_first_display
EXPORTING
* i_buffer_active = 'X'
* i_structure_name = 'GS_OUTTAB'
is_variant = gs_variant
i_save = 'A'
i_default = 'X'
is_layout = gs_layout
is_print = gs_print
* IT_SPECIAL_GROUPS =
it_toolbar_excluding = gt_exclude[]
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
CHANGING
it_outtab = gt_outtab[]
it_fieldcatalog = gt_fieldcat[]
it_sort = gt_sort[]
it_filter = gt_filter[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
*-- Allows to edit the toolbar
CALL METHOD gr_alvgrid->set_toolbar_interactive.
Maybe you are looking for
-
How to restore Windows 7 OA after HD replacement?
I had Windows 7 Home Premium OA installed on my Sony VAIO VPCSE13FX laptop. It is not under warranty. After malfunctioning of my HD, I replaced it. Do I have to pay $76.15 for a new recovery CD to be able to re-install Windows? And, guys, there is
-
Pass the BPEL Input Payload to Embedded Java Program
Please let me know how can we pass the Input to a BPEL process to the embedded Java Program. Requirement: To pass the payload recieved by the BPEL process to a Java method using embedded java activity where we can parse/modify this payload I tried th
-
Manage multiple Adobe Type Kit sets
Is there a way to manage or see my teams Adobe Type Kit sets from the plan administrator's console? If not do you have a method or recommendation for monitoring or consolidating the Adobe Type Kit sets across multiple users?
-
Can Flex get faster using BLAZEDS with JBOSS
how can i make the data push faster? i develop an application on java that reads data from a gps located in a car, and other java receive this data. im actually sending the data to FLEX using BlazeDS and JBoss as application server, but i dont know w
-
How many tracks max without a core audio overload?
How many tracks is everyone able to obtain before getting a core audio overload. I have a dual gig G4 with 2 gig of ram. I've got my audio on external D2 firewire drives. I have a project that may be about 45 tracks or so at the time of the mix. I wo