java 调用bapi_2.3.3 - 通过Java语言进行BAPI调用.doc

2.3.3 - 通过Java语言进行BAPI调用

2.3.3 - 通过Java语言进行BAPI调用

// 载入所需的类库:

import com.sap.rfc.*;

import com.sap.rfc.exception.*;

import com.ibm.sap.bapi.*;

import com.ibm.sap.bapi.generated.*;

// 连接SAP系统

static private IRfcConnection establishConnection(MiddlewareInfo aMiddlewareInfo)

throws JRfcRemoteException

{

IRfcConnection aConnection = null ;

ConnectInfo aConnectInfo = null ;

UserInfo aUserInfo = null ;

String orbServerName = aMiddlewareInfo.getOrbServerName() ;

boolean bAdjusted = true;

if (!bAdjusted)

{

throw (new JRfcRfcConnectionException (

"Please adjust the Connection-Parameters to your needs!"));

}

//连接信息:调整为所需要输入的值

aConnectInfo = new ConnectInfo (

3,// int Rfc模式 3=R/3 or 2=R/2

null,// String RFC目标

"9.7.12.7",// String 主机名(IP地址)

0,// int 系统编号

null,// String 网关主机

null,// String 网关服务

null,// String 系统名

null,// String 服务器组名

null,// String 消息服务器

false,// Boolean 负载平衡选项

true);// Boolean 权限检查选项

// 用户信息

aUserInfo = new UserInfo (

"MUSTER",// String 用户名

"IDES",// String 密码

"800",// String 集团

"e",// String 登录语言

1103);// int 代码页

// Technical conversion for the selected middleware;

// 打开连接Open connection:

IRfcConnectionFactory aConnectionFactory =

FactoryManager.getSingleInstance().getRfcConnectionFactory() ;

aConnection = aConnectionFactory.createRfcConnection(aConnectInfo, aUserInfo) ;

aConnection.open() ;

// 返回连接

return aConnection ;

}

// 调用main方法

public static void main (java.lang.String[] args)

//通过所指定的中间件设定连接选项

{

MiddlewareInfo aMiddlewareInfo = new MiddlewareInfo(args) ;

FactoryManager aFactoryManager = FactoryManager.getSingleInstance() ;

aFactoryManager.setMiddlewareInfo(aMiddlewareInfo) ;

//初始化连接连接对象

IRfcConnection aConnection = null ;

try

{

aConnection = establishConnection(aMiddlewareInfo) ;

}

catch (Exception ex)

{

System.out.println("ERROR : Could not create connection : " + ex) ;

System.exit(-1) ;

}

System.out.println("Conn

BAPI_PRODORD_CREATE是SAP系统中的一个标准的BAPI函数模块,用于创建生产订单。在调用这个BAPI函数模块之前,你需要先准备好一些数据,包括: 1. 订单类型 2. 生产版本 3. 生产工厂 4. 产品编号 5. 订单数量 6. 计划开始日期和结束日期 7. 工作中心 调用BAPI_PRODORD_CREATE的具体步骤如下: 1. 使用Function Module 'BAPI_TRANSACTION_COMMIT'开启事务处理。 2. 创建一个Function Module对象。 3. 设置Function Module的输入参数。 4. 调用Function Module执行BAPI_PRODORD_CREATE。 5. 使用Function Module 'BAPI_TRANSACTION_COMMIT'提交事务。 下面是一个简单的ABAP代码示例,演示如何调用BAPI_PRODORD_CREATE。 ``` DATA: lv_order_type TYPE AUFART, lv_production_version TYPE VERID, lv_plant TYPE WERKS_D, lv_material TYPE MATNR, lv_quantity TYPE MENG07, lv_planned_start_date TYPE D, lv_planned_finish_date TYPE D, lv_work_center TYPE ARBPL. *设置输入参数 lv_order_type = 'PP01'. lv_production_version = '0001'. lv_plant = '1000'. lv_material = 'M-01'. lv_quantity = 100. lv_planned_start_date = '20210801'. lv_planned_finish_date = '20210831'. lv_work_center = 'WC-01'. *创建一个Function Module对象 CALL FUNCTION 'BAPI_PRODORD_CREATE' EXPORTING order_type = lv_order_type production_version = lv_production_version plant = lv_plant material = lv_material quantity = lv_quantity planned_start_date = lv_planned_start_date planned_finish_date = lv_planned_finish_date work_center = lv_work_center IMPORTING order_number = lv_order_number EXCEPTIONS OTHERS = 1. *提交事务处理 CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. ``` 以上示例代码仅供参考,具体实现方式可能因SAP系统版本和业务需求而异。如果你需要更加详细的帮助,请参考SAP官方文档或者咨询SAP开发专家。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值