matinal:ABAP Conditional Operator

2023-10-24 16:20:55 浏览数 (1)

代码语言:javascript复制
COND:

    DATA(time) = COND string(
          WHEN sy-timlo < '120000' THEN |{ sy-timlo TIME = ISO } AM|
          WHEN sy-timlo > '120000' THEN |{ CONV t( sy-timlo - 12 * 3600 ) TIME = ISO } PM|
          WHEN sy-timlo = '120000' THEN |High Noon|
          ELSE THROW cx_cant_be( ) ).

Switch:

  DATA(number) = SWITCH string( sy-index
                                WHEN 1 THEN 'one'
                                WHEN 2 THEN 'two'
                                WHEN 3 THEN 'three'
                                ELSE THROW cx_overflow( ) ).

0 人点赞