05-15-2009 5:41 AM
Hi,
i have my table control which can show 14 entries at a time. and i have almost 100 entries in table control.
now if i selected 2 entries in the visible part.
now scroll vertically.
again come back to see the selected records now they are unselected.
please respond soon.
Thanks
Malya
05-15-2009 5:46 AM
Hi Dude,
REPORT demo_dynpro_tabcont_loop.
CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.
DATA: ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm.
DATA: itab TYPE TABLE OF demo_conn,
fill TYPE i.
TABLES demo_conn.
DATA: lines TYPE i,
limit TYPE i.
SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.
CALL SCREEN 100.
MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN_100'.
DESCRIBE TABLE itab LINES fill.
flights-lines = fill.
ENDMODULE.
MODULE fill_table_control OUTPUT.
READ TABLE itab INTO demo_conn INDEX flights-current_line.
ENDMODULE.
MODULE cancel INPUT.
LEAVE PROGRAM.
ENDMODULE.
MODULE read_table_control INPUT.
lines = sy-loopc.
MODIFY itab FROM demo_conn INDEX flights-current_line.
ENDMODULE.
MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'NEXT_LINE'.
flights-top_line = flights-top_line + 1.
limit = fill - lines + 1.
IF flights-top_line > limit.
flights-top_line = limit.
ENDIF.
WHEN 'PREV_LINE'.
flights-top_line = flights-top_line - 1.
IF flights-top_line < 0.
flights-top_line = 0.
ENDIF.
WHEN 'NEXT_PAGE'.
flights-top_line = flights-top_line + lines.
limit = fill - lines + 1.
IF flights-top_line > limit.
flights-top_line = limit.
ENDIF.
WHEN 'PREV_PAGE'.
flights-top_line = flights-top_line - lines.
IF flights-top_line < 0.
flights-top_line = 0.
ENDIF.
WHEN 'LAST_PAGE'.
flights-top_line = fill - lines + 1.
WHEN 'FIRST_PAGE'.
flights-top_line = 0.
ENDCASE.
ENDMODULE.
05-15-2009 6:55 AM
hi,
thanks for your immediate response but iam not getting SY-UCOMM value which you have given iam getting the fcode for the the line selection which is given at the table control properties.
so can you please tell me how we can do this.
thanks
Malya
05-15-2009 6:59 AM
hi,
my issue is only the selected rows are unselected after scroling down.
not the data issue.
thanks
malya
05-15-2009 7:01 AM
HI,
Please check the standard program which is suitable for your scenario.
demo_dynpro_tabcont_loop_at.
05-15-2009 7:06 AM
hi,
The selection is not updated because the table is not getting updated when ever you are trying to display them back as the PBO will get triggered and the select statement in the PBO module gets executed
without the updated data...
your selection button is getting cleared every time you trigger an event so for that you need to declare another field with character 1 and update it with 'X'.
So your selection will remain even when you trigger an event check the code i gave in the previous post for that,
your problem will be solved.
Thanks&Regards
Sarves
05-15-2009 6:51 AM
HI,
Please check the standard program which is suitable for your scenario.
demo_dynpro_tabcont_loop_at.
05-15-2009 6:52 AM
Hi,
I have redone the scenario and follow the steps it will work....
STEP 1: Create an internal table with field for selection in table.
STEP 2: Assign the selection field in the table control for the line selection.
STEP 3: Now whenever the line is selected, the selection field will have a field 'X'.
STEP 4: In PAI Modify the table fields those are selected with 'X'.
STEP 5: Set a flag in PAI, flag = 'X'.
STEP 6: In PBO set a condition . " We set a flag so that we fetch the data only once.
If flag NE 'X'.
Fetch data.
endif.
Data:
begin of ztable,
ID type char4,
Name type char30,
Sel type c,
end of ztable.
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
LOOP AT ITAB INTO FS WITH CONTROL EMP CURSOR W_I.
MODULE UPDATE.
ENDLOOP.
*
PROCESS AFTER INPUT.
LOOP AT ITAB.
MODULE APPEND.
ENDLOOP.
MODULE USER_COMMAND_0100.
INCLUDE YMODTOP . " global Data
*&---------------------------------------------------------------------*
*& Module UPDATE OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE UPDATE OUTPUT.
MOVE FS TO FS.
ENDMODULE. " UPDATE OUTPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
IF FL_FLAG <> 1.
SELECT * FROM ZTABLE INTO CORRESPONDING FIELDS OF TABLE ITAB.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module append INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE APPEND INPUT.
MODIFY ITAB INDEX SY-STEPL FROM FS TRANSPORTING SEL .
FL_FLAG = 1.
ENDMODULE.
Thanks&Regards
Sarves
05-15-2009 9:59 AM
05-15-2009 10:01 AM
or use FM compute_scrolling_in_tc
FORM compute_scrolling_in_tc USING p_tc_name
p_ok.
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA l_tc_new_top_line TYPE i.
DATA l_tc_name LIKE feld-name.
DATA l_tc_lines_name LIKE feld-name.
DATA l_tc_field_name LIKE feld-name.
FIELD-SYMBOLS <tc> TYPE cxtab_control.
FIELD-SYMBOLS <lines> TYPE i.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (p_tc_name) TO <tc>.
*&SPWIZARD: get looplines of TableControl *
CONCATENATE 'G_' p_tc_name '_LINES' INTO l_tc_lines_name.
ASSIGN (l_tc_lines_name) TO <lines>.
*&SPWIZARD: is no line filled? *
IF <tc>-lines = 0.
*&SPWIZARD: yes, ... *
l_tc_new_top_line = 1.
ELSE.
*&SPWIZARD: no, ... *
CALL FUNCTION 'SCROLLING_IN_TABLE'
EXPORTING
entry_act = <tc>-top_line
entry_from = 1
entry_to = <tc>-lines
last_page_full = c_x
loops = <lines>
ok_code = p_ok
overlapping = c_x
IMPORTING
entry_new = l_tc_new_top_line
EXCEPTIONS
NO_ENTRY_OR_PAGE_ACT = 01
NO_ENTRY_TO = 02
NO_OK_CODE_OR_PAGE_GO = 03
OTHERS = 0.
ENDIF.
*&SPWIZARD: get actual tc and column *
GET CURSOR FIELD l_tc_field_name
AREA l_tc_name.
IF syst-subrc = 0.
IF l_tc_name = p_tc_name.
*&SPWIZARD: et actual column *
SET CURSOR FIELD l_tc_field_name LINE 1.
ENDIF.
ENDIF.
*&SPWIZARD: set the new top line *
<tc>-top_line = l_tc_new_top_line.
ENDFORM. " COMPUTE_SCROLLING_IN_TC
Edited by: krupa jani on May 15, 2009 11:01 AM