当前位置: 代码迷 >> 综合 >> SAP-ABAP-一些很方便的小运算及小函数
  详细解决方案

SAP-ABAP-一些很方便的小运算及小函数

热度:39   发布时间:2023-12-13 04:18:20.0

A = 3.14

B= -3.1415

1.四舍五入取整

CEIL( A ) = 3.

2.向下取整

FLOOR( A ) = 3 .

3.取绝对值

ABS( B ) = 3.1415 .

4.字符串长度

STRLEN( A ) = 4

5.除法取整

A DIV B = 0 .

B DIV A = -1 .

6.除法取余

A MOD B

7.内表行数

DATA: LV_LINES TYPE INT4.
LV_LINES = LINES( GT_OUT[] ).

8.取UUID

cl_system_uuid=>if_system_uuid_static~create_uuid_c22( RECEIVING uuid = DATA(lv_uuid_c22) ).
cl_system_uuid=>if_system_uuid_static~create_uuid_x16( RECEIVING uuid = DATA(lv_uuid_x16) ).
cl_system_uuid=>if_system_uuid_static~create_uuid_x16( RECEIVING uuid = DATA(lv_uuid_c26) ).
cl_system_uuid=>if_system_uuid_static~create_uuid_x16( RECEIVING uuid = DATA(lv_uuid_c32) ).
cl_system_uuid=>if_system_uuid_static~create_uuid_x16( RECEIVING uuid = DATA(lv_uuid_c36) )."取不同位数的UUID

9.快速展示报表,无fieldcat

  cl_demo_output=>display( <itab> ) .

10.抓异常的万能异常

DATA lv_oref TYPE REF TO cx_root.
TRY .
。。。              
    CATCH cx_root INTO lv_oref.

11.选择屏幕假必输,选择屏幕带必输的勾,但是实际上可以不输入数据


initialization.
  LOOP AT SCREEN.
    IF screen-NAME = 'p_gjahr' OR screen-NAME = 'p_monat'.
      screen-required = '2'.
    ENDIF.
    MODIFY SCREEN.
  ENDLOOP.
 

12. 直接修改程序不传请求:程序RS_REPAIR_SOURCE的FORM authority_check 

13. 程序检查报错直接返回选择屏幕不往后面执行


    IF s_budat[] IS INITIAL.
      MESSAGE '过账日期必输' TYPE 'S'  DISPLAY LIKE  'E'.
      LEAVE LIST-PROCESSING AND RETURN TO SCREEN 0.
    ENDIF.