在VB脚本中传递变量值时遇到错误

2020-08-18 06:21发布

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


嗨,

在我的要求中,我需要读取工作簿中的单元格值,并需要传递到"计划"序列的"输入"变量。

通过使用 SAPGetCellInfo ,它在 lResult1(类型 variant), 中的读取单元格值,但无法 传入 SAPSetPlanParameter" 计划序列变量。

我直接通过costcentre值代替了 lResult1 ,例如," CC01010101"计划序列正在运行,但是如果我使用 IResult1 ,则它不接受。

编码

将lResult1设为变体

将lI范围作为对象

调用Application.Run(" SAPSetRefreshBehaviour","关闭")

调用Application.Run(" SAPExecuteCommand"," PauseVariableSubmit","打开")

lResult1 = Application.Run(" SAPGetCellInfo",ActiveCell," SELECTION",lNameChar)

lResult = Application.Run(" SAPSetPlanParameter"," PS_2"," ZV_ISGM_COSTCENTER_002", lResult1 ," INPUT_STRING") ---- IResult变量未传递值

MsgBox IIf(Val(lResult)= 1,"应用了过滤器","没有过滤器")--- 仅抛出"没有过滤器"消息

调用Application.Run(" SAPExecuteCommand"," PauseVariableSubmit","关闭")

调用Application.Run(" SAPSetRefreshBehaviour","打开")

lResult = Application.Run(" SAPExecutePlanningSequence"," PS_2")

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


嗨,

在我的要求中,我需要读取工作簿中的单元格值,并需要传递到"计划"序列的"输入"变量。

通过使用 SAPGetCellInfo ,它在 lResult1(类型 variant), 中的读取单元格值,但无法 传入 SAPSetPlanParameter" 计划序列变量。

我直接通过costcentre值代替了 lResult1 ,例如," CC01010101"计划序列正在运行,但是如果我使用 IResult1 ,则它不接受。

编码

将lResult1设为变体

将lI范围作为对象

调用Application.Run(" SAPSetRefreshBehaviour","关闭")

调用Application.Run(" SAPExecuteCommand"," PauseVariableSubmit","打开")

lResult1 = Application.Run(" SAPGetCellInfo",ActiveCell," SELECTION",lNameChar)

lResult = Application.Run(" SAPSetPlanParameter"," PS_2"," ZV_ISGM_COSTCENTER_002", lResult1 ," INPUT_STRING") ---- IResult变量未传递值

MsgBox IIf(Val(lResult)= 1,"应用了过滤器","没有过滤器")--- 仅抛出"没有过滤器"消息

调用Application.Run(" SAPExecuteCommand"," PauseVariableSubmit","关闭")

调用Application.Run(" SAPSetRefreshBehaviour","打开")

lResult = Application.Run(" SAPExecutePlanningSequence"," PS_2")

付费偷看设置
发送
1条回答
哎,真难
1楼-- · 2020-08-18 06:55

lResult1 = Application.Run(" SAPGetCellInfo",ActiveCell," SELECTION",lNameChar)

未定义变量INameChar是什么意思?

请阅读此博客,了解正确的语法:

https://blogs.sap.com/2013/11/17/sapgetcellinfo-specifying-a-filter-doesnt-determine-the-order-of-results /

 lResult1 = Application.Run(" SAPGetCellInfo",ActiveCell," SELECTION"," DimName")

在VBA调试器中查看lResult1!

并删除与您的代码无关的无用行:

调用Application.Run(" SAPSetRefreshBehaviour","关闭")
 调用Application.Run(" SAPExecuteCommand"," PauseVariableSubmit","开")
 ...
 调用Application.Run(" SAPExecuteCommand"," PauseVariableSubmit","关闭")
 调用Application.Run(" SAPSetRefreshBehaviour","打开")

与SAPExecutePlanningSequence无关

一周热门 更多>