首页 > 其他分享 >ZCX_STATIC_CHECK

ZCX_STATIC_CHECK

时间:2023-05-18 23:23:22浏览次数:42  
标签:exception zcx check cx static go STATIC ZCX CHECK

Introduction

Class: ZCX_STATIC_CHECK

  • Enhance Exception Class: CX_STATIC_CHECK
  • Easy to trace exception

History

VersionDateNameDescription
V001 2020/10/8 Huang Roy 初版
V002 2020/10/22 Huang Roy Add Method: GET_SHOW_MSG_STR

Class Screen

  • Long Text: 設定如文章一般的超長訊息
  • 左側為Text ID,右為Text

  • 請 不要 修改此Exception Class,以繼承方式加上新的textid或是直接自訂訊息
  • 繼承的Exception Class皆可以upcasting to ZCX_STATIC_CHECK
  • Exception Class一定要是YCX_ or ZCX_ 開頭

RAISE Syntax

  • textid未設定,預設是使用exception class同名text id
  • msg1~msg4為自訂訊息,在text內可以用 &msgN& 作為變數附加訊息
RAISE EXCEPTION TYPE zcx_static_check
  EXPORTING
    textid = xx
    msg1   = xx
    msg2   = xx
    msg3   = xx
    msg4   = xx.

Public Method

SHOW

  • 顯示錯誤訊息視窗(Background Job顯示於spool)
ParameterLevelPass ValueOptionalType(Ref To)DefaultDescription
I_LONG Importing   X ABAP_BOOL   Show Long Text

Sample 1: 使用textid(zcx_static_check=>no_data)

  • 由於是static check,須在methods後加上RAISING語法,未加時check syntax會提示。
  • 如果沒有Raising指定exception作為通道,在實際執行時會直接short dump

Click to Expand Code
CLASS lcl_test DEFINITION FINAL.
  PUBLIC SECTION.
    CLASS-METHODS trigger_exception RAISING zcx_static_check.
ENDCLASS.
CLASS lcl_test IMPLEMENTATION.
  METHOD trigger_exception.
    RAISE EXCEPTION TYPE zcx_static_check
      EXPORTING
        textid = zcx_static_check=>no_data.
  ENDMETHOD.
ENDCLASS.
DATA: go_cx TYPE REF TO zcx_static_check.
START-OF-SELECTION.
  TRY.
      lcl_test=>trigger_exception( ).
    CATCH zcx_static_check INTO go_cx.
      go_cx->show( ).
  ENDTRY.

Result(左dialog,右backgroun。如訊息,出錯於YQQTEST第17列) 


Sample 2: 使用textid+自訂message(zcx_static_check=>no_data_memo)

Click to Expand Code
CLASS lcl_test DEFINITION FINAL.
  PUBLIC SECTION.
    CLASS-METHODS trigger_exception RAISING zcx_static_check.
ENDCLASS.
CLASS lcl_test IMPLEMENTATION.
  METHOD trigger_exception.
    RAISE EXCEPTION TYPE zcx_static_check
      EXPORTING
        textid = zcx_static_check=>no_data_memo
        msg1   = 'QQQQQ'.
  ENDMETHOD.
ENDCLASS.
DATA: go_cx TYPE REF TO zcx_static_check.
START-OF-SELECTION.
  TRY.
      lcl_test=>trigger_exception( ).
    CATCH zcx_static_check INTO go_cx.
      go_cx->show( ).
  ENDTRY.

Result


Sample 3: 完全自訂message

Click to Expand Code
CLASS lcl_test DEFINITION FINAL.
  PUBLIC SECTION.
    CLASS-METHODS trigger_exception RAISING zcx_static_check.
ENDCLASS.
CLASS lcl_test IMPLEMENTATION.
  METHOD trigger_exception.
    RAISE EXCEPTION TYPE zcx_static_check
      EXPORTING
        msg1 = 'Q'
        msg2 = 'Q'
        msg3 = 'Q'
        msg4 = 'Q'.
  ENDMETHOD.
ENDCLASS.
DATA: go_cx TYPE REF TO zcx_static_check.
START-OF-SELECTION.
  TRY.
      lcl_test=>trigger_exception( ).
    CATCH zcx_static_check INTO go_cx.
      go_cx->show( ).
  ENDTRY.

Result


Sample 4: Global Class

  • 同local class,只是raising在Exception設定,未設定時check syntax會提示。


Click to Expand Code

Method Code

METHOD trigger_exception.
  RAISE EXCEPTION TYPE zcx_static_check
    EXPORTING
      textid = zcx_static_check=>no_data.
ENDMETHOD.

Report Code:

DATA: go_cx TYPE REF TO zcx_static_check.
START-OF-SELECTION.
  TRY.
      ycl_qqtest=>trigger_exception( ).
    CATCH zcx_static_check INTO go_cx.
      go_cx->show( ).
  ENDTRY.

Result


GET_SHOW_MSG

  • 取得Method: SHOW顯示的所有文字
ParameterLevelPass ValueOptionalType(Ref To)DefaultDescription
I_LONG Importing   X ABAP_BOOL   Show Long Text
RT_MSG Returning X   CHAR80_T   Show Message

Sample:

Click to Expand Code
CLASS lcl_test DEFINITION FINAL.
  PUBLIC SECTION.
    CLASS-METHODS trigger_exception RAISING zcx_static_check.
ENDCLASS.
CLASS lcl_test IMPLEMENTATION.
  METHOD trigger_exception.
    RAISE EXCEPTION TYPE zcx_static_check
      EXPORTING
        textid = zcx_static_check=>no_data.
  ENDMETHOD.
ENDCLASS.
DATA: go_cx TYPE REF TO zcx_static_check,
      gt_msg TYPE char80_t.
START-OF-SELECTION.
  TRY.
      lcl_test=>trigger_exception( ).
    CATCH zcx_static_check INTO go_cx.
      gt_msg = go_cx->get_show_msg( ).
  ENDTRY.

Result(Debug Mode)


GET_SHOW_MSG_STR

  • 取得Method: SHOW顯示的所有文字(String型)(V002 Add)
ParameterLevelPass ValueOptionalType(Ref To)DefaultDescription
I_LONG Importing   X ABAP_BOOL   Show Long Text
R_MSG Returning X   STRING   Show Message

Sample:

Click to Expand Code
CLASS lcl_test DEFINITION FINAL.
  PUBLIC SECTION.
    CLASS-METHODS trigger_exception RAISING zcx_static_check.
ENDCLASS.
CLASS lcl_test IMPLEMENTATION.
  METHOD trigger_exception.
    RAISE EXCEPTION TYPE zcx_static_check
      EXPORTING
        textid = zcx_static_check=>no_data.
  ENDMETHOD.
ENDCLASS.
DATA: go_cx TYPE REF TO zcx_static_check,
      g_msg TYPE string.
START-OF-SELECTION.
  TRY.
      lcl_test=>trigger_exception( ).
    CATCH zcx_static_check INTO go_cx.
      g_msg = go_cx->get_show_msg_str( ).
  ENDTRY.

Result(Debug Mode)


技術提供: Gitea 版本: 1.15.5 頁面: 456ms 樣板: 2ms   繁體中文(台灣)  授權條款 API 網站 Go1.16.9

标签:exception,zcx,check,cx,static,go,STATIC,ZCX,CHECK
From: https://www.cnblogs.com/TYAING/p/17413589.html

相关文章

  • 泛微CheckServer.jsp注入
    /mobile/plugin/CheckServer.jsp通过urldecode可以绕过泛微waf......
  • abc269_f Numbered Checker 题解
    NumberedChecker题意有一个\(n\timesm\)的方格矩阵,左上角是\((1,1)\),右下角是\((n,m)\),每个方格中都有一个整数,其中\((x,y)\)中的数字为:如果\(x+y\)是奇数,则\((x,y)\)中的数字为\(0\)。否则,\((x,y)\)中的数字为\((x-1)\timesm+y\)。有\(Q\)组询问,每组......
  • bits of static binary analysis阅读随笔
    标题是bitsofstaticbinaryanalysis,意思为碎片化粒度的静态二进制分析作为安全研究人员,如何从复杂系统的二进制文件中挖掘出漏洞是个难题在这篇随笔中,阅读bitsofstaticbinaryanalysis演讲内容,学习查找二进制程序中的漏洞,并快速找到它们静态分析,使用VEX和CFG来表示分析......
  • [ABC269F] Numbered Checker
    [ABC269F]NumberedChecker题意有一个\(n\timesm\)的矩阵,有:\(a_{ij}=\begin{cases}(i-1)m+j&i+j\equiv0\pmod{2}\\0&i+j\equiv1\pmod{2}\end{cases}\)给定\(a,b,c,d\)问从\((a,c)\)到\((b,d)\)的数字和是多少。思路数学,我们可以发现,每一行可以表......
  • Java static、final、static final 以及final static区别
    一、相同点都是Java修饰符二、不同点finalfinal修饰类:表示该类不能被继承;final修饰方法:表示该方法不能被重写;final修饰方法参数:表示在变量的编译期中它的值不能被改变;final修饰变量:包括成员变量和局部变量,该变量只能被赋值一次且它的值无法被改变。对于成员变量来讲......
  • Java:static关键字
    (一)static关键字的基本用法1.static关键字基本概念我们可以一句话来概括:方便在没有创建对象的情况下来进行调用。也就是说:被static关键字修饰的不需要创建对象去调用,直接根据类名就可以去访问。2.static关键字修饰类Java里面static一般用来修饰成员变量或函数。但有一种特殊用......
  • C++:全局变量和static变量初始化
    (一)全局变量全局变量、文件域中的静态变量、类中的成员静态变量在main函数执行前初始化;局部变量中的静态变量在第一次调用时初始化。C++保证,全局变量在main函数第一次使用它之前,就把它初始化好。(可以直接理解成在main函数执行前就初始化好)但这个初始化可细分为:编译时初始化和运......
  • AntDeisgn中checkbox group的使用
    <template><!--弹窗类型选择--><div><a-modal:visible="state.modalAttr.visible"title="规选类型"width="680px"@ok="showModal"@cancel="hideModal"><a-checkbox......
  • ERROR: Command errored out with exit status 1: python setup.py egg_info Check th
     001、在利用python2.7环境下利用pip安装pyfaidx模块时报如下错误:ERROR:Commanderroredoutwithexitstatus1:pythonsetup.pyegg_infoCheckthelogsforfullcommandoutput. 002、查看pip版本[root@PC1pip]#pip--versionpip20.3.4from/usr/lib/pyth......
  • git status check
    check-outdated-files.sh if[-n"$(gitstatus--porcelain)"]; then  gitdiff  forfin$(gitls-files--modified); do    echo"::warning::$fmaybeoutdated"  done  forfin$(gitls-files--others--exclude-standar......