Archive

Posts Tagged ‘optimisation’

SAP – ABAP – Optimisation – Partie 2 – Le WHERE

November 27th, 2010 No comments

Dans un souci d’optimisation des accès à la base de données, il faut faire attention aux opérateurs que l’on utilise dans le “where”.

On doit privilégier, si possible, les égalités “=”

Exemple :

select qmnum matnr serialnr into table lt_qmel

from qmel

where qmart = pa_qmart.

Dans l’ordre décroissant des performances, on peut ensuite utiliser les “IN”

Exemple :

select qmnum matnr serialnr into table lt_qmel

from qmel

where qmart in so_qmart.

On trouve ensuite les “between”

Exemple :

select qmnum matnr serialnr into table lt_qmel

from qmel

where qmnum between ’0007000000′ and ’000705000′.

Il faut éviter les LIKE et surtout les NOT…

Exemple :

select qmnum matnr serialnr into table lt_qmel

from qmel

where qmnum like ’0007%’.

ou

select qmnum matnr serialnr into table lt_qmel

from qmel

where not qmart in ( ‘S1′, ‘S2′ ).

Categories: SAP Tags: ,

SAP – ABAP – Optimisation – Partie 1 – Le SELECT

November 25th, 2010 No comments

Ce post marque le début d’une série d’articles portant sur l’optimisation du code ABAP et plus particulièrement des accès à la base de données.

1er principe : La diminution des colonnes à récupérer

Il faut si nécessaire (cad si le nombre de colonnes est important) limiter le nombre de colonnes à récupérer, il faut donc limiter l’utilisation du SELECT *

Exemple :

*Déclaration des données

types : begin of t_qmel1,

qmnum type qmnum,

qmart    type qmart,

matnr   type matnr,

serialnr type gernr,

end of t_qmel1.

types : begin of t_qmel2,

qmnum type qmnum,

qmart    type qmart,

matnr   type matnr,

end of t_qmel2.

data : lt_qmel type table of qmel,

lt_qmel1 type table of t_qmel1,

lt_qmel2 type table of t_qmel2.

———————————————————–

Select * into table lt_qmel

from qmel

where qmnum in s_qmnum.

——————————————————-

Select qmnum qmart matnr into corresponding fields of table lt_qmel1

from qmel

where qmnum in s_qmnum.

——————————————————–

Select qmnum qmart matnr into  table lt_qmel2

from qmel

where qmnum in s_qmnum.

Categories: SAP Tags: ,