在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
RFC
begin (*assigntheexistingconnectiontothe*) (*componentSAPFunctions1*) SAPFunctions1.Connection:=Connection; Funct:=SAPFunctions1.add('RFC_READ_TABLE'); Funct.exports('QUERY_TABLE').value:='CSKT'; ifnotFunct.callthen showMessage(Funct.exception) elsebegin Table:=Funct.tables.item('DATA'); grid.rowCount:=Table.rowcount+1; grid.cells[0,0]:='Client'; grid.cells[1,0]:='CostCent-No'; grid.cells[2,0]:='CostCent-Des.'; forr:=1togrid.rowCount-1dobegin txt:=Table.value(r,1); grid.cells[0,r]:=copy(txt,0,3); grid.cells[1,r]:=copy(txt,9,10); grid.cells[2,r]:=copy(txt,27,20); end; grid.visible:=True; end; end; end; end. BAPI/RFCwithDelphi(系列之六)--TSAPFunctions使用BAPI创建PO(有登录对话框的delphi源代码) 1、新建一个Form,并在form上添加下列控件 ComponentFunction SAPFunctions1SAPActiveX-componenttoconnectRFC/BAPI Button1Buttontostarttheprocedure Panel1notrelevant! 2、源代码如下(使用BAPI_PO_CREATE函数创建PO) unitPO_Create; interface uses Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,StdCtrls,OleCtrls,SAPFunctionsOCX_TLB,ExtCtrls; type TForm1=class(TForm) SAPFunctions1:TSAPFunctions; Button1:TButton; Panel1:TPanel; procedureButton1Click(Sender:TObject); private {Private-Deklarationen} public {Public-Deklarationen} end; var Form1:TForm1; Funct, Header, POItems, Schedules, ItemsRow, SchedulesRow:Variant; implementation {$R*.DFM} procedureTForm1.Button1Click(Sender:TObject); varMLDText:String; begin Button1.Enabled:=false; Panel1.Caption:='RFCistrunning,pleasewait.....'; (*definefunction*) Funct:=sapFunctions1.add('BAPI_PO_CREATE'); (***definetables,usestructuresofthedictionary***) (*tableforthepurcaseorderheader*) Header:=funct.exports('PO_HEADER'); (*tableofthepurcaseorderitems*) POItems:=funct.tables.item('PO_ITEMS'); (*tableoftheschedules*) Schedules:=funct.tables.item('PO_ITEM_SCHEDULES'); (***fillingthePO_Header-table***) (*purcasingdocumenttype*) Header.Value[2]:='NB'; (*purcasingdocumentcategory*) Header.Value[3]:='F'; (*purcasingorganisation*) Header.Value[5]:='600'; (*purcasinggroup*) Header.Value[6]:='610'; (*vendoraccountnumber,onnumericvaluesdon't*) (*forgettheleadingzeroes!!!*) Header.Value[8]:='0099000123'; (***fillingthePO_Items-table***) (*addnewrowtothetable*) ItemsRow:=POItems.rows.add; (*itemnumberofpurcasingdocument*) ItemsRow.Value[2]:='00010'; (*material-number,onnumericvaluesdon'tforget*) (*theleadingzeros!!!*) ItemsRow.Value[5]:='000000000000001161'; (*storagelocation*) ItemsRow.Value[11]:='100'; (*plant*) ItemsRow.Value[17]:='0001'; (*netpriceinpurcasingdocument,*) (*indocumentcurrency*) ItemsRow.Value[21]:='10,00'; (***fillingthePO_Items_Schedules-table***) (*addnewrowtothetable*) SchedulesRow:=Schedules.rows.add; (*itemnumberofpurcasingdocument*) SchedulesRow.Value[1]:='00010'; (*categoryofdeliverydate*) SchedulesRow.Value[3]:='1'; (*itemdeliverydate*) SchedulesRow.Value[4]:='30.05.2000'; (*scheduledquantity*) SchedulesRow.Value[6]:='10'; (***callfunction***) ifnotfunct.callthen (*onerrorshowmessage*) showMessage(funct.exception) else begin (*shownumberofthepurcaseorder*) MLDText:=funct.imports('PURCHASEORDER'); MessageDlg('purcaseorder'+MLDText+'created.', MTInformation,[mbOK],0); end; end; BAPI/RFCwithDelphi(系列之七)--TBAPIControl使用BUS1001显示物料(Delphi源代码) 1、新建一个Form,并在form上添加下列控件 ComponentFunction SAPBAPIControl1SAPActiveX-ComponenttoconnecttoBAPI Button1Buttontostarttheprocedure Panel1Elementtodisplaythematerial-description 2、源代码如下(BUS1001显示物料) unitUnit1; interface uses Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs, StdCtrls,OleCtrls,SAPBAPIControlLib_TLB,ExtCtrls; type TForm1=class(TForm) SAPBAPIControl1:TSAPBAPIControl; Button1:TButton; Panel1:TPanel; procedureButton1Click(Sender:TObject); private {Private-Deklarationen} public {Public-Deklarationen} end; var Form1:TForm1; Connection,MAT:Variant; implementation {$R*.DFM} procedureTForm1.Button1Click(Sender:TObject); begin Connection:=SAPBapiControl1.Connection; ifConnection.Logonthen begin ShowMessage('LogOn'); (*Calltheobjectwiththeneededparameters*) MAT:=sapbapicontrol1.GetSAPObject('BUS1001','000000000000017550'); (*Displaymaterial-description*) Panel1.Caption:=MAT.MATERIALDESCRIPTION; end; end; end. BAPI/RFCwithDelphi(系列之八)--TBAPIControl使用BUS2012建立PO(Delphi源代码) 1、新建一个Form,并在form上添加下列控件 ComponentFunction SAPLogonControl1SAPActiveX-Componenttologontothesystem SAPBAPIControl1SAPActiveX-ComponenttoconnecttoBAPI Button1Buttontostarttheprocedure Button2Buttontologon Panel1-3Elementstodisplaymessages 2、源代码如下(BUS2012建立PO) unitbest; interface uses Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs, StdCtrls,OleCtrls,SAPBAPIControlLib_TLB,ExtCtrls,Grids, SAPLogonCtrl_TLB; type TForm1=class(TForm) SAPBAPIControl1:TSAPBAPIControl; Button1:TButton; Panel1:TPanel; Panel2:TPanel; Panel3:TPanel; Button2:TButton; SAPLogonControl1:TSAPLogonControl; Edit1:TEdit; Edit2:TEdit; Label1:TLabel; Label2:TLabel; procedureButton1Click(Sender:TObject); procedureButton2Click(Sender:TObject); private {Private-Deklarationen} public {Public-Deklarationen} end; var Form1:TForm1; Connection,Mat,Header,Ret,Schedul,Item:Variant; implementation {$R*.DFM} procedureTForm1.Button1Click(Sender:TObject); begin (*selectBusinessObject*) Mat:=SAPBapiControl1.GetSAPObject('BUS2012'); (*definestructures*) Header:=SAPBapiCcontrol1.dimAs(Mat,'CreateFromData','PoHeader'); Schedul:=SAPBapiCcontrol1.dimAs(Mat,'CreateFromData','PoItemSchedules'); Item:=SAPBapiCcontrol1.dimAs(Mat,'CreateFromData','PoItems'); Ret:=SAPBapiCcontrol1.dimAs(Mat,'CreateFromData','Return'); (*purchaseorderheaderdata's*) Header.value('DOC_TYPE'):='NB'; Header.value('DOC_CAT'):='F'; Header.value('PURCH_ORG'):='10'; Header.value('PUR_GROUP'):='10'; Header.value('VENDOR'):='0010000999'; (*dataforposition00010*) Item.Rows.Add; Item.Value(1,'PO_ITEM'):='00010'; Item.Value(1,'PUR_MAT'):='000000000000000017'; Item.Value(1,'STORE_LOC'):='100'; Item.Value(1,'PLANT'):='1000'; Item.Value(1,'NET_PRICE'):='10,00'; (*schedulesforposition00010*) Schedul.Rows.Add; Schedul.Value(1,'PO_ITEM'):='00010'; Schedul.Value(1,'DEL_DATCAT'):='1'; Schedul.Value(1,'DELIV_DATE'):='20.09.2000'; Schedul.Value(1,'QUANTITY'):='10'; (*dataforposition00020*) Item.Rows.Add; Item.value(2,'PO_ITEM'):='00020'; Item.value(2,'PUR_MAT'):='000000000000001161'; Item.value(2,'STORE_LOC'):='100'; Item.value(2,'PLANT'):='1000'; Item.value(2,'NET_PRICE'):='10,00'; (*schedulesforposition00020*) Schedul.Rows.Add; Schedul.Value(2,'PO_ITEM'):='00020'; Schedul.Value(2,'DEL_DATCAT'):='1'; Schedul.Value(2,'DELIV_DATE'):='20.09.2000'; Schedul.Value(2,'QUANTITY'):='10'; (*callthemethodCreateFromData*) Mat.CreateFromData(PoHeader:=Header, SkipItemsWithError:='', PoItems:=Item, PoItemSchedules:=Schedul, Return:=Ret); (*ErrorsaresavedinthestructureRet*) ifRet.RowCount>0then begin Panel1.Caption:=Ret.Value(1,'TYPE'); Panel2.Caption:=Ret.Value(1,'MESSAGE'); end (*Ifthemethodwascalleswithouterrors,*) (*displaythenumberofthepurchaseorder*) elsePanel2.Caption:=Mat.PurchaseOrder; end; procedureTForm1.Button2Click(Sender:TObject); begin (*Logontothesystem*) Connection:=SAPLogoncontrol1.newConnection; Connection.User:=Ansiuppercase(Edit1.text); Connection.System:='IDS'; Connection.Client:='800'; Connection.ApplicationServer:='SAPIDES'; Connection.SystemNumber:='00'; Connection.Password:=Edit2.text; Connection.Language:='DE'; SAPLogonControl1.Enabled:=false; ifConnection.LogOn(0,true)=Truethen begin ShowMessage('LogonO.K.'); Button1.Enabled:=true; (*assigntheexistingconnectiontothe*) (*componentSAPBapiControl1*) SapBapiControl1.Connection:=Connection; end else begin ShowMessage('Erroronlogon:-((('); end; end; end. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论