学习笔记一

来源:互联网 发布:移动充值卡冲淘宝 编辑:程序博客网 时间:2024/06/09 20:18

 

1.测试内表的行数。lines( i_tab )
DATA: name(10)   TYPE c VALUE 'SOURCE',
      source(10) TYPE c VALUE 'Antony',
      target(10) TYPE c.
...
WRITE (name) TO target.
WRITE target.
() 是先取里面的值.
============================
计算:
两数相除:
取商
div
取余数:
mod
============================
DATA: BEGIN OF rate,
         usa TYPE f VALUE '0.6667',
         frg TYPE f VALUE '1.0',
         aut TYPE f VALUE '7.0',
      END OF rate.

DATA: BEGIN OF money,
         usa TYPE i VALUE 100,
         frg TYPE i VALUE 200,
         aut TYPE i VALUE 300,
      END OF money.
MULTIPLY-CORRESPONDING money BY rate."两数相乘
============================
DATA: BEGIN OF series,
         n1 TYPE i VALUE 10,
         n2 TYPE i VALUE 20,
         n3 TYPE i VALUE 30,
         n4 TYPE i VALUE 40,
         n5 TYPE i VALUE 50,
         n6 TYPE i VALUE 60,
      END OF series.

DATA sum TYPE i.

ADD series-n1 THEN series-n2 UNTIL series-n5 GIVING sum.
WRITE sum.

ADD series-n2 THEN series-n3 UNTIL series-n6 to sum.
WRITE / sum.
*:第二次是赋值是在第一次的基础上相加的。如果第行的to改为了GIVING那么sum上一次的150会被清空,成为200

===========================
计算数据的函数
abs ---Absolute value of the argument arg
sign ---Plus/minus sign of the argument arg: -1, if the value of arg is negative; 0 if the value of arg is 0; 1 if the value of arg is positive.
ceil ---Smallest integer number that is not smaller than the value of the argument arg.
floor ---Largest integer number that is not larger than the value of the argument arg.
trunc ---Value of the integer part of the argument arg
frac ---Value of the decimal places of the argument arg
==========================
*
Funktion func Meaning Definition Area
acos --Arcuscosinus [-1,1]
asin --Arcussinus [-1,1]
atan --Arcustangens 
cos --Cosinus 
sin --Sinus 
tan --Tangens 
cosh --Hyperbelcosinus 
sinh --Hyperbelsinus 
tanh --Hyperbeltangens 
exp --Exponential function for basis e [-709, 710]
log --Natural logarithm > 0
log10 --Logarithm for basis 10 > 0
sqrt --Square root >= 0
==========================
时间计算的例子

* date calculation

DATA: ultimo TYPE d.

ultimo      = sy-datum.
ultimo+6(2) = '01'.
ultimo      = ultimo - 1.
WRITE ultimo.

ULINE.

* time calculation

DATA: diff TYPE i,
      seconds TYPE i,
      hours TYPE i.

DATA: t1 TYPE t VALUE '200000',
      t2 TYPE t VALUE '020000'.

diff = t2 - t1.
seconds = diff MOD 86400.
hours = seconds / 3600.

WRITE: / text-001, hours.

ULINE.

* convert date


DATA: odate TYPE d VALUE '19955011',
      idate LIKE odate.

DATA  field(8) TYPE c.

field = odate.   WRITE / field.

CONVERT DATE odate INTO INVERTED-DATE idate.

field = idate.   WRITE / field.

CONVERT INVERTED-DATE idate INTO DATE odate.

field = odate.   WRITE / field.

================================================

数据类型:

Predefined ABAP Types

The table below shows the predefined ABAP types. Additional attributes can be found under value ranges and initial values. TypeLengthStandard lengthDescriptionb1 Byte 1 byte integer (internal)c1 to 65,535 characters1 characterText fieldcursoras ias iDatabase cursord8 characters Date fieldf8 bytes Floating point numberi4 bytes 4 byte integern1 to 65,535 characters1 characterNumeric textp1 to 16 bytes8 bytesPacked numberstringvariable Text strings2 bytes 2 byte integer (internal)t6 characters Time fieldx1 to 65,535 bytes1 byteByte fieldxstringvariable Byte string

原创粉丝点击