{"id":1483,"date":"2011-10-13T15:52:45","date_gmt":"2011-10-13T13:52:45","guid":{"rendered":"http:\/\/www.karadere.com\/blog\/?p=1483"},"modified":"2011-10-13T15:52:45","modified_gmt":"2011-10-13T13:52:45","slug":"sap-abap-try-catch-ile-hata-yakalamak-nasil-hata-yakalanir-dump-onlemek-cx_ai_system_fault-in-rfc-hatasini-yakalamak","status":"publish","type":"post","link":"https:\/\/www.karadere.com\/blog\/sap-abap-try-catch-ile-hata-yakalamak-nasil-hata-yakalanir-dump-onlemek-cx_ai_system_fault-in-rfc-hatasini-yakalamak.html","title":{"rendered":"Sap Abap Try Catch ile hata yakalamak, nas\u0131l hata yakalan\u0131r dump \u00f6nlemek ? CX_AI_SYSTEM_FAULT in RFC hatas\u0131n\u0131 yakalamak ?"},"content":{"rendered":"<p><span style=\"font-family: Arial monospaced for SAP;\">\u00a0<\/span>\u00a0<span style=\"font-family: Arial monospaced for SAP;\">Basit kullan\u0131m\u0131 ile try ile hata yakalamak a\u015fa\u011f\u0131daki gibidir. <\/span><\/p>\n<p><span style=\"font-family: Arial monospaced for SAP;\">ty ile yakalay\u0131p catch ile i\u00e7eri\u011fi yazd\u0131rabilirsiniz.<\/span><\/p>\n<p><span style=\"font-family: Arial monospaced for SAP;\">\u00a0<\/span>\u00a0<\/p>\n<p><span style=\"font-family: Arial monospaced for SAP;\">TRY.<br \/>\n\u00a0\u00a0\u00a0 CALL METHOD o1-&gt;m1.<br \/>\n\u00a0\u00a0\u00a0 PERFORM f1.<br \/>\n\u00a0 CATCH cx_root.\u00a0 &#8220;Handler for all exceptions<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8221; ABAP code(What to do when error occures)&#8230;&#8230;..<br \/>\nENDTRY.<\/p>\n<p>FORM f1 RAISING cx_my.<br \/>\n\u00a0 TRY.<br \/>\n\u00a0\u00a0\u00a0 IF &#8230;&#8230; RAISE EXCEPTION TYPE cx_my2. ENDIF.<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0 CALL METHOD o1-&gt;m3.<br \/>\n\u00a0 CATCH cx_my1 cx_my3 INTO ex.<br \/>\n\u00a0\u00a0\u00a0 RAISE EXCEPTION TYPE cx_my4.<br \/>\n\u00a0 CATCH cx_my4.<br \/>\n\u00a0\u00a0\u00a0\u00a0 &#8220;Handler for exceptions of type cx_my4<br \/>\n\u00a0\u00a0\u00a0\u00a0 &#8221; ABAP code(What to do when error occures)&#8230;&#8230;..<br \/>\n\u00a0 CLEANUP.<br \/>\n\u00a0\u00a0\u00a0\u00a0 &#8220;Cleanup section, used to restore to a consistant state<br \/>\n\u00a0\u00a0\u00a0\u00a0 &#8221; ABAP code&#8230;&#8230;..<br \/>\n\u00a0 ENDTRY.<br \/>\nENDFORM.<\/span><\/p>\n<p><span style=\"font-family: Arial monospaced for SAP;\"><br \/>\n<\/span><span style=\"font-family: Arial monospaced for SAP;\">&#8220;&amp;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/span><\/p>\n<p><span style=\"font-family: Arial monospaced for SAP;\">&#8220;&amp; <\/span><\/p>\n<p><span style=\"font-family: Arial monospaced for SAP;\">&#8220;&amp;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/span><\/p>\n<p><span style=\"font-family: Arial monospaced for SAP;\"><\/span><\/p>\n<p>\u00a0 <!-- SPAN { font-family: \"Courier New\"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S32 { color: #3399FF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } -->REPORT\u00a0\u00a0TRYORNEGI.<\/p>\n<p>parameters\u00a0NUMBER\u00a0type\u00a0I.<\/p>\n<p>data\u00a0RESULT\u00a0type\u00a0P\u00a0decimals\u00a02.<br \/>\ndata\u00a0OREF\u00a0type\u00a0ref\u00a0to\u00a0CX_ROOT.<br \/>\ndata\u00a0TEXT\u00a0type\u00a0STRING.<\/p>\n<p>start-of-selection.<\/p>\n<p>\u00a0\u00a0write:\u00a0\/\u00a0&#8216;Testing\u00a0division\u00a0and\u00a0Sqare\u00a0root\u00a0with&#8217;,\u00a0NUMBER.<br \/>\n\u00a0\u00a0uline.<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0try.<br \/>\n\u00a0\u00a0\u00a0\u00a0if\u00a0ABS(\u00a0NUMBER\u00a0)\u00a0&gt;\u00a0100.<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0raise\u00a0exception\u00a0type\u00a0CX_DEMO_ABS_TOO_LARGE.<br \/>\n\u00a0\u00a0endif.<br \/>\n\u00a0\u00a0\u00a0\u00a0try.<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0RESULT\u00a0=\u00a0\u00a01\u00a0\/\u00a0NUMBER.<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0write:\u00a0\/\u00a0&#8216;Result\u00a0of\u00a0division:&#8217;,\u00a0RESULT.<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0RESULT\u00a0=\u00a0SQRT(\u00a0NUMBER\u00a0).<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0write:\u00a0\/\u00a0&#8216;Result\u00a0of\u00a0square\u00a0root:&#8217;,\u00a0RESULT.<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0catch\u00a0CX_SY_ZERODIVIDE\u00a0into\u00a0OREF.<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0TEXT\u00a0=\u00a0OREF-&gt;GET_TEXT(\u00a0).<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0cleanup.<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0clear\u00a0RESULT.<br \/>\n\u00a0\u00a0endtry.<br \/>\n\u00a0\u00a0\u00a0\u00a0catch\u00a0CX_SY_ARITHMETIC_ERROR\u00a0into\u00a0OREF.<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0TEXT\u00a0=\u00a0OREF-&gt;GET_TEXT(\u00a0).<br \/>\n\u00a0\u00a0\u00a0\u00a0catch\u00a0CX_ROOT\u00a0into\u00a0OREF.<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0TEXT\u00a0=\u00a0OREF-&gt;GET_TEXT(\u00a0).<br \/>\n\u00a0\u00a0endtry.<br \/>\n\u00a0\u00a0if\u00a0not\u00a0TEXT\u00a0is\u00a0initial.<br \/>\n\u00a0\u00a0\u00a0\u00a0write\u00a0\/\u00a0TEXT.<br \/>\n\u00a0\u00a0endif.<br \/>\n\u00a0\u00a0write:\u00a0\/\u00a0&#8216;Final\u00a0result:&#8217;,\u00a0RESULT.<\/p>\n<p>\u00a0&#8220;&amp;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>&#8220;&amp;\u00a0 CX_AI_SYSTEM_FAULT ile hata yakalamak<\/p>\n<p>\u00a0&#8220;&amp;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p><a href=\"http:\/\/wiki.sdn.sap.com\/wiki\/display\/Snippets\/How+to+handle+CX_AI_SYSTEM_FAULT+in+RFC\">http:\/\/wiki.sdn.sap.com\/wiki\/display\/Snippets\/How+to+handle+CX_AI_SYSTEM_FAULT+in+RFC<\/a><\/p>\n<p><a href=\"https:\/\/www.sdn.sap.com\/irj\/scn\/thread?threadID=1070418&amp;tstart=120\">https:\/\/www.sdn.sap.com\/irj\/scn\/thread?threadID=1070418&amp;tstart=120<\/a><\/p>\n<p>Description<\/p>\n<div>\n<div>Courtesy of OLE from the above thread. This is very useful when calling a Client Proxy. The SAP help isn&#8217;t very clear on how to handle system exceptions in an RFC. I was getting the warning &#8220;The exception CX_AI_SYSTEM_FAULT is neither caught nor is declared in the RASING clause of &lt;function&gt;&#8221; when I checked the function in SE37.<\/div>\n<\/div>\n<p>data: lo_system_ex type ref to cx_ai_system_fault,<br \/>\nlo_app_ex type ref to cx_ai_application_fault,<br \/>\nl_sys_exc TYPE REF TO cx_ai_system_fault,<br \/>\nl_app_exc TYPE REF TO cx_ai_application_fault,<br \/>\nl_exception_msg type string.<br \/>\n\u00a0<br \/>\n\u00a0<br \/>\ntry.<br \/>\ncreate object l_wsproxy.<br \/>\n\u00a0<br \/>\ntry.<br \/>\ncall method l_wsproxy-&gt;execute_synchronous<br \/>\nexporting<br \/>\noutput = ****<br \/>\nimporting<br \/>\ninput = ****.<br \/>\ncatch cx_ai_system_fault into l_sys_exc.<br \/>\ncatch cx_ai_application_fault into l_app_exc.<br \/>\nendtry.<br \/>\n\u00a0<br \/>\ncatch cx_ai_system_fault into l_sys_exc.<br \/>\nendtry.<br \/>\nl_exception_msg = l_sys_exc-&gt;get_text( ).<br \/>\nwrite l_exception_msg.<\/p>\n","protected":false},"excerpt":{"rendered":"<p> Basit kullan\u0131m\u0131 ile try ile hata yakalamak a\u015fa\u011f\u0131daki gibidir. <\/p>\n<p>ty ile yakalay\u0131p catch ile i\u00e7eri\u011fi yazd\u0131rabilirsiniz.<\/p>\n<p>TRY.<br \/>\n    CALL METHOD o1->m1.<br \/>\n    PERFORM f1.<br \/>\n  CATCH cx_root.  &#8220;Handler for all exceptions<br \/>\n       &#8221; ABAP code(What to do when error occures)&#8230;&#8230;..<br \/>\nENDTRY.<\/p>\n<p>FORM f1 RAISING cx_my.<br \/>\n  TRY.<br \/>\n    IF &#8230;&#8230; RAISE EXCEPTION TYPE cx_my2. ENDIF.<br \/>\n      CALL METHOD o1->m3.<br \/>\n  CATCH cx_my1 cx_my3 INTO ex.<br \/>\n    RAISE EXCEPTION TYPE cx_my4.<br \/>\n  CATCH cx_my4.<br \/>\n     &#8220;Handler for exceptions of type cx_my4<br \/>\n     &#8221; ABAP code(What to do when error occures)&#8230;&#8230;..<br \/>\n  CLEANUP.<br \/>\n     &#8220;Cleanup section, used to restore to a consistant state<br \/>\n     &#8221; ABAP code&#8230;&#8230;..<br \/>\n  ENDTRY.<br \/>\nENDFORM.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":"","_links_to":"","_links_to_target":""},"categories":[87,88,45],"tags":[395,649,1103,2101,2340],"class_list":["post-1483","post","type-post","status-publish","format-standard","hentry","category-advanced-business-application-programming","category-abap-sap","category-sap","tag-abap","tag-catch","tag-hata","tag-try","tag-yakalamak","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"aioseo_notices":[],"views":4839,"_links":{"self":[{"href":"https:\/\/www.karadere.com\/blog\/wp-json\/wp\/v2\/posts\/1483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.karadere.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.karadere.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.karadere.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.karadere.com\/blog\/wp-json\/wp\/v2\/comments?post=1483"}],"version-history":[{"count":0,"href":"https:\/\/www.karadere.com\/blog\/wp-json\/wp\/v2\/posts\/1483\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.karadere.com\/blog\/wp-json\/wp\/v2\/media?parent=1483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.karadere.com\/blog\/wp-json\/wp\/v2\/categories?post=1483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.karadere.com\/blog\/wp-json\/wp\/v2\/tags?post=1483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}