• BAPI / RFC with Delphi(系列之六)--TSAPFunctions使用BAPI创建PO(有登录对话框的delphi源代码)


    1、新建一个Form,并在form上添加下列控件

    Component

    Function

    SAPFunctions1 SAP ActiveX-component to connect RFC/BAPI
    Button1 Button to start the procedure
    Panel1 not relevant!

    2、源代码如下(使用BAPI_PO_CREATE函数创建PO) 

    unit PO_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;
      procedure Button1Click(Sender: TObject);
    private
    { Private-Deklarationen }
    public
    { Public-Deklarationen }
    end;

    var
    Form1: TForm1;
    Funct,
    Header,
    POItems,
    Schedules,
    ItemsRow,
    SchedulesRow: Variant;

    implementation
    {$R *.DFM}

    procedure TForm1.Button1Click(Sender: TObject);
    var MLDText : String;
    begin
      Button1.Enabled:=false;
      Panel1.Caption := 'RFC ist running, please wait.....';
      (* define function *)
      Funct := sapFunctions1.add('BAPI_PO_CREATE');

    (*** define tables, use structures of the dictionary ***)

      (* table for the purcaseorder header *)
      Header := funct.exports('PO_HEADER');

      (* table of the purcaseorder items *)
      POItems := funct.tables.item('PO_ITEMS');

      (* table of the schedules *)
      Schedules := funct.tables.item('PO_ITEM_SCHEDULES');

    (*** filling the PO_Header-table ***)

      (* purcasing document type *)
      Header.Value[2] := 'NB ' ;

      (* purcasing document category *)
      Header.Value[3] := 'F' ;

      (* purcasing organisation *)
      Header.Value[5] := '600' ;

      (* purcasing group *)
      Header.Value[6] := '610' ;

      (* vendor account number, on numeric values don't *)
      (* forget the leading zeroes!!!                     *)
      Header.Value[8] := '0099000123';

    (*** filling the PO_Items-table ***)

      (* add new row to the table *)
      ItemsRow := POItems.rows.add;

      (* item number of purcasing document *)
      ItemsRow.Value[2]:='00010';

      (* material-number, on numeric values don't forget *)
      (* the leading zeros !!!                            *)
      ItemsRow.Value[5]:='000000000000001161';

      (* storage location *)
      ItemsRow.Value[11]:='100';

      (* plant *)
      ItemsRow.Value[17]:='0001';

      (* netprice in purcasing document, *)
      (* in document currency              *)
      ItemsRow.Value[21]:='10,00';

    (*** filling the PO_Items_Schedules-table ***)

      (* add new row to the table *)
      SchedulesRow := Schedules.rows.add;

      (* item number of purcasing document *)
      SchedulesRow.Value[1]:='00010';

      (* category of delivery date *)
      SchedulesRow.Value[3]:='1';

      (* item delivery date *)
      SchedulesRow.Value[4]:='30.05.2000';

      (* scheduled quantity *)
      SchedulesRow.Value[6]:='10';

    (*** call function ***)

      if not funct.call then

        (* on error show message *)
        showMessage(funct.exception)

      else
      begin

        (* show number of the purcaseorder *)
        MLDText:= funct.imports('PURCHASEORDER');
        MessageDlg('purcaseorder '+MLDText+' created.',
        MTInformation,[mbOK],0);
      end;
    end;

  • 相关阅读:
    淘淘商城项目分析报告
    LDAP入门
    spring APO的简单理解
    MySQL数据库的导入导出
    servlet CDI
    Result 架构
    java的设计模型
    JavaEE人力资源管理系统测试报告——许珍源、朱国辉小组
    部分代码片段——人力资源管理系统
    期末项目——人力资源管理系统需求分析
  • 原文地址:https://www.cnblogs.com/xiaomaohai/p/6157379.html
Copyright © 2020-2023  润新知