ALV Grid: method double_click provides wrong information with 'totals line'
Hi together,
I´m using 'method double_click' with an ALV grid...like:
CLASS lcl_events IMPLEMENTATION.
METHOD double_click.
READ TABLE it_outtab INDEX e_row-index INTO s_datatab.
Everything works perfect as long as I don´t use totals with it.
Using totals /subtotals lines 'READ TABLE...' provides a wrong row-index.
Any idea how to resolve this problem?
Thanks for any help
Hi, this is a big problem when you use OO to build an ALV, to resolve your problem, you have to implement an event TOOLBAR_BUTTON_CLICK to get button function, when your code pass by this method you have to use the method
CALL METHOD gcl_grid->set_function_code
CHANGING
c_ucomm = l_ucomm.
l_ucomm is the function code of button, the method set_function_code sort your internal table dynamically and you get the correct index when you use double_click.
Regards.
David Carballido
PD: Sry for my bad english ^^
Similar Messages
-
ALV grid abort processing, if wrong value
Hello,
i've a editable alv grid.
Is it possible to abort at event data_changed/data_changed_finished, if an value is wrong (f.e. to high < 500), and write the old value back.
Best regards,
TomSdHello Thomas
The sample report <b>ZUS_SDN_ALVGRID_EDITABLE_10</b> provides a possible (perhaps not the most elegant) solution for your problem.
*& Report ZUS_SDN_ALVGRID_EDITABLE_10
*& Description: Reset false values entered in editable ALV list
*& to original values
*& Example: Column SORT_KEY allows values from '000'-'150'
* -> reset if value > '010'
*& Thread: ALV grid abort processing, if wrong value
*& Link: https:||<a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="669430"></a>
REPORT zus_sdn_alvgrid_editable_10.
TYPE-POOLS: abap.
INCLUDE <icon>. " NOTE: replace by TYPE-POOLS: icon. on >= 6.20
DATA:
gd_repid TYPE syrepid,
gd_okcode TYPE sy-ucomm,
gs_layout TYPE lvc_s_layo,
gt_fcat TYPE lvc_t_fcat,
go_docking TYPE REF TO cl_gui_docking_container,
go_grid TYPE REF TO cl_gui_alv_grid.
TYPES: BEGIN OF ty_s_outtab.
INCLUDE TYPE knb1.
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE OF ty_s_outtab
WITH DEFAULT KEY.
DATA:
gt_outtab TYPE ty_t_outtab,
gt_outtab_pbo TYPE ty_t_outtab.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-DATA:
mo_data_changed TYPE REF TO cl_alv_changed_data_protocol.
CLASS-METHODS:
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING
er_data_changed
e_onf4
e_onf4_before
e_onf4_after
e_ucomm
sender,
handle_data_changed_finished
FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING
e_modified
et_good_cells,
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING
e_ucomm,
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING
e_object
e_interactive.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_data_changed.
* define local data
DATA:
ld_idx TYPE i,
ls_cell TYPE lvc_s_modi,
ls_msg TYPE symsg.
FIELD-SYMBOLS:
<lt_outtab> TYPE ty_t_outtab,
<ls_outtab> TYPE ty_s_outtab.
ASSIGN er_data_changed->mp_mod_rows->* TO <lt_outtab>.
LOOP AT er_data_changed->mt_mod_cells INTO ls_cell
WHERE ( fieldname = 'ZUAWA' ).
ld_idx = syst-tabix.
IF ( ls_cell-value <= '010' ).
READ TABLE <lt_outtab> ASSIGNING <ls_outtab> INDEX ld_idx.
MODIFY gt_outtab FROM <ls_outtab> INDEX ls_cell-row_id. " !!!
ELSE.
CLEAR: ls_msg.
ls_msg-msgv1 = 'Value'.
ls_msg-msgv2 = ls_cell-value.
ls_msg-msgv3 = 'too high (> 010)'.
CALL METHOD er_data_changed->add_protocol_entry
EXPORTING
i_msgid = '00'
i_msgty = 'E'
i_msgno = '398'
i_msgv1 = ls_msg-msgv1
i_msgv2 = ls_msg-msgv2
i_msgv3 = ls_msg-msgv3
* I_MSGV4 =
i_fieldname = ls_cell-fieldname
i_row_id = ls_cell-row_id
i_tabix = ls_cell-tabix.
DELETE er_data_changed->mt_mod_cells INDEX ld_idx.
DELETE er_data_changed->mt_good_cells INDEX ld_idx.
ENDIF.
ENDLOOP.
IF ( syst-subrc = 0 ).
er_data_changed->display_protocol( ).
ENDIF.
** cl_gui_cfw=>set_new_ok_code( 'REFRESH' ). " not possible on 4.6c
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'DUMMY'
* IMPORTING
* RC =
ENDMETHOD. "handle_data_changed
METHOD handle_data_changed_finished.
* define local data
DATA:
ls_outtab TYPE ty_s_outtab,
ls_cell TYPE lvc_s_modi.
ENDMETHOD. "handle_data_changed_finished
METHOD handle_user_command.
ENDMETHOD. "handle_user_command
METHOD handle_toolbar.
* define local data
DATA:
ls_button TYPE stb_button.
ls_button-function = 'DEFAULT'.
ls_button-icon = icon_mass_change.
ls_button-quickinfo = 'Set default value for column'.
APPEND ls_button TO e_object->mt_toolbar.
ENDMETHOD. "handle_toolbar
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_outtab UP TO 20 ROWS
WHERE bukrs = '1000'.
gt_outtab_pbo = gt_outtab. " store PBO data
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
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 ALV grid
CREATE OBJECT go_grid
EXPORTING
i_parent = go_docking
EXCEPTIONS
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.
* Build fieldcatalog
PERFORM build_fieldcatalog.
PERFORM set_layout.
SET HANDLER:
lcl_eventhandler=>handle_toolbar FOR go_grid,
lcl_eventhandler=>handle_data_changed FOR go_grid,
lcl_eventhandler=>handle_data_changed_finished FOR go_grid.
* Display data
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_outtab = gt_outtab
it_fieldcatalog = gt_fcat
EXCEPTIONS
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.
go_grid->set_toolbar_interactive( ).
CALL METHOD go_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter
EXCEPTIONS
error = 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.
* Link the docking container to the target dynpro
gd_repid = syst-repid.
CALL METHOD go_docking->link
EXPORTING
repid = gd_repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
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.
* ok-code field = GD_OKCODE
CALL SCREEN '0100'.
* Flow logic (no elements on screen):
* PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
* PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
* SET TITLEBAR 'xxx'.
CALL METHOD go_grid->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.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
TRANSLATE gd_okcode TO UPPER CASE.
* Fetch changes on ALV grid
go_grid->check_changed_data( ).
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
WHEN 'DUMMY'. " do nothing but pass PAI -> list refresh at PBO
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form BUILD_FIELDCATALOG_KNB1
* text
* --> p1 text
* <-- p2 text
FORM build_fieldcatalog .
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'KNB1'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
" Set required fields editable
LOOP AT gt_fcat INTO ls_fcat
WHERE ( fieldname = 'ZUAWA' OR
fieldname = 'BUSAB' ).
ls_fcat-edit = abap_true.
MODIFY gt_fcat FROM ls_fcat.
ENDLOOP.
DELETE gt_fcat WHERE ( fieldname = 'ZINRT' ).
ENDFORM. " BUILD_FIELDCATALOG
*& Form SET_LAYOUT
* text
* --> p1 text
* <-- p2 text
FORM set_layout .
CLEAR: gs_layout.
gs_layout-cwidth_opt = abap_true.
gs_layout-zebra = abap_true.
** gs_layout-stylefname = 'CELLTAB'.
ENDFORM. " SET_LAYOUT
Regards,
Uwe -
Alv grid : is it possible to create 2 header lines ?
alv grid : is it possible to create 2 header lines ?
for example :
open year close year
from 2006 until 2008
data
data
data
data
i know that i can do so in alv list , but is it possible in alv
grid ( with screen ) ?No, this is not supported by the ALV Grid control.
Regards,
Rich Heilman -
ALV Grid Traffic control Example program implemented with function modules
Hi Friends,
Can any one please give me ALV Grid control traffic lights example program implented using function modules instead of OOP ALV. It is very urgent,
Thanks in advance,
Santosh Kumar.Hi Santosh ,
Here is a sampla code for the same
TYPE-POOLS : SLIS.
DATA : BEGIN OF IT_1 OCCURS 0 ,
MATNR TYPE matnr ,
FLAG TYPE C , " added for the traffic control
END OF IT_1.
SELECT MATNR INTO TABLE IT_1 " Select Data
UP TO 10 ROWS
FROM MARA.
DATA : CATALOG TYPE SLIS_T_FIELDCAT_ALV ,
WA_CATALOG TYPE SLIS_FIELDCAT_ALV ,
LAYOUT TYPE SLIS_LAYOUT_ALV .
*" create catalog
WA_CATALOG-FIELDNAME = 'FLAG'.
WA_CATALOG-TABNAME = 'IT_1'.
APPEND WA_CATALOG TO CATALOG.
WA_CATALOG-FIELDNAME = 'MATNR'.
WA_CATALOG-TABNAME = 'IT_1'.
APPEND WA_CATALOG TO CATALOG.
DATA : FLAG_T TYPE I.
*"assign value to traffic signal
LOOP AT IT_1.
FLAG_T = SY-TABIX MOD 2.
IF FLAG_T = 0.
IT_1-FLAG = '1'.
ELSE.
IT_1-FLAG = '2'.
ENDIF.
MODIFY IT_1.
ENDLOOP.
*"specify the traffic signal field in the layout
LAYOUT-LIGHTS_FIELDNAME = 'FLAG'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
* I_CALLBACK_PROGRAM = ' '
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
IS_LAYOUT = LAYOUT
IT_FIELDCAT = CATALOG
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IT_ALV_GRAPHICS =
* IT_ADD_FIELDCAT =
* IT_HYPERLINK =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IT_EXCEPT_QINFO =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_1
* EXCEPTIONS
* PROGRAM_ERROR = 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.
so rem all you need to do is add a feild in internal table for the traffic signal , assign values 0 , 1, 2 to it and last specify the name of this feild in the layout.
Regards
Arun -
ALV GRID: How to change Subtotal and Main total values in standard row
Hi Experts,
By using SORT-SUBTOT = 'X' and FIELDCATALOG-DO_SUM = 'X', I will get subtotal and Main total.
My requiremnt is I need be calculate values manually and pass the calculated values to subtotal and maintotal.
is it possible in ALV GRID?
By adding extra row we will do this but I am looking standard subtotal and maintotal row change.
Thanks in advance,
MaheHi,
With function REUSE_ALV_GRID_DISPLAY you cannot do this.
It´s possible if you create a class inherited from cl_gui_alv_grid and rewrite the method set_data_table, you can do this. Like:
CLASS xgrid DEFINITION INHERITING FROM cl_gui_alv_grid.
PROTECTED SECTION.
METHODS: set_data_table REDEFINITION.
ENDCLASS. "xgrid DEFINITION
CLASS xgrid IMPLEMENTATION.
METHOD set_data_table.
* ....MODIFY data_table ...
CALL METHOD super->set_data_table
CHANGING
data_table = data_table.
ENDMETHOD. "set_data_table
ENDCLASS. "xgrid IMPLEMENTATION
DATA: grid TYPE REF TO xgrid.
CREATE OBJECT custom_container EXPORTING container_name = mycontainer.
CREATE OBJECT grid EXPORTING i_parent = custom_container.
CALL METHOD grid1->set_table_for_first_display ...
Best regards,
Leandro Mengue -
Subtotal in ALV grid for a particular type and Grand total in ALV
Hi,
I need to have sub total for a particular type(eg: goods, services).. and grand total at end in ALV grid..
ALV output required as below:
Type VAT registration number Country Total Gross Amounts Total Tax Amounts Total Amount, ex-tax
Goods ATU12345678 AT 222.42 0 222.42
Goods NL123456789B02 NL 3,417.00 0 3,417.00
Goods Total 3,639.42 - 3,639.42
Services ATU12345678 AT 2,342.34 0 2,342.34
Services NL123456789B02 NL 223.33 0 223.33
Services Total 2,565.67 - 2,565.67
Grand Total 6,205.09 - 6,205.09
Let me as to how to achieve the above type in ALV grid...
Regards
Shivacheck this link..
Grand Totals in ALV grid disply function module
or do like this..
REPORT ZALVTESTFORSUBTOTAL.
tables:pa0008.
type-pools:slis.
types:begin of ty_pa0008,
pernr like pa0008-pernr,
begda like pa0008-begda,
endda like pa0008-endda,
ansal like pa0008-ansal,
lga01 like pa0008-lga01,
bet01 like pa0008-bet01,
end of ty_pa0008.
data:it_pa0008 type standard table of ty_pa0008 with header line.
data:it_fieldcat type SLIS_T_FIELDCAT_ALV,
wa_fieldcat type slis_fieldcat_alv,
it_layout type slis_layout_alv,
WA_events TYPE slis_alv_event,
it_events TYPE slis_t_event.
select-options:s_pernr for pa0008-pernr.
start-of-selection.
perform getD_data.
perform disp_alv.
*& Form getD_data
text
--> p1 text
<-- p2 text
form getD_data .
select pernr
begda
endda
ansal
lga01
bet01
from pa0008
into table it_pa0008
where pernr in s_pernr.
sort it_pa0008 by pernr begda descending.
endform. " getD_data
*& Form disp_alv
text
--> p1 text
<-- p2 text
form disp_alv .
wa_fieldcat-fieldname = 'PERNR'.
wa_FIELDCAT-REPTEXT_DDIC = 'Personnel no'.
*WA_FIELDCAT-no_subtotals = 'X'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'BEGDA'.
wa_FIELDCAT-REPTEXT_DDIC = 'Start date'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ENDDA'.
wa_FIELDCAT-REPTEXT_DDIC = 'End date'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ANSAL'.
wa_FIELDCAT-REPTEXT_DDIC = 'Annula salary'.
wa_fieldcat-do_sum = 'X'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'LGA01'.
wa_FIELDCAT-REPTEXT_DDIC = 'Wage Type'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'BET01'.
wa_FIELDCAT-REPTEXT_DDIC = 'Amount for wagetype'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
DATA: sort TYPE slis_sortinfo_alv,
it_sort TYPE slis_t_sortinfo_alv.
sort-fieldname = 'PERNR'.
sort-subtot = 'X'.
SORT-UP = 'X'.
APPEND sort TO it_sort.
*sort-fieldname = 'BEGDA'.
*SORT-NO_SUBTOTS = 'X'.
*APPEND sort TO it_sort.
IT_layout-totals_text = 'total text'.
IT_layout-subtotals_text = 'Subtotal text'.
*WA_EVENTS-NAME = 'SUBTOTAL TEXT'.
*WA_EVENTS-FORM = 'SUBTOTAL TEXT'.
*APPEND WA_EVENTS TO IT_EVENTS.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IS_LAYOUT = it_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
it_sort = it_sort
it_events = it_events
TABLES
t_outtab = it_pa0008 .
endform. " disp_alv -
I used the demo program BCALV_GRID_EDIT to implement my editable grid and now I got stuck in the
method data_changed, where I do that loop:
LOOP AT rr_data_changed->mt_good_cells INTO ls_mod_cells.
where I check, get the values and modify the cells.
If something is wrong, I call the alv error protocol like this:
CALL METHOD rr_data_changed->add_protocol_entry
EXPORTING
i_msgid = '0K'
i_msgno = '000'
i_msgty = 'E'
i_msgv1 = text-004 "Buchungskreis
i_msgv2 = l_rbukrs
i_msgv3 = text-006 "exisitiert nicht
i_fieldname = ls_mod_cells-fieldname
i_row_id = ls_mod_cells-row_id.
The right wrong value is highlighted in red, the message is displayed, everything works fine until I change the value back to normal.
Then I get a run time error TSV_TNEW_PAGE_ALLOC_FAILED because MT_GOOD_CELLS couldn't be expanded.
It happened in class CL_ALV_CHANGED_DATA_PROTOCOL, in method MODIFY_STYLE in line 41.
append ls_modi to mt_good_cells.
I already tried to debug that method, to see what went wrong, but the debugger doesn't work any more at this point.
I guess I use the method wrong.
Does it has got something to do with
cl_gui_control=>www_active which is not active in my test? (p_loce in BCALV_GRID_EDIT)
I tried already many things with refresh_protocol and protocol_is_visible but the problem does not change.
Any suggestions? Should I simply choose to a message_list class and do the highlighting manually?My problem is solved, because the method modify_style was the reason for the run time error.
I called for one special field in the loop at mt_good_cells the method modify style
which tried to append a line to it.
append ls_modi to mt_good_cells.
in a loop to change the internal table the loop is based on isn't a good idea.
So the memory ran out and the system hang up when the memory size for the table was overrun.
Thanks for listening, the problem is solved. -
Alv Grid method get_grid_modified
Hi,
Method get_grid_modified is returning true after making any changes in Grid.
Please help me to make it working.
Regards,
VenkatHi,
Use sy-subrc to check and then debug.The function module seems to be not associated with want actually you want to ahcive .could you ellaborate your problem more ? -
ALV GRID -- METHOD set_selected_cells
Dear all.
I have a program with ALV_GRID in which, with event DBL_CLICK in one cell, I show data with function REUSE_ALV_POPUP_TO_SELECT to select the data with the objective fill this cell only with data I suggest in it.
But I don't know, when I use this method set_selected_cells , don't save the value data..., and in ALV don't show the change...
What happen??... Why don't save this method the value???
Before I execute Method SET ..., I execute Method GET... and the value of cell it's null... don't save the data.
Can you help me??
I put my code in resume...
FORM f_handle_double_click1 USING p_row TYPE lvc_s_row
p_column TYPE lvc_s_col.
DATA: it_cells TYPE lvc_t_cell,
wa_cells TYPE lvc_s_cell.
*Read the line of the internal table of the ALV
READ TABLE i_datos INDEX p_row-index.
IF sy-subrc = 0.
CASE p_column-fieldname.
WHEN 'COD_MODELO_AFIS'.
*POP UP with data to select .
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
i_selection = 'X'
i_zebra = 'X'
it_fieldcat = lt_fieldcat
i_tabname = 'TB_MODELOS'
i_checkbox_fieldname = 'CHECKBOX'
is_private = ls_private
IMPORTING
e_exit = l_exit
TABLES
t_outtab = tb_modelos.
CHECK l_exit = space.
READ TABLE tb_modelos WITH KEY checkbox = 'X'.
wa_cells-col_id = p_column.
wa_cells-row_id = p_row.
wa_cells-value = tb_modelos-nom_modelo_afis.
APPEND wa_cells TO it_cells.
*Save the data in cell
CALL METHOD g_grid1->set_selected_cells
EXPORTING
it_cells = it_cells.
REFRESH it_cells. .
*Verify if the data have been saved
CALL METHOD g_grid1->get_selected_cells
IMPORTING
et_cell = it_cells.
ENDCASE.
ENDFORM. " F_HANDLE_DOUBLE_CLICK1-
-
Display listbox key value in ALV GRID method
Hi All,
I have a program in which columns are generted dynamically based on number of fields. The column name is dynamic as it depends on its text while The value in Column's can be 1, 2, 3, 4, 5.
I am trying to display this in a list box along with the text which are maintained as fixed values at domain level.
space Walking
1 Archery
2 Boxing
3 Cycling
4 Rowing
Also I am displaying by using 'DD_DOMVALUEs_GET, looping through all the fixed values and concatenate
domvalue_l ddtext separated by cl_abap_char_utilities=>horizontal_tab. No tab space is coming between key and value.
Also for the 1st value which is space it is not coming properly as space is condensed.
The point is that after I am putting values in the grid. The system event data changed is called where the value selected is 1 Archery and it is going to bad cells, error protocol display . I want only the 1st character. How to modify the content in the grid before the system event gets called.
Regards,
DPMHi,
try follow code to setup fieldcat of that DROP DOWN field.
FCAT-DOMNAME = ' '.
FCAT-CHECKTABLE= '!'. -
Total and non-total lines in ALV grid
Hi all,
Does anyone know if there is any standard SAP functionality for retrieving the non-total/raw item lines that lies beneath a total line in an ALV grid (after the user has selected the total line)?
All helpful answers will be rewarded!
Best regards,
MVTry the ALV event AFTER-LINE-OUTPUT may be it can help u to achieve ur requirement.
Append AFTER-LINE-OUTPUT event to the internal table T_EVENT.
CLEAR W_EVENT.
W_EVENT-FORM = SLIS_EV_AFTER_LINE_OUTPUT.
W_EVENT-NAME = SLIS_EV_AFTER_LINE_OUTPUT.u201CAFTER_LINE_OUTPUT event
APPEND W_EVENT TO T_EVENT.
FORM AFTER_LINE_OUTPUT
USING P_RS_LINEINFO TYPE SLIS_LINEINFO.
Here you have to write the logic to retrieve the 'total' line
ENDFROM.
Now call the alv FM
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = L_REPID "Program Name
IS_LAYOUT = W_LAYOUT "Layout of the Report
IT_FIELDCAT = T_FIELDCAT "Field Catalog for Report
IT_EVENTS = T_EVENT "For setting the events
TABLES
T_OUTTAB = T_OUTPUT "Report data Internal Table
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2. -
Problems with checkbox in ALV-GRID OO
Hi,
i have Problems by listing an editable checkbox
in ALV GRID OO and handle the itab with
the marked fields.
Here my Code extract. Has anybody an idea or a short example.
TYPES: BEGIN OF ALV_TAB,
SGTXT LIKE RK23B-SGTXT,
CHECK(1),
END OF ALV_TAB.
DATA: ITAB TYPE TABLE OF ALV_TAB.
Is this Declaration correct??
<b> GS_FIELDCAT-FIELDNAME = 'CHECK'.
GS_FIELDCAT-CHECKBOX = 'X'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
GS_LAYOUT-EDIT = 'X'.
GS_LAYOUT-BOX_FNAME = 'CHECK'.</b>
CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IT_TOOLBAR_EXCLUDING = PT_EXCLUDE
IS_LAYOUT = GS_LAYOUT
CHANGING
IT_FIELDCATALOG = GT_FIELDCAT
IT_OUTTAB = ITAB.
FORM HANDLE_USER_COMMAND USING E_UCOMM.
CASE E_UCOMM.
WHEN 'REFR'.
<b> Here i will have the itab with the marked checkbox.
how can i refresh?</b>*
WHEN 'EXCEL'.
MESSAGE I010 WITH E_UCOMM.
ENDCASE.
ENDFORM. "HANDLE_USER_COMMAND
Regards, DieterHi, in reference to....
ASE E_UCOMM.
WHEN 'REFR'.
Here i will have the itab with the marked checkbox.
how can i refresh?*
Do you want to get rid of the checks in any checkbox?
If so, just loop at modify.
ASE E_UCOMM.
WHEN 'REFR'.
<b> Loop at itab where check = 'X'.
itab-check = space.
modify itab.
endloop.</b>
Regards,
Rich Heilman -
Hi all F4 in alv grid with restricted value -- no solution from forum
hi all
i have developed report using alv grid using FM (important).
i have a field xyz which is input/output enabled in alv grid output. this field is attached with f4 help.
my requirement is to get or read the row in alv grid when user press f4 on that field so that restricted value should come in f4 help i.e. i have to read current line when user presses f4 i.e. the single line data in alv grid.
so how to get or read the current row when user press f4 i.e user will choose any row in alv grid and this output is on alv grid and there are multiple records.
or in other word is it possible to read current row in alv grid when user presses F4, if yes how???.
i hope u understood the query.Hai,
Check the code it may help u.
For F4 Values on Screen:
PROCESS ON VALUE_REQUEST
using module call starting with FIELD i.e FIELD field MODULE module
There are number of function modules that can be used for the purpose, but these
can fullfill the task easily or combination of them.
DYNP_VALUE_READ
F4IF_FIELD_VALUE_REQUEST
F4IF_INT_TABLE_VALUE_REQUEST
POPUP_WITH_TABLE_DISPLAY
DYNP_VALUE_READ
This function module is used to read values in the screen fields. Use of this
FM causes forced transfer of data from screen fields to ABAP fields.
There are 3 exporting parameters
DYNAME = program name = SY-CPROG
DYNUMB = Screen number = SY-DYNNR
TRANSLATE_TO_UPPER = 'X'
and one importing TABLE parameter
DYNPFIELDS = Table of TYPE DYNPREAD
The DYNPFIELDS parameter is used to pass internal table of type DYNPREAD
to this FM and the values read from the screen will be stored in this table.This
table consists of two fields:
FIELDNAME : Used to pass the name of screen field for which the value is to
be read.
FIELDVALUE : Used to read the value of the field in the screen.
e.g.
DATA: SCREEN_VALUES TYPE TABLE OF DYNPREAD ,
SCREEN_VALUE LIKE LINE OF SCREEN_VALUES.
SCREEN_VALUE-FIELDNAME = 'KUNNR' . * Field to be read
APPEND SCREEN_VALUE TO SCREEN_VALUES. * Fill the table
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
TRANSLATE_TO_UPPER = 'X'
TABLES
DYNPFIELDS = SCREEN_VALUES.
READ TABLE SCREEN_VALUES INDEX 1 INTO SCREEN_VALUE.Now the screen value for field KUNNR is in the SCREEN_VALUE-FIELDVALUE and can be used for further processing like using it to fill the internal table to be used as parameter in F4IF_INT_TABLE_VALUE_REQUEST ETC.
F4IF_FIELD_VALUE_REQUEST
This FM is used to display value help or input from ABAP dictionary.We have to pass the name of the structure or table(TABNAME) along with the field name(FIELDNAME) . The selection can be returned to the specified screen field if three
parameters DYNPNR,DYNPPROG,DYNPROFIELD are also specified or to a table if RETRN_TAB is specified.
CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
EXPORTING
TABNAME = table/structure
FIELDNAME = 'field name'
DYNPPROG = SY-CPROG
DYNPNR = SY-DYNR
DYNPROFIELD = 'screen field'
IMPORTING
RETURN_TAB = table of type DYNPREAD
F4IF_INT_TABLE_VALUE_REQUEST
This FM is used to dsiplay values stored in an internal table as input
help.This FM is used to program our own custom help if no such input help
exists in ABAP dictionary for a particular field. The parameter VALUE_TAB is used to pass the internal table containing input values.The parameter RETFIELD
is used to specify the internal table field whose value will be returned to the screen field or RETURN_TAB.
If DYNPNR,DYNPPROG and DYNPROFIELD are specified than the user selection is passed to the screen field specified in the DYNPROFIELD. If RETURN_TAB is specified the selectionis returned in a table.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = field from int table whose value will be returned
DYNPPROG = SY-CPROG
DYNPNR = SY-DYNNR
DYNPROFIELD = 'screen field'
VALUE_ORG = 'S'
TABLES
VALUE_TAB = internal table whose values will be shown.
RETURN_TAB = internal table of type DDSHRETVAL
EXCEPTIONS
parameter_error = 1
no_values_found = 2
others = 3.
POPUP_WITH_TABLE_DISPLAY
This FM is used to display the contents of an internal table in a popup window.The user can select a row and the index of that is returned in the CHOISE
parameter.The VALUETAB is used to pass the internal table.
A suitable title can be set using TITLETEXT parameter. The starting and end position of the popup can be specified by the parameters STARTPOS_COL / ROW and ENDPOS_ROW / COL .
CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
EXPORTING
ENDPOS_COL =
ENDPOS_ROW =
STARTPOS_COL =
STARTPOS_ROW =
TITLETEXT = 'title text'
IMPORTING
CHOISE =
TABLES
VALUETAB =
EXCEPTIONS
BREAK_OFF = 1
OTHERS = 2.
e.g.
DATA: w_choice TYPE SY-TABIX.
DATA: BEGIN OF i_values OCCURS 0 WITH HEADER LINE,
values TYPE I,
END OF i_values.
PARAMETRS : id TYPE I.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR id
i_values-values = '0001'.
APPEND i_values.
i_values-values = '0002'.
APPEND i_values.
i_values-values = '0003'.
APPEND i_values.
i_values-values = '0004'.
APPEND i_values.
CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
EXPORTING
ENDPOS_COL = 40
ENDPOS_ROW = 12
STARTPOS_COL = 20
STARTPOS_ROW = 5
TITLETEXT = 'Select an ID'
IMPORTING
CHOISE = w_choice
TABLES
VALUETAB = i_values
EXCEPTIONS
BREAK_OFF = 1
OTHERS = 2.
CHECK w_choice > 0.
READ TABLE i_values INDEX w_choice....now we can process the selection as it is contained
...in the structure i_values.
Other FM that may be used to provide input help is HELP_START .
check this also.
See the following ex:
TYPES: BEGIN OF TY_MBLNR,
MBLNR LIKE MKPF-MBLNR,
END OF TY_MBLNR.
DATA: IT_MBLNR TYPE STANDARD TABLE OF TY_MBLNR WITH HEADER LINE.
data: it_ret like ddshretval occurs 0 with header line.
At selection-screen on value-request for s_mat-low.
Select MBLNR from mkpf into table it_mblnr.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
DDIC_STRUCTURE = ' '
RETFIELD = 'MBLNR'
PVALKEY = ' '
DYNPPROG = ' '
DYNPNR = ' '
DYNPROFIELD = ' '
STEPL = 0
WINDOW_TITLE =
VALUE = ' '
VALUE_ORG = 'S'
MULTIPLE_CHOICE = ' '
DISPLAY = ' '
CALLBACK_PROGRAM = ' '
CALLBACK_FORM = ' '
MARK_TAB =
IMPORTING
USER_RESET =
TABLES
VALUE_TAB = IT_MBLNR
FIELD_TAB =
RETURN_TAB = IT_RET
DYNPFLD_MAPPING =
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF SY-SUBRC = 0.
read table it_ret index 1.
move it_ret-fieldval to S_mat-low.
ENDIF.
Go through the test program.
REPORT Ztest_HELP .
TABLES : MARA.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_MATNR(10) TYPE C.
SELECTION-SCREEN END OF BLOCK B1.
DATA : BEGIN OF ITAB OCCURS 0,
MATNR TYPE MATNR,
END OF ITAB.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_MATNR.
SELECT MATNR
FROM MARA
INTO TABLE ITAB
UP TO 10 ROWS.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'MATERIAL NUMBER'
DYNPPROG = SY-REPID
DYNPNR = SY-DYNNR
DYNPROFIELD = 'P_MATNR'
VALUE_ORG = 'S'
TABLES
VALUE_TAB = ITAB
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3.
regards.
sowjanya.b. -
Group feature at ALV grid with editable columns
Am I right ?
Group function by using a sorted layout is disabled while having one (or more) editable columns, isn't it ?
... or is there a possibility to use gouped rows ?
Greetings
MarkusAlso...
*& Report ZDEMO_ALVGRID_EDIT *
*& Example of a simple ALV Grid Report *
*& The basic ALV grid, Enhanced to display specific fields as *
*& editable depending on field value *
REPORT ZDEMO_ALVGRID_EDIT .
TABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
field_style TYPE lvc_t_styl, "FOR DISABLE
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA: it_fieldcat TYPE lvc_t_fcat, "slis_t_fieldcat_alv WITH HEADER LINE,
wa_fieldcat TYPE lvc_s_fcat,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE lvc_s_layo, "slis_layout_alv,
gd_repid LIKE sy-repid.
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM set_specific_field_attributes.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
wa_fieldcat-fieldname = 'EBELN'.
wa_fieldcat-scrtext_m = 'Purchase Order'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-outputlen = 10.
wa_fieldcat-emphasize = 'X'.
wa_fieldcat-key = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'EBELP'.
wa_fieldcat-scrtext_m = 'PO Item'.
wa_fieldcat-col_pos = 1.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'STATU'.
wa_fieldcat-scrtext_m = 'Status'.
wa_fieldcat-col_pos = 2.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'AEDAT'.
wa_fieldcat-scrtext_m = 'Item change date'.
wa_fieldcat-col_pos = 3.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-scrtext_m = 'Material Number'.
wa_fieldcat-col_pos = 4.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MENGE'.
wa_fieldcat-scrtext_m = 'PO quantity'.
wa_fieldcat-col_pos = 5.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MEINS'.
wa_fieldcat-scrtext_m = 'Order Unit'.
wa_fieldcat-col_pos = 6.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'NETPR'.
wa_fieldcat-scrtext_m = 'Net Price'.
wa_fieldcat-edit = 'X'. "sets whole column to be editable
wa_fieldcat-col_pos = 7.
wa_fieldcat-outputlen = 15.
wa_fieldcat-datatype = 'CURR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'PEINH'.
wa_fieldcat-scrtext_m = 'Price Unit'.
wa_fieldcat-col_pos = 8.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
Set layout field for field attributes(i.e. input/output)
gd_layout-stylefname = 'FIELD_STYLE'.
gd_layout-zebra = 'X'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = gd_repid
i_callback_user_command = 'USER_COMMAND'
is_layout_lvc = gd_layout
it_fieldcat_lvc = it_fieldcat
i_save = 'X'
TABLES
t_outtab = it_ekko
EXCEPTIONS
program_error = 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.
ENDFORM. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
UP TO 10 ROWS
FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE it_ekko.
ENDFORM. " DATA_RETRIEVAL
*& Form set_specific_field_attributes
populate FIELD_STYLE table with specific field attributes
form set_specific_field_attributes .
DATA ls_stylerow TYPE lvc_s_styl .
DATA lt_styletab TYPE lvc_t_styl .
Populate style variable (FIELD_STYLE) with style properties
The NETPR field/column has been set to editable in the fieldcatalog...
The following code sets it to be disabled(display only) if 'NETPR'
is gt than 10.
LOOP AT it_ekko INTO wa_ekko.
IF wa_ekko-netpr GT 10.
ls_stylerow-fieldname = 'NETPR' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
"set field to disabled
APPEND ls_stylerow TO wa_ekko-field_style.
MODIFY it_ekko FROM wa_ekko.
ENDIF.
ENDLOOP.
endform. " set_specific_field_attributes
REWARD POINTS IF usefful !! -
hey,
alv grid method for export data from alv grid to itab.
regards,
purnaHey,
Any methods for exporting alv grid data into itab.
Maybe you are looking for
-
Need to Open Two Windows at the same time
Hi All , I have a requirement wherein I am opening a new page when the user presses a link . The information displayed to the user in the new page is Read-Only.To display the reqd info on the new page I pass some parameters encoded in the page call U
-
BSP Extensions doesn't work with Pocket PC2003
hello, i faced out following problem, that i have alreday posted in the BSP-forum. They said the guys here may have a solution. I want to write an application using webas on abap 6.20 SP 41 using BSP-Extension. The Extension framework dumps: browser
-
Import Image from scanner to database Direct ..
can any Colleagues help me .. how can i Import Image From Scanner directly if anyone can descuss code and how can i do that thank for all Colleagues .......
-
Inclue children and exclue children in a single hierarchy in parent child dimension in mdx
hi, include children and exclude children in a single hierarchy in parent child dimension in mdx *12-parent **20-parent - 9-parent --250-child1 --210-child2 --240-child3 aggregation of 12-parent only aggregation of 20-parent
-
We have an exchange 2013 environment that we host here. Everything has been working fine except for the fact that I have a half dozen users that can not see certain shared calendars. It is not the same calendars for all users. For example... I can't