OPEN SQL
1、SELECT 、INSERT、UPDATE、DELETE、MODIFY
SELECT 命令包含如下从句:SELECT: 需要查询资料库指定表的那些列,是一行还是多行INTO: 查询的结果保存在哪里FROM:从哪些表查询数WHERE: 指定查询条件GROUP BY: 以哪些栏位进行分組ORDER BY: 以哪些栏位进行排序.在INTO中使用 CORRESPONDING FIELDS OF,系统只填充与你的Work Area相同名称的栏位值;执行成功返回代码 SY-SUBRC = 0,如果失敗SY-SUBRC <> 0。
SELECT:
SELECT <F1> … <Fn> FROM <dbtab>
INTO <work area>
INTO (<f1>, <f2>, <f3> … )
INTO CORRESPONDING FIELDS OF <work area>
WHERE <tabfield> <operator> <value>.
ENDSELECT.
SELECT <f1> … <fn>
FROM <dbtab>
INTO TABLE <itab>
WHERE …
SELECT ... FROM <tables> UP TO <n> ROWS ...
SELECT...INTO|APPENDING CORRESPONDING FIELDS OF TABLE <itab>...
SELECT
menge "数量
INTO CORRESPONDING FIELDS OF TABLE gt_mseg
FROM mseg ORDER BY menge.
SELECT SINGLE 命令
SELECT SINGLE 命令允许你查询一条记录 ,为了确保你查询的记录是唯一的,你必须在你的 WHERE 子句指定所有KEY值,如若查询的记录不止一条,系统会返回代码 SY-SUBRC = 8,查询结果为空
SELECT SINGLE <F1> <F2> FROM <dbtab>
INTO <work area>
INTO (<f1>, <f2>, <f3> … )
INTO CORRESPONDING FIELDS OF <work area>
WHERE <Key1> <op> AND <Key2> <op> …
SELECT SINGLE
menge "数量
INTO CORRESPONDING FIELDS OF gs_mseg FROM mseg.
INSERT:
INSERT INTO <dbtab> VALUES wa.
INSERT <dbtab> FROM TABLE itab.
UPDATE:
UPDATE <dbtab> SET f1 … fn [WHERE sql_cond] .
UPDATE <dbtab> FROM TABLE itab [WHERE sql_cond] .
DELETE:
DELETE FROM <dbtab> WHERE cond.
DELETE <dbtab> FROM TABLE itab.
MODIFY:
MODIFY <dbtab>. (相当于INSERT 和UPDATE)
MODIFY <dbtab> FROM TABLE itab.