{"id":235,"date":"2007-01-25T23:02:15","date_gmt":"2007-01-25T15:02:15","guid":{"rendered":"http:\/\/j178.mtgbb.com\/101"},"modified":"2007-01-25T23:02:15","modified_gmt":"2007-01-25T15:02:15","slug":"%e5%88%a9%e7%94%a8-vb6-%e9%96%8b%e7%99%bc-sap-%e9%80%a3%e7%b5%90%e7%a8%8b%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/j178.mtgbb.com\/?p=235","title":{"rendered":"\u5229\u7528 VB6 \u958b\u767c SAP \u9023\u7d50\u7a0b\u5f0f"},"content":{"rendered":"<p>\u4f5c\u8005\uff1a\u99ae\u5f37<br \/>\n\u51fa\u8655\uff1a <a href=\"http:\/\/comments.yesky.com\/t\/%B7%BD%D6%DB\/6,324\/2200031.shtml\">\u5929\u6975\u958b\u767c<\/a><\/p>\n<p>SAP R\/3 \u5167\u5efa\u958b\u767c\u5e73\u53f0\uff0c\u4f7f\u7528\u7684\u958b\u767c\u8a9e\u8a00\u53eb\u505aABAP\uff0c\u662f\u4e00\u7a2e\u985e\u4f3c\u65bcCOBOL\u7684\u7de8\u7a0b\u8a9e\u8a00\u3002ABAP\u5728\u5831\u8868\u8f38\u51fa\u65b9\u9762\u529f\u80fd\u76f8\u5c0d\u8f03\u5f31\uff08\u53ea\u80fd\u9010\u884c\u5217\u5370\u5728\u756b\u9762\u4e0a\u6216\u8005\u532f\u51fa\u5230Excel\u4e2d\u8655\u7406\uff09\uff0c\u6240\u4ee5\u65e5\u5e38\u5de5\u4f5c\u4e2d\u7d93\u5e38\u9700\u8981\u5728\u5916\u90e8\u958b\u767c\u7a0b\u5e8f\u3002\u901a\u904e\u7a0b\u5f0f\u9023\u7d50\u81ea\u52d5\u8b80\u53d6SAP R\/3\u7684\u8cc7\u6599\u5eab\uff08\u8996\u5716\uff09\uff0c\u5728\u5916\u90e8\u9032\u884c\u8655\u7406\u548c\u5229\u7528Crystal Report \u7b49\u5de5\u5177\u7522\u751f\u7b26\u5408\u570b\u4eba\u7fd2\u6163\u7684\u5831\u8868\u6a23\u5f0f\u3002<\/p>\n<p><!--more--><\/p>\n<p>SAP R\/3\u7684\u9023\u63a5\u65b9\u5f0f\u4e3b\u8981\u6709RFC\u3001IDOC\u3001BAPI\u4e09\u7a2e\uff0c\u672c\u6587\u8981\u4ecb\u7d39\u7684\u662f\u76f8\u5c0d\u6bd4\u8f03\u7c21\u55ae\u7684RFC\uff08Romote Function Call\uff0c\u9060\u7aef\u547c\u53eb\u51fd\u6578\uff09\u3002SAP\u7cfb\u7d71 RFC \u547c\u53eb\u7684\u539f\u7406\u5176\u5be6\u5f88\u7c21\u55ae\uff0c\u6709\u4e00\u4e9b\u985e\u4f3c\u65bc\u4e09\u5c64\u69cb\u67b6\u7684C\/S\u7cfb\u7d71\uff0c\u7b2c\u4e09\u65b9\u7684 Client \u7a0b\u5f0f\u901a\u904e\u9023\u63a5\u547c\u53eb SAP\u5167\u90e8\u7684\u6a19\u6e96\u6216\u81ea\u8a02\u51fd\u6578\uff0c\u53d6\u5f97\u51fd\u6578\u50b3\u56de\u7684\u8cc7\u6599\u5f8c\u9032\u884c\u8655\u7406\u5f8c\u986f\u793a\u6216\u5217\u5370\u3002\u4e0b\u9762\u662fRFC\u547c\u53eb\u7684\u6a21\u578b\uff1a<br \/>\n<a href=\"https:\/\/j178.mtgbb.com\/?attachment_id=502\" rel=\"attachment wp-att-502\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/j178.mtgbb.com\/wp-content\/uploads\/2007\/01\/1139481888.png\" alt=\"SAP\u6a21\u578b\" title=\"1139481888\" width=\"332\" height=\"215\" class=\"alignnone size-full wp-image-502\" \/><\/a><\/p>\n<p>\u4e0b\u9762\u4e3b\u8981\u4ee5 VB6 \u70ba\u4f8b\u4ecb\u7d39\u4e00\u4e0b SAP \u547c\u53eb RFC \u7684\u958b\u767c\u65b9\u5f0f\u3002\u5728SAP client \u7aef(SAP Gui Client) \u5b89\u88dd\u7684\u6642\u5019\uff0c\u6ce8\u610f\u9078\u64c7\u5b89\u88dd\u9644\u52a0\u7684 SDK package\uff08\u6700\u4fdd\u96aa\u662f\u9078\u64c7\u5b8c\u5168\u5b89\u88dd\uff09\u3002RFC \u547c\u53eb\u7a0b\u5f0f\u958b\u767c\uff0c\u4e3b\u8981\u7528\u7684\u662f &#8220;SAP.Functions&#8221; \u9019\u500b\u63a7\u4ef6\uff0c\u900f\u904e\u5143\u4ef6\u5728\u5916\u90e8\u7a0b\u5f0f\u6a21\u64ec SAP Gui Client \u7684\u7528\u6236\u767b\u5165\u548c\u51fd\u6578\u547c\u53eb\uff0c\u7136\u5f8c\u50b3\u56de\u51fd\u6578\u7684\u56de\u50b3\u503c\u3002\u4ee5\u4e0b\u662f\u4e0b\u9762\u7684\u7a0b\u5f0f\u548c\u91cd\u9ede\u8a3b\u89e3\uff08\u5c24\u5176\u662ftest_Click()\uff09\uff1a<\/p>\n<pre lang=\"VB\" line=\"1\">\nPrivate Sub Command1_Click()\n' \u5b9a\u7fa9R\/3\u5e33\u865f\u548c\u5bc6\u78bc\u8b8a\u6578\uff08\u5e33\u865f\u61c9\u5177\u5099 SAP\u7ba1\u7406\u54e1 \u958b\u767c\u57f7\u884c\u51fd\u6578\u7684\u6b0a\u9650\uff09\nDim logname As String * 22, password As String * 22\nCall logonr3(logname, password) ' \u63a7\u5236SAP\u767b\u9304\u754c\u9762\u7a0b\u5f0f\nIf logflag Then ' \u63a7\u5236\u751f\u7522\u3001\u958b\u767c\u7cfb\u7d71\u6307\u6a19\nStatusBar1.Visible = True\nStatusBar1.SimpleText = \"\u6b63\u5728\u767b\u9304SAP R\/3\u7cfb\u7d71...\"\nDim R3AppServer As String, R3Client As String, R3SystemNo As String\nIf Form2.opPRD.Value Then\n' \u4ee5\u4e0b\u670d\u52d9\u5668\u53c3\u6578\u8acb\u6839\u64da\u5ba2\u6236\u914d\u7f6e\u60c5\u6cc1\u66f4\u6539\nR3AppServer = \"10.3.1.4\" ' ERP \u4f3a\u670d\u5668 IP\nR3Client = \"800\"\u3000\u3000\u3000\u3000\u3000'ERP \u96c6\u5718\u4ee3\u78bc\nR3SystemNo = \"00\" '\u751f\u7522\u7cfb\u7d71\u865f\nElse\nR3AppServer = \"10.3.3.1\" ' ERP \u958b\u767c\u5e73\u53f0 IP\nR3Client = \"101\"\nR3SystemNo = \"00\"\nEnd If\nUnload Form2 ' \u91cb\u653e Form2 \uff0c \u6240\u6709\u5143\u4ef6\u53ca\u8b8a\u6578\u4e0d\u53ef\u4f7f\u7528\nSet Functions = CreateObject(\"Sap.Functions\") ' \u5efa\u7acb RFC \u7684\u672c\u6a5f\u5143\u4ef6\nSet Connect = Functions.Connection ' \u8a2d\u7f6e\u9023\u63a5\nConnect.ApplicationServer = R3AppServer ' \u9023\u63a5 Server IP\nConnect.Client = R3Client ' \u9023\u7dda SAP Client ID\nConnect.Language = \"EN\" ' \u9023\u63a5 SAP\u7cfb\u7d71\u754c\u9762\u82f1\u6587\nConnect.User = Trim(logname) ' \u9023\u7ddaSAP\u767b\u5165\u5e33\u865f\nConnect.password = Trim(password) ' \u9023\u7ddaSAP\u767b\u5165\u7528\u6236\u5bc6\u78bc\nConnect.SystemNumber = R3SystemNo ' \u9023\u7dda SAP \u7cfb\u7d71\u865f\u78bc\nIf Not Connect.Logon(0, True) Then ' \u5224\u65b7\u767b\u9304 SAP\nMsgBox \"\u767b\u9304SAP R\/3\u5931\u6557\uff0c\u8acb\u91cd\u65b0\u767b\u9304!\", vbOKOnly + vbExclamation, \"\u7cfb\u7d71\u63d0\u793a\"\nCommand1.SetFocus\nElse ' \u767b\u9304SAP\u6210\u529f\nCommand1.Enabled = False\nCommand2.Enabled = True\ntest.Enabled = True\nEnd If\n\nStatusBar1.SimpleText = \"\"\nStatusBar1.Visible = False\nEnd If\nEnd Sub \n\nPrivate Sub Command2_Click() ' \u8a3b\u92b7SAP\u767b\u9304\nConnect.LogOff\nCommand2.Enabled = False\nCommand1.Enabled = True\ntest.Enabled = False\nEnd Sub \n\nPrivate Sub Command3_Click() ' \u9000\u51faSAP\u9023\u63a5\u7bc4\u4f8b\u7a0b\u5f0f\nIf Form1.Command2.Enabled Then\nMsgBox \"\u9000\u51fa\u524d\u8acb\u7d50\u675fSAP R\/3\u7cfb\u7d71!\", vbOKOnly + vbInformation, \"\u7cfb\u7d71\u63d0\u793a\"\nElse\nEnd\nEnd If\nEnd Sub \n\nPrivate Sub Form_Load()\nCommand2.Enabled = False\ntest.Enabled = False\nlogoflag = False\nEnd Sub\n\nPrivate Sub test_Click() ' SAP RFC \u9060\u7a0b\u547c\u53eb\u7bc4\u4f8b\nDim GetCustomers As Object\nDim Customers As Object\nDim i As Integer\n' \u901a\u904e RFC \u9023\u63a5\u9060\u7aef SAP \u5167\u90e8\u51fd\u6578 RFC_CUSTOMER_GET\n'\u53d6\u5f97\u63a7\u5236\u7684 SAP \u5167\u5efa\u51fd\u6578\u540d\u7a31\nSet GetCustomers = Functions.Add(\"RFC_CUSTOMER_GET\") \n\nGetCustomers.Exports(\"KUNNR\") = \"L001765\" ' \u5411\u51fd\u6578\u5165\u53e3\u9023\u7dda\uff08\u5ba2\u6236\u4ee3\u78bc\uff09\n' \u5411\u51fd\u6578\u5165\u53e3\u50b3\u5165\u67e5\u8a62\u8868\u683c\u540d\u7a31\nSet Customers = GetCustomers.Tables(\"CUSTOMER_T\")\n\nIf GetCustomers.Call Then ' \u6210\u529f\u50b3\u56de\u6642\u986f\u793a\u6240\u6709\u8cc7\u6599\nFor i = 1 To Customers.rowcount\nMsgBox Customers(i, \"KUNNR\")\nNext i\nElse\nMsgBox \" \u641c\u7d22\u932f\u8aa4! \u932f\u8aa4\u8a0a\u606f: \" + GetCustomers.Exception\nEnd If\nEnd Sub\n<\/pre>\n<p>SAP\u7684 RFC \u547c\u53eb \u662f\u5176\u9023\u63a5\u6280\u8853\u4e2d\u6700\u7c21\u55ae\u548c\u5bb9\u6613\u4f7f\u7528\u7684\u4e00\u7a2e\u65b9\u5f0f\uff0c\u8a72\u65b9\u5f0f\u958b\u767c\u6bd4\u8f03\u7c21\u4fbf\uff0c\u7279\u5225\u9069\u5408\u65bc\u5916\u90e8\u5831\u8868\u958b\u767c\uff0c\u4f46\u5c0d\u65bc\u5927\u91cf\u8cc7\u6599\u7684\u67e5\u8a62\u6548\u7387\u76f8\u5c0d\u8f03\u4f4e\u3002\u5927\u5bb6\u5728\u719f\u7df4\u638c\u63e1\u5f8c\uff0c\u53ef\u4ee5\u9032\u4e00\u6b65\u5b78\u7fd2\u9ad8\u7d1a\u7684IDOC\u548cBAPI \u9023\u63a5\u958b\u767c\u6280\u8853\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff1a\u99ae\u5f37 \u51fa\u8655\uff1a \u5929\u6975\u958b\u767c SAP R\/3 \u5167\u5efa\u958b\u767c\u5e73\u53f0\uff0c\u4f7f\u7528\u7684\u958b\u767c\u8a9e\u8a00\u53eb\u505aABAP\uff0c\u662f\u4e00\u7a2e\u985e\u4f3c\u65bcCOBOL &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[58,31],"class_list":["post-235","post","type-post","status-publish","format-standard","hentry","category-others","tag-sap","tag-vb6"],"_links":{"self":[{"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/posts\/235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=235"}],"version-history":[{"count":0,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/posts\/235\/revisions"}],"wp:attachment":[{"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}