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

Help deleting a row from a table using a screen pushbutton (ABAP)

0 Likes
1,781

table: z625_user

Screen input field: WA_USER-Username

pushbutton: DEL

Hi all, I am trying to make it so the user can enter a username into a text field that was brought into Layout (called wa_user-username) and press a pushbutton to delete the row from the z625_user table that shares that username in its "Username" field. I am new to this and am having lots of trouble with the logic, this is what I have:

when 'DEL'.
select * from z625_user into wa_user where username = wa_user-username.
endselect.
delete it_user where username = wa_user-username.

table: z625_user

Screen input field: WA_USER-Username

pushbutton: DEL

Hi all, I am trying to make it so the user can enter a username into a text field that was brought into Layout (called wa_user-username) and press a pushbutton to delete the row from the z625_user table that shares that username in its "Username" field. I am new to this and am having lots of trouble with the logic, this is what I have:

when 'DEL'.
select * from z625_user into wa_user where username = wa_user-username.
endselect.
delete it_user where username = wa_user-username.

6 REPLIES 6
Read only

former_member751591
Participant
0 Likes
1,667

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with Community Q&A , as it provides tips for preparing questions that draw responses from our members.

For example, you can:

- outline what steps you took to find answers (and why they weren't helpful)

- share screenshots of what you've seen/done

- make sure you've applied the appropriate tags

- use a more descriptive subject line.

The more details you provide, the more likely it is that members will be able to respond. Feel free to also take our Q&A tutorial Q&A tutorial

Should you wish, you can revise your question by selecting Actions, then Edit.

By adding a picture to your Profile you encourage readers to respond.

Read only

Sandra_Rossi
Active Contributor
1,667

SQL syntax:

delete from <dbtablename> where <condition>.
Read only

retired_member
Product and Topic Expert
Product and Topic Expert
1,667

Your code seems to delete from an internal table, not from a database table,

But see

https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenopen_sql_writing....

BR

Horst

Read only

0 Likes
1,667

Thank you, could you elaborate on <condition>?

I have tried:

delete from z625_user where username = wa_user-username.

But nothing gets deleted. wa_user-username is the value from the screen that is intended used to identify the row for deletion. What could I be doing wrong if the entered Username matches perfectly with a record's Username field and it doesn't get deleted?

Read only

FredericGirod
Active Contributor
1,667

in debug, did you check the value of SY-SUBRC after the statement DELETE ... ?

Read only

Sandra_Rossi
Active Contributor
1,667

<condition> = any condition behind the where

If nothing gets deleted, either the line doesn't even exist (see Frederic remark about checking sy-subrc by debug) or you check before the commit happens or something rollbacks the deletion before an eventual commit.

Also, be careful with lower case and upper case.