Skip to Content
0
Former Member
Mar 28, 2007 at 09:10 AM

How to delete a row from table control

213 Views

I have created a push button on the screen for delete.

its getting stored in ok_code.

'FLAG' is the name of the mark on the table control.

I am getting probs in this line.

I am not getting anything in mark_field.

ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.

The code is:

MODULE tablctrl2_user_command INPUT.

PERFORM user_ok_tc USING 'TABLCTRL2'

'I_ZSKILLEMP'

'FLAG'

CHANGING ok_code.

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 'INSR'. "insert row

PERFORM fcode_insert_row USING p_tc_name

p_table_name.

CLEAR p_ok.

WHEN 'DELE'. "delete row

PERFORM fcode_delete_row USING p_tc_name

p_table_name

p_mark_name.

CLEAR p_ok.

FORM fcode_delete_row

USING p_tc_name TYPE dynfnam

p_table_name

p_mark_name .

-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>.

-END OF LOCAL DATA----


ASSIGN (p_tc_name) TO <tc>.

  • 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

  • delete marked lines *

DESCRIBE TABLE <table> LINES <tc>-lines.

LOOP AT <table> ASSIGNING <wa>.

  • 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.

IF sy-subrc = 0.

<tc>-lines = <tc>-lines - 1.

ENDIF.

ENDIF.

ENDLOOP.

ENDFORM.