Loading

ABAP EDITOR 代码模板

前言:为了提高开发效率,sap abap editor提供了可自定义的代码模板,帮助ABAP开发者们提高工作效率,下面就介绍一下如何使用代码模板。

1.登入SAP系统,进入程序编辑器,找到右下角编辑选项

image

2.点击进入选项面板,选择代码模板

image

选择其中一个模板进行查看:loop

image
看到这里相信大家已经知道是怎么一回事了,没错,在这里定义相应的代码模板,在编辑器里使用快捷命令生成代码。

3.自定义模板

3.1点击添加,输入快捷指令及相应的描述并在下方添加对应的模板代码

image
image

3.2效果展示:输入快捷指令按下TAB键

image
image

只需要一个命令+一个按键就可以快速生成代码,怎么样,是不是非常方便快捷呢,赶紧去试试吧。

4.代码模板案例

4.1程序详情

*---------------------------------------------------------------------*
* Program ID  :                                                 *
* Program Name: %Document%                                                *
* T-CODE      : %Document%                                               *
* Program Type:                                               *
* Description :                                            *
*---------------------------------------------------------------------*
* Date Created : %DateTime%                                           *
* Created By   : ZHANGYH                                              *
*---------------------------------------------------------------------*
* Edit Log  :                                                         *
*  Version       Date          Author     Remark                      *
*  <YYYYMMDDnnn> <YYYY/MM/DD>  <修改人>   <修改理由/内容>             *
*---------------------------------------------------------------------*

*--------------------------------------------------------------------*
*&---------------------------「TABLES」-----------------------------&*
*--------------------------------------------------------------------*

*--------------------------------------------------------------------*
*&---------------------------「TYPES」------------------------------&*
*--------------------------------------------------------------------*

*--------------------------------------------------------------------*
*&-----------------------「INTERNAL TABLES」------------------------&*
*--------------------------------------------------------------------*

*--------------------------------------------------------------------*
*&--------------------------「VARIABLE」----------------------------&*
*--------------------------------------------------------------------*

*--------------------------------------------------------------------*
*&--------------------------「CONSTANT」----------------------------&*
*--------------------------------------------------------------------*

*--------------------------------------------------------------------*
*&--------------------------「SCREEN」------------------------------&*
*--------------------------------------------------------------------*

*--------------------------------------------------------------------*
*&--------------------------「PROCESS」-----------------------------&*
*--------------------------------------------------------------------*

4.2注释模板

4.2.1添加AD
*<START>------「Add By Author Time: %DateTime%」-------<START>*
%SurroundedText%
*<END>--------「Add By Author Time: %DateTime%」---------<END>*
4.2.2修改MD
*<START>------「Modify By Author Time: %DateTime%」-------<START>*
%SurroundedText%
*<END>--------「Modify By Author Time: %DateTime%」---------<END>*
4.2.2删除DE
*<START>------「Delete By Author Time: %DateTime%」-------<START>*
%SurroundedText%
*<END>--------「Delete By Author Time: %DateTime%」---------<END>*

4.3FORM子例程

*&---------------------------------------------------------------------*
*& Form %Form Name%
*&---------------------------------------------------------------------*
*& %Form Text%
*&---------------------------------------------------------------------*
FORM %Form Name%.

ENDFORM.

4.4循环内表

LOOP AT %Interal_table% into DATA(%Structure%).

ENDLOOP.

4.5搜索帮助

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_%Screen_Field%-low.
  PERFORM frm_f4_help_for_%Screen_Field%.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_%Screen_Field%-high.
  PERFORM frm_f4_help_for_%Screen_Field%.


*&---------------------------------------------------------------------*
*& Form frm_f4_help_for_%Screen_Field%
*&---------------------------------------------------------------------*
*& %Screen_Field_Text%搜索帮助
*&---------------------------------------------------------------------*
FORM frm_f4_help_for_%Screen_Field% .
  SELECT  INTO TABLE @DATA(lt_data) FROM .
  SORT lt_data BY %Screen_Field%.
  DELETE ADJACENT DUPLICATES FROM lt_data COMPARING %Screen_Field%.
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield        = '%Screen_Field%'
      dynpprog        = sy-repid
      dynpnr          = sy-dynnr
      dynprofield     = 'S_%Screen_Field%'
      value_org       = 'S'
    TABLES
      value_tab       = lt_data
    EXCEPTIONS
      parameter_error = 1
      no_values_found = 2
      OTHERS          = 3.
  IF sy-subrc <> 0.
* Implement suitable error handling here
  ENDIF.

ENDFORM.
posted @ 2021-11-23 11:16  Gjboy666  阅读(967)  评论(0编辑  收藏  举报