--建立一个structure.
DATA: BEGIN OF count_line,
carrid TYPE spfli-carrid,
count TYPE i,
END OF count_line,
spfli_tab TYPE TABLE OF spfli.
DATA: dbcur1 TYPE cursor,
dbcur2 TYPE cursor.
--定义parameters参数.接收从页面获得的参数;
PARAMETERS: p_cityfr TYPE spfli-cityfrom,
p_cityto TYPE spfli-cityto.
--建立一个Structure.
DATA: BEGIN OF waa,
fldate TYPE sflight-fldate,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
END OF waa.
--建立一个internal table.内表.
DATA itab LIKE SORTED TABLE OF waa
WITH UNIQUE KEY fldate carrname connid.
--多表连接查询.
SELECT c~carrname p~connid f~fldate
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( scarr AS c
INNER JOIN spfli AS p ON p~carrid = c~carrid
AND p~cityfrom = p_cityfr
AND p~cityto = p_cityto )
INNER JOIN sflight AS f ON f~carrid = p~carrid
AND f~connid = p~connid ).
--循环输出内表里面的,字段.
LOOP AT itab INTO waa.
WRITE: / wa-fldate, wa-carrname, wa-connid.
ENDLOOP.
--指定透明表.
TABLES:ZEDITAB.
--引用zeditab表的structure结构.
DATA:WA_ZDITAB TYPE ZEDITAB.
--对透明表的更新操作.
UPDATE ZEDITAB SET EANCOMSEGMENT = 'G01DTM' EDI_INDEX = '3'
WHERE EDI_INDEX = '11'.
UPDATE ZEDITAB SET EANCOMSEGMENT = 'G01DTM' EDI_INDEX = '2'
WHERE EDI_INDEX = '10'.
UPDATE ZEDITAB SET EANCOMSEGMENT = 'G01DTM' EDI_INDEX = '1'
WHERE EDI_INDEX = '9'.
WRITE:/ 'OK'.
TABLES:ZHT_EMPLOYEE.
DATA:EMPLOYEE_ITAB LIKE STANDARD TABLE OF ZHT_EMPLOYEE WITH HEADER LINE,
EMPLOYEE_WA LIKE LINE OF EMPLOYEE_ITAB.
--给结构赋值.
EMPLOYEE_WA-EMP_ID = 101.
EMPLOYEE_WA-EMP_NAME = 'Admin'.
EMPLOYEE_WA-EMP_SEX = '男'.
APPEND EMPlOYEE_WA TO EMPLOYEE_ITAB.
EMPLOYEE_WA-EMP_ID = 102.
EMPLOYEE_WA-EMP_NAME = 'Apple'.
EMPLOYEE_WA-EMP_SEX = '女'.
APPEND EMPLOYEE_WA TO EMPLOYEE_ITAB.
EMPLOYEE_WA-EMP_ID = 103.
EMPLOYEE_WA-EMP_NAME = '周海涛'.
EMPLOYEE_WA-EMP_SEX = '男'.
--追加到内表中.
APPEND EMPLOYEE_WA TO EMPLOYEE_ITAB.
--循环输出.内部的记录, 这里没有用到into 的原因是,EMPLOYEE_ITAB,有 -
-with..header Line.有头行,就不需要用 into 到一个Structure中.
LOOP AT EMPLOYEE_ITAB.
WRITE: / EMPLOYEE_ITAB-EMP_ID,EMPLOYEE_ITAB-EMP_NAME,EMPLOYEE_ITAB-EMP_SEX.
INSERT INTO zht_employee VALUES employee_itab. "循环添加.
ENDLOOP.
EMPLOYEE_WA-EMP_ID = 103.
EMPLOYEE_WA-EMP_NAME = '周海涛'.
EMPLOYEE_WA-EMP_SEX = '男'.
--删除操作.
delete zht_employee FROM EMPLOYEE_WA.
COMMIT WORK.
WRITE: / sy-uline.
IF sy-subrc = 0.
WRITE: / '删除成功'.
else.
WRITE: / '删除失败'.
ENDIF.
CLEAR EMPLOYEE_ITAB.
SELECT * FROM zht_employee INTO CORRESPONDING FIELDS OF TABLE employee_itab.
LOOP AT EMPLOYEE_ITAB.
WRITE: / EMPLOYEE_ITAB-EMP_ID,EMPLOYEE_ITAB-EMP_NAME,EMPLOYEE_ITAB-EMP_SEX.
ENDLOOP.
WRITE: / sy-uline.
IF sy-subrc = 0.
WRITE:/ '修改成功'.
ELSE.
WRITE: / '修改失败'.
ENDIF.
--更新操作.
UPDATE zht_employee set emp_id = 102 emp_name = 'My Love' emp_sex = '女' WHERE emp_id = 102.
CLEAR employee_wa.
EMPLOYEE_WA-EMP_ID = 101.
EMPLOYEE_WA-EMP_NAME = 'TestName'.
EMPLOYEE_WA-EMP_SEX = '女'.
UPDATE ZHT_EMPLOYEE FROM EMPLOYEE_WA.
COMMIT WORK.
CLEAR EMPLOYEE_ITAB.
SELECT * FROM zht_employee INTO CORRESPONDING FIELDS OF TABLE employee_itab.
LOOP AT EMPLOYEE_ITAB.
WRITE: / EMPLOYEE_ITAB-EMP_ID,EMPLOYEE_ITAB-EMP_NAME,EMPLOYEE_ITAB-EMP_SEX.
ENDLOOP.
SKIP.
DATA:ZEDI_IDOC_ITAB LIKE STANDARD TABLE OF ZEDI_IDOC_PARAM WITH HEADER LINE,
ZEDI_IDOC_WA LIKE LINE OF ZEDI_IDOC_ITAB.
SELECT * INTO CORRESPONDING FIELDS OF TABLE ZEDI_IDOC_ITAB FROM ZEDI_IDOC_PARAM.
DATA:size type i.
size = lines( ZEDI_IDOC_ITAB ).
WRITE: / '输出结果:',size.
LOOP AT ZEDI_IDOC_ITAB .
WRITE:/ ZEDI_IDOC_ITAB-LINE_ID,ZEDI_IDOC_ITAB-MESTYP,ZEDI_IDOC_ITAB-DOCNUM.
ENDLOOP.
SKIP.
DELETE FROM ZEDI_IDOC_PARAM.
WRITE 'Please fill in your name before printing:'.
WRITE / ' Enter name here ' INPUT ON.
ULINE.
WRITE 'You can overwrite the following line:'.
FORMAT INPUT ON INTENSIFIED OFF.
ULINE.
FORMAT INPUT OFF INTENSIFIED ON.
--包含.
INCLUDE <LIST>.
START-OF-SELECTION.
WRITE 'Now comes a'.
FORMAT HOTSPOT ON COLOR 5 INVERSE ON.
WRITE 'HOTSPOT'.
FORMAT HOTSPOT OFF COLOR OFF.
AT LINE-SELECTION.
WRITE / 'New list AT-LINE-SELECTION'.
SKIP.
WRITE 'This is also a hotspot:'.
WRITE ICON_LIST AS ICON HOTSPOT.
上面是一个很简单的例子, 毕竟发的时间不多..还是刚刚掌握一些最基础的语法知识.. 高手级别的人物,千万请别喷..