ABAP常用小技巧-SQL语句
1.1 尽量少的使用INTO CORRESPONDING FIELDS语句
尽量避免
DATA : TD_MARA TYPE TABLE OF MARA.
SELECT MATNR MTART
INTO CORRESPONDING FIELDS OF TABLE TD_MARA
FROM MARA
WHERE MATNR IN S_MATNR.
推荐用法
TYPES : BEGIN OF TYP_MARA,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
END OF TYP_MARA.
DATA : TD_MARA TYPE TABLE OF TYP_MARA.
SELECT MATNR MTART
INTO TABLE TD_MARA
FROM MARA
WHERE MATNR IN S_MATNR.
1.2 尽量减少使用SELECT * 、SELECT SINGLE *等,建议使用已知的列进行查询
尽量避免
SELECT *
INTO CORRESPONDING FIELDS OF TABLE TD_MARA
FROM MARA
WHERE MATNR IN S_MATNR.
推荐用法
SELECT MATNR MTART
INTO TABLE TD_MARA
FROM MARA
WHERE MATNR IN S_MATNR.