ABAP如何檢查字串是否為日期或時間格式

2021-08-14 12:13:23 字數 763 閱讀 9993

1、下面函式是檢查日期的合法性的函式

call function 'date_check_plausibility'

exporting

date = v_date

exceptions

plausibility_check_failed = 1

others = 2.

if sy-subrc ne 0. "如果返回非0,則日期不合法..

endif. 

2、下面函式是檢查時間合法性的函式

call function 'time_check_plausibility'

exporting

time = v_time

exceptions

plausibility_check_failed = 1

others = 2.

if sy-subrc ne 0. "如果返回非0,則時間不合法..

endif.

注意:以上兩個函式,輸入引數如果不是日期或時間型別的話,會dump,比如隨便輸「abcdef」

也可以用下面型別轉換的方法來判斷

data: lv_date type sy-datum,

lv_c(8).

lv_c = 'abcd『.

lv_date = lv_c.

if lv_date = 0.

write: lv_date,'錯誤'.

else.

write: lv_date,'正確'.

endif.

檢查字串是否相等

在j a中可以使用 equals 方法判斷兩個字串是否相等。s.equals t 如果字串s與字串t相等,則返回true 否則,返回false。想要檢測兩個字串是否相等,而不區分大小寫,可以使用equalsignorecase方法 hello equalsignorecase hello 一定不要使...

jquery如何檢查字串中是否包含指定字元?

方法 使用indexof 或lastindexof 來檢查,它們都可返回指定字元在字串中的位置,如果字串不包含指定字元,則返回 1 因此只需判斷返回值是否大於等於即可,例 if 字串.indexof 字元 0 相關推薦 jquery 教程 方法一 使用indexof 和lastindexof 方法 ...

檢查字串是否可運算的數字

在網上查到有兩種辨別字串是否為數字的方法 1.function checkinput return true 2.js自帶的isnan 方法 但是如果要檢查字串是否為能運算的數字時,兩種方法都有一定的缺點 方法1是運用正規表示式判斷,雖然能判斷是否為數字,但是對於負數,小數則無法判斷 方法2是js自...