‎2006 Nov 17 7:36 AM
hello all,
i am using table cntl. i am selcting records in table cntl (lt_final) and putting those selcted records in another tablegt-final). the problem is when ever i scroll down to selct another record, already selected record is getting duplicated in gt_final which is un wanted. How can correct that. The logic i am using is.
<u>flow logic.</u>
LOOP AT lt_final.
FIELD lt_final-sel MODULE check_sel.
ENDLOOP.
MODULE user_command_2000.
<u>in main program</u>
MODULE check_sel INPUT.
IF lt_final-sel = 'X'.
MODIFY lt_final INDEX tab_cntl-current_line.
APPEND lt_final TO gt_final.
ENDIF.
ENDMODULE. " check_sel INPUT
Can any one help me to avoid duplicate record getting into gt-final.
regards
rahul
‎2006 Nov 17 7:56 AM
helo kesi,
if you won't have consideration about sorting for your gt_final then you can user combination sort and delete adjacent duplicates. for example :
sort gt_final.
delete adjacent duplicates from gt_final.
there are some others tricks if you won't change the itab content sequece.
Regards
Deny Dafid
‎2006 Nov 17 7:48 AM
1st you need to understand how the table control works...
Say in a table control there are 5 rows... with data as a,b,c,d,e in rows 1,2,3,4,5 respectively.
i.e . field(1) = a , field(2) = b .... field(5) = e ...like that...
Now if you scroll down to see the values after e i.e. f,g,h..... the row no does not change...
If u press the scroll down button once.. this is how the situation looks like..
field(1) = b , field (2) = c ..... field(5) = f
I hope this is clear...
I am not sure how ur code looks like... but the point is that if you scroll the button once..
then u need to reduce the index counter once...
I hope this is not confusing you... So check ur code... see the values in debugging mode and you will find the answer your self...
Plz .. tell if it was helpful and reward points...
‎2006 Nov 17 7:56 AM
helo kesi,
if you won't have consideration about sorting for your gt_final then you can user combination sort and delete adjacent duplicates. for example :
sort gt_final.
delete adjacent duplicates from gt_final.
there are some others tricks if you won't change the itab content sequece.
Regards
Deny Dafid
‎2006 Nov 17 8:20 AM
Hi kesi,
See when you select records and scroll down the PAI will get executed and selected records will appended into your internal table.And you have written that selected records your are putting into internal table .That means to put the data into internal table you are triggering some event(Save button or some other).That time also the selected data will go and appepending the same data.So to test this select the records in table control and enter the "/H"(Debugging) on command field press enter and now Scroll down .You can see what is happing there .
See the below code .
If sy-ucomm eq 'Save' (Say here save is your button)
IF lt_final-sel = 'X'.
MODIFY lt_final INDEX tab_cntl-current_line.
APPEND lt_final TO gt_final.
ENDIF.
endif.
Hope this will solve your problem.
Don't forget to reward points if it helps you.
‎2006 Nov 17 8:26 AM
hi,
To handle Scrolling you need to add the following.
form compute_scrolling_in_tc using p_tc_name
p_ok.
*-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.
*-END OF LOCAL DATA----------------------------------------------------*
assign (p_tc_name) to <tc>.
* get looplines of TableControl
concatenate 'G_' p_tc_name '_LINES' into l_tc_lines_name.
assign (l_tc_lines_name) to <lines>.
* is no line filled? *
if <tc>-lines = 0.
* yes, ...
*
l_tc_new_top_line = 1.
else.
* no, ...
call function 'SCROLLING_IN_TABLE'
exporting
entry_act = <tc>-top_line
entry_from = 1
entry_to = <tc>-lines
last_page_full = 'X'
loops = <lines>
ok_code = p_ok
overlapping = '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.
* 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.
* set actual column *
set cursor field l_tc_field_name line 1.
endif.
endif.
* set the new top line *
<tc>-top_line = l_tc_new_top_line.
endform. " COMPUTE_SCROLLING_IN_TC
form compute_scrolling_in_tc using p_tc_name
p_ok.
*-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.
*-END OF LOCAL DATA----------------------------------------------------*
assign (p_tc_name) to <tc>.
* get looplines of TableControl
concatenate 'G_' p_tc_name '_LINES' into l_tc_lines_name.
assign (l_tc_lines_name) to <lines>.
* is no line filled? *
if <tc>-lines = 0.
* yes, ...
*
l_tc_new_top_line = 1.
else.
* no, ...
call function 'SCROLLING_IN_TABLE'
exporting
entry_act = <tc>-top_line
entry_from = 1
entry_to = <tc>-lines
last_page_full = 'X'
loops = <lines>
ok_code = p_ok
overlapping = '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.
* 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.
* set actual column *
set cursor field l_tc_field_name line 1.
endif.
endif.
* set the new top line *
<tc>-top_line = l_tc_new_top_line.
endform. " COMPUTE_SCROLLING_IN_TC
module tc_conf_change_tc_attr output.
describe table it_conf lines tc_conf-lines.
endmodule.
form user_ok_tc using p_tc_name type dynfnam
p_table_name
p_mark_name
changing p_ok like sy-ucomm.
*-BEGIN OF LOCAL DATA--------------------------------------------------*
data: l_ok type sy-ucomm,
l_offset type i.
*-END OF LOCAL DATA----------------------------------------------------*
* Table control specific operations *
* evaluate TC name and operations *
search p_ok for p_tc_name.
if sy-subrc <> 0.
exit.
endif.
l_offset = strlen( p_tc_name ) + 1.
l_ok = p_ok+l_offset.
* execute general and TC specific operations *
case l_ok.
when 'P--' or "top of list
'P-' or "previous page
'P+' or "next page
'P++'. "bottom of list
perform compute_scrolling_in_tc using p_tc_name
l_ok.
clear p_ok.
when 'DELE'. "delete row
*code for delete.
* ......
endcase.
endform. " USER_OK_TC
module tc_conf_user_command input.
perform user_ok_tc using 'TC_CONF'
'IT_CONF'(026)
'CHECK'
changing ok_code.
sy-ucomm = ok_code.
endmodule.
*And in Screen
PROCESS BEFORE OUTPUT.
module TC_CONF_change_tc_attr.
loop at IT_CONF
into X_CONF
with control TC_CONF
cursor TC_CONF-current_line.
module TC_CONF_get_lines.
module update_crt_tc.
endloop.
module update_screen.
PROCESS AFTER INPUT.
loop at IT_CONF.
chain.
field X_CONF-EBTYP.
field X_CONF-EINDT.
field X_CONF-LPEIN.
field X_CONF-UZEIT.
field X_CONF-ERDAT.
field X_CONF-MENGE.
field X_CONF-XBLNR.
module TC_CONF_modify on chain-request.
endchain.
field X_CONF-CHECK
module TC_CONF_mark on request.
endloop.
module TC_CONF_user_command.
MODULE USER_COMMAND_0102.
Hope this helps.
Regards,
Richa
‎2006 Nov 17 8:26 AM
U just got to do this thing in ur logic of PBO
describe table it_final lines N.
tab_cntl-lines = N.
This will solve ur scrolling issue of table control
Regarsd
- Gopi
‎2006 Nov 17 8:28 AM
hi rahul,
try the following code,this will help you.
PROCESS BEFORE OUTPUT.
MODULE STATUS_9000.
LOOP AT IT_STR WITH CONTROL TC.
MODULE FILL_MODULE_9OOO.
MODULE ICON_9000.
ENDLOOP.
PROCESS AFTER INPUT.
MODULE CANCEL AT EXIT-COMMAND.
LOOP AT IT_STR.
CHAIN.
FIELD IT_STR-MNO.
FIELD IT_STR-QTY.
MODULE FILL_TABLE_9000 ON CHAIN-REQUEST.
ENDCHAIN.
ENDLOOP.
****************************************************
MODULE FILL_TABLE_9000 ON CHAIN-REQUEST.
DATA : V_LINECOUNT TYPE I, "TO FIND NO OF LINES IN INTERNAL TABLE
V_PAGECOUNT TYPE I, "TO ADD LINES WHEN SCROLLING
V_ABS_LINE TYPE I. "FOR CURRENT LINE
IF SY-DATAR = 'X'. "CLICK IS ON MESSAGE OR IN SCROLL.
DESCRIBE TABLE IT_STR LINES V_LINECOUNT. "TO GET THE NO OF LINES
IF SY-SUBRC = 0.
V_ABS_LINE = TC-TOP_LINE + SY-STEPL - 1. "GETTING THE CURRENT LINE
IF V_ABS_LINE LE V_LINECOUNT. "CHECKING WHEATHER CURRENT LINE IS GT LINECOUNT
MODIFY IT_STR INDEX V_ABS_LINE. "SY-STEPL.
ELSE.
IT_STR-ZINO = V_ABS_LINE.
APPEND IT_STR.
ENDIF.
ENDIF.
*tc-lines = sy-tfill + 1.
V_PAGECOUNT = SY-STEPL DIV SY-LOOPC. "CHECKING WHEATHER TO ADD LINES OR NOT
IF V_PAGECOUNT > 0.
TC-LINES = V_LINECOUNT + SY-LOOPC.
ENDIF.
ENDMODULE.
ENDIF.
reward points if you can understand and able to get the picture of it.
with regards ,
shan