Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

The most common performance problem that occurs in ABAP programs is because of huge number of records in

the internal tables. The problem complexifies if a program has huge nested internal tables. How much ever
efficient data select routines are, data processing routines would be contributing significantly for the bad
performance. When analysed it would be revealed that the where condition that is used in inner loops expend a
significant amount of processing time. The idea is to avoid where conditions in the inner loops by maintaining the
loop indexes manually.

Conventional Code for nested loops


Error rendering macro 'code': Invalid value specified for parameter 'lang'
loop at lt_vbpa into wa_vbpa.
loop at lt_kna1 into wa_kna1 where kunnr = wa_vbpa-kunnr.
****** Your Actual logic within inner loop ******
endloop.
endloop.
Code sample: Parallel Cursor method
Error rendering macro 'code': Invalid value specified for parameter 'lang'
sort: lt_vbpa by kunnr, "Sorting by key is very important
lt_kna1 by kunnr. "Same key which is used for where condition is used here
loop at lt_vbpa into wa_vbpa.
read lt_kna1 into wa_kna1 " This sets the sy-tabix
with key kunnr = wa_vbpa-kunnr
binary search.
if sy-subrc = 0. "Does not enter the inner loop
v_kna1_index = sy-tabix.
loop at lt_kna1 into wa_kna1 from v_kna1_index. "Avoiding Where clause
if wa_kna1-kunnr <> wa_vbpa-kunnr. "This checks whether to exit out of loop
exit.
endif.
****** Your Actual logic within inner loop ******
endloop. "KNA1 Loop
endif.
endloop. " VBPA Loop

Field symbols are similar to pointers in C language, field symbols does not have any memory instead they will be
pointing to a memory location.

The concept of field symbols is very important in order to increase the performance of SAP applications, but
unethical use of field-symbols leads to application issues.
Field symbol name should always be within <>, example:.
Syntax for declaring a field symbol.

FIELD-SYMBOLS : <FIELD_SYMBOL> TYPE MARA-MATNR. "here MARA-MATNR is a variable type


FIELD-SYMBOLS : <FIELD_SYMBOL> TYPE MARA. "here MARA is a structure
FIELD-SYMBOLS : <FIELD_SYMBOL> TYPE REF TO DATA . "here DATA is a reference type
ASSIGNING and ASSIGN are the keywords which are used to assign a value to the field symbol.

Example of using field symbol as work area


In the below example we are going to use field symbol as work area.

REPORT ZSAPN_FIELDSYMBOLS.

DATA : IT_MARA TYPE TABLE OF MARA.


DATA : WA_MARA TYPE MARA.
FIELD-SYMBOLS : <FS_MARA> TYPE MARA.
SELECT * FROM MARA
INTO TABLE IT_MARA UP TO 50 ROWS.

LOOP AT IT_MARA ASSIGNING <FS_MARA>.


IF <FS_MARA> IS ASSIGNED.
WRITE :/ <FS_MARA>-MATNR, <FS_MARA>-MTART, <FS_MARA>-MEINS.
ENDIF.
ENDLOOP.
Check weather the field symbol is assigned or not before processing field symbol, it is very important to check
field symbol, if it is not assigned it will get a run-time error, use the blow syntax to check field symbol assignment.

IF <FS_MARA> IS ASSIGNED.
**process field symbol
ENDIF.
Increase performance using field symbols in SAP ABAP
I belive there are always performance differences between reference variables(work area) and memory
pointing(field symbols), here I wants to add some proof for that

Chain and Endchain

For example if there are 10 fields in the screen and for 5 fields whenever the user enters wrong values u like to
give some error message. You can declare that fields in the chain enchain so that only those fields will be input
enabled and all other fields will disabled.
Description - Generally in input screen, when the user gives the input and their is no record present in the
database, the user input is restricted by a error message. This error message disables the input screen and now
the user can not provide correct values in the input field as it is disabled by the error message. To overcome this
problem Chain And EndChain Statement is used in the Flow Logic of the screen where Input fields are validated.
CHAIN.
FIELD chk_connobj.
FIELD chk_inst.
FIELD chk_devloc.
FIELD ehaud-haus.
FIELD eanl-anlage.
MODULE modify_screenfields.
ENDCHAIN.
&----
*& Module modify_screenfields INPUT
&----
 text
----
MODULE modify_screenfields INPUT.
CLEAR okcode.
okcode = sy-ucomm.
CASE okcode.
WHEN 'ENTER' OR 'EXECUTE'.
IF chk_connobj IS INITIAL AND chk_inst EQ c_x AND
chk_devloc EQ c_x.
IF ehaud-haus IS INITIAL.
SET CURSOR FIELD 'EHAUD-HAUS'.
MESSAGE e000(zo_spa) WITH text-017. " Enter Connection obj
ELSE.
PERFORM conn_obj_check.
ENDIF.
ENDIF.
ENDMODULE. " modify_screenfields INPUT
Regards,

TMG

Introduction
Table Maintenance Generator (TMG) is a tool which is used to create equipment by which customized tables created
by end users can be changed as required, such as making an entry to that table, deleting an entry, modifying an
existing entry etc.
Table Maintenance generator can be created using transaction SE54 or SE11.
A table maintenance generator is used to create table maintenance program to add, modify or delete records in the
database tables. It is generated to maintain customizing data with these maintenance dialogs.
We can check the table maintenance dialog in SM30 or SE16. In SM30, We have display and maintain options. Display
option is used to view the table contents and maintain option is used to maintain the entries in the table.

Reasons to use Table Maintenance Generator


There are different reasons due to which table maintenance generator is used.
1. In the production system, end-users will not be having access to transaction codes like SE11 and
SE16. Therefore, developers will not be having access to many transaction codes including the above SE11 and SE16.
So in order to edit or create the contents of a database table, we should go for table maintenance generator.
2. With the help of table maintenance generator, we can edit or create multiple entries at a time.
3. Various events can be added to the table maintenance generator to maintain the entries. These events get
triggered while maintaining the entries in the table. They help in enhancing the functionality of the table
maintenance.

Modify your SAP database table maintenance events, screen, interface and code.

Once you have created your basic SAP database table and then added a standard table maintenance to it you may
find that you want to change the functionality of it slightly. I.e. you may want to display a message when the data is
saved or prevent users from saving certain combinations of data.

If you required to have custom logic/custom validations in your already created table maintenance, you can use
events to implement custom requirements. Events in table maintenance allow developers to access and modify
predefined positions in the maintenance dialog which couldn’t be access using user flow logic modules. These event
modules are dynamically executed at table maintenance runtime. There are different types of events which executes
at different sections of the maintenence PAI and PBO runtime. For example, before saving the data, after saving the
data, before deleting, after deleting are few of the event types available.

Transaction Codes

SE54: Generate Table Maintenance Dialog


SE55: Table view maintenance DDIC call
SE56: Table view display DDIC call
SE57: Deletion of Table Maintenance

Table Maintenance Events


The value to be displayed on the maintenance screen for any field can also be altered as per the requirement like
for every new entry in the table one of the field should have the constant value appearing automatically. For this
purpose, the event needs to be chosen which performs the action. In this case event "05 creating a new entry".

List of Events available in Table maintenance

01 Before saving the data in the database

02 After saving the data in the database

03 Before deleting the data displayed

04 After deleting the data displayed

05 Creating a new entry

06 After completely performing the function 'Get original'

07 Before correcting the contents of a selected field

08 After correcting the contents of a selected field

09 After getting the original of an entry

10 After creating the header entries for the change task (E071)
11 After changing a key entry for the change task (E071K)

12 After changing the key entries for the change task (E071K)

You might also like