ECATT SAPGUI method to capture ALV grid contents
Dear All,
I am using eCATT SAPGUI method to record the transaction VF04. The problem here is I am unable to capture the contents of the ALV grid present in the transaction.
Were any one of you able to capture the contents of ALV grid using SAPGUI method, if so, please do help me to solve this problem.
Thanks in advance,
Sidharth
Hi Sidharth,
Did u find any solution for this problem .
Iam facing same problem for MRIS,MRRL alv reports.Iam recording through SAP GUI but I want One out put field in log. If U find any solution for this plz forward to me.
Thanks in advance
Raju.K
Similar Messages
-
Capturing the current ALV grid contents. How?
Hi forum,
After lots of searching, I still can't find out how I can get the current contents of the ALV grid. I need this for an editable ALV grid to keep track of the data changes.
By the way, I am using the traditional ALV, not OO ALV.
Let me share the steps I already did but still failed.
1
I used the FM GET_GLOBALS_FROM_SLVC_FULLSCR to have access to the CL_GUI_ALV_GRID object. I tried using some of the methods inside that class, all to no avail.
Some methods I tried were set_selected_columns and set_selected_rows and then call the method get_selected_cells. Basically, the idea is to simulate highlighting of cells, and select them using get_selected_cells. But the problem is that get_selected_cells is not returning the value (although it correctly returns the row and column that I set -- but not the value in that cell coordinates).
2
I also saw the protected method get_changed_data -- but the problem is that it is protected, so I created a subclass of CL_GUI_ALV_GRID to ZCL_GUI_ALV_GRID and copied the private attributes and methods that get_changed_data depends on. I was able to do this but GET_GLOBALS_FROM_SLVC_FULLSCR strictly returns CL_GUI_ALV_GRID. The upcast from CL_GUI_ALV_GRID to ZCL_GUI_ALV_GRID fails. So I still can't use/test get_changed_data.
3
I also saw some code regarding events. Here's a sample but this doesn't work:
REFRESH lt_events.
lwa_event-name = 'DATA_CHECK'. "Event name
lwa_event-form = 'HANDLE_DATA_CHANGED'.
APPEND lwa_event TO lt_events.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
it_fieldcat_lvc = it_fieldcat
is_layout_lvc = ls_layout
it_events = lt_events
FORM handle_data_changed using ref_data_changed
type ref to cl_alv_changed_data_protocol.
BREAK-POINT.
ENDFORM.
I would really appreciate it (and I know a lot of other ABAPers will, too) if you could point me to how I can get the ALV grid contents. Thanks.
KyleHi Keshav,
sure I will check those tomorrow when I get back to work.
All,
Here's the code if it helps:
*& Report Z_ALV_EDITABLE
REPORT Z_ALV_EDITABLE.
TYPE-POOLS:
slis
DATA:
BEGIN OF i_out OCCURS 0,
operand1 TYPE i,
operand2 TYPE i,
operator TYPE c,
result TYPE i,
END OF i_out
START-OF-SELECTION.
PERFORM prepareData.
PERFORM refreshResults.
PERFORM createALV_LVC.
FORM prepareData.
REFRESH i_out.
DO 10 TIMES.
i_out-operand1 = 1.
i_out-operand2 = 2.
i_out-operator = '+'.
APPEND i_out.
ENDDO.
ENDFORM.
FORM refreshResults.
LOOP AT i_out.
CASE i_out-operator.
WHEN '+'.
i_out-result = i_out-operand1 + i_out-operand2.
WHEN '-'.
i_out-result = i_out-operand1 - i_out-operand2.
WHEN '*'.
i_out-result = i_out-operand1 * i_out-operand2.
WHEN '/'.
IF i_out-operand2 NE 0.
i_out-result = i_out-operand1 - i_out-operand2.
ENDIF.
WHEN OTHERS.
i_out-result = ''.
ENDCASE.
MODIFY i_out.
ENDLOOP.
ENDFORM.
FORM createALV_LVC.
DATA:
it_fieldcat TYPE lvc_t_fcat,
ls_layout TYPE lvc_s_layo,
lt_events TYPE slis_t_event,
lwa_event TYPE slis_alv_event
" Field Catalog
PERFORM createFieldcat CHANGING it_fieldcat.
" Sorting
PERFORM createSort.
" Layout
ls_layout-cwidth_opt = 'X'.
" Events
REFRESH lt_events.
lwa_event-name = 'DATA_CHECK'. "Event name
lwa_event-form = 'HANDLE_DATA_CHANGED'.
APPEND lwa_event TO lt_events.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
it_fieldcat_lvc = it_fieldcat
is_layout_lvc = ls_layout
* it_sort =
it_events = lt_events
i_callback_program = 'Z_ALV_EDITABLE'
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'PF_STATUS_SET'
i_save = 'X'
TABLES
t_outtab = i_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM.
FORM createFieldcat CHANGING it_fieldcat TYPE lvc_t_fcat.
DATA:
wa_fcat LIKE LINE OF it_fieldcat
REFRESH it_fieldcat.
DEFINE m_append_fieldcat.
CLEAR wa_fcat.
wa_fcat-edit = &1.
wa_fcat-fieldname = &2.
wa_fcat-scrtext_m = &3.
APPEND wa_fcat TO it_fieldcat.
END-OF-DEFINITION.
m_append_fieldcat '' 'OPERAND1' 'Operand 1'.
m_append_fieldcat '' 'OPERAND2' 'Operand 2'.
m_append_fieldcat 'X' 'OPERATOR' 'Operator'.
m_append_fieldcat '' 'RESULT' 'Result'.
ENDFORM.
FORM createSort.
ENDFORM.
FORM PF_STATUS_SET USING P_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'Z_ALV_STATUS' EXCLUDING P_EXTAB.
ENDFORM. "PF_STATUS_SET
FORM user_command
USING
r_ucomm TYPE sy-ucomm
ls_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN 'REFRESH'.
" CHECK i_out HERE IF IT CHANGED ALONG WITH THE EDITS
BREAK-POINT.
* PERFORM refreshALV.
ENDCASE.
ENDFORM.
FORM handle_data_changed using ref_data_changed
type ref to cl_alv_changed_data_protocol.
BREAK-POINT.
ENDFORM. -
ALV Grid contents to be saved as Report Varaint
Hello Folks,
There is a requirement to select and specify Table Fields on the Report Selection Screen. The UI should be something in a form of a Table Control or an Editable ALV grid. ALV Grid is the choice made for capturing the Table Fields (through classical Dynpro).
This Table Fields will be then read in the program to retrieve data from the DB table and finally display it in the dynamic ALV.
I am thinking of how to achieve the following:
- Is it possible to have an editable ALV grid on a Report Selection Screen? If yes, how can it be achieved.
- is it possible to save the contents (data) on the ALV grid in something like a report variant. So that the the user do not have to fill-up the data in the grid everytime.
Thank youWell , Let this be a start for you. In the below code the alv is displayed in selection screen and the values can be saved as variant.
The dynamic table creation stuff's are discussed a lot here, please search for that. The below code is just written instantly and can be firther corrected and optimized.
Execute and check it once.
TYPE-POOLS:slis.
CLASS lcl_event_receiver DEFINITION DEFERRED.
TYPES:BEGIN OF ty,
field TYPE fld_namev,
END OF ty.
DATA:it TYPE TABLE OF ty,
wa TYPE ty,
fieldcat TYPE lvc_t_fcat,
l_valid TYPE c,
obj type ref to cl_gui_alv_grid,
g_verifier type ref to lcl_event_receiver,
wa_fcat type lvc_s_fcat,
repid type sy-repid,
dock type ref to cl_gui_docking_container.
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
ENDCLASS.
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
DATA:ls_good TYPE lvc_s_modi.
LOOP AT er_data_changed->mt_good_cells INTO ls_good.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
PARAMETERS:pa_tab TYPE tabname16.
PARAMETERS:pa_str TYPE string NO-DISPLAY.
AT SELECTION-SCREEN OUTPUT.
IF NOT sy-slset IS INITIAL.
SPLIT pa_str AT cl_abap_char_utilities=>cr_lf INTO TABLE it.
ENDIF.
IF dock IS INITIAL.
repid = sy-repid.
CREATE OBJECT dock
EXPORTING
repid = repid
dynnr = sy-dynnr
ratio = 80
side = cl_gui_docking_container=>dock_at_bottom
name = 'DOCK_CONT'.
ENDIF.
IF obj IS INITIAL.
CREATE OBJECT obj
EXPORTING
i_parent = dock.
ENDIF.
IF fieldcat IS INITIAL.
wa_fcat-fieldname = 'FIELD'.
wa_fcat-seltext = 'Field Name'.
wa_fcat-edit = 'X'.
APPEND wa_fcat TO fieldcat.
ENDIF.
if g_verifier is initial.
CREATE OBJECT g_verifier.
SET HANDLER g_verifier->handle_data_changed FOR obj.
endif.
CALL METHOD obj->set_table_for_first_display
CHANGING
it_fieldcatalog = fieldcat
it_outtab = it.
CALL METHOD obj->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
AT SELECTION-SCREEN.
IF sy-ucomm EQ 'SPOS'.
CALL METHOD obj->check_changed_data
IMPORTING e_valid = l_valid.
LOOP AT it INTO wa.
IF sy-tabix = 1.
pa_str = wa-field.
ELSE.
CONCATENATE pa_str cl_abap_char_utilities=>cr_lf
wa-field INTO pa_str.
ENDIF.
ENDLOOP.
ENDIF.
START-OF-SELECTION. -
Hi guys,
I use the following method (register_edit_event) in the PBO soon after first display of an editable ALV grid to register enter as an event to do validations on fields like qty. If user enters some character like 'abc' for qty and hits enter on keyboard, ALV grid pop's up a standard message ( I haven't coded for this.Since I use DDIC structure in field catalog, the Std. ALV program takes care of it. ). THis takes care of the validation before I click on save.
call method alv_grid->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
This works fine. But I want this validation to run when I also click the SAVE button of the screen. Is it possible to run this standard validation in my PAI event eg. SAVE ? I thought I will be, by calling the method check_changed_data in my PAI event. But this is doing nothing. Does this method conflict with register_edit_event or something ? So , basically what I am looking for is to trigger the event or call the method which does the same work as the "check" button on ALV grid.
Any advice or tips or sample code is greatly appreciated.
Thanks,
ShareenHi Shareen,
Handle the data_changed event in the grid.
Whenever you make changes in the data in ALV Grid this event would be triggered. Here you can perform additional validations that you may need to perform.
METHODS handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
Implementation:
METHOD handle_data_changed.
PERFORM validations USING er_data_changed.
ENDMETHOD.
FORM validations USING er_data_changed TYPE REF TO cl_alv_changed_data_protocol.
DATA: ls_good TYPE lvc_s_modi.
DATA wa LIKE LINE OF lt_good_cells.
CALL METHOD g_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
LOOP AT er_data_changed->mt_good_cells INTO ls_good.
CASE ls_good-fieldname.
WHEN 'FIELDNAME'. "Your fieldname
CALL METHOD er_data_changed->get_cell_value "Get the changed value
EXPORTING
i_row_id = ls_good-row_id
i_fieldname = ls_good-fieldname
IMPORTING
e_value = temp. "Your temp variable
"Make your validations here.
ENDCASE.
Ps: Reward points if helpful.
Regards,
Wenceslaus. -
How to handle user command method in module ALV Grid
HI Experts,
I have 3 containers grid.
GR_GRID TYPE REF TO CL_GUI_ALV_GRID,
GR_GRID1 TYPE REF TO CL_GUI_ALV_GRID,
GR_GRID2 TYPE REF TO CL_GUI_ALV_GRID.
Please advise me how can I insert, save, delete 3 Module ALV Grid in method user command. How can i get which grid button (save, insert, delete) is clicked and how can i control those grid.
Thks in advance.
CLASS LCL_EVENT_RECEIVER DEFINITION.
PUBLIC SECTION.
METHODS :
HANDLE_TOOLBAR
FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID
IMPORTING E_OBJECT E_INTERACTIVE SENDER,
HANDLE_USER_COMMAND
FOR EVENT USER_COMMAND OF CL_GUI_ALV_GRID
IMPORTING E_UCOMM,
HANDLE_DATA_CHANGED
FOR EVENT DATA_CHANGED OF CL_GUI_ALV_GRID
IMPORTING ER_DATA_CHANGED
E_ONF4
E_ONF4_BEFORE
E_ONF4_AFTER,
HANDLE_DOUBLE_CLICK
FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW
E_COLUMN,
HANDLE_HOTSPOT_CLICK
FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW_ID
E_COLUMN_ID
ES_ROW_NO.
ENDCLASS. "(LCL_EVENT_RECEIVER DEFINITION)
METHOD HANDLE_USER_COMMAND.
CLEAR G_CODE.
G_CODE = E_UCOMM.
CASE G_CODE.
WHEN 'INSERT'.
MESSAGE 'insert' TYPE 'I'.
APPEND INITIAL LINE TO GT_MAIN.
WHEN 'SAVE'.
MODIFY ZTNBOOK FROM GT_MAIN.
MESSAGE 'save' TYPE 'I'.
WHEN 'DELETE'.
DELETE FROM ZTNBOOK WHERE B_ID EQ GT_ZTBOOK-B_ID.
MESSAGE 'delete' TYPE 'I'.
ENDCASE.
IF NOT G_CODE IS INITIAL.
PBO, PAI
CALL METHOD CL_GUI_CFW=>SET_NEW_OK_CODE
EXPORTING
NEW_CODE = G_CODE.
CLEAR G_CODE.
ENDIF.
ENDMETHOD.Hi,
Before posting, Search in SDN.
See the below tread it will help you.
Re: Get table for cl_gui_alv_grid -
Problem in GET_CURRENT_CELL method in oops ALV GRID
Hi,
I got output records int eh ALV GRID and i have a one push button in the report. When i select any CELL(say 5 row) in ALV GRID and click on this push Button, it should display me the Row number (row number = 5). I have used the GET_CURRENT_CELL. when I execute the report and select one cell (5 row cell )and click on push button, it is giving me the Row number(row number = 5) correctly. Again when i choose the cell (say 8 record)second time, it should display give the row number = 8 but always it is giving me the First row number .
Get selected row
PERFORM get_selected_row CHANGING l_sel_row.
FORM get_selected_row CHANGING p_l_sel_row.
DATA: li_sel_row TYPE i, "Selected row
lv_rowid TYPE lvc_s_row.
Query which row was selected.
CALL METHOD grid_brr_main->get_current_cell
IMPORTING
e_row = li_sel_row
es_row_id = lv_rowid.
MOVE lv_rowid-index TO p_l_sel_row.
ENDFORM. " get_selected_row
Regards,
Deepthi.Hi,
Probably the data is not getting refreshed.
Please call the following methods.
REFRESH_TABLE_DISPLAY in PBO.
Call this method only if the grid has been created and called once using SET_TABLE_FOR_FIRST_DISPLAY.
As follows:-
If grid is initial.
call method grid-set_table_for_first_display
else
call method grid->REFRESH_TABLE_DISPLAY.
endif.
In the PAI.
call the following method.
grid->CHECK_CHANGED_DATA
So that the data changes are transferred.
Regards,
Ankur Parab
Edited by: Ankur Parab on Jun 4, 2009 5:18 PM -
How to capture multiple rows of ALV grid when user selected?
Actually,It is easy to get one single line.However, my user wants select several lines of ALV grid by condition . i need to process the selected lines ,so i need to put these lines into an internal table. But now, i have no idea to capture the lines.
What method for an ALV Grid will return the lines the user has selected?
Appreciate for your help!
Edited by: Heyman52 on Aug 25, 2010 4:28 AM
Edited by: Heyman52 on Aug 25, 2010 4:30 AMHi,
Once user selects multiple rows and press another button for further execution, you can modify your internal table with marked rows using selection column.
You need to add user command code in your ALV grid call. Please refer below code.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'F_GUI_STATUS'
I_CALLBACK_USER_COMMAND = 'F_USERCOMMAND'
I_GRID_TITLE = TEXT-026
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = I_FIELDCAT
TABLES
T_OUTTAB = I_OUTTAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC NE 0.
MESSAGE S475 DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
*- User command for details display.
PERFORM F_USERCOMMAND USING I_UCOMM
I_SELFIELD.
FORM F_USERCOMMAND USING FP_R_UCOMM LIKE SY-UCOMM
FP_SELFIELD TYPE SLIS_SELFIELD.
IF L_V_REF_GRID IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = L_V_REF_GRID.
ENDIF.
IF NOT L_V_REF_GRID IS INITIAL.
CALL METHOD L_V_REF_GRID->CHECK_CHANGED_DATA.
ENDIF.
ENDFORM.
You can then read your final internal table as below and take the selected records in another internal table.
LOOP AT I_OUTTAB ASSIGNING <FS_OUTTAB> WHERE SEL EQ 'X'.
APPEND <FS_OUTTAB> TO I_CHECK.
ENDLOOP.
Edited by: Archana Pawar on Aug 25, 2010 11:16 AM -
ALV using methods. Capturing editable cell data.
Hi, I have created ALV grid using container. I have made one of the cells as editable. Now how can i capture the edited data.
Hi Vishnu,
try the below options..
Have u used
DATA gr_event_handler TYPE REF TO lcl_event_handler .
*--Creating an instance for the event handler
CREATE OBJECT gr_event_handler .
*--Registering handler methods to handle ALV Grid events
SET HANDLER gr_event_handler->handle_data_changed FOR gr_alvgrid .
SET HANDLER gr_event_handler->handle_data_changed_finished FOR gr_alvgrid .
CASE sy-ucomm.
WHEN 'SAVE'.
to reflect the data changed into internal table
DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new
IF ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid.
ENDIF.
IF NOT ref_grid IS INITIAL.
CALL METHOD ref_grid->check_changed_data.
ENDIF.
ENDCASE.
"User command module at PAI:
CASE gd_okcde. WHEN 'SWITCH'.
" switch editable / non-editable PERFORM switch. ...
FORM switch. "(1) Read current fieldcatalog
go_grid->get_frontend_layout( ). "(2) Mark / Unmark EDIT flag in fieldcatalog
LOOP AT gt_fcat INTO ls_fcat WHERE ( fieldname = '<name of column>' ). " which you want to edit
IF ( ls_fcat-edit = 'X' ).
ls_fcat-edit = space.
ELSE.
ls_fcat-edit = 'X'.
ENDIF.
MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix. ENDLOOP. "(3) Set modified fieldcatalog:
go_grid->set_frontend_layout( ).
ENDFORM.
also have a look on the below programs
BCALV_EDIT_01
BCALV_EDIT_02
BCALV_EDIT_03
BCALV_EDIT_04
BCALV_EDIT_05
BCALV_EDIT_06
BCALV_EDIT_07
BCALV_EDIT_08
Use attribute CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell to status "editable".
Use attribute CL_GUI_ALV_GRID=>MC_STYLE_DISABLED to set a cell to status "non-editable". -
ALV GRID DISPLAY USING FACTORY METHODS
Hi all
I am using factory methods for my alv grid display.
I have a list of functionalities, for which i am not able to find a correct method..
1) Header of alv(with all the values of the selection-screen)
2)How to give text to a subtotal(ed) column, i.e. if i subtotal a qty field against a sorted field, i want to display ==> Nett Wt. = 123.00 (for first header entry) and so on for each header entry.
3)how to remove the zeroes from a quantity field?
4) Displaying the cells as blanks where data is 0( for quantity fields if i have a cell with zero value, it should be blank.)
5) double click on a cell to open a transaction with the cell's value.
Any help on this would be appreciated.
Points will be rewarded for sure...
Thanks & Regards
Ravish GargHello Ravish
Regarding the display of zero values as empty cells have a look at my <i>modified </i>sample report <b>ZUS_SDN_CL_SALV_TABLE_INTERACT</b>.
*& Report ZUS_SDN_CL_SALV_TABLE_INTERACT
REPORT zus_sdn_cl_salv_table_interact.
TYPE-POOLS: abap.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1.
DATA:
go_table TYPE REF TO cl_salv_table,
go_events TYPE REF TO cl_salv_events_table.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_double_click FOR EVENT
if_salv_events_actions_table~double_click
OF cl_salv_events_table
IMPORTING
row
column.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
* define local data
DATA:
lo_table TYPE REF TO cl_salv_table,
lt_orders TYPE STANDARD TABLE OF bapiorders,
ls_knb1 TYPE knb1.
READ TABLE gt_knb1 INTO ls_knb1 INDEX row.
IF ( syst-subrc = 0 ).
CALL FUNCTION 'BAPI_SALESORDER_GETLIST'
EXPORTING
customer_number = ls_knb1-kunnr
sales_organization = '1000'
* MATERIAL =
* DOCUMENT_DATE =
* DOCUMENT_DATE_TO =
* PURCHASE_ORDER =
* TRANSACTION_GROUP = 0
* PURCHASE_ORDER_NUMBER =
* IMPORTING
* RETURN =
TABLES
sales_orders = lt_orders.
* Create ALV grid instance
TRY.
CALL METHOD cl_salv_table=>factory
* EXPORTING
* LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
* R_CONTAINER =
* CONTAINER_NAME =
IMPORTING
r_salv_table = lo_table
CHANGING
t_table = lt_orders.
CATCH cx_salv_msg .
ENDTRY.
lo_table->display( ).
** SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
** SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
** CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
ENDIF.
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = '1000'.
* Create ALV grid instance
TRY.
CALL METHOD cl_salv_table=>factory
* EXPORTING
* LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
* R_CONTAINER =
* CONTAINER_NAME =
IMPORTING
r_salv_table = go_table
CHANGING
t_table = gt_knb1.
CATCH cx_salv_msg .
ENDTRY.
* Create event instance
go_events = go_table->get_event( ).
* Set event handler
SET HANDLER:
lcl_eventhandler=>handle_double_click FOR go_events.
PERFORM modify_columns.
go_table->display( ).
END-OF-SELECTION.
*& Form MODIFY_COLUMNS
* text
* --> p1 text
* <-- p2 text
FORM modify_columns .
* define local data
DATA:
lt_dfies TYPE ddfields,
ls_dfies TYPE dfies,
lo_typedescr TYPE REF TO cl_abap_typedescr,
lo_strucdescr TYPE REF TO cl_abap_structdescr,
lo_tabledescr TYPE REF TO cl_abap_tabledescr,
lo_columns TYPE REF TO cl_salv_columns_table,
lo_column TYPE REF TO cl_salv_column.
lo_columns = go_table->get_columns( ).
lo_typedescr = cl_abap_typedescr=>describe_by_data( gt_knb1 ).
lo_tabledescr ?= lo_typedescr.
lo_strucdescr ?= lo_tabledescr->get_table_line_type( ).
lt_dfies = lo_strucdescr->get_ddic_field_list( ).
LOOP AT lt_dfies INTO ls_dfies.
lo_column = lo_columns->get_column( ls_dfies-fieldname ).
IF ( ls_dfies-keyflag = abap_true ).
CONTINUE.
ELSEIF ( ls_dfies-fieldname = 'WEBTR' ). " Bill of ex. limit
lo_column->set_zero( if_salv_c_bool_sap=>true ). " display zero
lo_column->set_zero( if_salv_c_bool_sap=>false ). " hide zero
ELSE.
lo_column->set_technical( if_salv_c_bool_sap=>true ). " hide col
ENDIF.
ENDLOOP.
ENDFORM. " MODIFY_COLUMNS
Regards
Uwe -
Hi all
I am using <b>factory methods for my alv grid display.</b>
I have a list of functionalities, for which i am not able to find a correct method..
1) Header of alv(with all the values of the selection-screen) along with labels
2)How to give text to a subtotal(ed) column, i.e. if i subtotal a qty field against a sorted field, i want to display ==> Nett Wt. = 123.00 (for first header entry) and so on for each header entry.
3)how to remove the zeroes from a quantity field?
4) Displaying the cells as blanks where data is 0( for quantity fields if i have a cell with zero value, it should be blank.)
5) double click on a cell to open a transaction with the cell's value.
6) how to have multiple subtotal columns, without disturbing the sort order of grid display
Any help on this would be appreciated.
Points will be rewarded for sure...
Thanks & Regards
Ravish GargHello Ravish
Regarding the handling of the <u>double-click</u> event have a look at sample report <b>ZUS_SDN_CL_SALV_TABLE_INTERACT</b>.
*& Report ZUS_SDN_CL_SALV_TABLE_INTERACT
REPORT zus_sdn_cl_salv_table_interact.
TYPE-POOLS: abap.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1.
DATA:
go_table TYPE REF TO cl_salv_table,
go_events TYPE REF TO cl_salv_events_table.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_double_click FOR EVENT
if_salv_events_actions_table~double_click
OF cl_salv_events_table
IMPORTING
row
column.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
* define local data
DATA:
lo_table TYPE REF TO cl_salv_table,
lt_orders TYPE STANDARD TABLE OF bapiorders,
ls_knb1 TYPE knb1.
READ TABLE gt_knb1 INTO ls_knb1 INDEX row.
IF ( syst-subrc = 0 ).
CALL FUNCTION 'BAPI_SALESORDER_GETLIST'
EXPORTING
customer_number = ls_knb1-kunnr
sales_organization = '1000'
* MATERIAL =
* DOCUMENT_DATE =
* DOCUMENT_DATE_TO =
* PURCHASE_ORDER =
* TRANSACTION_GROUP = 0
* PURCHASE_ORDER_NUMBER =
* IMPORTING
* RETURN =
TABLES
sales_orders = lt_orders.
* Create ALV grid instance
TRY.
CALL METHOD cl_salv_table=>factory
* EXPORTING
* LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
* R_CONTAINER =
* CONTAINER_NAME =
IMPORTING
r_salv_table = lo_table
CHANGING
t_table = lt_orders.
CATCH cx_salv_msg .
ENDTRY.
lo_table->display( ).
** SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
** SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
** CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
ENDIF.
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = '1000'.
* Create ALV grid instance
TRY.
CALL METHOD cl_salv_table=>factory
* EXPORTING
* LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
* R_CONTAINER =
* CONTAINER_NAME =
IMPORTING
r_salv_table = go_table
CHANGING
t_table = gt_knb1.
CATCH cx_salv_msg .
ENDTRY.
* Create event instance
go_events = go_table->get_event( ).
* Set event handler
SET HANDLER:
lcl_eventhandler=>handle_double_click FOR go_events.
go_table->display( ).
END-OF-SELECTION.
Regards
Uwe -
Require some tutorials to use ALV grids to access database
I am new to ALV grids
I want step by step method to use ALV grids in ABAP reports to access database.Hi,
pls go throgugh this link.
http://www.erpgenie.com/abap/controls/alvgrid.htm
sample program
Sample programs on ALV Grid
report zbnstest.
TABLES AND DATA DECLARATION.
*TABLES: mara,makt.",marc.
data syrepid like sy-repid.
data sydatum(10). " LIKE sy-datum.
data sypagno(3) type n.
WHEN USING MORE THAN ONE TABLE IN ALV WE NEEED TO DECLARE THE TYPE
GROUP (TYPE-POOLS--------->SLIS)
type-pools : slis.
INTERNAL TABLE DECLARATION.
INTERNAL TABLE TO HOLD THE VALUES FROM THE MARA TABLE
data: begin of t_mara occurs 0,
matnr like mara-matnr,
meins like mara-meins,
mtart like mara-mtart,
matkl like mara-matkl,
end of t_mara.
INTERNAL TABLE TO HOLD THE CONTENTS FROM THE EKKO TABLE
data : begin of t_marc occurs 0,
matnr like mara-matnr,
werks like marc-werks,
minbe like marc-minbe.
data: end of t_marc.
INTERNAL TABLE TO HOLD THE VALUES FROM MAKT TABLE.
data : begin of t_makt occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
spras like makt-spras,
end of t_makt.
INTERNAL TABLE WHICH ACTUALLY MERGES ALL THE OTHER INTERNAL TABLES.
data: begin of itab1 occurs 0,
matnr like mara-matnr,
meins like mara-meins,
maktx like makt-maktx,
spras like makt-spras,
werks like marc-werks,
minbe like marc-minbe,
end of itab1.
THE FOLLOWING DECLARATION IS USED FOR DEFINING THE FIELDCAT
AND THE LAYOUT FOR THE ALV.
HERE AS slis_t_fieldcat_alv IS A INTERNAL TABLE WITHOUT A HEADER LINE
WE EXPLICITELY DEFINE AN INTERNAL TABLE OF THE SAME STRUCTURE AS THAT
OF slis_t_fieldcat_alv BUT WITH A HEADER LINE IN THE DEFINITION.
THIS IS DONE TO MAKE THE CODE SIMPLER.
OTHERWISE WE MAY HAVE TO DEFINE THE STRUCTURE AS IN THE NORMAL SAP
PROGRAMS.
IN THE FIELDCATALOG TABLE WE ACTUALLY PASS THE FIELDS FROM ONE OR
MORE TABLES AND CREATE A STRUCTURE
IN THE LAYOUT STRUCTURE WE BASICALLY DEFINE THE FORMATTING OPTIONS
LIKE DISPLAY IN THE ZEBRA PATTERN ,THE HOTSPOT OPTIONS ETC.
data: fieldcatalog type slis_t_fieldcat_alv with header line,
fieldlayout type slis_layout_alv.
DECLARING THE EVENTTABLE INTERNL TABLE FOR USING EVENTS LIKE
TOP-OF-PAGE ETC.
data : eventstab type slis_t_event with header line.
DECLARING AN INTERNAL TABLE TO HOLD THE DATA FOR THE TOP-OF-PAGE
data : heading type slis_t_listheader with header line.
data : heading1 type slis_t_listheader with header line.
data : heading2 type slis_t_listheader with header line.
data : heading3 type slis_t_listheader with header line.
data : heading4 type slis_t_listheader with header line.
data : heading5 type slis_t_listheader with header line.
data : heading6 type slis_t_listheader with header line.
data : heading7 type slis_t_listheader with header line.
data : heading8 type slis_t_listheader with header line.
STRUCTURE TO PASS THE COLOR ATTRIBUTES FOR DISPLAY.
data : colorstruct type slis_coltypes.
INITIALIZATION. *
initialization.
syrepid = sy-repid.
sypagno = sy-pagno.
clear fieldcatalog.
START-OF-SELECTION. *
start-of-selection.
SUBROUTINE TO POPULATE THE COLORSTRUCT
perform fill_colorstruct using colorstruct.
SUBROUTINE TO POPULATE THE FIELDS OF THE FIELD CATALOGUE
perform populate_fieldcatalog.
SUBROUTINE TO SELECT DATA FROM VARIOUS TABLES AND POPULATE IT IN THE
INTERNAL TABLE.
perform selectdata_and_sort.
SUBROUTINE TO POPULATE THE LAYOUT STRUCTURE.
perform populate_layout using fieldlayout.
SUBROUTINE TO CALL THE FUNCTION MERGE TO ENSURE PROPER DISPLAY.
perform merge_fieldcatalog.
SUBROUTINE TO POPULATE THE EVENTSTAB.
perform fill_eventstab tables eventstab.
SUBROUTINE TO POPULATE THE HEADING TABLES.
perform fill_headingtable tables heading using 'HEADING'.
perform fill_headingtable tables heading1 using 'HEADING1'.
perform fill_headingtable tables heading2 using 'HEADING2'.
perform fill_headingtable tables heading3 using 'HEADING3'.
perform fill_headingtable tables heading4 using 'HEADING4'.
perform fill_headingtable tables heading5 using 'HEADING5'.
perform fill_headingtable tables heading6 using 'HEADING6'.
perform fill_headingtable tables heading7 using 'HEADING7'.
perform fill_headingtable tables heading8 using 'HEADING8'.
SUBROUTINE TO DISPLAY THE LIST.
perform display_alv_list.
FORMS
IN THIS SUBROUTINE WE POPULATE THE FIELDCATALOG TABLE WITH THE NAMES
OF THE TABLE,FIELDNAME,WHETHER IT IS KEY FIELD OR NOT,HEADING AND
COLUMN JUSTIFICATION.
form populate_fieldcatalog.
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MATNR' 'X' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MEINS' ' '.
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MAKTX' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MTART' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MATKL' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'SPRAS' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'WERKS' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MINBE' ' ' .
endform. " POPULATE_FIELDCATALOG
FORM FILL_FIELDS_OF_FIELDCATALOG *
--> FIELDCATALOG *
--> P_TABNAME *
--> P_FIELDNAME *
--> P_KEY *
--> P_KEY *
form fill_fields_of_fieldcatalog tables fieldcatalog
structure fieldcatalog
using p_tabname
p_fieldname
p_key.
p_no_out.
fieldcatalog-tabname = p_tabname.
fieldcatalog-fieldname = p_fieldname.
fieldcatalog-key = p_key.
fieldcatalog-emphasize = '1234'.
*fieldcatalog-no_out = p_no_out.
append fieldcatalog.
endform. " FILL_FIELDSOFFIELDCATALOG
FORM POPULATE_LAYOUT *
--> FIELDLAYOUT *
form populate_layout using fieldlayout type slis_layout_alv.
fieldlayout-f2code = '&ETA' .
fieldlayout-zebra = 'X'.
FOR THE WINDOW TITLE.
fieldlayout-window_titlebar = 'ALV with Events'.
fieldlayout-colwidth_optimize = 'X'.
fieldlayout-no_vline = ' '.
*fieldlayout-no_input = 'X'.
fieldlayout-confirmation_prompt = ''.
fieldlayout-key_hotspot = 'X'.
This removes the column headings if the flag is set to 'X'
fieldlayout-no_colhead = ' '.
*fieldlayout-hotspot_fieldname = 'MAKTX'.
fieldlayout-detail_popup = 'X'.
fieldlayout-coltab_fieldname = 'X'.
endform. " POPULATE_LAYOUT
FORM SELECTDATA_AND_SORT *
form selectdata_and_sort.
select matnr meins mtart matkl from mara
into corresponding fields of t_mara
up to 500 rows .
select matnr maktx spras from makt
into corresponding fields of t_makt
where matnr = t_mara-matnr and
spras = sy-langu.
select matnr werks minbe from marc
into corresponding fields of t_marc
where matnr = t_mara-matnr.
append t_marc.
endselect.
append t_makt.
endselect.
append t_mara.
endselect.
perform populate_itab1.
sort itab1 by matnr.
endform. " SELECTDATA_AND_SORT
FORM MERGE_FIELDCATALOG *
form merge_fieldcatalog.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = syrepid
i_internal_tabname = 'ITAB1'
i_structure_name = 'COLORSTRUCT'
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = syrepid
changing
ct_fieldcat = fieldcatalog[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
endform. " MERGE_FIELDCATALOG
IN THIS FUNCTION THE MINIMUM PARAMETERS THAT WE NEED TO PASS IS AS
FOLLOWS:-
i_callback_program --> CALLING PROGRAM NAME
i_structure_name --> STRUCTURE NAME.
is_layout --> LAYOUT NAME.
it_fieldcat ---> BODY OF THE FIELD CATALOGUE INTERNAL TABLE
form display_alv_list.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
i_callback_program = syrepid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
i_structure_name = 'ITAB1'
is_layout = fieldlayout
it_fieldcat = fieldcatalog[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
THE FOLLOWING PARAMETER IS SET AS 'A' INORDER TO DISPLAY THE STANDARD
TOOL BAR
i_save = 'A'
IS_VARIANT = ' '
it_events = eventstab[]
IT_EVENT_EXIT =
IS_PRINT =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = itab1
exceptions
program_error = 1
others = 2.
endform. " DISPLAY_ALV_LIST
*& Form POPULATE_ITAB1
text
--> p1 text
<-- p2 text
form populate_itab1.
loop at t_mara.
loop at t_makt where matnr = t_mara-matnr.
loop at t_marc where matnr = t_mara-matnr.
move-corresponding t_mara to itab1.
move-corresponding t_makt to itab1.
move-corresponding t_marc to itab1.
append itab1.
endloop.
endloop.
endloop.
endform. " POPULATE_ITAB1
*& Form FILL_EVENTSTAB
text
-->P_EVENTSTAB text *
form fill_eventstab tables p_eventstab structure eventstab.
WHEN THE FOLLOWING FUNCTION IS CALLED THE SYSTEM POPULATES THE
INTERNAL TABLE EVENTSTAB WITH A LIST OF EVENTS NAME.
AS SHOWN BELOW WHEN USING I_LIST_TYPE = 0 THE FUNCTION RETURNS 14
EVENTS NAME.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = p_eventstab[]
exceptions
list_type_wrong = 1
others = 2.
BY CALLING THE ABOVE FUNCTION WE FIRST POPULATE THE EVENTSTAB WITH
THE PREDEFINED EVENTS AND THEN WE MOVE THE FORM NAME AS SHOWN BELOW.
WE ASSIGN A FORM NAME TO THE EVENT AS REQUIRED BY THE USER.
FORM NAME CAN BE ANYTHING.THE PERFORM STATEMENT FOR THIS FORM
IS DYNAMICALY CALLED.
read table p_eventstab with key name = slis_ev_top_of_page.
if sy-subrc = 0 .
move 'TOP_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_top_of_coverpage.
if sy-subrc = 0 .
move 'TOP_OF_COVERPAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_coverpage .
if sy-subrc = 0 .
move 'END_OF_COVERPAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_foreign_top_of_page.
if sy-subrc = 0 .
move 'FOREIGN_TOP_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_foreign_end_of_page.
if sy-subrc = 0 .
move 'FOREIGN_END_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_list_modify.
if sy-subrc = 0 .
move 'LIST_MODIFY' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_top_of_list.
if sy-subrc = 0 .
move 'TOP_OF_LIST' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_page.
if sy-subrc = 0 .
move 'END_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_list .
if sy-subrc = 0 .
move 'END_OF_LIST' to p_eventstab-form.
append p_eventstab.
endif.
endform. " FILL_EVENTSTAB
*& Form FILL_HEADINGTABLE
text
-->P_HEADING text *
form fill_headingtable tables p_heading structure heading
using tablename.
case tablename.
when 'HEADING'.
p_heading-typ = 'H'.
concatenate
' REPORT NAME:-' syrepid
' ABB Industry Pte Ltd' into p_heading-info.
append p_heading.
write sy-datum using edit mask '__/__/____' to sydatum.
concatenate
' DATE:-' sydatum ' USER: ' sy-uname 'PAGE NO:' sypagno
into p_heading-info.
append p_heading.
when 'HEADING1'.
p_heading-typ = 'H'.
p_heading-info = 'TOP-OF-COVER-PAGE'.
append p_heading.
when 'HEADING2'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-COVER-PAGE'.
append p_heading.
when 'HEADING3'.
p_heading-typ = 'H'.
p_heading-info = 'FOREIGN-TOP-OF-PAGE'.
append p_heading.
when 'HEADING4'.
p_heading-typ = 'H'.
p_heading-info = 'FOREIGN-END-OF-PAGE'.
append p_heading.
WHEN 'HEADING5'.
P_HEADING-TYP = 'H'.
P_HEADING-INFO = 'LIST-MODIFY'.
APPEND P_HEADING.
when 'HEADING6'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-PAGE'.
append p_heading.
when 'HEADING7'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-LIST'.
append p_heading.
when 'HEADING8'.
p_heading-typ = 'H'.
p_heading-info = 'TOP-OF-LIST'.
append p_heading.
endcase.
endform. " FILL_HEADINGTABLE
FORM TOP_OF_PAGE *
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading[]
exceptions
others = 1.
endform.
*& Form FILL_COLORSTRUCT
text
-->P_COLORSTRUCT text *
form fill_colorstruct using p_colorstruct type slis_coltypes .
p_colorstruct-heacolfir-col = 6.
p_colorstruct-heacolfir-int = 1.
p_colorstruct-heacolfir-inv = 1.
endform. " FILL_COLORSTRUCT
FORM TOP_OF_COVERPAGE *
form top_of_coverpage.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading1[]
exceptions
others = 1.
endform.
FORM END_OF_COVERPAGE *
form end_of_coverpage.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading2[]
exceptions
others = 1.
endform.
FORM FOREIGN_TOP_OF_PAGE *
form foreign_top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading3[]
exceptions
others = 1.
endform.
FORM FOREIGN_END_OF_PAGE *
form foreign_end_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading4[]
exceptions
others = 1.
endform.
FORM LIST_MODIFY *
*FORM LIST_MODIFY.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEADING5[]
EXCEPTIONS
OTHERS = 1.
*ENDFORM.
FORM END_OF_PAGE *
form end_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading6[]
exceptions
others = 1.
endform.
FORM END_OF_LIST *
form end_of_list.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading7[]
exceptions
others = 1.
endform.
FORM TOP_OF_LIST *
form top_of_list.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading8[]
exceptions
others = 1.
endform.
*--- End of Program
Thanks,
Shankar -
Dump when summing up CURR field in ALV GRID display
Hi All,
I am getting dump when I try to sum the CURR field in my ALV Grid Display. The field is of CURR 23. I am using classes and methods to display alv grid.
I tried passing <fs_fieldcat>-do_sum = 'X'. When I did this, it is dumping without even displaying the alv grid.
Here is the part it is throwing dump:
ls_lvc_data-value = space.
clear ls_lvc_data-style.
loop at it_fcat_local assigning <ls_fcat>
where tech ne 'X' and no_out ne 'X'.
if l_invisible eq 'X'.
clear l_invisible.
if <ls_fcat>-do_sum is initial.
continue.
else.
clear ls_lvc_data-col_pos.
endif.
endif.
add 1 to ls_lvc_data-col_pos.
assign component <ls_fcat>-fieldname
of structure <ls_data> to <l_field_value>.
_if sy-subrc ne 0.
message x000(0k).
endif._
Regards,
GuruThomas,
Here is the dump:
Runtime Errors MESSAGE_TYPE_X
Date and Time 10/22/2010 23:30:53
Short text
The current application triggered a termination with a short dump.
What happened?
The current application program detected a situation which really
should not occur. Therefore, a termination with a short dump was
triggered on purpose by the key word MESSAGE (type X).
Error analysis
Short text of error message:
Long text of error message:
Technical information about the message:
Message class....... "0K"
Number.............. 000
Variable 1.......... " "
Variable 2.......... " "
Variable 3.......... " "
Variable 4.......... " "
How to correct the error
Probably the only way to eliminate the error is to correct the program.
If the error occures in a non-modified SAP program, you may be able to
find an interim solution in an SAP Note.
If you have access to SAP Notes, carry out a search with the following
keywords:
"MESSAGE_TYPE_X" " "
"SAPLSLVC" or "LSLVCF36"
"FILL_DATA_TABLE"
If you cannot solve the problem yourself and want to send an error
notification to SAP, include the following information:
1. The description of the current problem (short dump)
To save the description, choose "System->List->Save->Local File
(Unconverted)".
2. Corresponding system log
Display the system log by calling transaction SM21.
Restrict the time interval to 10 minutes before and five minutes
after the short dump. Then choose "System->List->Save->Local File
(Unconverted)".
3. If the problem occurs in a problem of your own or a modified SAP
program: The source code of the program
In the editor, choose "Utilities->More
Utilities->Upload/Download->Download".
4. Details about the conditions under which the error occurred or which
actions and input led to the error.
Source Code Extract
Line
SourceCde
2708
is_subtottxt_info = ls_subtot_info
2709
ip_subtot_line = lr_data
2710
changing
2711
c_subtottxt = l_subtottxt.
2712
ls_lvc_data-value = l_subtottxt.
2713
2714
append ls_lvc_data to ct_lvc_data.
2715
endif.
2716
2717
2718
Column per Fieldcat Entry
2719
2720
ls_lvc_data-value = space.
2721
clear ls_lvc_data-style.
2722
loop at it_fcat_local assigning <ls_fcat>
2723
where tech ne 'X' and no_out ne 'X'.
2724
if l_invisible eq 'X'.
2725
clear l_invisible.
2726
if <ls_fcat>-do_sum is initial.
2727
continue.
2728
else.
2729
clear ls_lvc_data-col_pos.
2730
endif.
2731
endif.
2732
2733
add 1 to ls_lvc_data-col_pos.
2734
2735
assign component <ls_fcat>-fieldname
2736
of structure <ls_data> to <l_field_value>.
2737
if sy-subrc ne 0.
>>>>>
message x000(0k).
2739
endif.
2740
2741
*... work on average
2742
if <ls_fcat>-do_sum eq 'C'.
2743
Initialize average result and entries
2744
<l_field_value> = 0.
2745
clear l_entries.
2746
2747
retrive unit from fieldcatalog
2748
assign space to <l_unit>.
2749
if not <ls_fcat>-cfieldname is initial.
2750
assign component <ls_fcat>-cfieldname
2751
of structure <ls_data> to <l_unit>.
2752
endif.
2753
if not <ls_fcat>-qfieldname is initial.
2754
assign component <ls_fcat>-qfieldname
2755
of structure <ls_data> to <l_unit>.
2756
endif.
2757 -
hey,
alv grid method for export data from alv grid to itab.
regards,
purnaHey,
Any methods for exporting alv grid data into itab. -
Dynamic ALV GRID screen in a class? Possible?
I have created a class(I have done it locally as to be able to use it for mutiple clients) that I include in programs that I want to implement the alv grid for using the FM approach. Doing this allows me to easily implement the ALV quickly. However, I am wanting to use the OO ALV grid approach since there is more flexibility and control doing it this way. But I do not want to have to create a screen for every program that I want to do this for, I would like to just have a method in my existing class that would call a screen and then be able to control it like normal. I know that screens can not be called from a method so I was thinking of doing something similiar to another post using a FM to call the screen. I realize that this could be complicated because certain methods for the ALV GRID are called in the PBO/PAI events. Any help or suggestions would be appreciated.
Note: I am on 6.20 and have searched all over the web before posting.
Thanks.Yes, i have written a function module which calls a generice ALV grid in a dialog box. Everything about the ALV grid is encapsulated in a function module. In this case, all I need to do is send this function module a fieldcatalog and the data, that's about it. Doing this may limit the functionality of event handling or you would just have to handle everything by doing more code for it.. This function module is very simple, not a whole lot to it. You could do something like this only instead of using a model dialog box, you would throw a regular dynpro.
function z_popup_with_alvgrid.
*"*"Global interface:
*" IMPORTING
*" REFERENCE(ENDPOS_COL) TYPE I DEFAULT 90
*" REFERENCE(ENDPOS_ROW) TYPE I DEFAULT 22
*" REFERENCE(STARTPOS_COL) TYPE I DEFAULT 10
*" REFERENCE(STARTPOS_ROW) TYPE I DEFAULT 2
*" REFERENCE(TEXTLINE1) TYPE C OPTIONAL
*" REFERENCE(TEXTLINE2) TYPE C OPTIONAL
*" REFERENCE(TEXTLINE3) TYPE C OPTIONAL
*" REFERENCE(TEXTLINE4) TYPE C OPTIONAL
*" REFERENCE(TITLE) TYPE C OPTIONAL
*" REFERENCE(FIELDCAT) TYPE LVC_T_FCAT
*" TABLES
*" I_ALV
call screen 0200 starting at startpos_col
startpos_row
ending at endpos_col
endpos_row.
endfunction.
* Module STATUS_0200 OUTPUT
module status_0200 output.
set pf-status '0200'.
set titlebar '0200' with title.
data: alv_container type ref to cl_gui_custom_container.
data: alv_grid type ref to cl_gui_alv_grid.
data: xfieldcat type lvc_t_fcat.
xfieldcat = fieldcat.
* Create Controls
create object:
alv_container
exporting
container_name = 'ALV_CONTAINER',
alv_grid
exporting
i_parent = alv_container.
* Set grid for first display
call method alv_grid->set_table_for_first_display(
exporting
i_structure_name = 'I_ALV'
changing
it_outtab = i_alv[]
it_fieldcatalog = xfieldcat[] ).
endmodule.
* Module USER_COMMAND_0100 INPUT
module user_command_0200 input.
case sy-ucomm.
when 'CONTINUE' or 'CANCEL'.
set screen 0.
leave screen.
endcase.
endmodule.
Regards,
Rich Heilman -
Deactivate buttons in ALV GRID being called in subscreen
Hi,
In a screen, when a specific tab is selected (tab strip), the subscreen area is filled with ALV GRID. I need to deactivate few buttons on the ALV GRID. How can that be done??
Advance ThanksHi Aadarsh,
Check out the following program.
Global data definitions for ALV
To allow the declaration of gr_event_handler before the
lcl_event_receiver class is defined, decale it as deferred in the
start of the program
CLASS lcl_event_handler DEFINITION DEFERRED.
Object reference
ALV Grid instance reference
DATA: gr_alvgrid TYPE REF TO cl_gui_alv_grid,
Custom container instance reference
gr_ccontainer TYPE REF TO cl_gui_custom_container,
Event class reference
gr_event_handler TYPE REF TO lcl_event_handler. "IC210507+
Internal Table
Field catalog table
DATA: gt_fieldcat TYPE lvc_t_fcat,
Internal table holding list data
gt_list TYPE STANDARD TABLE OF sflight,
Table to be filled up for excluding some of the standard function
buttons
gt_exclude TYPE ui_functions. "IC210507+
Work area
Layout structure
DATA: gs_layout TYPE lvc_s_layo,
Field catalog structure
gs_fcat TYPE lvc_s_fcat,
Exclude button structure
gs_exclude TYPE ui_func, "IC210507+
Structure to add button in the ALV toolbar
gs_toolbar TYPE stb_button. "IC210507+
Variables
DATA: ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm,
Name of the custom control added on the screen
gv_custom_control_name TYPE scrfname VALUE 'CC_ALV'.
Begin of IC210507
Local classes
CLASS lcl_event_handler 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 e_interactive,
To implement user commands
handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS. "lcl_event_handler DEFINITION
End of IC210507
Calling the screen where ALV output is displayed
CALL SCREEN 100.
*& Module STATUS_0100 OUTPUT
PBO
MODULE status_0100 OUTPUT.
ALV display
PERFORM display_alv.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
PAI
MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
IF save_ok EQ 'EXIT'.
LEAVE PROGRAM.
ENDIF.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form display_alv
ALV display
FORM display_alv.
PERFORM get_data.
PERFORM create_alv.
ENDFORM. " display_alv
*& Form get_data
Fetch data to be displayed in the list
FORM get_data.
SELECT * FROM sflight
INTO TABLE gt_list.
ENDFORM. " get_data
*& Form create_alv
Create and set or Refresh ALV
FORM create_alv.
Checking whether an instance of the container (or ALV Grid) exists.
IF gr_alvgrid IS INITIAL.
If not, creating and setting ALV for the first display.
Creating custom container instance
CREATE OBJECT gr_ccontainer
EXPORTING
container_name = gv_custom_control_name
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
Creating ALV Grid instance
CREATE OBJECT gr_alvgrid
EXPORTING
i_parent = gr_ccontainer
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
Begin of IC210507
Creating an instance for the event handler
CREATE OBJECT gr_event_handler.
Registering handler methods to handle ALV Grid events
SET HANDLER gr_event_handler->handle_user_command FOR gr_alvgrid.
SET HANDLER gr_event_handler->handle_toolbar FOR gr_alvgrid.
End of IC210507
Preparing field catalog.
PERFORM prepare_field_catalog CHANGING gt_fieldcat.
Preparing layout structure
PERFORM prepare_layout CHANGING gs_layout.
Excluding Unwanted Standard Function Buttons
PERFORM exclude_tb_functions CHANGING gt_exclude. "IC210507+
Method to display ALV grid
CALL METHOD gr_alvgrid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
To exclude buttons the exclusion table must be passed to the following
field
it_toolbar_excluding = gt_exclude "IC210507+
CHANGING
it_outtab = gt_list
it_fieldcatalog = gt_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
To make ALV show our additional buttons, we must call the method
set_toolbar_interactive for the ALV Grid instance after the instance
is created.
CALL METHOD gr_alvgrid->set_toolbar_interactive. "IC210507+
ELSE.
If an instance of the container (or ALV Grid) exists, refreshing it.
CALL METHOD gr_alvgrid->refresh_table_display
EXCEPTIONS
finished = 1
OTHERS = 2.
ENDIF.
ENDFORM. " create_alv
*& Form prepare_field_catalog
Subroutine to populate field catalog
<--P_GT_FIELDCAT Table to describe the field catalog
FORM prepare_field_catalog CHANGING p_gt_fieldcat TYPE lvc_t_fcat.
Generating the field catalog semi automatically
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
ct_fieldcat = p_gt_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
LOOP AT p_gt_fieldcat INTO gs_fcat.
CASE gs_fcat-fieldname.
WHEN 'CARRID'.
gs_fcat-outputlen = '10'.
gs_fcat-coltext = 'Airline Carrier ID'.
MODIFY p_gt_fieldcat FROM gs_fcat.
WHEN 'FLDATE'.
gs_fcat-just = 'C'.
gs_fcat-hotspot = 'X'.
MODIFY p_gt_fieldcat FROM gs_fcat.
ENDCASE.
ENDLOOP.
ENDFORM. " prepare_field_catalog
*& Form prepare_layout
Preparing layout structure
<--P_GS_LAYOUT Layout structure
FORM prepare_layout CHANGING p_gs_layout TYPE lvc_s_layo.
p_gs_layout-zebra = 'X' .
p_gs_layout-grid_title = 'Flight Info System'.
p_gs_layout-smalltitle = 'X'.
ENDFORM. " prepare_layout
Begin of IC210507
*& Form exclude_tb_functions
Excluding Unwanted Standard Function Buttons
<--P_GT_EXCLUDE Table to be filled up to exclude buttons
FORM exclude_tb_functions CHANGING p_gt_exclude TYPE ui_functions.
MC_FC_ are names for functions directly and the names beginning with
MC_MB_ are for the function menus including some subfunctions as menu
entries.
In this case 'Maximum' and 'Minimum' options under 'Sum' button & 'Print'
button are excluded
gs_exclude = cl_gui_alv_grid=>mc_fc_maximum.
APPEND gs_exclude TO p_gt_exclude.
gs_exclude = cl_gui_alv_grid=>mc_fc_minimum.
APPEND gs_exclude TO p_gt_exclude.
gs_exclude = cl_gui_alv_grid=>mc_fc_print.
APPEND gs_exclude TO p_gt_exclude.
ENDFORM. " exclude_tb_functions
*& Class (Implementation) lcl_event_handler
Event handler for the ALV Grid instance.
CLASS lcl_event_handler IMPLEMENTATION.
Handle Toolbar
METHOD handle_toolbar.
PERFORM handle_toolbar USING e_object e_interactive .
ENDMETHOD . "handle_toolbar
Handle User Command
METHOD handle_user_command .
PERFORM handle_user_command USING e_ucomm .
ENDMETHOD. "handle_user_command
ENDCLASS. "lcl_event_handler
*& Form handle_toolbar
Subroutine called from event handler method for event toolbar.
This is to add a new button in the ALV application toolbar
-->P_E_OBJECT
-->P_E_INTERACTIVE
FORM handle_toolbar USING p_e_object TYPE REF TO cl_alv_event_toolbar_set
p_e_interactive.
Begin of 'Adding a new Button'
CLEAR gs_toolbar.
Function code
MOVE 'EXIT' TO gs_toolbar-function.
Button type that will be added to the toolbar
gs_toolbar-butn_type = 0.
Icon for the button
From the type group ICON in SE11, we can get the value to be passed
for icon
gs_toolbar-icon = '@2N@'.
Quick info for the button
MOVE 'Exit' TO gs_toolbar-quickinfo.
Text for the button
MOVE 'Exit' TO gs_toolbar-text.
Adds the button as disabled if set to X
MOVE ' ' TO gs_toolbar-disabled.
Appending the structure to the table attribute mt_toolbar of the object
APPEND gs_toolbar TO p_e_object->mt_toolbar.
End of 'Adding a new Button'
Begin of 'Disabling an existing standard Button'
LOOP AT p_e_object->mt_toolbar
INTO gs_toolbar
Identify which button to disable from the function code
In this case disabling the 'Filter' button
WHERE function = '&MB_FILTER'.
Set the 'DISABLED' field to disable a button
gs_toolbar-disabled = 'X'.
MODIFY p_e_object->mt_toolbar FROM gs_toolbar.
ENDLOOP.
End of 'Disabling an existing standard Button'
ENDFORM. " handle_toolbar
*& Form handle_user_command
Implement any new function
-->P_E_UCOMM text
FORM handle_user_command USING p_e_ucomm TYPE syucomm.
IF p_e_ucomm EQ 'EXIT'.
LEAVE PROGRAM.
ENDIF.
ENDFORM. " handle_user_command
End of IC210507
Award points if found useful.
Regards
Indrajit.
Maybe you are looking for
-
Is Adobe Bridge included in my Creative Cloud Subscription. I have the Photoshop and Lightroom subscription for Mac
-
Converting a String to Calendar
I have a String which is actually a date in the format yyyyMMdd. I need to take this String and convert it into a Calendar to do a before() check. I want to delete dates prior to a certain date. I am able to use this code to get a String to a Date bu
-
Nik Filters not showing up in 'Edit in' with LR 4.2
I'm running LR 4.2 and all the Nik filters (complete set) are updated yet I only see Color Efex 3.0 Complete and Edit in PS 6.0. All the filters are showing and operating in PS 6.0. I do see HDR Efex Pro 2.0 under export as expected. I'm guessing
-
Any way to clear search history in maps ?
I'm new to IOS but wondering how can I clear search history in the new IOS maps application. Thanks@
-
My iPhone not recognizing SIM Card
I Have an iPhone 4. Since few days my iPhone is not recognizing my SIM Card. I tried all the suggustions for the net but none worked out. How can I recover my iPhone from this problem?