Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

table control

Former Member
0 Likes
364

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.

3 REPLIES 3
Read only

Former Member
0 Likes
341

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

Read only

Former Member
0 Likes
341

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.

Read only

Former Member
0 Likes
341

Hi,

Use the this code:

DELETE FROM table WHERE <keyfield> = <internaltable value>.

Thanks and Regards,

Kinjal