SAP System Setup Training Course
Reveals How To Setup A Free SAP Developer System.
Learn SAP & Practice For Certification. Developer Tips Included:

Using ABAP to modify data in a database table

As I’ve mentioned in the previous review SAP offers you some great tools to help you maintain your database tables. However, to make things better, they’ve added SQL support (Open and Native-SQL).
So, If you’ve had some experience with SQL (I’ll take MySQL as an example in this review) you’ll hardly have any problems with those statements in SAP. Furthermore, the Pete’s course gives you some excellent examples which illustrate how things actually work, what you should be aware of and much more.

Open-SQL statements

SELECT

The SELECT statement in ABAP doesn’t differ too much from the MySQL one and as you can guess it works as a loop. I’m not sure though if you can use the HAVING, GROUP BY and ORDER BY clauses? Maybe someone more experienced could say…

ABAPModifyDataINSERT

Unlike selecting rows, inserting ones in ABAP has some differences from inserting rows in MySQL. In fact, in ABAP we can use either the INSERT or the INSERT INTO statements. The INSERT INTO is basically the same as in MySQL with the slight difference that you use a work area, not arguments. On the other side, the pure INSERT statement can seem a bit strange at first sight (as it did to me). The following syntax was odd to me in the beginning:

INSERT target FROM wa

Then I realized that we only omit the INTO clause and add one FROM before the work area and it’s done. But don’t worry – this statement is beautifully explained in the course.

UPDATE

The UPDATE statement has the same construction like the INSERT. It works the same way as the UPDATE in MySQL – updates row contents based on the key field.

MODIFY

This one also has the same format like the two previous statements. I don’t think it has an analogue in MySQL or I just haven’t seen it yet. One thing you should pay attention to here is the key field. If you mistype it, you could end up having two duplicate rows with different keys.

DELETE

The DELETE statement, just like INSERT, has two forms – DELETE and DELETE FROM. The DELETE FROM is the same as in MySQL – you specify the table you want to delete from and then in the WHERE clause you point a criteria for deletion. The pure DELETE works as the other ABAP statements – with work area. This time though, you just have to fill the key field from the work area – to tell the program which record to remove.

That’s the story about Open-SQL statements in ABAP. Of course, you can dig in even more, but as Mr. Moxon said – this will be enough for you to cope with your tables. And the most beautiful thing is that if you have any problems with some of the above mentioned statements, you can just hit the F1 key and answer your questions.

This is a guest article is by Plamen Velkov, who is taking my Beginners Guide To SAP ABAP programming course. This is part 6 of his course review / journey.

Categories

About the Author:

Pete has been working with SAP technologies for over 10 years. He started out as an ABAP consultant and then moved on to BW where he has worked many different clients covering a wide variety of industries. "I love introducing SAP technology (especially BI) to new clients and showing them how they can go from zero to hero within their business in super fast time". Contact me on twitter @PeterMoxon