‎2010 Apr 21 4:14 PM
Hi,
I am using the event in the handle_data_changed to capture the data from the screen entered into the table.
My logic is working fine.
I have to put some logic so the when the enters the data in the 4th or 5th line and press Enter, the data which is in the 4th line should move to the 1st line and four line should get cleared. (like it happens in the ME21N)
First I am capturing all the data entered using the method handle_data_changed. After I have the data in the internal table I wrote logic so that all the field values entered in the 4th line will move the 1st line.
after that I am using the method refresh_table_display to display the changes I have made internally in the program.
But for some reason this is not working properly.
See below example
SrNo Operation Item Qty
1
2
3
4 Operation1 item 1 100
My requirement is
SrNo Operation Item Qty
1 Operation1 item 1 100
2
3
4
What actually happening in the my program
SrNo Operation Item Qty
1 Operation1 item 1 100
2
3
4 Operation1 item 1 100
For some reason this 4th line which is entered before is not getting cleared. I have checked my internal table before the refresh_table_display. It has only one Line data and that to it is the 1st line. the 4th line is completely empty.
I am using cl_gui_alv_grid, and suppressed all the functions using it_toolbar_excluding and no tool bar. Right click on the row or column on the alv will not have any options available.
Thanks
‎2010 Apr 22 6:06 AM
hi,
free the container by using method free and also grid
and then again call method set_table_for_first_display.
and let me know wat happened.
Thanks,
Gaurav.
‎2010 Apr 21 5:01 PM
Hi,
Call Refresh_table_display after data_changed method.
Like.
class c1 implementation.
Method data_changed.
Endmethod.
Call grid1->refresh_table_display().
endclass.
‎2010 Apr 21 5:07 PM
‎2010 Apr 21 5:23 PM
Whats is the method I should call to refresh an OO ALV after changing the corresponding internal table?
‎2010 Apr 21 5:36 PM
Hi Rock,
Am giving a solution only after usage.
I done the same thing several times and alv grid refreshed sucessfully.
Don't use the words like Sense or something.
U are not paying anything for our suggestions.
‎2010 Apr 21 6:02 PM
No offence, it doest make sense to me but i'm the one trying to learn here.
when I tried your sugestion it gave me the following error:
You cannot use the statement "CALL METHOD" in the current environment.
However, you could use the similar statement "METHOD". how can I make this properly? (i'm trying to do your sugestion inside the class implementation)
‎2010 Apr 21 9:33 PM
you can put the call method grid1->refresh_table_display inside a methiod.
Like.
Method data_changed.
call method grid1->refresh_table_display().
endmethod.
‎2010 Apr 22 5:46 AM
Hi Subas,
I am doing the same which you have suggested. see the code below which I am using. After that only I got this problem.
METHOD handle_data_changed.
DATA: ls_good TYPE lvc_s_modi.
LOOP AT er_data_changed->mt_good_cells INTO ls_good.
s_operation-heatnum = zaodheader-heatnum.
CASE ls_good-fieldname.
WHEN 'ITEM'.
s_operation-item = ls_good-value.
READ TABLE gt_outtab INTO gs_outtab INDEX ls_good-row_id.
IF sy-subrc EQ 0.
s_operation-srno = ls_good-row_id.
gs_outtab-item = s_operation-item.
gs_outtab-heatnum = s_operation-heatnum.
ENDIF.
MODIFY gt_outtab FROM gs_outtab INDEX ls_good-row_id TRANSPORTING srno heatnum item.
* PERFORM update_internal_table USING ls_good-row_id.
***********changes for handling Blank lines
LOOP AT gt_outtab INTO gs_outtab.
IF gs_outtab-operations IS INITIAL
AND gs_outtab-item IS INITIAL
AND gs_outtab-quantity IS INITIAL.
DELETE gt_outtab INDEX sy-tabix.
ENDIF.
ENDLOOP.
DESCRIBE TABLE gt_outtab LINES v_fill_lines.
DATA: v_times TYPE int1,
v_sr_counter TYPE num2.
v_times = 99 - v_fill_lines.
v_count = v_fill_lines + 1.
DO v_times TIMES.
gs_outtab-srno = v_count.
APPEND gs_outtab TO gt_outtab.
v_count = v_count + 1.
ENDDO.
LOOP AT gt_outtab INTO gs_outtab.
IF sy-tabix = 1.
gs_outtab-srno = 1.
MODIFY gt_outtab FROM gs_outtab TRANSPORTING srno.
v_sr_counter = 1.
CONTINUE.
ENDIF.
v_sr_counter = v_sr_counter + 1.
gs_outtab-srno = v_sr_counter.
MODIFY gt_outtab FROM gs_outtab TRANSPORTING srno.
ENDLOOP.
CALL METHOD g_grid->refresh_table_display
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDMETHOD. "handle_data_changed
ENDCLASS. "lcl_event_receiver IMPLEMENTATION.
..
I have checked my internal table and it definitely has only the data which I want to display. But after this refresh table display the data which is already existing is not getting cleared like I told in my example. Please suggest me if there any way I can resolve this.
Thanks
‎2010 Apr 22 6:06 AM
hi,
free the container by using method free and also grid
and then again call method set_table_for_first_display.
and let me know wat happened.
Thanks,
Gaurav.
‎2010 Apr 22 6:27 AM
Hi Gaurav,
I have commented the refresh table display and did what you said, Program is going to dump.
‎2010 Apr 22 6:36 AM
hi,
jst post ur set_table_for_first_display method
let me see then i will suggest wat to do.
‎2010 Apr 22 7:03 AM
See the code below. It is commented
***********changes for handling Blank lines
LOOP AT gt_outtab INTO gs_outtab.
IF gs_outtab-operations IS INITIAL
AND gs_outtab-item IS INITIAL
AND gs_outtab-quantity IS INITIAL.
DELETE gt_outtab INDEX sy-tabix.
ENDIF.
ENDLOOP.
DESCRIBE TABLE gt_outtab LINES v_fill_lines.
DATA: v_times TYPE int1,
v_sr_counter TYPE num2.
v_times = 99 - v_fill_lines.
v_count = v_fill_lines + 1.
DO v_times TIMES.
gs_outtab-srno = v_count.
APPEND gs_outtab TO gt_outtab.
v_count = v_count + 1.
ENDDO.
LOOP AT gt_outtab INTO gs_outtab.
IF sy-tabix = 1.
gs_outtab-srno = 1.
MODIFY gt_outtab FROM gs_outtab TRANSPORTING srno.
v_sr_counter = 1.
CONTINUE.
ENDIF.
v_sr_counter = v_sr_counter + 1.
gs_outtab-srno = v_sr_counter.
MODIFY gt_outtab FROM gs_outtab TRANSPORTING srno.
ENDLOOP.
*************************
* CALL METHOD g_custom_container->free.
*
* CALL METHOD g_grid->free.
*
* CALL METHOD g_grid->set_table_for_first_display
* EXPORTING
* is_layout = gs_layout
* it_toolbar_excluding = gt_exclude
* CHANGING
* it_fieldcatalog = gt_fieldcat
* it_outtab = gt_outtab[].
************************
CALL METHOD g_grid->refresh_table_display
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
‎2010 Apr 22 7:10 AM
hiii,
IF C_ALV IS NOT INITIAL.
CALL METHOD C_ALV->FREE
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
FREE C_ALV.
ENDIF.
ENDIF.
IF C_CONTAINER IS NOT INITIAL.
CALL METHOD C_CONTAINER->FREE
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
FREE C_CONTAINER.
ENDIF.
ENDIF.
and after that u have to again create object of container and grid.
Creating object of container.
CREATE OBJECT C_CONTAINER
EXPORTING
CONTAINER_NAME = 'CONTAINER'.
*Creating object of alv
CREATE OBJECT C_ALV
EXPORTING
I_PARENT = C_CONTAINER.
Fieldcatalog.
PERFORM ALV_FIELDCAT.
CALL METHOD C_ALV->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = WA_LAYOUT
CHANGING
IT_OUTTAB = IT_OUTPUT
IT_FIELDCATALOG = IT_FIELDCAT.
use as i have done in my code it will surely work .
use and let me now output.
Thanks.
‎2010 Apr 22 7:29 AM
See the Code below. Still going to dump. Is because I doing this in the Method handle_data_changed?
Exception condition "CNTL_ERROR" raised. Dump Message
CALL METHOD g_custom_container->free.
CALL METHOD g_grid->free.
IF g_custom_container IS INITIAL.
PERFORM create_and_init_alv. " CHANGING gt_outtab
" gt_fieldcat
" gs_layout.
ENDIF.
FORM create_and_init_alv . "CHANGING pt_outtab LIKE gt_outtab[]
" pt_fieldcat TYPE lvc_t_fcat
" ps_layout TYPE lvc_s_layo.
CREATE OBJECT g_custom_container
EXPORTING
container_name = g_container.
CREATE OBJECT g_grid
EXPORTING
i_parent = g_custom_container.
PERFORM build_fieldcat CHANGING gt_fieldcat.
PERFORM exclude_tb_functions CHANGING gt_exclude.
IF sy-tcode <> 'ZQMAOD4'.
IF sy-tcode = 'ZQMAOD2'.
PERFORM set_display_property.
ENDIF.
ENDIF.
PERFORM build_layout USING gs_layout.
PERFORM fill_outtab.
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
it_toolbar_excluding = gt_exclude
CHANGING
it_fieldcatalog = gt_fieldcat
it_outtab = gt_outtab[].
* set editable cells to ready for input
CALL METHOD g_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
CALL METHOD g_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
CREATE OBJECT cl_er.
SET HANDLER cl_er->handle_data_changed FOR g_grid.
IF sy-tcode = 'ZQMAOD3'.
CALL METHOD g_grid->refresh_table_display
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDFORM. " CREATE_AND_INIT_ALV
‎2010 Apr 22 7:38 AM
hii,
i have mentioned in my code only when c_alv is not initial then only free it otherwise it will go for short dump.
IF C_ALV IS NOT INITIAL.
CALL METHOD C_ALV->FREE
IF C_container IS NOT INITIAL.
CALL METHOD C_container->FREE
‎2010 Apr 22 11:07 AM
I've also tried that, and also get a dump.
the strange thing is that my program does the free's and re-does de alv again using CALL METHOD alv->set_table_for_first_display but then when it finishes processing my handling_data_change method it gives a dump
‎2010 Apr 23 10:55 AM
‎2010 Apr 23 2:31 PM
My problem is solved.
I am supposed to use the Event DATA_CHANGED_FINISHED.
I am modifying the data of the internal table and using the refresh table display in the event. That should done in the event DATA_CHANGED_FINISHED.
I just added this even and wrote what ever logic I want in the implementation this Method in my program and the problem is solved.
Thank you Gaurav for all your suggestions and the rest as well.
I have never used OOPS before and now I am more comfortable using them.