‎2009 Aug 12 3:29 PM
hi there,
as seen in the subject i need to copy selected values from a table control into another table control in the same screen. as i dont know much about table controls i made 2 table controls with the wizard and started to change the code... right now im totally messed up. nothing works anymore and i don't know where to start over.
i looked up the forums and google, but there is nothing to help me with this problem (or i suck in searching the internet for solutions)
i have 2 buttons. one to push the selected data from the top table control into the bottom tc and the other button is to push selected data from the bottom tc into the top tc. does somebody has a sample code to do this?
‎2009 Aug 12 3:32 PM
Hi
U should have two internal table where the data, to be displayed by the two table controls, are stored.
So u need to move a record from the forst internal table to the second one
Max
‎2009 Aug 12 3:32 PM
Hi
U should have two internal table where the data, to be displayed by the two table controls, are stored.
So u need to move a record from the forst internal table to the second one
Max
‎2009 Aug 12 3:43 PM
yes i know that. its so easy but i dont know how to code it cause i lack in abap programming language
‎2009 Aug 12 3:54 PM
Hi
If you have managed the selection, your internal table should have a mark field, so in PAI u should loop the first table where the mark is set and append the lines to the second table.
Have u inserted a field for marker in the internal tables?
Max
‎2009 Aug 12 4:03 PM
yea i had it working that way once. but it did not work properly and i could copy selected fields which don't contain any data and that should not be possible.
no i didn't made a marker field. im using another field which i don't show in the tc for the marker. but maybe that's the problem... but i'm going crazy if i have to start all over only to make a special marker field in the internal table.
‎2009 Aug 12 4:22 PM
Hi
be quiet
U don't need to start again, but if u need to manage a multiselection, it's easier to have a field for mark i the table.
So define a field for mark in both tables, go into LOOP/ENLOOP of PAI of both table controls and move the value of your old field for mark to the field of the tables.
U should have a module of PAI in order to move the data from table control to internal table and update it, something like this:
PROCESS PAI.
LOOP AT ITAB.
MODULE MODIFY_ITAB.
ENDLOOP.
MODULE MODIFY_ITAB.
ITAB-FIELD1 = ....
ITAB-FIELD2 = .....
MODIFY ITAB INDEX <TABLE CONTROL>-CURRENT_LINE.
ENDMODULE.
So in this module u need to move the value of field for mark too:
MODULE MODIFY_ITAB.
ITAB-FIELD1 = ....
ITAB-FIELD2 = .....
ITAB-MARK = MARK.
MODIFY ITAB INDEX <TABLE CONTROL>-CURRENT_LINE.
ENDMODULE.If the fields of table control are the same name of the fields of internal table, u need to move the mark only:
MODULE MODIFY_ITAB.
ITAB-MARK = MARK.
MODIFY ITAB INDEX <TABLE CONTROL>-CURRENT_LINE.
ENDMODULE.Max
‎2009 Aug 13 9:49 AM
you're funny
i still don't get it... can't believe, there is no tutorial or sample code around how to copy multiple selected rows from a tc.
here's my code, maybe you can tell me exactly were i have to change it:
tc1 = upper table control
tc2 = lower table control
SCREEN 0100:
PROCESS BEFORE OUTPUT.
MODULE status_0100.
MODULE get_nfo. --> gets data from the dictionary table
MODULE tc1_change_tc_attr.
LOOP AT it_roles_tc1
INTO wa_roles_tc1
WITH CONTROL tc1
CURSOR tc1-current_line.
ENDLOOP.
MODULE tc2_change_tc_attr.
LOOP AT it_roles_tc2
INTO wa_roles_tc2l
WITH CONTROL tc2
CURSOR tc2-current_line.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP AT it_roles_tc1.
CHAIN.
FIELD wa_roles_tc1-agr_name.
FIELD wa_roles_tc1-text.
ENDCHAIN.
FIELD wa_roles_tc1-mark
MODULE tc1_mark ON REQUEST.
ENDLOOP.
LOOP AT it_roles_tc2.
CHAIN.
FIELD wa_roles_tc2-agr_name.
FIELD wa_roles_tc2-text.
ENDCHAIN.
FIELD wa_roles_tc2-mark
MODULE tc2_mark ON REQUEST.
ENDLOOP.
MODULE ok_code.
MODULE user_command_0100.
INCLUDE PAI:
MODULE tc1_mark INPUT.
IF tc1-line_sel_mode = 2
AND wa_roles_tc1-mark = 'X'.
LOOP AT it_roles_tc1 INTO g_tc1_wa2
WHERE mark = 'X'. -
> big problem here is, that no entry has an 'X' there
g_tc1_wa2-mark = ''.
MODIFY it_roles_tc1
FROM g_tc1_wa2
TRANSPORTING mark.
ENDLOOP.
ENDIF.
MODIFY it_roles_tc1
FROM wa_roles_tc1
INDEX tc1-current_line
TRANSPORTING mark.
ENDMODULE. "TC1_MARK INPUT
MODULE tc2_mark INPUT.
IF tc2-line_sel_mode = 2
AND wa_roles_tc2-mark = 'X'.
LOOP AT it_roles_tc2 INTO g_tc2_wa2
WHERE mark = 'X'. -
> same here, it doesn't gets any data
g_tc2_wa2-mark = ''.
MODIFY it_roles_tc2
FROM g_tc2_wa2
TRANSPORTING mark.
ENDLOOP.
ENDIF.
MODIFY it_roles_tc2
FROM wa_roles_tc2
INDEX tc2-current_line
TRANSPORTING mark.
ENDMODULE.
thx for anybody who can help with this!
‎2009 Aug 13 10:01 AM
Hi
This is your code:
MODULE tc1_mark INPUT.
IF tc1-line_sel_mode = 2 AND wa_roles_tc1-mark = 'X'.
LOOP AT it_roles_tc1 INTO g_tc1_wa2 WHERE mark = 'X'. -----------> big problem here is, that no entry has an 'X' there
g_tc1_wa2-mark = ''.
MODIFY it_roles_tc1 FROM g_tc1_wa2 TRANSPORTING mark.
ENDLOOP.
ENDIF.
MODIFY it_roles_tc1 FROM wa_roles_tc1 INDEX tc1-current_line TRANSPORTING mark.
ENDMODULE. "TC1_MARK INPUT
but the code should be like this:
MODULE tc1_mark INPUT.
MODIFY it_roles_tc1 FROM wa_roles_tc1 INDEX tc1-current_line TRANSPORTING mark.
ENDMODULE. "TC1_MARK INPUT
So u should delete the loop, I think it's useless, the module tc1_mark is just in the loop of table it_roles_tc1 (the LOOP of PAI process, you don't need to repeat it again.
Max
‎2009 Aug 13 10:24 AM
Hi
Just another consideration
I suppose the structure wa_roles_tc1 and wa_roles_tc2 are used to design the input/output field of the table control, so if some data are changed, the modifications have to be transfered in the internal table it_roles_tc1 and it_roles_tc2 having the same structure of wa_roles_tc1 and wa_roles_tc2.
If it's so why u transfering the value of mark field only?
So the module to update to update it_roles_tc1 and it_roles_tc2 should be
MODULE tc1_mark INPUT.
MODIFY it_roles_tc1 FROM wa_roles_tc1 INDEX tc1-current_line.
ENDMODULE. "TC1_MARK INPUTSo without option TRANSPORTING
Max
‎2009 Aug 13 10:35 AM
thx for your help so far but its still not working...
it should be like this
tc1
_____________
test1 |
test2 |
_____________ |
button
tc2
_____________
_____________ |
but after pushing the button both tc should look like this:
tc1
_____________
_____________ |
button
tc2
_____________
test1 |
test2 |
_____________ |
Edited by: rafe b. on Aug 13, 2009 11:35 AM
‎2009 Aug 13 11:12 AM
Hi
I think your code should be like this:
SCREEN 0100:
PROCESS BEFORE OUTPUT.
MODULE status_0100.
MODULE get_nfo. --> gets data from the dictionary table
* Tab ctrl 1
MODULE tc1_change_tc_attr.
LOOP AT it_roles_tc1 INTO wa_roles_tc1
WITH CONTROL tc1 CURSOR tc1-current_line.
ENDLOOP.
* Tab ctrl 2
MODULE tc2_change_tc_attr.
LOOP AT it_roles_tc2 INTO wa_roles_tc2l
WITH CONTROL tc2 CURSOR tc2-current_line.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP AT it_roles_tc1.
FIELD wa_roles_tc1-agr_name.
FIELD wa_roles_tc1-text.
FIELD wa_roles_tc1-mark MODULE tc1_mark.
ENDLOOP.
LOOP AT it_roles_tc2.
FIELD wa_roles_tc2-agr_name.
FIELD wa_roles_tc2-text.
FIELD wa_roles_tc2-mark MODULE tc2_mark..
ENDLOOP.
MODULE ok_code.
MODULE user_command_0100.INCLUDE PAI:
.MODULE tc1_mark INPUT.
MODIFY it_roles_tc1 FROM wa_roles_tc1 INDEX tc1-current_line TRANSPORTING mark.
ENDMODULE. "TC1_MARK INPUT
MODULE tc2_mark INPUT.
MODIFY it_roles_tc2 FROM wa_roles_tc2 INDEX tc2-current_line TRANSPORTING mark.
ENDMODULE..
The module of user_command
.module user_command_0100.
CASE OK_CODE.
WHEN 'COPY'.
LOOP AT IT_ROLES_TC1 INTO IT_ROLES_TC2.
DELETE IT_ROLES_TC1.
APPEND IT_ROLES_CT2.
ENDLOOP.
endmodule..
U make sure the ouput module to get data from dictionary doesn't get the data again.
Max
‎2009 Aug 13 12:53 PM
its working now. not perfect but i have a very good base to build on. thanks max for your time. you really helped me out.
good guy 😛