ABAP项目砖家之旅-screen和表单项目实战( 三 )

<--p2text*----------------------------------------------------------------------*FORM GET_DATA .REFRESHLT_ZTTEST.select * from zttest_01 into TABLE LT_ZTTESTwhere zname in s_znameand zdesc in s_zdesc .ENDFORM.
3.3 添加新增按钮
回到主程序 。
引入icon和添加按键
TYPE-POOLS icon."使用icon库TABLES:zttest_01 ,sscrfields. "选择屏幕上的字段结构DATA:bttxt TYPE smp_dyntxt . "菜单、按键SELECTION-SCREEN: FUNCTION KEY 1 . "添加f8同行按键INITIALIZATION."按键初始化BTTXT-ICON_ID = ICON_ADD_ROW .bttxt-ICON_TEXT = '新增'.sscrfields-FUNCTXT_01 = bttxt .AT SELECTION-SCREEN .CASE sscrfields-ucomm.WHEN 'FC01'.CALL SCREEN 0100. "新增界面WHEN OTHERS.ENDCASE.
当然也要在0100屏幕添加按钮
MODULE USER_COMMAND_0100 INPUT.CASE SY-UCOMM.WHEN 'BACK' OR '&BACK'.LEAVE TO SCREEN 0 .WHEN '%EX' OR '&UP' .leave PROGRAM .WHEN 'RW' OR '&EXIT'.leave PROGRAM .WHEN 'SAVE' OR '&SAVE'.MODIFY zttest_01 FROM zttest_01 .IF sy-subrc = 0.MESSAGE '保存成功' type 'S'.PERFORM GET_DATA."更新数据ELSE.MESSAGE '保存失败' type 'E'.ENDIF.WHEN '&ADDNEW'. "新增按键REFRESH LT_ZTTEST.CLEAR zttest_01.CALL SCREEN 0100.WHEN OTHERS.ENDCASE.ENDMODULE.
总结
【ABAP项目砖家之旅-screen和表单项目实战】今天内容到此为止,相信通过这个简单实战,大家可以在项目写简单的录入界面了 。当然还有打印、复制、删除、切换修改编辑等功能,这里不一一列举了