2012 May 26 9:58 AM
This is my code for alv..I my below code i have used call method oref_alv->check_changed_data. method in PAI to update alv to itab which checked with check box.. but.when i select second time using check box it is not getting updated???Only gets updated first time??
start of selection
PERFORM select.
perform build_fieldcat.
call SCREEN 9000.
FORM select.
select VBELN
AUART
VKORG
VTWEG
SPART
from vbak
into CORRESPONDING FIELDS OF TABLE lt_alv
FOR ALL ENTRIES IN it_convert
WHEre vbeln = it_convert-vbeln.
ENDFORM.
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module STATUS_9000 output.
SET PF-STATUS 'GUI'.
* SET TITLEBAR 'xxx'.
CREATE OBJECT oref_container
EXPORTING
* parent =
container_name = 'CUST'
* style =
* lifetime = lifetime_default
* repid =
* dynnr =
* no_autodef_progid_dynnr =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT oref_splitter
EXPORTING
parent = oref_container
rows = 2
columns = 1
EXCEPTIONS
cntl_error = 1
cntl_system_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.
CALL METHOD oref_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = container1.
CALL METHOD oref_splitter->set_row_height
EXPORTING
id = 1
height = 20
EXCEPTIONS
cntl_error = 1
cntl_system_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.
CALL METHOD oref_splitter->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = container2.
CREATE OBJECT v_html
EXPORTING
style = 'ALV_GRID'.
CREATE OBJECT oref_alv
EXPORTING
* i_shellstyle = 0
* i_lifetime =
i_parent = container2
* i_appl_events = space
* i_parentdbg =
* i_applogparent =
* i_graphicsparent =
* i_name =
* i_fcat_complete = space
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
wa_layout-cwidth_opt = 'X'.
CALL METHOD oref_alv->set_table_for_first_display
EXPORTING
is_layout = wa_layout
CHANGING
it_outtab = LT_ALV
it_fieldcatalog = Lt_fcat
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.
* Create object
IF v_event_receiver IS INITIAL.
CREATE OBJECT v_event_receiver.
ENDIF.
SET HANDLER v_event_receiver->handle_print_top_of_page FOR oref_alv.
SET HANDLER v_event_receiver->handle_top_of_page FOR oref_alv.
***********************************
* Must be after the SET HANDLER for TOP_OF_PAGE and foreground only
CALL METHOD oref_alv->list_processing_events
EXPORTING i_event_name = 'TOP_OF_PAGE'
i_dyndoc_id = v_html.
CALL METHOD v_html->add_picture
EXPORTING
picture_id = 'ENJOYSAP_LOGO'
width = '100'.
* CALL METHOD v_html->add_gap
* EXPORTING
* width = 120.
CALL METHOD v_html->add_text
EXPORTING
text = 'Sales Order Details'.
CALL METHOD v_html->new_line.
CALL METHOD v_html->add_gap
EXPORTING
width = 1.
* CALL METHOD v_html->add_text
* EXPORTING
* text = 'v_text16'.
CALL METHOD v_html->add_gap
EXPORTING
width = 1.
* CALL METHOD v_html->add_text
* EXPORTING
* text = 'v_text16'.
CALL METHOD v_html->new_line.
* Display the data
CALL METHOD v_html->display_document
EXPORTING
parent = container1.
* Handle the event
CALL METHOD oref_alv->list_processing_events
EXPORTING i_event_name = 'PRINT_TOP_OF_PAGE'.
endmodule. " STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module USER_COMMAND_9000 input.
call method oref_alv->check_changed_data.
* IMPORTING
* E_VALID =
* CHANGING
* C_REFRESH = 'X'
*
CLEAR OK_CODE.
OK_CODE = SY-UCOMM.
CASE OK_CODE.
WHEN 'CLICK'.
LOOP AT LT_ALV INTO LS_ALV.
IF LS_ALV-SELECT = 'X'.
MARK_COUNT = MARK_COUNT + 1.
ENDIF.
ENDLOOP.
IF MARK_COUNT > 1 OR MARK_COUNT = 0 .
MESSAGE 'oNLY ONE SHLD BE SELECTED' TYPE 'S' DISPLAY LIKE 'E'.
CLEAR MARK_COUNT.
ELSE.
MESSAGE 'GOING TO PERFORM SAPSCRIPT ' TYPE 'S'.
ENDIF.
PERFORM redisplay.
ENDCASE.
endmodule. " USER_COMMAND_9000 INPUT
form build_fieldcat.
LS_fcat-fieldname = 'SELECT'.
ls_fcat-CHECKBOX = 'X'.
LS_fcat-EDIT = 'X'.
LS_fcat-SCRTEXT_S = 'SELECT'.
APPEND LS_fcat to Lt_fcat.
CLEAR LS_fcat.
LS_fcat-fieldname = 'VBELN'.
LS_fcat-SCRTEXT_S = 'Sales Document'.
APPEND LS_fcat to Lt_fcat.
CLEAR LS_fcat.
LS_fcat-fieldname = 'AUART'.
LS_fcat-SCRTEXT_S = 'Sales Document type'.
APPEND LS_fcat to Lt_fcat.
CLEAR LS_fcat.
LS_fcat-fieldname = 'VKORG'.
LS_fcat-SCRTEXT_S = 'Sales Organisation'.
APPEND LS_fcat to Lt_fcat.
CLEAR LS_fcat.
LS_fcat-fieldname = 'VTWEG'.
LS_fcat-SCRTEXT_S = 'Distribution Channel'.
APPEND LS_fcat to Lt_fcat.
CLEAR LS_fcat.
LS_fcat-fieldname = 'SPART'.
LS_fcat-SCRTEXT_S = 'Divison'.
APPEND LS_fcat to Lt_fcat.
CLEAR LS_fcat.
endform.
FORM top_of_page.
WRITE: 'text-020'.
ENDFORM. " top_of_page
FORM redisplay .
*Row and column of the alv are refreshed after changing values
stable-row = 'X'.
stable-col = 'X'.
*REfreshed ALV display with the changed values
*This ALV is non editable and contains new values
CALL METHOD oref_alv->refresh_table_display
EXPORTING
is_stable = stable
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.
ENDFORM.
2012 May 26 3:46 PM
Issue Solved:
Used the following method
CALL METHOD oref_alv->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
Then call the
call method oref_alv->check_changed_data
This is my code for alv..I my below code i have used call method oref_alv->check_changed_data. method in PAI to update alv to itab which checked with check box.. but.when i select second time using check box it is not getting updated???Only gets updated first time??
start of selection
PERFORM select.
perform build_fieldcat.
call SCREEN 9000.
FORM select.
select VBELN
AUART
VKORG
VTWEG
SPART
from vbak
into CORRESPONDING FIELDS OF TABLE lt_alv
FOR ALL ENTRIES IN it_convert
WHEre vbeln = it_convert-vbeln.
ENDFORM.
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module STATUS_9000 output.
SET PF-STATUS 'GUI'.
* SET TITLEBAR 'xxx'.
CREATE OBJECT oref_container
EXPORTING
* parent =
container_name = 'CUST'
* style =
* lifetime = lifetime_default
* repid =
* dynnr =
* no_autodef_progid_dynnr =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT oref_splitter
EXPORTING
parent = oref_container
rows = 2
columns = 1
EXCEPTIONS
cntl_error = 1
cntl_system_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.
CALL METHOD oref_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = container1.
CALL METHOD oref_splitter->set_row_height
EXPORTING
id = 1
height = 20
EXCEPTIONS
cntl_error = 1
cntl_system_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.
CALL METHOD oref_splitter->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = container2.
CREATE OBJECT v_html
EXPORTING
style = 'ALV_GRID'.
CREATE OBJECT oref_alv
EXPORTING
* i_shellstyle = 0
* i_lifetime =
i_parent = container2
* i_appl_events = space
* i_parentdbg =
* i_applogparent =
* i_graphicsparent =
* i_name =
* i_fcat_complete = space
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
wa_layout-cwidth_opt = 'X'.
CALL METHOD oref_alv->set_table_for_first_display
EXPORTING
is_layout = wa_layout
CHANGING
it_outtab = LT_ALV
it_fieldcatalog = Lt_fcat
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.
* Create object
IF v_event_receiver IS INITIAL.
CREATE OBJECT v_event_receiver.
ENDIF.
SET HANDLER v_event_receiver->handle_print_top_of_page FOR oref_alv.
SET HANDLER v_event_receiver->handle_top_of_page FOR oref_alv.
***********************************
* Must be after the SET HANDLER for TOP_OF_PAGE and foreground only
CALL METHOD oref_alv->list_processing_events
EXPORTING i_event_name = 'TOP_OF_PAGE'
i_dyndoc_id = v_html.
CALL METHOD v_html->add_picture
EXPORTING
picture_id = 'ENJOYSAP_LOGO'
width = '100'.
* CALL METHOD v_html->add_gap
* EXPORTING
* width = 120.
CALL METHOD v_html->add_text
EXPORTING
text = 'Sales Order Details'.
CALL METHOD v_html->new_line.
CALL METHOD v_html->add_gap
EXPORTING
width = 1.
* CALL METHOD v_html->add_text
* EXPORTING
* text = 'v_text16'.
CALL METHOD v_html->add_gap
EXPORTING
width = 1.
* CALL METHOD v_html->add_text
* EXPORTING
* text = 'v_text16'.
CALL METHOD v_html->new_line.
* Display the data
CALL METHOD v_html->display_document
EXPORTING
parent = container1.
* Handle the event
CALL METHOD oref_alv->list_processing_events
EXPORTING i_event_name = 'PRINT_TOP_OF_PAGE'.
endmodule. " STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module USER_COMMAND_9000 input.
call method oref_alv->check_changed_data.
* IMPORTING
* E_VALID =
* CHANGING
* C_REFRESH = 'X'
*
CLEAR OK_CODE.
OK_CODE = SY-UCOMM.
CASE OK_CODE.
WHEN 'CLICK'.
LOOP AT LT_ALV INTO LS_ALV.
IF LS_ALV-SELECT = 'X'.
MARK_COUNT = MARK_COUNT + 1.
ENDIF.
ENDLOOP.
IF MARK_COUNT > 1 OR MARK_COUNT = 0 .
MESSAGE 'oNLY ONE SHLD BE SELECTED' TYPE 'S' DISPLAY LIKE 'E'.
CLEAR MARK_COUNT.
ELSE.
MESSAGE 'GOING TO PERFORM SAPSCRIPT ' TYPE 'S'.
ENDIF.
PERFORM redisplay.
ENDCASE.
endmodule. " USER_COMMAND_9000 INPUT
form build_fieldcat.
LS_fcat-fieldname = 'SELECT'.
ls_fcat-CHECKBOX = 'X'.
LS_fcat-EDIT = 'X'.
LS_fcat-SCRTEXT_S = 'SELECT'.
APPEND LS_fcat to Lt_fcat.
CLEAR LS_fcat.
LS_fcat-fieldname = 'VBELN'.
LS_fcat-SCRTEXT_S = 'Sales Document'.
APPEND LS_fcat to Lt_fcat.
CLEAR LS_fcat.
LS_fcat-fieldname = 'AUART'.
LS_fcat-SCRTEXT_S = 'Sales Document type'.
APPEND LS_fcat to Lt_fcat.
CLEAR LS_fcat.
LS_fcat-fieldname = 'VKORG'.
LS_fcat-SCRTEXT_S = 'Sales Organisation'.
APPEND LS_fcat to Lt_fcat.
CLEAR LS_fcat.
LS_fcat-fieldname = 'VTWEG'.
LS_fcat-SCRTEXT_S = 'Distribution Channel'.
APPEND LS_fcat to Lt_fcat.
CLEAR LS_fcat.
LS_fcat-fieldname = 'SPART'.
LS_fcat-SCRTEXT_S = 'Divison'.
APPEND LS_fcat to Lt_fcat.
CLEAR LS_fcat.
endform.
FORM top_of_page.
WRITE: 'text-020'.
ENDFORM. " top_of_page
FORM redisplay .
*Row and column of the alv are refreshed after changing values
stable-row = 'X'.
stable-col = 'X'.
*REfreshed ALV display with the changed values
*This ALV is non editable and contains new values
CALL METHOD oref_alv->refresh_table_display
EXPORTING
is_stable = stable
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.
ENDFORM.
2012 May 26 10:12 AM
Hi Deepan,
Please put braek point inside Module USER_COMMAND_900A0 INPUT at CASE OK_CODE.
WHEN 'CLICK' and check what is the value of OK_CODE.
It might be the case that on second and next clicks ,OK_CODE is updated with some other value.
Best Regrds,
Sachin,
2012 May 26 10:17 AM
2012 May 26 10:19 AM
I have put method above the ok_code
call method oref_alv->check_changed_data.
* IMPORTING
* E_VALID =
* CHANGING
* C_REFRESH = 'X'
*
CLEAR OK_CODE.
OK_CODE = SY-UCOMM.
CASE OK_CODE.
WHEN 'CLICK'.
2012 May 26 10:24 AM
Try by putting CLEAR OK_CODE befor End module stmt of USER_COMMAND_9000 INPUT
2012 May 26 10:30 AM
Ok_code is not my problem..The check box values when i check second time it is not getting updated
2012 May 26 10:38 AM
Hi Deepan,
When you click check box, it's value in turn is getting populated inside Ok_code .so there might be some problem with your ok_code .
or u might check declaration of your check box field .It should be as follows:
PARAMETERS : cb AS CHECKBOX USER-COMMAND chk MODIF ID cb.
2012 May 26 3:46 PM
Issue Solved:
Used the following method
CALL METHOD oref_alv->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
Then call the
call method oref_alv->check_changed_data
2012 May 26 4:24 PM
Hi Deepan,
You dont need to call CHECK_CHANGED_DATA after that. It will do it automatically.
Just check your internal; table, it will be updated even before the call.
2012 May 26 4:22 PM
Hi Deepan,
Add this line after SET_TABLE_FOR_FIRST_DISPLAY.
oref_alv->register_edit_event( cl_gui_alv_grid=>mc_evt_modified ).
Thanks,
Shambu
2012 May 26 4:25 PM