zoukankan      html  css  js  c++  java
  • ABAP开发需要养成的习惯—变量定义

    变量定义

    Global variables are BAD 

    定义内表先在程序开头定义types,如

    types: begin of ty_structure,
            id type i,
            date type datum,
            time type uzeit,
            message type string,
           end of ty_structure.

    "structure"常常简写为"stru"或"struc".

    局部变量

    l表示local,it表示internal table,wa表示工作区;

    DATA l_index type i value 0.

    一般不用lv_index

    DATA l_wa_xxx type line of ty_structure."

    这条语句会报错,因为ty_structure不是内表,直接用 data l_wa_xxx type ty_structure.

    DATA l_it_xxx type ty_structure occurs 0.

    "不带表头,loop和read需要别的工作区来操作数据

    DATA l_it_xxx type ty_structure occurs 0 with header line.

    "有header line,也就是有了l_it_xxx这个工作区和l_it_xxx[]这个内表

    DATA l_it_xxx type table of ty_structure.
    
    DATA l_it_xxx type table of ty_structure with header line.
    
    DATA l_it_xxx type standard table of ty_structure.
    
    DATA l_it_xxx type sorted table of ty_structure.
    
    DATA l_it_xxx type hashed table of ty_structure.

     *同上,新式声明,一般还有standard table,sorted table以及hashed table之分

    尽量放在FORM里面用局部变量

    全局变量

    非要定义的话,用g_xxx,g_it_xxx,全局变量使用要更加注意CLEAR的问题,使用前/后clear掉。

  • 相关阅读:
    怎样绘制一个三角形边框
    怎样绘制一条线段
    怎样绘制矩形
    怎样判断浏览器是否支持canvas
    怎样创建一个canvas画布环境
    怎样理解Canvas
    怎样删除一条Cookie
    怎样在浏览器端增加一条Cookie
    怎样限制第三方Cookie
    怎样理解第三方Cookie
  • 原文地址:https://www.cnblogs.com/aurora-cj/p/9303194.html
Copyright © 2011-2022 走看看