一、CONCATENATE 连接字符时换行
CONCATENATE 'FIELD1' cl_ABAP_char_utilities=>cr_lf 'FIELD2' INTO TEXT.
“这个时候把TEXT写到EXCEL里的时候,FIELD1和FIELD2之间会换行.同ALT+回车.
二、让程序停顿30秒钟
方法一:WAIT UP TO 3 SECONDS .
方法二:FM:RZL_SLEEP 这个FM最多只能SLEEP5秒,如果多于5秒可以用DO循环
call function 'RZL_SLEEP'
exporting
seconds = 5
exceptions
argument_error = 1
others = 2.
if sy-subrc <> 0.
clear msgstr.
concatenate sy-datum sy-uzeit 'sleep³ö´í' into msgstr separated by space.
write: /, msgstr.
endif.
三、定义RANGE表的两种方法:
1、DATA: l_hkont LIKE RANGE OF bseg-hkont.
2、RANGES <seltab> FOR <f>.
四、把工具栏上的某一个按钮隐藏()
SET PF-STATUS 'GUI_STATUS_0300' EXCLUDING 'NSAVE'. "把GUI 状态(GUI_STATUS_0300)上的NSAVE按钮隐藏
当需要隐藏多个按钮的时候,需要定义一个内表,代码如下:
DATA: fcode LIKE sy-ucomm OCCURS 0 WITH HEADER LINE.
IF lv_year <> sy-datum(4).
APPEND 'MODY' TO fcode.
APPEND 'ADD' TO fcode.
SET PF-STATUS 'SET_PF_0100' EXCLUDING fcode.
ENDIF.
五、FORM的多次调用:
如下PERFORM会调用三次FORM,第一次把1123990000的值传给FORM,并写到内表回传,
第二次把2202000000的值传给FORM并写到内表等。
PERFORM frm_add_hkont TABLES s_lfa_hkont USING: '1123990000','2202000000','2202010000'.
FORM frm_add_hkont TABLES p_hkont STRUCTURE s_lfa_hkont USING value(p_0158).
CLEAR p_hkont.
p_hkont-sign = 'I'.
p_hkont-option = 'BT'.
p_hkont-low = p_0158.
p_hkont-high = p_0158.
APPEND p_hkont.
ENDFORM.
六、在ABAP中将负号提前的方面
第一种:
PERFORM change_qty USING l_srqty
CHANGING it_inv-srqty.
FORM change_qty USING p_qty
CHANGING p_qty1.
p_qty1 = p_qty.
SHIFT p_qty1 LEFT DELETING LEADING ' '.
SHIFT p_qty1 UP TO '-' LEFT CIRCULAR.
CONDENSE p_qty1 NO-GAPS.
ENDFORM. " change_qty
第二种:
目的:将字符串尾的负号放在字符串首
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = itab-amunt.
七、检查字符串是否全部是数值
方法一:
DATA:BB TYPE I.
PARAMETERS P_CHAR(20) TYPE C.
CATCH SYSTEM-EXCEPTIONS CONVERSION_ERRORS = 1.
MOVE P_CHAR TO BB.
ENDCATCH.
IF SY-SUBRC = 1 .
WRITE '这不是个数字'.
ELSE.
WRITE '这是个数字的字符'.
ENDIF.
方法二:
data: l_str(10) type c value '0000'.
DATA: l_type like DD01V-DATATYPE .
CALL FUNCTION 'NUMERIC_CHECK'
EXPORTING
string_in = l_str
IMPORTING
* STRING_OUT =
HTYPE = l_type .
if l_type = 'CHAR' .
WRITE: '这不是个数字'.
ELSE.
WRITE: '这是个数字的字符'.
ENDIF.
八、LOOP 的另外一种用法
LOOP AT it_value TRANSPORTING NO FIELDS WHERE opt = 'BT'.
EXIT.
ENDLOOP.