Handling checkboxes in ALV Grid.
Hi guys.
I have displayed an ALV grid with checkboxes. I want to opearate on the selected checkboxes by the user by clicking on a added button.
I am using oops and using function set_table_for_first_display.
if no box is selected the function works properly. If i select a checkbox, i get a dump.
Thanks
Hi arun
here is the required code.
<b>Form to register events</b>
FORM register_events .
CREATE OBJECT gr_event_handler .
SET HANDLER gr_event_handler->handle_toolbar FOR gr_alvgrid .
SET HANDLER gr_event_handler->handle_user_command FOR gr_alvgrid.
SET HANDLER gr_event_handler->handle_hotspot_click FOR gr_alvgrid.
SET HANDLER gr_event_handler->handle_double_click FOR gr_alvgrid.
ENDFORM.
<b>Class Defination and implementation</b>
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,
To handle hotspot click.
handle_hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no,
To handle Double Click
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column .
ENDCLASS. "LCL_EVENT_HANDLER DEFINITION
*& Class (Implementation) lcl_event_handler
Text
CLASS lcl_event_handler IMPLEMENTATION.
METHOD handle_toolbar.
PERFORM handle_toolbar USING e_object.
ENDMETHOD . "handle_toolbar
METHOD handle_user_command.
perform handler_user_command using e_ucomm .
ENDMETHOD. "handle_user_command
METHOD handle_hotspot_click .
PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no .
ENDMETHOD . "handle_hotspot_click
METHOD handle_double_click .
PERFORM handle_double_click USING e_row e_column .
ENDMETHOD . "handle_hotspot_click
ENDCLASS. "lcl_event_handler
<b>
PBO of screen that is called after the pushbutton is pressed.</b>
MODULE STATUS_9400 OUTPUT.
SET PF-STATUS 'SCREEN9400'.
perform diaply_checkbox.
<b>and the method display_checkbox.</b>
FORM diaply_checkbox .
data: count type i.
count = 0.
loop at za004_t_t into wa_a004_t_t.
if wa_a004_t_t-checkboc = 'X'.
count = count + 1.
endif.
count = count + 1.
endloop.
ENDFORM. " diaply_checkbox
thanks
Abhinav Dhasmana
Similar Messages
-
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 -
How to Set Checkbox of ALV Grid Dark on Display Mode
ABAP experts, I want to switch between display mode and edit mode for some columns of ALV Grid. So I set "LVC_S_FCAT-EDIT" "X" for the columns which need to switch mode, and use method "SET_READY_FOR_INPUT" to switch.
Currently, the function of switch mode has been achieved. But icons of checkbox columns are light but not dark when display mode, although the columns can't be edited. (Please refer to the image below.) I want to make checkbox columns dark as other columns on display mode.
I tried to use "CL_GUI_ALV_GRID=>MC_STYLE_ENABLED" and "CL_GUI_ALV_GRID=>MC_STYLE_DISABLED", but failed. I also studied sample program "BCALV_EDIT_05" which is related to checkbox in ALV Grid, and compared my program with this program. But I still have not found problems.
Help me solve this problem, please.
Part of my codes are as follows.
Part 1:
IF iv_is_create_group = abap_true OR iv_is_edit_group = abap_true.
set_enable( iv_flag = 1 ).
LOOP AT gt_acct_group_item ASSIGNING <lfs_acct_group_item>.
CLEAR ls_celltab.
IF <lfs_acct_group_item>-celltab IS INITIAL.
CLEAR ls_celltab.
ls_celltab-fieldname = 'CHECK_BOX'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
APPEND ls_celltab TO <lfs_acct_group_item>-celltab.
CLEAR ls_celltab.
ls_celltab-fieldname = 'XPORE'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
APPEND ls_celltab TO <lfs_acct_group_item>-celltab.
ELSE.
LOOP AT <lfs_acct_group_item>-celltab ASSIGNING <lfs_celltab>.
<lfs_celltab>-style = cl_gui_alv_grid=>mc_style_enabled.
ENDLOOP.
ENDIF.
ENDLOOP.
ELSE.
set_enable( iv_flag = 0 ).
LOOP AT gt_acct_group_item ASSIGNING <lfs_acct_group_item>.
IF <lfs_acct_group_item>-celltab IS INITIAL.
CLEAR ls_celltab.
ls_celltab-fieldname = 'CHECK_BOX'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
APPEND ls_celltab TO <lfs_acct_group_item>-celltab.
CLEAR ls_celltab.
ls_celltab-fieldname = 'XPORE'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
APPEND ls_celltab TO <lfs_acct_group_item>-celltab.
ELSE.
LOOP AT <lfs_acct_group_item>-celltab ASSIGNING <lfs_celltab>.
<lfs_celltab>-style = cl_gui_alv_grid=>mc_style_disabled.
ENDLOOP.
ENDIF.
ENDLOOP.
ENDIF.
CALL METHOD gr_grid->refresh_table_display
* EXPORTING
* is_stable =
* i_soft_refresh =
EXCEPTIONS
finished = 1
OTHERS = 2
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
Part 2:
METHOD set_enable.
gr_grid->set_ready_for_input(
i_ready_for_input = iv_flag
ENDMETHOD.Hi Liu,
Please go through the below code.
*& Report YEDIT_DISPLAY
REPORT YEDIT_DISPLAY.
TABLES : VBAK.
TYPE-POOLS SLIS.
TYPES : BEGIN OF TY_VBAK,
VBELN TYPE VBAK-VBELN,
END OF TY_VBAK,
BEGIN OF TY_FINAL,
BOX TYPE C,
VBELN TYPE VBAK-VBELN,
END OF TY_FINAL.
DATA : IT_VBAK TYPE TABLE OF TY_VBAK,
WA_VBAK TYPE TY_VBAK,
IT_FINAL TYPE TABLE OF TY_FINAL,
WA_FINAL TYPE TY_FINAL,
IT_FCAT TYPE TABLE OF SLIS_FIELDCAT_ALV,
WA_FCAT TYPE SLIS_FIELDCAT_ALV.
START-OF-SELECTION.
PERFORM FETCH_DATA.
PERFORM FCAT_DATA.
PERFORM DISPLAY.
*& Form FETCH_DATA
* text
* --> p1 text
* <-- p2 text
FORM FETCH_DATA .
SELECT VBELN INTO TABLE IT_VBAK FROM VBAK UP TO 10 ROWS.
LOOP AT IT_VBAK INTO WA_VBAK.
WA_FINAL-VBELN = WA_VBAK-VBELN.
APPEND WA_FINAL TO IT_FINAL.
CLEAR : WA_FINAL , WA_VBAK.
ENDLOOP.
ENDFORM. " FETCH_DATA
*& Form FCAT_DATA
* text
* --> p1 text
* <-- p2 text
FORM FCAT_DATA .
WA_FCAT-COL_POS = 1.
WA_FCAT-FIELDNAME = 'BOX'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-OUTPUTLEN = '3'.
WA_FCAT-SELTEXT_M = 'BOX'.
wa_fcat-checkbox = 'X'.
WA_FCAT-EDIT = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = 2.
WA_FCAT-FIELDNAME = 'VBELN'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-OUTPUTLEN = '3'.
WA_FCAT-SELTEXT_M = 'Sales Document'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
ENDFORM. " FCAT_DATA
*& Form DISPLAY
* text
* --> p1 text
* <-- p2 text
FORM DISPLAY .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
* I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* I_CALLBACK_TOP_OF_PAGE = ' '
IT_FIELDCAT = IT_FCAT
* I_DEFAULT = 'X'
* I_SAVE = ' '
TABLES
T_OUTTAB = IT_FINAL
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM. " DISPLAY
FORM USER_COMMAND USING UCOMM TYPE SY-UCOMM
RTAB TYPE slis_selfield.
CASE UCOMM.
WHEN '&IC1'.
MESSAGE 'SUCESSFUL' TYPE 'S'.
WHEN '&DATA_SAVE'.
PERFORM FIL_FCAT.
PERFORM DISPLAY1.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN OTHERS.
LEAVE TO SCREEN 0.
ENDCASE.
ENDFORM.
*& Form FIL_FCAT
* text
* --> p1 text
* <-- p2 text
FORM FIL_FCAT .
CLEAR IT_FCAT.
WA_FCAT-COL_POS = 1.
WA_FCAT-FIELDNAME = 'BOX'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-OUTPUTLEN = '3'.
WA_FCAT-SELTEXT_M = 'BOX'.
wa_fcat-checkbox = 'X'.
** WA_FCAT-EDIT = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = 2.
WA_FCAT-FIELDNAME = 'VBELN'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-OUTPUTLEN = '3'.
WA_FCAT-SELTEXT_M = 'Sales Document'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
ENDFORM. " FIL_FCAT
*& Form DISPLAY1
* text
* --> p1 text
* <-- p2 text
FORM DISPLAY1 .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
* I_CALLBACK_TOP_OF_PAGE = ' '
IT_FIELDCAT = IT_FCAT
* I_DEFAULT = 'X'
* I_SAVE = ' '
TABLES
T_OUTTAB = IT_FINAL
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM. " DISPLAY1
Here i written code under the SAVE button , if requires you create your own status and apply.
Regards,
Krishna -
User command for checkbox in alv grid output
Hi,
Does anyone knows the user command for checkbox in alv grid display. My requirement is to have a column for checkbox in alv output. When the user checks the checkbox, a pop-up dialog box will appear. This dialog box was created in screen painter. I can't find the user command for this. Please help.
Thanks in advance.Hi,
there r two ways for creating checkbox col on the ALV grid.
1.) take an extra field in your internal table i.e
data:
checkbox type c.
loop at internal_table into wa.
checkbox.
endloop.
or
the fieldcatalog attribute
2.) wa_fcat-checkbox = 'X'.
append wa_fcat to t_fcat.
clear wa_fcat.
if itab-checkbox = 'X'.
call screen <dialogbox screen number>.
endif.
regards
ravi -
Set editable/non-editable checkbox in alv grid
Hi all,
How to set a checkbox in alv grid in editable/non-editable. i am using alv gird display function module for this. i tried to used method cl_gui_alv_grid=>mc_style_disabled. but its not working. is it possible to have this functionality in grid? please help. thanks in advance.Hi,
Try like this.
CALL METHOD gr_alvgrid->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
is_layout = gs_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
CHANGING
it_outtab = gt_list[]
it_fieldcatalog = gt_fieldcat
IT_SORT =
IT_FILTER =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4
regards
Rajesh kumar -
hi all,
Is there any way to handle the single click/tick on checkbox. Is there user command on that? For now, if we will click on the checkbox, the changes made on it does not reflect. I checked on the debugging mode, checkbox is not populated/ marked even if it was ticked by the user.
thanks in advance.Hi Akira,
For Controling Check Box , you have to use grid display using customised Container screen.
From there you can control check Box .
CREATE OBJECT custom_container
EXPORTING container_name = o_container.
CREATE OBJECT o_grid
EXPORTING i_parent = custom_container.
Form for building the fieldcatalog
PERFORM build_fieldcat CHANGING it_fieldcat.
Form for excluding the unwanted functionalities from the toolbar.
PERFORM exclude_tb_functions CHANGING it_exclude.
Method for displaying the ALV grid.
CALL METHOD o_grid->set_table_for_first_display
EXPORTING
is_layout = it_layout
it_toolbar_excluding = it_exclude
CHANGING
it_fieldcatalog = it_fieldcat
it_outtab = it_final.
CREATE OBJECT o_event_receiver.
Setting the event handlers for events toolbar, usercommand and datachange.
SET HANDLER o_event_receiver->catch_toolbar FOR o_grid.
SET HANDLER o_event_receiver->catch_user_command FOR o_grid.
SET HANDLER o_event_receiver->catch_datachange FOR o_grid.
Set editable cells to ready for input.
CALL METHOD o_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1. -
Functionality of Checkbox in ALV Grid Report
Hi Experts,
I created a ALV grid report with the checkbox as my first coloum and other fields as shown below. Initially, my ALV report displays as below. It is working fine till here.
checkbox customer material quantity UOM Sales Order Delivery
C1 M1 1 KG
C1 M2 2 KG
C2 M1 1 KG
C2 M2 2 KG
C3 M1 1 KG
C3 M2 2 KG
C3 M3 3 KG
C4 M1 1 KG
C5 M5 1 KG
I have created a push button on application toolbar for creating sales order and delivery using bapi's. When I click on my pushbutton, as of now it creates the SO and delivery for the first customer C1 and updates my Internal table with the sales order number and delivery number. If I need to create sales order for the second customer I need to run my ALV report again and so on for 3rd, 4th and 5th customers. It is also working fine till here.
checkbox customer material quantity UOM Sales Order Delivery
C1 M1 1 KG SO1 DEL1
C1 M2 2 KG SO1 DEL1
C2 M1 1 KG
C2 M2 2 KG
C3 M1 1 KG
C3 M2 2 KG
C3 M3 3 KG
C4 M1 1 KG
C5 M5 1 KG
Need help on this:
When I select the check boxes as shown below and when I click the push button to create SO and Delivery then my program should create sales order and delivery for all the checked ones as shown below. What is the condition do I need to put here for selecting the checkbox.
checkbox customer material quantity UOM Sales Order Delivery
X C1 M1 1 KG SO1 DEL1
X C1 M2 2 KG SO1 DEL1
C2 M1 1 KG
C2 M2 2 KG
X C3 M1 1 KG SO3 DEL3
X C3 M2 2 KG SO3 DEL3
X C3 M3 3 KG SO3 DEL3
C4 M1 1 KG
X C5 M5 1 KG SO5 DEL5
I would really appreciate if somebody could help me / guide me on this. I will also post my code if someone needs to understand what I am doing exactly.
Thanks.You need to use OO ABAP
Use Class the class 1) CL_GUI_ALV_GRID, 2) CL_GUI_CUSTOM_CONTAINER
Create Sceen and container on same screen.
Check following COde it used for printing purpose.
Using AFTER_USER_COMMAND Event you will find Check box selected entries.
Capture those in another internal Table and use it for SO Creation
DATA: O_GRID TYPE REF TO CL_GUI_ALV_GRID,
O_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
T_FCAT TYPE LVC_T_FCAT,
CONTAINER(15) TYPE C VALUE 'ET_CONTAINER'.
CLASS EVENT_CLASS DEFINITION
CLASS EVENT_CLASS DEFINITION.
PUBLIC SECTION.
METHODS: BEFORE_COMMAND FOR EVENT AFTER_USER_COMMAND OF CL_GUI_ALV_GRID IMPORTING E_UCOMM,
DOUBLE_CLICK_N FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID IMPORTING E_ROW E_COLUMN,
TOOLBAR FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID IMPORTING E_OBJECT.
ENDCLASS. "EVENT_CLASS DEFINITION
CLASS EVENT_CLASS IMPLEMENTATION
CLASS EVENT_CLASS IMPLEMENTATION.
METHOD BEFORE_COMMAND.
IF E_UCOMM = 'PRINT'.
CLEAR : W_FLAG.
T_FINAL2 = T_FINAL.
SORT T_FINAL2 BY COL_CHK .
DELETE T_FINAL2 WHERE COL_CHK = ' '.
IF NOT T_FINAL2 IS INITIAL.
LOOP AT T_FINAL2 INTO WA_FINAL.
IF W_FLAG IS INITIAL.
Does some of modification/s in control parameters
W_CONTROL_PARAM-NO_OPEN = 'X'.
W_CONTROL_PARAM-NO_CLOSE = 'X'.
W_CONTROL_PARAM-PREVIEW = 'X'.
W_CONTROL_PARAM-NO_DIALOG = SPACE.
W_OUTPUT_OPTIONS-TDNEWID = 'X'.
W_OUTPUT_OPTIONS-TDIMMED = SPACE.
Opens the smartform print-job
CALL FUNCTION 'SSF_OPEN'
EXPORTING
OUTPUT_OPTIONS = W_OUTPUT_OPTIONS
CONTROL_PARAMETERS = W_CONTROL_PARAM
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
IF SY-SUBRC EQ 0.
W_FLAG = 'X'.
ELSE.
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
IF W_FLAG = 'X'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZFORM_BIW_PRINT'
IMPORTING
FM_NAME = LF_FM_NAME
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
ENDIF.
IF SY-SUBRC = 0.
CALL FUNCTION LF_FM_NAME
EXPORTING
CONTROL_PARAMETERS = W_CONTROL_PARAM
V_VBELN = WA_FINAL-VBELN
WA_FINAL = WA_FINAL.
TABLES
T_FINAL = T_FINAL.
ELSE.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDLOOP.
* Close the smartform print job
IF W_FLAG EQ 'X'.
CALL FUNCTION 'SSF_CLOSE'
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
OTHERS = 4.
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD. "BEFORE_COMMAND -
hi,
Hi,
I am displaying some fields from VBAP in ALV gid and have give drop down check box to storage location making it editable so if the user changes Storage location of
some entries and clicks SAVE button, when we click save button i need to capture all the rows that were been changed and update VA02 using these records through bapi.
but iam not able to capture this SAVE event but iam able to capture Enter and cursor event.
i have written following code for this
LOCAL CLASSES: Definition
class lcl_event_receiver: local class to handle event CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
PRIVATE SECTION.
ENDCLASS. "lcl_event_receiver DEFINITION
LOCAL CLASSES: Implementation
class lcl_event_receiver (Implementation)
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
DATA: l_error_in_data TYPE c.
PERFORM handle_data_changed USING er_data_changed l_error_in_data.
*§7.Display application log if an error has occured.
IF l_error_in_data EQ 'X'.
CALL METHOD er_data_changed->display_protocol.
ENDIF.
ENDMETHOD. "handle_data_changed
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
*& Form handle_data_changed
Identify columns which were changed and check input
-->P_ER_DATA_CHANGED text
FORM handle_data_changed USING p_er_data_changed
TYPE REF TO cl_alv_changed_data_protocol
p_error_in_data TYPE c.
DATA : lw_mod_cell TYPE lvc_s_modi ,
l_value TYPE lvc_value ,
l_lgort TYPE lgort_d.
SORT p_er_data_changed->mt_mod_cells BY row_id .
LOOP AT p_er_data_changed->mt_mod_cells INTO lw_mod_cell
WHERE fieldname = 'LGORT'.
CALL METHOD p_er_data_changed->get_cell_value
EXPORTING
i_row_id = lw_mod_cell-row_id
i_fieldname = 'LGORT'
IMPORTING
e_value = l_value.
SELECT SINGLE lgort FROM t001l INTO l_lgort WHERE werks = p_werks
AND lgort = l_value.
IF sy-subrc NE 0.
In case of error, create a protocol entry in the *application log.
CALL METHOD p_er_data_changed->add_protocol_entry
EXPORTING
i_msgid = '0K'
i_msgno = '000'
i_msgty = 'E'
i_msgv1 = text-003
i_msgv2 = l_value
i_msgv3 = text-004
i_fieldname = lw_mod_cell-fieldname
i_row_id = lw_mod_cell-row_id.
p_error_in_data = 'X'.
EXIT.
ELSE.
*§5b.If the value is valid change values of
cells.
CALL METHOD p_er_data_changed->modify_cell
EXPORTING
i_row_id = lw_mod_cell-row_id
i_fieldname = lw_mod_cell-fieldname
i_value = l_value.
READ TABLE t_list1 INTO w_list1 INDEX lw_mod_cell-row_id.
IF sy-subrc EQ 0.
*comparing old value with the changed value
IF w_list1-lgort <> l_value.
MOVE: w_list1-werks TO w_list3-werks,
w_list1-matnr TO w_list3-matnr,
w_list1-arktx TO w_list3-arktx,
w_list1-vbeln TO w_list3-vbeln,
w_list1-posnr TO w_list3-posnr,
w_list1-pstyv TO w_list3-pstyv,
w_list1-vstel TO w_list3-vstel,
w_list1-auart TO w_list3-auart,
w_list1-kwmeng TO w_list3-kwmeng,
w_list1-vrkme TO w_list3-vrkme,
w_list1-mbdat TO w_list3-mbdat,
l_value TO w_list3-lgort.
APPEND w_list3 TO t_list3.
*t_list3 will contain all the records that are changed
CLEAR w_list3.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
*& Module STATUS_0100 OUTPUT
text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
IF go_custom_container IS INITIAL.
create a custom container control for our ALV Control
CREATE OBJECT go_custom_container
EXPORTING
container_name = g_cont_on_main
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc NE 0.
Display error message.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = sy-repid
txt2 = sy-subrc
txt1 = 'The control could not be created'.
ENDIF.
create an instance of alv control
CREATE OBJECT go_grid
EXPORTING
i_parent = go_custom_container.
*If display or change radio button is cheked
IF ( p_chng = 'X' OR p_disp = 'X' ) .
Set a titlebar for the grid control
g_layout-grid_title = 'Sales Orders'.
g_layout-excp_fname = 'TRAFFIC_LIGHT'.
Define a drop down table.
PERFORM set_drdn_table.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
is_layout = g_layout
CHANGING
it_outtab = t_list1
it_fieldcatalog = t_fieldcat1
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.
ENDIF.
register ENTER and CURSOR to raise event DATA_CHANGED.
(Per default the user may check data by using the check icon).
CALL METHOD go_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
CALL METHOD go_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
CREATE OBJECT g_event_receiver.
SET HANDLER g_event_receiver->handle_double_click FOR go_grid.
SET HANDLER g_event_receiver->handle_hotspot_click FOR go_grid .
SET HANDLER g_event_receiver->handle_data_changed FOR go_grid .
ENDIF.
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = go_grid.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
MODULE user_command_0100 INPUT.
ok_code = sy-ucomm.
CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN 'SAVE'.
PERFORM update_sales_order using t_list3[].
endcase.
Thanks in Advance,
SiriHi Sirisha,
You can get the event code for Enter because you have regitered in the event reciever .
But for the SAVE you will have to set in the PF-status of the screen and not the ALV-grid save .
Please award if helpful. -
Reg: CheckBox in ALV Grid Display
Hi all,
My requirement is to display checkbox field in ALV Grid which is editable.
And i also need to get all the records that i have selected in ALV grid.
How can i do it. Kindly Help me with sample codes.
Its Urgent.
<REMOVED BY MODERATOR>
Regards
Naveen
Edited by: Alvaro Tejada Galindo on Feb 18, 2008 5:41 PMHi,
First declare ur itab with the first field of length 1 char,
Dont mention dat in the field cat.
Give that field name and itab name in the layout.
as
is_layout-box_fieldname = 'CHECK'.
is_layout-box_tabname = 'IT_FINAL'.
u can dispaly ur checkbox in the output dispaly.
now to read the selected checkboxes u need to read the display with the syntax..
first describe the table + headre length = w_count.
FORM sub_read_checkbox.
DATA: w_cbox TYPE char1.
REFRESH : it_mail,it_text,it_selected.
REFRESH : it_selected.
DO w_count TIMES.
READ LINE sy-index FIELD VALUE : is_final-cbox INTO w_cbox.
IF w_cbox = c_x.
READ TABLE it_header INTO is_header WITH KEY lifnr = is_header-lifnr
u_r = is_header-u_r.
IF sy-subrc = 0.
APPEND is_header TO it_selected .
CLEAR: is_header,w_cbox.
ENDIF.
ENDIF.
ENDDO.
endform.
This serves ur purpose.
Regards............ -
ALV REPORT: read selected checkbox in alv grid and process the pushbutton
my requirement is to check some rows from alv grid and the press the pushbutton. Thereby following things should process:
select all checked rows into an itab and call the transaction code CJ01 for all
entries......
I am finding the problem that when I select the checkbox....the internal table doesnt recognize the boxes as checked ones......
thanks in advance...
Kartikey Singh,Data: ref1 type ref to cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = ref1.
call method ref1->check_changed_data.
loop at t_output where Flag = 'X'.
if t_output-VKUEGRU is initial.
message e000 with text-110.
endif.
endloop. -
To activate/deactivate checkbox in ALV grid report
Hi All,
I am trying to create an ALV Grid that contains check-box as column fields. I am able to either activate or deactivate all the check-boxes in the entire column. But, I need to keep only certain check-boxes for editing based on certain conditions. The other check-boxes in the column should be deactivated for editing by the user. Any help is appreciated.
-DineshHi dinesh babu ,
In this example, i use 'REUSE_ALV_GRID_DISPLAY_LVC'
FORM display_alv .
DATA: ls_event_exit TYPE slis_event_exit,
lt_event_exit TYPE slis_event_exit OCCURS 1.
DESCRIBE TABLE itab_data LINES lv_cont.
PERFORM layout_build USING gs_layout.
PERFORM eventtab_build USING gt_events[].
PERFORM comment_build USING gt_lheader[].
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZHRESS_FORMACION_ALV'
i_client_never_display = 'X'
i_bypassing_buffer = 'X'
CHANGING
ct_fieldcat = gt_fieldcat[]
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.
LOOP AT gt_fieldcat INTO ls_fcat.
Active check field
IF ls_fcat-fieldname EQ 'CHECK'.
ls_fcat-checkbox = 'X'.
ls_fcat-edit = 'X'.
ls_fcat-fix_column = 'X'.
ls_fcat-reptext = 'Check'.
ENDIF.
PERFORM field_attributes.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_background_id = 'ALV_BACKGROUND'
i_callback_program = g_repid
i_callback_pf_status_set = 'PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
is_layout_lvc = gs_layout
it_fieldcat_lvc = gt_fieldcat[]
i_save = g_save
is_variant = g_variant
it_events = gt_events[]
it_event_exit = lt_event_exit
i_default = 'X'
TABLES
t_outtab = itab_data.
ENDFORM. " DISPLAY_ALV
FORM field_attributes .
DATA ls_stylerow TYPE lvc_s_styl .
DATA lt_styletab TYPE lvc_t_styl .
LOOP AT itab_data INTO wa_data.
IF wa_data-status NE c_status_p. " Condition for enable / disable check
ls_stylerow-fieldname = 'CHECK' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled. "set field to disabled
APPEND ls_stylerow TO wa_data-field_style.
MODIFY itab_data FROM wa_data.
ENDIF.
ENDLOOP.
ENDFORM.
Regards,
José
Edited by: Jose Luzardo on Oct 6, 2009 3:37 PM -
Handling Events in ALV Grid Display
Hi,
I need ur urgent help on how to trigger and handle the events associated with the class CL_GUI_ALV_GRID_DISPLAY .Events like
ONF4
ONF1
DATA_CHANGED
USER_COMMAND
TOOLBAR
HOTSPOT_CLICK
Please help me in this matter and post some valid codes depicting these events.Ur help will be really appreciated throught points.
Thnkx in advance.Hi,
Please refer program "BCALV_TEST_GRID_EVENTS"
Best regards,
Prashant
*& Report BCALV_TEST_GRID_EVENTS *
report bcalv_test_grid_events.
types: g_ty_t_carrid type standard table of alv_tab,
g_ty_t_connid type standard table of alv_chck,
g_ty_t_curr type standard table of alv_cur,
g_ty_s_sflight type alv_t_t2,
g_ty_s_carrid type alv_tab,
g_ty_s_connid type alv_chck,
g_ty_s_curr type alv_cur.
constants: con_sflight type lvc_fname value 'ALV_T_T2',
con_scarr type lvc_fname value 'ALV_TAB',
con_spfli type lvc_fname value 'ALV_CHCK'.
* DATA *
class lcl_events_d0100 definition deferred.
types: begin of g_ty_s_plane,
carrid type g_ty_s_sflight-carrid,
connid type g_ty_s_sflight-connid,
planetype type g_ty_s_sflight-planetype,
seatsmax type g_ty_s_sflight-seatsmax,
end of g_ty_s_plane,
g_ty_t_plane type sorted table of g_ty_s_plane
with unique key carrid connid,
begin of g_ty_s_event,
user_command type char1,
before_user_command type char1,
after_user_command type char1,
double_click type char1,
hotspot_click type char1,
button_click type char1,
onf1 type char1,
onf4 type char1,
menu_button type char1,
toolbar type char1,
context_menu_request type char1,
ondrag type char1,
ondrop type char1,
ondropcomplete type char1,
ondropgetflavor type char1,
subtotal_text type char1,
data_changed type char1,
data_changed_finished type char1,
after_refresh type char1,
delayed_callback type char1,
delayed_changed_sel_callback type char1,
top_of_page type char1,
end_of_list type char1,
print_top_of_page type char1,
print_end_of_page type char1,
print_top_of_list type char1,
print_end_of_list type char1,
end of g_ty_s_event,
begin of g_ty_s_onf4,
register type char1,
get_before type char1,
change_after type char1,
internal_format type char1,
end of g_ty_s_onf4,
begin of g_ty_s_test,
select_amount type i,
no_info_popup type char1,
info_popup_once type char1,
events_info_popup type lvc_fname occurs 0,
application_events type char1,
event type g_ty_s_event,
onf4 type g_ty_s_onf4,
button_fields type lvc_fname occurs 0,
hotspot_fields type lvc_fname occurs 0,
onf1_fields type lvc_fname occurs 0,
onf4_fields type lvc_fname occurs 0,
bypassing_buffer type char1,
buffer_active type char1,
end of g_ty_s_test,
begin of g_ty_s_outtab.
include type g_ty_s_sflight.
types: box type char1,
lights type char1,
end of g_ty_s_outtab,
g_ty_t_outtab type table of g_ty_s_outtab.
constants: con_exit type sy-ucomm value 'EXIT',
con_canc type sy-ucomm value 'CANC',
con_back type sy-ucomm value 'BACK',
con_true type char1 value 'X'.
data: g_okcode type sy-ucomm.
data: gs_test type g_ty_s_test.
data: gt_outtab type g_ty_t_outtab with header line,
gr_container_d0100 type ref to cl_gui_custom_container,
gr_grid_d0100 type ref to cl_gui_alv_grid,
gr_events_d0100 type ref to lcl_events_d0100,
gr_grid_dragdrop type ref to cl_dragdrop.
data: g_static_menu type ref to cl_ctmenu,
g_static_menu_default type ref to cl_ctmenu.
data: g_field type lvc_s_fcat-fieldname.
* CLASS lcl_dragdrop_obj_d0100 DEFINITION
class lcl_dragdrop_obj_d0100 definition.
public section.
data: line type g_ty_s_outtab,
index type i.
endclass. "lcl_dragdrop_obj_d0100 DEFINITION
* CLASS lcl_events_d0100 DEFINITION
class lcl_events_d0100 definition.
public section.
methods:
user_command for event user_command
of cl_gui_alv_grid
importing e_ucomm sender,
before_user_command for event before_user_command
of cl_gui_alv_grid
importing e_ucomm,
after_user_command for event after_user_command
of cl_gui_alv_grid
importing e_ucomm
e_not_processed
e_saved,
double_click for event double_click
of cl_gui_alv_grid
importing e_row
e_column
es_row_no,
hotspot_click for event hotspot_click
of cl_gui_alv_grid
importing e_row_id
e_column_id
es_row_no,
menu_button for event menu_button
of cl_gui_alv_grid
importing e_object
e_ucomm,
toolbar for event toolbar
of cl_gui_alv_grid
importing e_object
e_interactive,
context_menu_request for event context_menu_request
of cl_gui_alv_grid
importing e_object,
top_of_page for event top_of_page
of cl_gui_alv_grid
importing e_dyndoc_id,
end_of_list for event end_of_list
of cl_gui_alv_grid
importing e_dyndoc_id,
print_top_of_page for event print_top_of_page
of cl_gui_alv_grid,
print_end_of_page for event print_end_of_page
of cl_gui_alv_grid,
print_top_of_list for event print_top_of_list
of cl_gui_alv_grid,
print_end_of_list for event print_end_of_list
of cl_gui_alv_grid,
after_refresh for event after_refresh
of cl_gui_alv_grid,
delayed_callback for event delayed_callback
of cl_gui_alv_grid,
delayed_changed_sel_callback
for event delayed_changed_sel_callback
of cl_gui_alv_grid,
subtotal_text for event subtotal_text
of cl_gui_alv_grid
importing es_subtottxt_info
ep_subtot_line
e_event_data,
ondrag for event ondrag
of cl_gui_alv_grid
importing e_row
e_column
es_row_no
e_dragdropobj,
ondrop for event ondrop
of cl_gui_alv_grid
importing e_row
e_column
es_row_no
e_dragdropobj,
ondropcomplete for event ondropcomplete
of cl_gui_alv_grid
importing e_row
e_column
es_row_no
e_dragdropobj,
ondropgetflavor for event ondropgetflavor
of cl_gui_alv_grid
importing e_row
e_column
es_row_no
e_dragdropobj
e_flavors,
data_changed for event data_changed
of cl_gui_alv_grid
importing er_data_changed
e_onf4
e_onf4_before
e_onf4_after,
data_changed_finished
for event data_changed_finished
of cl_gui_alv_grid,
button_click for event button_click
of cl_gui_alv_grid
importing es_col_id
es_row_no,
onf1 for event onf1
of cl_gui_alv_grid
importing e_fieldname
es_row_no
er_event_data,
onf4 for event onf4
of cl_gui_alv_grid
importing e_fieldname
e_fieldvalue
es_row_no
er_event_data
et_bad_cells
e_display.
endclass. "lcl_events_d0100 DEFINITION
* CLASS lcl_events_d0100 IMPLEMENTATION
class lcl_events_d0100 implementation.
* METHOD user_command *
method user_command.
perform d0100_event_ucomm using e_ucomm.
endmethod. "user_command
* METHOD before_user_command *
method before_user_command.
perform d0100_event_before_ucomm using e_ucomm.
endmethod. "before_user_command
* METHOD after_user_command *
method after_user_command.
perform d0100_event_after_ucomm using e_ucomm
e_not_processed
e_saved.
endmethod. "after_user_command
* METHOD double_click *
method double_click.
perform d0100_event_double_click using e_row
e_column.
endmethod. "double_click
* METHOD hotspot_click *
method hotspot_click.
* perform d0100_event_hotspot_click using e_row_id
* e_column_id.
gr_grid_d0100->refresh_table_display( ).
endmethod. "hotspot_click
* METHOD menu_button *
method menu_button.
perform d0100_event_menu_button using e_object
e_ucomm.
endmethod. "menu_button
* METHOD toolbar *
method toolbar.
perform d0100_event_toolbar using e_object
e_interactive.
endmethod. "toolbar
* METHOD context_menu_request *
method context_menu_request.
perform d0100_event_context_menu_reqst using e_object.
endmethod. "context_menu_request
* METHOD top_of_page *
method top_of_page.
perform d0100_event_top_of_page using e_dyndoc_id.
endmethod. "top_of_page
* METHOD end_of_list *
method end_of_list.
perform d0100_event_end_of_list using e_dyndoc_id.
endmethod. "end_of_list
* METHOD print_top_of_page *
method print_top_of_page.
perform d0100_event_print_top_of_page.
endmethod. "print_top_of_page
* METHOD print_end_of_page *
method print_end_of_page.
perform d0100_event_print_end_of_page.
endmethod. "print_end_of_page
* METHOD print_top_of_list *
method print_top_of_list.
perform d0100_event_print_top_of_list.
endmethod. "print_top_of_list
* METHOD print_end_of_list *
method print_end_of_list.
perform d0100_event_print_end_of_list.
endmethod. "print_end_of_list
* METHOD after_refresh *
method after_refresh.
perform d0100_event_after_refresh.
endmethod. "after_refresh
* METHOD delayed_callback *
method delayed_callback.
perform d0100_event_delayed_callback.
endmethod. "delayed_callback
* METHOD delayed_changed_sel_callback *
method delayed_changed_sel_callback.
perform d0100_event_changed_sel_callba.
endmethod. "delayed_changed_sel_callback
* METHOD subtotal_text *
method subtotal_text.
perform d0100_event_subtotal_text using es_subtottxt_info
ep_subtot_line
e_event_data.
endmethod. "subtotal_text
* METHOD ondrag *
method ondrag.
perform d0100_event_ondrag using e_row
e_column
e_dragdropobj.
endmethod. "ondrag
* METHOD ondrop *
method ondrop.
perform d0100_event_ondrop using e_row
e_column
e_dragdropobj.
endmethod. "ondrop
* METHOD ondropcomplete *
method ondropcomplete.
perform d0100_event_ondropcomplete using e_row
e_column
e_dragdropobj.
endmethod. "ondropcomplete
* METHOD ondropgetflavor *
method ondropgetflavor.
perform d0100_event_ondropgetflavor.
endmethod. "ondropgetflavor
* METHOD data_changed *
method data_changed.
perform d0100_event_data_changed using er_data_changed
e_onf4
e_onf4_before
e_onf4_after.
endmethod. "data_changed
* METHOD data_changed_finished *
method data_changed_finished.
perform d0100_event_data_changed_finis.
endmethod. "data_changed_finished
* METHOD button_click *
method button_click.
perform d0100_event_button_click using es_col_id
es_row_no.
endmethod. "button_click
* METHOD onf1 *
method onf1.
perform d0100_event_onf1 using e_fieldname
es_row_no
er_event_data.
endmethod. "onf1
* METHOD onf4 *
method onf4.
perform d0100_event_onf4 using e_fieldname
e_fieldvalue
es_row_no
er_event_data
et_bad_cells
e_display.
endmethod. "onf4
endclass. "lcl_events_d0100 IMPLEMENTATION
* SELECTION-SCREEN *
selection-screen begin of block gen with frame.
selection-screen begin of line.
parameters:
p_ext radiobutton group db.
selection-screen comment (29) for field p_ext.
selection-screen comment (29) for field p_d_file.
parameters:
p_d_file type char255.
selection-screen end of line.
selection-screen begin of line.
parameters:
p_db radiobutton group db default 'X'.
selection-screen comment (29) for field p_db.
selection-screen comment (29) for field p_amount.
parameters:
p_amount type i default 30.
selection-screen end of line.
selection-screen end of block gen.
selection-screen begin of block inf with frame.
parameters:
p_inf01 as checkbox default con_true,
p_inf02 as checkbox.
selection-screen end of block inf.
selection-screen begin of block app with frame.
parameters:
p_appevt as checkbox.
selection-screen end of block app.
selection-screen begin of block evt with frame.
parameters:
p_evt01 as checkbox, "USER_COMMAND
p_evt02 as checkbox, "BEFORE_USER_COMMAND
p_evt03 as checkbox. "AFTER_USER_COMMAND
selection-screen skip.
parameters:
p_evt04 as checkbox, "DOUBLE_CLICK
p_evt05 as checkbox. "HOTSPOT_CLICK
select-options:
p_hotspt for g_field no intervals default 'CARRID'.
parameters:
p_evt06 as checkbox. "BUTTON_CLICK
select-options:
p_button for g_field no intervals default 'CARRID'.
selection-screen skip.
parameters:
p_evt07 as checkbox. "ONF1
selection-screen begin of block of4 with frame.
parameters:
p_evt08 as checkbox. "ONF4
select-options:
p_onf4 for g_field no intervals default 'CARRID'.
selection-screen begin of line.
selection-screen comment 5(30) text-c01 for field p_f401.
parameters:
p_f401 as checkbox default con_true. "REGISTER
selection-screen end of line.
selection-screen begin of line.
selection-screen comment 5(30) text-c02 for field p_f402.
parameters:
p_f402 as checkbox. "GET_BEFORE
selection-screen end of line.
selection-screen begin of line.
selection-screen comment 5(30) text-c03 for field p_f403.
parameters:
p_f403 as checkbox. "CHANGE_AFTER
selection-screen end of line.
selection-screen begin of line.
selection-screen comment 5(30) text-c04 for field p_f404.
parameters:
p_f404 as checkbox. "INTERNAL_FORMAT
selection-screen end of line.
selection-screen end of block of4.
selection-screen skip.
parameters:
p_evt09 as checkbox, "MENU_BUTTON
p_evt10 as checkbox, "TOOLBAR
p_evt11 as checkbox. "CONTEXT_MENU_REQUEST
selection-screen skip.
parameters:
p_evt12 as checkbox, "ONDRAG
p_evt13 as checkbox, "ONDROP
p_evt14 as checkbox, "ONDROPCOMPLETE
p_evt15 as checkbox. "ONDROPGETFLAVOR
selection-screen skip.
parameters:
p_evt16 as checkbox. "SUBTOTAL_TEXT
selection-screen skip.
parameters:
p_evt17 as checkbox, "DATA_CHANGED
p_evt18 as checkbox, "DATA_CHANGED_FINISHED
p_evt19 as checkbox. "AFTER_REFRESH
selection-screen skip.
parameters:
p_evt20 as checkbox, "DELAYED_CALLBACK
p_evt21 as checkbox. "DELAYED_CHANGED_SEL_CALLBACK
selection-screen skip.
parameters:
p_evt22 as checkbox, "TOP_OF_PAGE
p_evt23 as checkbox, "END_OF_LIST
p_evt24 as checkbox, "PRINT_TOP_OF_PAGE
p_evt25 as checkbox, "PRINT_END_OF_PAGE
p_evt26 as checkbox, "PRINT_TOP_OF_LIST
p_evt27 as checkbox. "PRINT_END_OF_LIST
selection-screen end of block evt.
* AT SELECTION-SCREEN ON VALUE-REQUEST *
at selection-screen on value-request for p_hotspt-low.
perform d0100_f4_fcode changing p_hotspt-low.
at selection-screen on value-request for p_button-low.
perform d0100_f4_fcode changing p_button-low.
at selection-screen on value-request for p_onf4-low.
perform d0100_f4_fcode changing p_onf4-low.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_d_file.
PERFORM f4_file.
* START-OF-SELECTION *
start-of-selection.
gs_test-select_amount = p_amount.
gs_test-no_info_popup = p_inf01.
gs_test-info_popup_once = p_inf02.
gs_test-application_events = p_appevt.
gs_test-event-user_command = p_evt01.
gs_test-event-before_user_command = p_evt02.
gs_test-event-after_user_command = p_evt03.
gs_test-event-double_click = p_evt04.
gs_test-event-hotspot_click = p_evt05.
gs_test-event-button_click = p_evt06.
gs_test-event-onf1 = p_evt07.
gs_test-event-onf4 = p_evt08.
gs_test-event-menu_button = p_evt09.
gs_test-event-toolbar = p_evt10.
gs_test-event-context_menu_request = p_evt11.
gs_test-event-ondrag = p_evt12.
gs_test-event-ondrop = p_evt13.
gs_test-event-ondropcomplete = p_evt14.
gs_test-event-ondropgetflavor = p_evt15.
gs_test-event-subtotal_text = p_evt16.
gs_test-event-data_changed = p_evt17.
gs_test-event-data_changed_finished = p_evt18.
gs_test-event-after_refresh = p_evt19.
gs_test-event-delayed_callback = p_evt20.
gs_test-event-delayed_changed_sel_callback = p_evt21.
gs_test-event-top_of_page = p_evt22.
gs_test-event-end_of_list = p_evt23.
gs_test-event-print_top_of_page = p_evt24.
gs_test-event-print_end_of_page = p_evt25.
gs_test-event-print_top_of_list = p_evt26.
gs_test-event-print_end_of_list = p_evt27.
gs_test-onf4-register = p_f401.
gs_test-onf4-get_before = p_f402.
gs_test-onf4-change_after = p_f403.
gs_test-onf4-internal_format = p_f404.
if p_evt05 ne space.
loop at p_hotspt.
if not p_hotspt-low is initial.
append p_hotspt-low to gs_test-hotspot_fields.
endif.
endloop.
endif.
if p_evt06 ne space.
loop at p_button.
if not p_button-low is initial.
append p_button-low to gs_test-button_fields.
endif.
endloop.
endif.
if p_evt08 ne space.
loop at p_onf4.
if not p_onf4-low is initial.
append p_onf4-low to gs_test-onf4_fields.
endif.
endloop.
endif.
gs_test-bypassing_buffer = space.
gs_test-buffer_active = space.
* END-OF-SELECTION *
end-of-selection.
call screen 100.
*& Module d0100_set_status OUTPUT
* text
module d0100_set_status output.
perform d0100_set_status.
endmodule. " d0100_set_status OUTPUT
*& Module d0100_prepare_container OUTPUT
* text
module d0100_prepare_container output.
perform d0100_prepare_container.
endmodule. " d0100_prepare_container OUTPUT
*& Module d0100_exit INPUT
* text
module d0100_exit input.
perform d0100_exit.
endmodule. " d0100_exit INPUT
*& Module d0100_fcode INPUT
* text
module d0100_fcode input.
perform d0100_fcode.
endmodule. " d0100_fcode INPUT
*& Form d0100_set_status
* text
form d0100_set_status .
types: begin of l_ty_s_excl,
func type syucomm,
end of l_ty_s_excl,
l_ty_t_excl type standard table of l_ty_s_excl.
data: lt_excl type l_ty_t_excl.
set pf-status 'D0100' excluding lt_excl.
set titlebar 'D0100'.
endform. " d0100_set_status
*& Form d0100_prepare_container
* text
form d0100_prepare_container .
data: lt_fcat type lvc_t_fcat,
ls_layo type lvc_s_layo,
ls_vari type disvariant,
ls_prnt type lvc_s_prnt,
l_consistency_check type char1.
if gr_container_d0100 is initial.
if cl_gui_alv_grid=>offline( ) is initial.
create object gr_container_d0100
exporting container_name = 'D0100_CONTAINER'.
endif.
create object gr_grid_d0100
exporting i_parent = gr_container_d0100
i_appl_events = gs_test-application_events.
DATA: l_filename TYPE string,
l_struct TYPE string.
CASE con_true.
WHEN p_db.
perform d0100_get_outtab.
WHEN p_ext.
l_struct = 'g_ty_t_outtab'.
l_filename = p_d_file.
CALL METHOD cl_salv_test_data=>select_data
EXPORTING
structname = l_struct
SOURCE = 2
filename = l_filename
* AMOUNT = 30
CHANGING
data = gt_outtab[].
ENDCASE.
perform d0100_set_grid_vari changing ls_vari.
perform d0100_set_grid_layo changing ls_layo.
perform d0100_set_grid_fcat changing lt_fcat.
perform d0100_set_grid_onf4 changing lt_fcat.
perform d0100_set_grid_buttons changing lt_fcat.
perform d0100_set_grid_hotspot changing lt_fcat.
perform d0100_set_grid_dragdrop changing ls_layo.
perform d0100_set_grid_edit changing ls_layo.
perform d0100_set_grid_events.
ls_prnt-grpchgedit = con_true.
call method gr_grid_d0100->set_table_for_first_display
exporting
i_buffer_active = gs_test-buffer_active
i_bypassing_buffer = gs_test-bypassing_buffer
i_consistency_check = l_consistency_check
is_variant = ls_vari
i_save = 'A'
i_default = con_true
is_layout = ls_layo
is_print = ls_prnt
changing
it_outtab = gt_outtab[]
it_fieldcatalog = lt_fcat.
endif.
endform. " d0100_prepare_container
*& Form d0100_exit
* text
form d0100_exit .
data: l_okcode like sy-ucomm.
l_okcode = g_okcode.
clear g_okcode.
case l_okcode.
when con_exit or con_back or con_canc.
call method gr_grid_d0100->free.
call method gr_container_d0100->free.
call method cl_gui_cfw=>flush.
clear gr_container_d0100.
clear gr_grid_d0100.
clear gr_events_d0100.
set screen 0.
leave screen.
endcase.
endform. " d0100_exit
*& Form d0100_fcode
* text
form d0100_fcode .
data: l_okcode like sy-ucomm.
l_okcode = g_okcode.
clear g_okcode.
call method cl_gui_cfw=>dispatch.
case l_okcode.
when con_exit or con_back or con_canc.
g_okcode = l_okcode.
perform d0100_exit.
when others.
endcase.
endform. " d0100_fcode
*& Form d0100_set_grid_vari
* text
form d0100_set_grid_vari changing cs_vari type disvariant.
cs_vari-report = sy-repid.
cs_vari-handle = space.
cs_vari-log_group = space.
cs_vari-username = space.
cs_vari-variant = space.
cs_vari-text = space.
cs_vari-dependvars = space.
endform. " d0100_set_grid_vari
*& Form d0100_set_grid_layo
* text
form d0100_set_grid_layo changing cs_layo type lvc_s_layo.
*... ALV-Control: Allgemeine Anzeigeoptionen
cs_layo-stylefname = space.
cs_layo-cwidth_opt = con_true.
cs_layo-zebra = space.
cs_layo-smalltitle = space.
cs_layo-graphics = space.
cs_layo-frontend = space.
cs_layo-template = space.
*... ALV-Control: Gridcustomizing
cs_layo-no_colexpd = space.
cs_layo-no_hgridln = space.
cs_layo-no_vgridln = space.
cs_layo-no_rowmark = space.
cs_layo-no_headers = space.
cs_layo-no_merging = space.
cs_layo-grid_title = space.
cs_layo-no_toolbar = space.
cs_layo-sel_mode = 'D'.
cs_layo-box_fname = space.
cs_layo-sgl_clk_hd = space.
*... ALV-Control: Summenoptionen
cs_layo-totals_bef = space.
cs_layo-no_totline = space.
cs_layo-numc_total = space.
cs_layo-no_utsplit = space.
*... ALV-Control: Exceptions
cs_layo-excp_fname = 'LIGHTS'.
cs_layo-excp_rolln = space.
cs_layo-excp_conds = space.
cs_layo-excp_led = space.
*... ALV-Control: Steuerung Interaktion
cs_layo-detailinit = space.
cs_layo-detailtitl = space.
cs_layo-keyhot = space.
cs_layo-no_keyfix = space.
cs_layo-no_author = space.
clear cs_layo-s_dragdrop.
*... ALV-Control: Farben
cs_layo-info_fname = space.
cs_layo-ctab_fname = space.
*... ALV-Control: Eingabefähigkeit
cs_layo-edit = space.
cs_layo-edit_mode = space.
cs_layo-no_rowins = space.
cs_layo-no_rowmove = space.
*... ALV-Control: Web-Optionen
cs_layo-weblook = space.
cs_layo-webstyle = space.
cs_layo-webrows = space.
cs_layo-webxwidth = space.
cs_layo-webxheight = space.
endform. " d0100_set_grid_layo
*& Form d0100_set_grid_fcat
* text
form d0100_set_grid_fcat changing ct_fcat type lvc_t_fcat.
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_buffer_active = gs_test-buffer_active
i_structure_name = con_sflight
i_client_never_display = con_true
i_bypassing_buffer = gs_test-bypassing_buffer
changing
ct_fieldcat = ct_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.
endform. " d0100_set_grid_fcat
*& Form d0100_set_grid_onf4
* text
form d0100_set_grid_onf4 changing ct_fcat type lvc_t_fcat.
field-symbols: <ls_fcat> type lvc_s_fcat.
data: l_field type lvc_fname,
lt_f4 type lvc_t_f4,
ls_f4 type lvc_s_f4.
if gs_test-event-onf4 eq con_true.
loop at gs_test-onf4_fields into l_field.
read table ct_fcat assigning <ls_fcat>
with key fieldname = l_field.
if sy-subrc eq 0.
<ls_fcat>-f4availabl = con_true.
endif.
ls_f4-fieldname = l_field.
ls_f4-register = gs_test-onf4-register.
ls_f4-getbefore = gs_test-onf4-get_before.
ls_f4-chngeafter = gs_test-onf4-change_after.
ls_f4-internal = gs_test-onf4-internal_format.
insert ls_f4 into table lt_f4.
endloop.
endif.
check not lt_f4 is initial.
call method gr_grid_d0100->register_f4_for_fields
exporting
it_f4 = lt_f4.
endform. " d0100_set_grid_onf4
*& Form d0100_set_grid_buttons
* text
form d0100_set_grid_buttons changing ct_fcat type lvc_t_fcat.
field-symbols: <ls_fcat> type lvc_s_fcat.
data: l_field type lvc_fname.
loop at gs_test-button_fields into l_field.
*... Spaltenebene
* In Feldkatalog wird Feld STYLE für Spalte auf
* cl_gui_alv_grid=>mc_style_button gesetzt
read table ct_fcat assigning <ls_fcat>
with key fieldname = l_field.
if sy-subrc eq 0.
<ls_fcat>-style = cl_gui_alv_grid=>mc_style_button.
endif.
endloop.
endform. " d0100_set_grid_buttons
*& Form d0100_set_grid_hotspot
* text
form d0100_set_grid_hotspot changing ct_fcat type lvc_t_fcat.
field-symbols: <ls_fcat> type lvc_s_fcat.
data: l_field type lvc_fname.
loop at gs_test-hotspot_fields into l_field.
*... Spaltenebene
* In Feldkatalog wird Feld STYLE für Spalte auf
* cl_gui_alv_grid=>mc_style_hotspot gesetzt
read table ct_fcat assigning <ls_fcat>
with key fieldname = l_field.
if sy-subrc eq 0.
<ls_fcat>-style = cl_gui_alv_grid=>mc_style_hotspot.
endif.
endloop.
endform. " d0100_set_grid_hotspot
*& Form d0100_set_grid_edit
* text
form d0100_set_grid_edit changing cs_layo type lvc_s_layo.
if gs_test-event-data_changed eq con_true or
gs_test-event-data_changed_finished eq con_true or
gs_test-event-after_refresh eq con_true.
cs_layo-edit = con_true.
call method gr_grid_d0100->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
endif.
endform. " d0100_set_grid_edit
*& Form d0100_set_grid_dragdrop
* text
form d0100_set_grid_dragdrop changing cs_layo type lvc_s_layo.
data: l_effect type i,
l_handle_grid type i,
ls_dragdrop type lvc_s_dd01.
*... setzen für Zeilen
create object gr_grid_dragdrop.
l_effect = cl_dragdrop=>move + cl_dragdrop=>copy.
call method gr_grid_dragdrop->add
exporting
flavor = 'Line' "#EC NOTEXT
dragsrc = 'X'
droptarget = 'X'
effect = l_effect.
call method gr_grid_dragdrop->get_handle
importing
handle = l_handle_grid.
ls_dragdrop-cntr_ddid = space.
ls_dragdrop-grid_ddid = space.
ls_dragdrop-col_ddid = space.
ls_dragdrop-row_ddid = l_handle_grid.
ls_dragdrop-fieldname = space.
cs_layo-s_dragdrop = ls_dragdrop.
endform. " d0100_set_grid_dragdrop
*& Form d0100_set_grid_events
* text
form d0100_set_grid_events .
create object gr_events_d0100.
if gs_test-event-user_command eq con_true.
set handler gr_events_d0100->user_command
for gr_grid_d0100.
endif.
if gs_test-event-before_user_command eq con_true.
set handler gr_events_d0100->before_user_command
for gr_grid_d0100.
endif.
if gs_test-event-after_user_command eq con_true.
set handler gr_events_d0100->after_user_command
for gr_grid_d0100.
endif.
if gs_test-event-double_click eq con_true.
set handler gr_events_d0100->double_click
for gr_grid_d0100.
endif.
if gs_test-event-hotspot_click eq con_true.
set handler gr_events_d0100->hotspot_click
for gr_grid_d0100.
endif.
if gs_test-event-button_click eq con_true.
set handler gr_events_d0100->button_click
for gr_grid_d0100.
endif.
if gs_test-event-onf1 eq con_true.
set handler gr_events_d0100->onf1
for gr_grid_d0100.
endif.
if gs_test-event-onf4 eq con_true.
set handler gr_events_d0100->onf4
for gr_grid_d0100.
endif.
if gs_test-event-menu_button eq con_true.
set handler gr_events_d0100->menu_button
for gr_grid_d0100.
endif.
if gs_test-event-toolbar eq con_true.
set handler gr_events_d0100->toolbar
for gr_grid_d0100.
endif.
if gs_test-event-context_menu_request eq con_true.
set handler gr_events_d0100->context_menu_request
for gr_grid_d0100.
endif.
if gs_test-event-ondrag eq con_true.
set handler gr_events_d0100->ondrag
for gr_grid_d0100.
endif.
if gs_test-event-ondrop eq con_true.
set handler gr_events_d0100->ondrop
for gr_grid_d0100.
endif.
if gs_test-event-ondropcomplete eq con_true.
set handler gr_events_d0100->ondropcomplete
for gr_grid_d0100.
endif.
if gs_test-event-ondropgetflavor eq con_true.
set handler gr_events_d0100->ondropgetflavor
for gr_grid_d0100.
endif.
if gs_test-event-subtotal_text eq con_true.
set handler gr_events_d0100->subtotal_text
for gr_grid_d0100.
endif.
if gs_test-event-data_changed eq con_true.
set handler gr_events_d0100->data_changed
for gr_grid_d0100.
endif.
if gs_test-event-data_changed_finished eq con_true.
set handler gr_events_d0100->data_changed_finished
for gr_grid_d0100.
endif.
if gs_test-event-after_refresh eq con_true.
set handler gr_events_d0100->after_refresh
for gr_grid_d0100.
endif.
if gs_test-event-delayed_callback eq con_true.
set handler gr_events_d0100->delayed_callback
for gr_grid_d0100.
call method gr_grid_d0100->register_delayed_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_delayed_move_curr_cell.
endif.
if gs_test-event-delayed_changed_sel_callback eq con_true.
set handler gr_events_d0100->delayed_changed_sel_callback
for gr_grid_d0100.
call method gr_grid_d0100->register_delayed_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_delayed_change_select.
endif.
if gs_test-event-top_of_page eq con_true.
set handler gr_events_d0100->top_of_page
for gr_grid_d0100.
endif.
if gs_test-event-end_of_list eq con_true.
set handler gr_events_d0100->end_of_list
for gr_grid_d0100.
endif.
if gs_test-event-print_top_of_page eq con_true.
set handler gr_events_d0100->print_top_of_page
for gr_grid_d0100.
endif.
if gs_test-event-print_end_of_page eq con_true.
set handler gr_events_d0100->print_end_of_page
for gr_grid_d0100.
endif.
if gs_test-event-print_top_of_list eq con_true.
set handler gr_events_d0100->print_top_of_list
for gr_grid_d0100.
endif.
if gs_test-event-print_end_of_list eq con_true.
set handler gr_events_d0100->print_end_of_list
for gr_grid_d0100.
endif.
endform. " d0100_set_grid_events
*& Form d0100_get_outtab
* text
form d0100_get_outtab .
field-symbols: <ls_outtab> type g_ty_s_outtab.
data: l_excp_mod type i,
l_excp_div type i,
l_excp_amnt type i value 4,
l_excp type i,
lt_carrid type g_ty_t_carrid,
ls_carrid type g_ty_s_carrid,
l_carrid_amount type i,
l_carrid_select type i,
l_carrid_index1 type i,
lt_connid type g_ty_t_connid,
ls_connid type g_ty_s_connid,
l_connid_amount type i, "#EC NEEDED
l_connid_select type i,
l_connid_index1 type i,
l_connid_index2 type i,
lt_plane type g_ty_t_plane,
ls_plane type g_ty_s_plane.
if gs_test-select_amount gt 0.
select * from (con_sflight) into corresponding fields
of table gt_outtab up to gs_test-select_amount rows.
endif.
gs_test-select_amount = sy-dbcnt.
perform d0100_get_carrid changing lt_carrid.
perform d0100_get_connid changing lt_connid.
perform d0100_get_plane using lt_connid changing lt_plane.
describe table lt_carrid lines l_carri -
Hello friends
i have an internal table displayed in alv with one field as editable checkbox.
The display is OK.
After the user click the SAVE button, I want to process the ckecked records only.
My problem: after clicking the SAVE button, in USER_COMMAND form, all the records of the internal table have the checkbox field empty even if they were checked.
MOVE 'SET_PF_STATUS' TO wv_slis_formname.
wv_repid = sy-repid.
DELETE wt_input INDEX 1. "remove the header texts
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_user_command = 'USER_COMMAND'
i_callback_program = wv_repid
i_callback_pf_status_set = wv_slis_formname
is_layout = ws_layout
it_fieldcat = wt_field1
* i_save = 'X'
TABLES
t_outtab = wt_input
EXCEPTIONS
program_error = 1
OTHERS = 2.
anybody could give me a hint?
In debug session I check : wt_input table here
FORM user_command USING r_ucomm LIKE sy-ucomm
ls_selfield type slis_selfield.
DATA: save_ok TYPE sy-ucomm.
DATA: ref1 TYPE REF TO cl_gui_alv_grid.
save_ok = sy-ucomm.
CASE save_ok.
WHEN 'SAVE'.
ENDCASE.
ENDFORM. "user_command
and its fields corresponding for the checkbox are all emptyHi,
Go through this code . This code is for interactive alv . This interactive alv will display only for Checked ones.
TYPE-POOLS : SLIS.
PARAMETERS : P_EBELN TYPE EKKO-EBELN.
TYPES: BEGIN OF TY_EKKO,
CHECK TYPE C,
EBELN TYPE EKKO-EBELN,
BUKRS TYPE EKKO-BUKRS,
EKORG TYPE EKKO-EKORG,
BEDAT TYPE EKKO-BEDAT,
END OF TY_EKKO.
DATA : REPID TYPE SY-REPID.
DATA : IT_EKKO TYPE TABLE OF TY_EKKO,
WA_EKKO TYPE TY_EKKO.
DATA : ITAB TYPE TABLE OF TY_EKKO.
DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT TYPE SLIS_FIELDCAT_ALV.
data : gs_layout type SLIS_LAYOUT_ALV.
FIELD-SYMBOLS : <WA_EKKO> LIKE LINE OF IT_EKKO.
SELECT EBELN BUKRS EKORG BEDAT FROM EKKO INTO CORRESPONDING FIELDS OF TABLE IT_EKKO UP TO 10 ROWS.
PERFORM FIELDCAT.
PERFORM DISPLAY_DATA.
FORM SET_PF_STATUS USING STATUS.
SET PF-STATUS 'STATUS'.
ENDFORM.
FORM USER_COMMAND USING FU_UCOMM LIKE SY-UCOMM FU_SELFIELD TYPE SLIS_SELFIELD.
CASE fu_ucomm.
WHEN 'CHECK'.
LOOP AT IT_EKKO ASSIGNING <WA_EKKO>.
<WA_EKKO>-check = 'X'.
MODIFY TABLE IT_EKKO FROM <WA_EKKO> TRANSPORTING CHECK.
ENDLOOP.
FU_SELFIELD-REFRESH = 'X'.
WHEN 'UNCHECK'.
LOOP AT IT_EKKO ASSIGNING <WA_EKKO>.
<WA_EKKO>-check = ' '.
MODIFY TABLE IT_EKKO FROM <WA_EKKO> TRANSPORTING CHECK.
ENDLOOP.
FU_SELFIELD-REFRESH = 'X'.
WHEN 'READ'.
IF IT_EKKO IS NOT INITIAL.
LOOP AT IT_EKKO INTO <WA_EKKO> WHERE CHECK = 'X'.
BREAK-POINT.
APPEND <WA_EKKO> TO ITAB.
ENDLOOP.
ENDIF.
if itab is not initial.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = GS_LAYOUT
IT_FIELDCAT = IT_FCAT
I_SAVE = 'X'
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
endif.
WHEN OTHERS.
READ TABLE IT_EKKO ASSIGNING <WA_EKKO> INDEX FU_SELFIELD-TABINDEX.
<WA_EKKO>-CHECK = 'X'.
MODIFY table IT_EKKO FROM <WA_EKKO> TRANSPORTING CHECK .
*BREAK-POINT.
FU_SELFIELD-REFRESH = 'X'.
ENDCASE.
ENDFORM.
FORM FIELDCAT .
WA_FCAT-FIELDNAME = 'CHECK'.
wa_fcat-seltext_m = 'Select' .
wa_fcat-checkbox = 'X'.
wa_fcat-edit = 'X'.
WA_FCAT-COL_POS = 5.
WA_FCAT-OUTPUTLEN = '20'.
wa_fcat-hotspot = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'EBELN' .
WA_FCAT-TABNAME = 'EKKO' .
WA_FCAT-COL_POS = 1.
WA_FCAT-OUTPUTLEN = '20'.
wa_fcat-seltext_m = 'BILLING NUM' .
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'BUKRS' .
WA_FCAT-TABNAME = 'EKKO' .
WA_FCAT-COL_POS = 2.
WA_FCAT-OUTPUTLEN = '20'.
wa_fcat-seltext_m = 'COMPANY CODE' .
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'EKORG' .
WA_FCAT-TABNAME = 'EKKO' .
WA_FCAT-COL_POS = 3.
WA_FCAT-OUTPUTLEN = '20'.
wa_fcat-seltext_m = 'ORGANIZATION' .
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'BEDAT' .
WA_FCAT-TABNAME = 'EKKO' .
WA_FCAT-COL_POS = 4.
WA_FCAT-OUTPUTLEN = '20'.
wa_fcat-seltext_m = 'BILLING DATE' .
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
ENDFORM.
FORM DISPLAY_DATA .
IF NOT IT_EKKO IS INITIAL.
GS_LAYOUT-zebra = 'X' .
GS_LAYOUT-colwidth_optimize = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = GS_LAYOUT
IT_FIELDCAT = IT_FCAT
I_SAVE = 'X'
TABLES
T_OUTTAB = IT_EKKO
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
ENDIF.
ENDFORM.
Edited by: Aditya.G on Dec 29, 2011 12:35 PM -
Change Totals based on Checkbox in ALV Grid
Hi,
My report is having 5 Columns with 50 records as Output.
First :Check box.
Second : Inbound Delivery Number.
Third : Carton Id
Fourth: Weight
Fifth : Volume.
User can select/ deselect the records using Check box. I am writing this logic under Hot spot event.
I need to calculate sum of Weight and Volume for the records which user selects using Check box and
display it Total Weight and Total Volume.
How can i change the Totals in Top_of_page at run time based on user selection? Please suggest..
Thanks
BhuvanaHi,
Instead you could have one "Sum" button on application toolbar and if user selects the number of rows and clicks on that button, then you can sum up the selected rows and show (WRITE command at TOP_OF_PAGE event) it in screen.
Try it!
Regards
Sarav -
Urgent checkboxes handling in alv grid
helo all .i need to handle checkboxes in alv grid.
i did like
case u_comm.
when 'save'.
perform save.
endcase.
in the form.
form save.
loop at it_mara into it_mara1 where chk = 'X'
and moving the contents to it_mara1.
but after doing it is not looping when i have seen in debug .
plz help me
i need to have those selected values and move a head.Hi rakhee,
First add a single charecter field into the internal table you want to display in the ALV.Then set the field cataloge and set the value for Checkbox as 'X'.it wil display the field as a check box.when you check the check box it will update the internal table also.
please check the below code.
TYPE-POOLS : slis.
TYPES : BEGIN OF st_mara.
TYPES : matnr TYPE mara-matnr.
TYPES : a,
END OF st_mara.
DATA : it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat LIKE LINE OF it_fieldcat.
DATA : it_mara TYPE TABLE OF st_mara.
SELECT * FROM mara
INTO CORRESPONDING FIELDS OF TABLE it_mara UP TO 1 ROWS.
wa_fieldcat-col_pos = 1.
wa_fieldcat-fieldname = 'A'.
wa_fieldcat-checkbox = 'X'.
wa_fieldcat-edit = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = 2.
wa_fieldcat-fieldname = 'MATNR'.
APPEND wa_fieldcat TO it_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = it_fieldcat
TABLES
t_outtab = it_mara.
BREAK-POINT.
if you are using controls just call the method
CALL METHOD grid1->check_changed_data.
grid1 is the instance of the ALV grid.
when the method is called you will get the internal table with the field marked as 'X'.
Regards
Sandeep
Maybe you are looking for
-
I have over 50 iphone logged in with the same compant account to keep track of them, some of them are not showing anymore, including new devices, have I maxed out the ammount of devices I can associate with this feature?
-
when i switch to facetime or speaker phone my contancts can't hear me although i can hear them... how can i fix it ?
-
Oracle White Paper- Storage Option for RAC. on Linux
hi.. This in reference with White Paper.. Stotage Option for RAC on LINUX. Author- Umadevi Byrappa. Which states on page 10: To Use NAS for RAC database file storage select the file system storage option in OUI. or the Clustered file system storage o
-
Hi , I am getting following crash in 32 bit C++ application built on Linux platform 5.4 with Oracle client version 11.2.0.2. Program terminated with signal 6, Aborted. [New process 22157] #0 0xffffe410 in __kernel_vsyscall () (gdb) bt #0 0xffffe410 i
-
ITunes 11.1.4 vs 11.1.5 on SL, update or no?
I'm currently at 11.1.4 and all is well. When an updated comes out for iTunes, I generally follow this forum to see if there are any "consistent" issues. I've noticed many threads of "not being able to open iTunes" after updating to 11.1.5. That said