‎2006 Aug 09 12:44 PM
Hi all ,
I have created one table control and i am able to get the data from database . But How to delete selected records in TC,How to modify selected records ,and how to upload the selected records into Excel .
Thanks & Regards .
code :
CONTROLS TC TYPE TABLEVIEW USING SCREEN 1001 .
TABLES : ZPRIORITY .
data : zpror type standard table of ZPRIORITY.
DATA: cols LIKE LINE OF TC-cols,
lines TYPE i.
TYPES: begin of TY_EXCEL ,
FEU(45) type c,
LIFNR(60) type c,
SCFAMILY(30) type c,
ITEM(40) type c,
SHIPFROM(5) type c,
PRIORITY(5) TYPE C,
end of TY_EXCEL .
DATA: ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm.
DATA : I_ZPRIORITY TYPE TABLE OF ZPRIORITY .
*DATA : WA_ZPRIORITY LIKE LINE OF I_ZPRIORITY .
data : WA_ZPRIORITY type ZPRIORITY.
----
MODULE GETDATA OUTPUT
----
*
----
MODULE GETDATA OUTPUT.
data flag value 'X'.
if flag = 'X'.
SELECT * FROM ZPRIORITY INTO TABLE I_ZPRIORITY .
flag = SPACE.
ENDIF.
ENDMODULE. "GETDATA OUTPUT
&----
*& Module ASSIGN OUTPUT
&----
text
----
MODULE ASSIGN OUTPUT.
ZPRIORITY-FEU = WA_ZPRIORITY-FEU .
ZPRIORITY-LIFNR = WA_ZPRIORITY-LIFNR .
ZPRIORITY-SCFAMILY = WA_ZPRIORITY-SCFAMILY .
ZPRIORITY-ITEM = WA_ZPRIORITY-ITEM .
ZPRIORITY-SHIPFROM = WA_ZPRIORITY-SHIPFROM .
ZPRIORITY-PRIORITY = WA_ZPRIORITY-PRIORITY .
ENDMODULE. " ASSIGN OUTPUT
&----
*& Module MODIFYDATA INPUT
&----
text
----
MODULE MODIFYDATA INPUT.
OK_CODE = SY-UCOMM .
save_ok = OK_CODE.
CLEAR ok_code.
CASE save_ok.
WHEN 'MASS'.
READ TABLE TC-cols INTO cols WITH KEY screen-input = '1'.
IF sy-subrc = 0.
LOOP AT I_ZPRIORITY INTO WA_ZPRIORITY .
DELETE ZPRIORITY FROM WA_ZPRIORITY .
ENDLOOP.
ENDIF.
WHEN 'MODI'.
READ TABLE TC-cols INTO cols WITH KEY screen-input = '1'.
IF sy-subrc = 0.
LOOP AT I_ZPRIORITY INTO WA_ZPRIORITY .
MODIFY ZPRIORITY FROM WA_ZPRIORITY .
MODIFY I_ZPRIORITY FROM WA_ZPRIORITY INDEX tc-current_line.
.
ENDLOOP.
ENDIF.
WHEN 'LOAD'.
WHEN 'EXIT'.
ENDCASE.
ENDMODULE. "MODIFYDATA INPUT
&----
*& Module read_table_control INPUT
&----
text
----
MODULE read_table_control INPUT.
MODIFY i_ZPRIORITY FROM ZPRIORITY index tc-current_line.
ENDMODULE. " read_table_control INPUT
___________________
PROCESS BEFORE OUTPUT.
MODULE GETDATA .
LOOP AT I_ZPRIORITY INTO WA_ZPRIORITY WITH CONTROL TC CURSOR
TC-TOP_LINE .
MODULE ASSIGN .
ENDLOOP.
MODULE STATUS_1001.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_1001.
LOOP AT I_ZPRIORITY .
CHAIN.
FIELD ZPRIORITY-feu.
FIELD ZPRIORITY-lifnr.
FIELD ZPRIORITY-scfamily.
FIELD ZPRIORITY-item.
FIELD ZPRIORITY-shipfrom.
FIELD ZPRIORITY-priority.
MODULE read_table_control ON CHAIN-REQUEST.
ENDCHAIN.
ENDLOOP.
MODULE MODIFYDATA .
‎2006 Aug 09 12:49 PM
Hi,
you can find the selected row with 'READ TABLE' command
like this.
<b> READ TABLE grid_itab_1011 WITH KEY flag = 'X'.</b>
and then after changing in the fields you can use
MODIFY TABLE to change
DELETE TABLE to delete.
REgards,
HRA
‎2006 Aug 09 12:49 PM
hi for deletion and insertion do like this ::
WHEN 'DELE'.
DELETE IT_VBRP WHERE CHK = 'X'.
DESCRIBE TABLE IT_VBRP LINES TAB2-LINES.
WHEN 'INSE'.
LOOP AT IT_VBRP WHERE CHK = 'X'.
CLEAR IT_VBRP.
V_TABIX = SY-TABIX + 1.
INSERT IT_VBRP INDEX V_TABIX. "TAB2-CURRENT_LINE."
DESCRIBE TABLE IT_VBRP LINES TAB2-LINES.
ENDLOOP.
Regards
Ashok P
‎2006 Aug 09 1:06 PM
Hi,
To add to the previous two answers, first of all you`ll have to set the selection column attribute in the field attributes. You can do the same via the screen painter and select multiple columns and rows.
Hope this info. would be helpful, reward if so.
Regards