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

Performance tuning for DB Updates

Former Member
0 Likes
486

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
451

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.

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

1 REPLY 1
Read only

Former Member
0 Likes
452

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.