‎2008 Jun 10 4:49 PM
i had created table control for ztable.in that table control i have added 2 pushbuttons (add and delete).whenever i hit 'add' the record shuld be added in the database table and whenever i hit 'delete' selected records should be deleted in database also.add is working properly but delete is deleting records in table control but it is not deleting the records in database.
the code i had written for delete is as below:
FORM fcode_delete_row
USING p_tc_name TYPE dynfnam
p_table_name
p_mark_name .
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA l_table_name LIKE feld-name.
FIELD-SYMBOLS <tc> TYPE cxtab_control.
FIELD-SYMBOLS <table> TYPE STANDARD TABLE.
FIELD-SYMBOLS <wa>.
FIELD-SYMBOLS <mark_field>.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (p_tc_name) TO <tc>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE p_table_name '[]' INTO l_table_name. "table body
ASSIGN (l_table_name) TO <table>. "not headerline
*&SPWIZARD: delete marked lines *
DESCRIBE TABLE <table> LINES <tc>-lines.
LOOP AT <table> ASSIGNING <wa>.
*&SPWIZARD: access to the component 'FLAG' of the table header *
ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.
IF <mark_field> = 'X'.
DELETE <table> INDEX syst-tabix.
MODIFY zctf_as400intpro FROM TABLE g_tc_as400intpro_itab.
IF sy-subrc = 0.
<tc>-lines = <tc>-lines - 1.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM.
‎2008 Jun 10 5:10 PM
modify will not work.
You need to use delete.
Pick the line that is being deleted from the table control, put it in a work area and then delete that line from the DB
‎2008 Jun 10 5:23 PM
Hi,
Use the below code:
Create a fieldsymbol (<fs>) of type any.
Move the key field of the table row to be deleted to this fieldsymbol.
assign component <keyfield> of structure <wa> to <fs>.
DELETE FROM zctf_as400intpro WHERE <keyfield> = <fs>.
Thanks and Regards,
Lakshmi.
‎2008 Jun 10 10:23 PM
Hi,
Use the this code:
DELETE FROM table WHERE <keyfield> = <internaltable value>.
Thanks and Regards,
Kinjal