{"id":10006734,"date":"2022-10-26T10:32:32","date_gmt":"2022-10-26T02:32:32","guid":{"rendered":"https:\/\/ityet.com\/?p=10006734"},"modified":"2022-10-26T10:32:32","modified_gmt":"2022-10-26T02:32:32","slug":"%e5%9c%a8-abap-%e5%bc%80%e5%8f%91%e5%b7%a5%e5%85%b7%e8%bf%90%e8%a1%8c%e6%97%b6%e9%94%99%e8%af%af%e6%98%be%e7%a4%ba%e7%95%8c%e9%9d%a2%e9%87%8c%e6%a4%8d%e5%85%a5%e6%80%9d%e5%90%a6%e7%8c%ab","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10006734","title":{"rendered":"\u5728 ABAP \u5f00\u53d1\u5de5\u5177\u8fd0\u884c\u65f6\u9519\u8bef\u663e\u793a\u754c\u9762\u91cc\u690d\u5165\u601d\u5426\u732b"},"content":{"rendered":"<p>\u6211\u4eec\u5f00\u53d1\u4eba\u5458\u6bcf\u5929\u7f16\u7a0b\uff0c\u8c03\u8bd5\u4ee3\u7801\uff0c\u4e0d\u53ef\u907f\u514d\u5730\u4f1a\u9047\u5230\u8fd0\u884c\u65f6\u5f02\u5e38\u548c\u8fd0\u884c\u65f6\u9519\u8bef\u3002\u4e00\u65e6\u8fd0\u884c\u65f6\u9519\u8bef\u53d1\u751f\uff0c\u7a0b\u5e8f\u4f1a\u975e\u6b63\u5e38\u7ec8\u6b62\uff0c\u6807\u5fd7\u7740\u7a0b\u5e8f\u7684\u5b9e\u9645\u6267\u884c\u60c5\u51b5\u540c\u6211\u4eec\u7684\u9884\u671f\u6709\u5dee\u5f02\uff0c\u60f3\u5fc5\u6bcf\u4e00\u4f4d\u5f00\u53d1\u4eba\u5458\u770b\u5230\u8fd0\u884c\u65f6\u9519\u8bef\u5fc3\u60c5\u90fd\u4e0d\u4f1a\u592a\u597d\u3002<\/p>\n<p>\u7b14\u8005\u5e73\u65f6\u4f7f\u7528\u7684\u540e\u53f0\u5f00\u53d1\u8bed\u8a00\u662f ABAP\uff0c\u4f7f\u7528\u7684\u5f00\u53d1 IDE \u662f SAPGUI\uff0c\u56e0\u6b64\u5c1d\u8bd5\u7740\u628a\u601d\u5426\u793e\u533a\u7684\u5409\u7965\u7269\uff0c\u4e00\u53ea\u53ef\u7231\u7684\u601d\u5426\u732b\uff0c\u690d\u5165\u5230 ABAP \u8fd0\u884c\u65f6\u9519\u8bef\u663e\u793a\u754c\u9762\u4e0a\u6765\uff0c\u8bd5\u56fe\u8ba9\u601d\u5426\u732b\u7ed9\u9047\u5230\u8fd0\u884c\u65f6\u9519\u8bef\u7684\u5012\u9709\u7684\u5f00\u53d1\u4eba\u5458\u4e00\u4e1d\u6170\u85c9\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042666535\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>ABAP \u5f00\u53d1\u5de5\u5177\u91cc\u663e\u793a\u8fd0\u884c\u65f6\u9519\u8bef\u7684\u4e8b\u7269\u7801\u4e3a ST22\uff0c\u5176\u6807\u51c6\u5b9e\u73b0 ABAP \u7a0b\u5e8f\u540d\u79f0\u4e3a SAPMS380.<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042666536\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6309\u7167\u7b14\u8005\u6587\u7ae0\u4ecb\u7ecd\u7684\u6b65\u9aa4\u5f00\u53d1\u5b8c\u6210\u540e\uff0c\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<p>\u8fd9\u662f\u5728\u6211\u7684 ABAP \u7cfb\u7edf\u91cc\u7684\u5b9e\u73b0\u6548\u679c\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042666537\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4e0b\u9762\u662f\u8be6\u7ec6\u7684\u5b9e\u73b0\u6b65\u9aa4\u3002<\/p>\n<p>\u6211\u4eec\u4f7f\u7528 ABAP \u589e\u5f3a\u5de5\u5177\uff0c\u5bf9\u8fd9\u4e2a\u7cfb\u7edf\u7ea7\u522b\u7684 ABAP \u62a5\u8868\u8fdb\u884c\u589e\u5f3a\uff0c\u5728\u589e\u5f3a\u91cc\u521b\u5efa\u6211\u4eec\u81ea\u5df1\u7684\u690d\u5165\u601d\u5426\u732b\u7684\u903b\u8f91\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042666538\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6211\u4eec\u5728\u8fd9\u4e2a\u62a5\u8868\u7684 READ_SNAPT \u7684 subroutine \u91cc\u505a\u589e\u5f3a\uff0c\u8fd9\u4e2a subroutine \u5728\u8fd0\u884c\u65f6\u5f02\u5e38\u7684\u5177\u4f53\u5185\u5bb9\uff0c\u4ece\u6570\u636e\u5e93\u8868\u8bfb\u53d6\u5230 ST22 \u754c\u9762\u65f6\u8c03\u7528\uff0c\u56e0\u6b64\u8fd9\u662f\u4e00\u4e2a\u6700\u4f73\u7684\u690d\u5165\u601d\u5426\u732b\u56fe\u6848\u7684 hook \u6240\u5728\uff1a<br \/><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042666539\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u540d\u53eb <code>read_snapt<\/code> \u7684 subroutine\uff0c\u5176\u8f93\u51fa\u53c2\u6570 text_out, \u5b58\u653e\u7684\u5c31\u662f\u663e\u793a\u5728 ST22 \u4e8b\u7269\u7801\u8fd0\u884c\u65f6\u7684\u660e\u7ec6\u4fe1\u606f\uff0c\u56e0\u6b64\u6211\u4eec\u521b\u5efa\u4e00\u4e2a\u9690\u5f0f\u589e\u5f3a\uff0c\u628a\u601d\u5426\u732b\u5bf9\u5e94\u7684\u5b57\u7b26\u683c\u5f0f\u7684\u56fe\u6848\uff0c\u6dfb\u52a0\u5230\u8f93\u51fa\u53c2\u6570 text_out \u5373\u53ef\u3002<\/p>\n<p>\u9690\u5f0f\u589e\u5f3a\u7684\u6e90\u4ee3\u7801\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<pre><code class=\"sql\">ENHANCEMENT 1  ZST22_ENHANCEMENT.    &quot;active version\ndata: lt_god like text_out[] with header line.\n\n  define add_line.\n    append &amp;1 to lt_god.\n  end-of-definition.\n\n  add_line: ''.\n\n  if ttype = 'W'. &quot;\/\/ What happened?\n    insert lines of lt_god into text_out index 1.\n  endif.\nENDENHANCEMENT.<\/code><\/pre>\n<p>\u4ee3\u7801\u5b9e\u73b0\u6709 5 \u4e2a\u5173\u952e\u70b9\uff1a<\/p>\n<ol>\n<li>\u7ed9 subroutine <code>READ_SNAPT<\/code> \u521b\u5efa\u9690\u5f0f\u589e\u5f3a\u3002<\/li>\n<li>\u5b9a\u4e49\u4e00\u4e2a\u5185\u8868 lt_god\uff0c\u7528\u4e8e\u5b58\u50a8\u601d\u5426\u732b\u7684\u5b57\u7b26\u56fe\u6848\u5185\u5bb9\u3002<\/li>\n<li>\u5b9a\u4e49\u4e00\u4e2a\u5b8f\uff0c\u7528\u4e8e\u5c06\u601d\u5426\u732b\u9010\u884c\u7684\u5b57\u7b26\u56fe\u6848\u5185\u5bb9\uff0c\u62fc\u63a5\u5230\u5185\u8868 lt_god \u4e2d\u3002<\/li>\n<li>\u5728\u589e\u5f3a\u5b9e\u73b0\u91cc\u8c03\u7528 <code>add_line<\/code> \u5b8f\uff0c\u5c06\u5b8c\u6574\u7684\u601d\u5426\u732b\u56fe\u6848\u5185\u5bb9\uff0c\u6ce8\u5165\u5230\u5185\u8868 lt_god \u4e2d\u3002<\/li>\n<li>\u5c06\u5185\u8868 lt_god \u5305\u542b\u7684\u601d\u5426\u732b\u56fe\u6848\u5b8c\u6574\u5185\u5bb9\uff0c\u6dfb\u52a0\u5230 subroutine read_snapt \u7684\u8f93\u51fa\u53c2\u6570 <code>text_out<\/code> \u4e2d\uff0c\u8fd9\u6837\u601d\u5426\u732b\u7684\u5b57\u7b26\u56fe\u6848\uff0c\u5c06\u4f1a\u51fa\u73b0\u5728 ST22 \u663e\u793a\u754c\u9762\u7684\u5934\u90e8\u3002<br \/><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042666540\" alt=\"\" title=\"\" loading=\"lazy\"><\/li>\n<\/ol>\n<p>\u81f3\u6b64 ABAP \u7cfb\u7edf\u7684\u589e\u5f3a\u5de5\u4f5c\u5c31\u5b9e\u73b0\u5b8c\u6bd5\u4e86\uff0c\u5269\u4e0b\u7684\u5219\u662f\u5c06\u5b98\u7f51\u4e0b\u8f7d\u7684\u601d\u5426\u732b\u56fe\u7247\uff0c\u8f6c\u6362\u6210\u7eaf\u7cb9\u7684\u5b57\u7b26\u663e\u793a\u5f62\u5f0f\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u5c06\u8fd9\u4e9b\u5b57\u7b26\uff0c\u76f4\u63a5\u7c98\u8d34\u5230\u524d\u6587\u4ecb\u7ecd\u7684 <code>READ_SNAPT<\/code> subroutine \u5b9e\u73b0\u7684\u9690\u5f0f\u589e\u5f3a\u5185\u90e8\u3002<\/p>\n<p>42 \u884c Python \u4ee3\u7801\u5373\u53ef\u641e\u5b9a\uff1a<\/p>\n<pre><code class=\"python\">import base64\nimport re\nfrom io import BytesIO\nfrom PIL import Image\nimport base64\n\nfile_path = 'C:\/temp\/cat.png'\n \nimg = Image.open(file_path)\n\nchar = list('M3NB6Q#OC?7&gt;!:\u2013;. ')\n\n# \u989c\u8272\u503c\u6620\u5c04\u5b57\u7b26\u4e32\ndef get_char(r, g, b, alpha=256):\n    if alpha == 0:\n        return ' '\n\n    grey = (2126 * r + 7152 * g + 722 * b) \/ 10000\n\n    char_idx = int((grey \/ (alpha + 1.0)) * len(char))\n    return char[char_idx]\n\nimg = Image.open(file_path)\n\nimg_widht = img.size[0]\nimg_height = img.size[1]\n\n# \u8bbe\u5b9a\u7f29\u653e\u6bd4\u4f8b\nscale_width = 0.2  # 0.75\nscale_height = 0.2  # 0.5\n\n# \u7f29\u653e\u56fe\u7247\nimg = img.resize((int(img_widht*scale_width),\n                 int(img_height*scale_height)), Image.NEAREST)\n\ntext = ''\nfor i in range(int(img_height*scale_height)):\n    for j in range(int(img_widht*scale_width)):\n        text += get_char(*img.getpixel((j, i)))\n    text += '\/n'\n\nprint(text)<\/code><\/pre>\n<p>\u6211\u4eec\u4f7f\u7528 Python \u63d0\u4f9b\u7684 PIL \u5e93\uff0c\u8bfb\u53d6\u5305\u542b\u601d\u5426\u732b\u7684\u56fe\u7247\u6587\u4ef6\uff0c\u53d6\u5f97\u5176\u5bbd\u5ea6\u548c\u9ad8\u5ea6\u4e4b\u540e\uff0c\u9010\u4e00\u4fbf\u5229\u56fe\u7247\u6bcf\u4e00\u884c\u7684\u6bcf\u4e00\u4e2a\u50cf\u7d20\uff0c\u5c06\u5176 RGB \u503c\u5229\u7528\u516c\u5f0f\u8f6c\u6362\u6210\u7070\u5ea6\u503c\uff0c\u518d\u628a\u8fd9\u4e9b\u7070\u5ea6\u503c\u8f6c\u6362\u6210\u5b57\u7b26\u6570\u7ec4 char \u7684\u7d22\u5f15\u3002\u8fd9\u6837\uff0c\u601d\u5426\u732b\u56fe\u7247\u7684\u6bcf\u4e00\u4e2a\u50cf\u7d20\uff0c\u5c31\u552f\u4e00\u5bf9\u5e94\u5b57\u7b26\u6570\u7ec4\u91cc\u7684\u4e00\u4e2a\u5b57\u7b26\u3002\u6211\u4eec\u628a\u8fd9\u4e9b\u5b57\u7b26\u62fc\u63a5\u5230\u8f93\u51fa\u53d8\u91cf text \u91cc\u3002<br \/><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042666541\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5c06\u4e0a\u8ff0 Python \u4ee3\u7801\u53e6\u5b58\u4e3a\u6210 cat.py \u6587\u4ef6\uff0c\u5229\u7528\u547d\u4ee4\u884c <code>python cat.py &gt; result.txt<\/code>, \u7136\u540e\u5c06 <code>result.txt<\/code> \u7684\u5185\u5bb9\u590d\u5236\u5230 ABAP \u62a5\u8868 SAPMS380 \u7684\u9690\u5f0f\u589e\u5f3a\u5b9e\u73b0\u91cc\u5373\u53ef\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042666542\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6700\u540e\u6211\u4eec\u505a\u4e00\u4e2a\u6d4b\u8bd5\uff0c\u65b0\u5efa\u4e00\u4e2a ABAP \u62a5\u8868\uff0c\u968f\u4fbf\u5199\u4e00\u53e5\u4f1a\u5f15\u8d77\u8fd0\u884c\u65f6\u5f02\u5e38\u7684\u4ee3\u7801\uff0c\u6bd4\u5982 <code>ASSERT 1 = 0<\/code>\uff0c\u7136\u540e\u6267\u884c\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042666543\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6211\u4eec\u4f1a\u7acb\u5373\u8df3\u8f6c\u5230 ST22 \u4e8b\u7269\u7801\u7684\u8fd0\u884c\u65f6\u9519\u8bef\u8f93\u51fa\u754c\u9762\uff0cRuntime Errors \u5b57\u6bb5\u503c\u4e3a <code>ASSERTION_FAILED<\/code>, \u8fd9\u6b63\u662f <code>ASSERT 1 = 0<\/code> \u5f15\u8d77\u7684\u8fd0\u884c\u65f6\u9519\u8bef\u3002<\/p>\n<p>\u4ece\u56fe\u4e2d\u53ef\u4ee5\u770b\u5230\uff0c\u601d\u5426\u732b\u7684\u56fe\u6848\u5df2\u7ecf\u6210\u529f\u5d4c\u5165\u5230 ST22 \u754c\u9762\u4e86\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042666544\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<blockquote><p>\u672c\u6587\u53c2\u4e0e\u4e86<a href=\"https:\/\/segmentfault.com\/a\/1190000042567232\">1024\u7a0b\u5e8f\u5458\u8282<\/a>\uff0c\u6b22\u8fce\u6b63\u5728\u9605\u8bfb\u7684\u4f60\u4e5f\u52a0\u5165\u3002<\/p><\/blockquote>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000042666532\">https:\/\/segmentfault.com\/a\/1190000042666532<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eec\u5f00\u53d1\u4eba\u5458\u6bcf\u5929\u7f16\u7a0b\uff0c\u8c03\u8bd5\u4ee3\u7801\uff0c\u4e0d\u53ef\u907f\u514d\u5730\u4f1a\u9047\u5230\u8fd0\u884c\u65f6\u5f02\u5e38\u548c\u8fd0\u884c\u65f6\u9519\u8bef\u3002\u4e00\u65e6\u8fd0\u884c\u65f6\u9519\u8bef\u53d1\u751f\uff0c\u7a0b\u5e8f\u4f1a\u975e\u6b63\u5e38\u7ec8\u6b62\uff0c [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-10006734","post","type-post","status-publish","format-standard","hentry"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006734","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10006734"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006734\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10006734"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10006734"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10006734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}