2005 Apr 20 3:14 PM
Hello,
i have a beginner question:
We show some data in a table control and want to delete the line from database which the user has selected.
Where and how do we have to identify the line to delete?
Thanks for help,
Andre Siegling
Hello,
i have a beginner question:
We show some data in a table control and want to delete the line from database which the user has selected.
Where and how do we have to identify the line to delete?
Thanks for help,
Andre Siegling
2005 Apr 20 3:17 PM
Hi,
The table control has to have the column for line-selection indicator. In your PAI, when you loop through the Table Control, you can determine which line was selected by checking if this indicator is set.
For more information , refer to the Help on Table Cntrols oin the ABAP Programming section of the documentation.
Regards,
Anand Mandalika.
2005 Apr 20 3:21 PM
Thanks for the fast answer,
the mark column does exist - but the loop does not work. Do you have a code sample?
Thanks
André
2005 Apr 20 3:25 PM
check out the demo program DEMO_DYNPRO_TABLE_CONTROL_2, to get an idea.
2005 Apr 21 4:48 AM
Hi,
The database table should contain a character field of length 1 (say mark) in addition to other fields.
In PAI , you have to loop like this.
PROCESS AFTER INPUT.
*itab is the name of the internal table with header line
LOOP AT itab.
Marking the row to be deleted by using this field(mark)
FIELD itab-mark MODULE check.
....
ENDLOOP.
MODULE user_command_9000.
declaration
here zzz_abc is the name of the database table which
should contain mark as one of the field
DATA : itab TYPE STANDARD TABLE OF zzz_abc WITH HEADER LINE.
CONTROLS: t_ctrl TYPE TABLEVIEW USING SCREEN '9000'.
MODULE check INPUT.
MODIFY itab INDEX t_ctrl-current_line.
ENDMODULE. " CHECK INPUT
MODULE user_command_9000 INPUT.
DATA :lv_fcode LIKE sy-ucomm, "Function Code
lv_answer(1) type c. "Storing the answer
lv_fcode = sy-ucomm.
CASE lv_fcode.
WHEN 'DELETE'.
Setting the flag to make the table control in editable * mode after deleting the selected line
flg = 'Y'.
Confirmation of delete
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = 'Confirm'
text_question = 'Are you sure to delete from database?'
TEXT_BUTTON_1 = 'Yes'(001)
TEXT_BUTTON_2 = 'No'(002)
IMPORTING
ANSWER = lv_answer.
if lv_answer eq '1'.
Updating the database table from the internal table
UPDATE zzz_abc FROM TABLE itab.
Deleting the selected row from the internal table
DELETE itab WHERE mark = 'X'.
Deleting the selected row from the database table
DELETE FROM itab WHERE mark = 'X'.
MESSAGE s005 WITH 'Deleted Successfully'.
ENDIF.
ENDMODULE. " USER_COMMAND_9000 INPUT
Message was edited by: Jayanthi Jayaraman
Message was edited by: Jayanthi Jayaraman
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |