Application Development 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: 

Performance tuning for DB Updates

Former Member
0 Kudos
91

What should be taken care of for Database updates in ABAP?

1 ACCEPTED SOLUTION

Former Member
0 Kudos
56

All Database manipulations in SAP (UPDATE, INSERT, DELETE) can be executed one record at a time or through an 'Array' operation.

Example:

No good

LOOP AT T_MAT.

  • Assign value to material group MARA-MATKL

……

UPDATE MARA SET MATKL = T_MAT-MATKL.

WHERE MATNR = T_MAT-MATNR.

ENDLOOP.

GOOD

LOOP AT T_MAT.

  • Assign value to material group MARA-MATKL

……

ENDLOOP

UPDATE MARA FROM TABLE T_MAT.

After the execution of the array update, the following system fields are populated:

• SY-SUBRC - Contains 0 if all updates were successfully executed

• SY-DBCNT -Contains the number of successfully updated records

Restrictions:

• The Array update function can't be combined with UPDATE SET

Recommendation:

• Array updateIf a large number of fields are changed in multiple records

• Update setIf a small number of fields are changed in one record

• If a small number of fields are changed in multiple records

-> Define a modifiable view using the key fields and the fields which are to be changed

Updating Key fields

Key fields can be updated for transparent tables just like any other table.

Exception:

If synchronous match codes exist for the table, the key field update will be unsuccessful.

1 REPLY 1

Former Member
0 Kudos
57

All Database manipulations in SAP (UPDATE, INSERT, DELETE) can be executed one record at a time or through an 'Array' operation.

Example:

No good

LOOP AT T_MAT.

  • Assign value to material group MARA-MATKL

……

UPDATE MARA SET MATKL = T_MAT-MATKL.

WHERE MATNR = T_MAT-MATNR.

ENDLOOP.

GOOD

LOOP AT T_MAT.

  • Assign value to material group MARA-MATKL

……

ENDLOOP

UPDATE MARA FROM TABLE T_MAT.

After the execution of the array update, the following system fields are populated:

• SY-SUBRC - Contains 0 if all updates were successfully executed

• SY-DBCNT -Contains the number of successfully updated records

Restrictions:

• The Array update function can't be combined with UPDATE SET

Recommendation:

• Array updateIf a large number of fields are changed in multiple records

• Update setIf a small number of fields are changed in one record

• If a small number of fields are changed in multiple records

-> Define a modifiable view using the key fields and the fields which are to be changed

Updating Key fields

Key fields can be updated for transparent tables just like any other table.

Exception:

If synchronous match codes exist for the table, the key field update will be unsuccessful.