删除特定行/订单项的代码

时间:2019-05-10 14:11:19

标签: excel vba

我创建了一个脚本来删除SAP中的PO。只要PO包含一个订单项,该脚本就相当简单。但是,如果我有多个订单项的采购订单,并且只想删除采购订单上的特定项目/行,该怎么办?

随附的是SAP中带有4个订单项的采购订单的图片。记录我的脚本是为了删除等于line =(session.findById(“ wnd [0] / usr / subSUB0:SAPLMEGUI:0010 / subSUB2:SAPLMEVIEWS:1100 / subSUB2:SAPLMEVIEWS:1200 / subSUB1 :SAPLMEGUI:1211 / tblSAPLMEGUITC_1211“)。getAbsoluteRow(1).selected = true

enter image description here

现在,我需要创建一个脚本,该脚本从excel工作表中获取有关要访问哪个PO(第1列)以及要删除该PO上的哪个行项目(第2列)的信息,然后获取下一个PO并执行相同的操作,直到循环结束完成。

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/training/saving/saveable_object_util.py in op_list_to_dict(op_list, convert_variable_to_tensor)
    286         if name in names_to_saveables:
    287           raise ValueError("At least two variables have the same name: %s" %
--> 288                            name)
    289         names_to_saveables[name] = var
    290 

ValueError: At least two variables have the same name: dense/bias

1 个答案:

答案 0 :(得分:0)

您可以尝试以下操作:

...
For i = 2 to objSheet.UsedRange.Rows.Count
COL1 = Trim(CStr(objSheet.Cells(i, 1).Value)) 'Column1
COL2 = Trim(CStr(objSheet.Cells(i, 2).Value)) 'Column2

session.findById("wnd[0]/tbar[0]/okcd").text = "/nme22n"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[17]").press
session.findById("wnd[1]/usr/subSUB0:SAPLMEGUI:0003/ctxtMEPO_SELECT-EBELN").text = Col1
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211").getAbsoluteRow(" & COL2 & ").selected = true
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/btnDELETE").press
session.findById("wnd[1]/usr/btnSPOP-OPTION1").press
session.findById("wnd[0]/tbar[0]/btn[11]").press
session.findById("wnd[1]/usr/btnSPOP-VAROPTION1").press
session.findById("wnd[0]/tbar[1]/btn[17]").press

aux=COL1 & " / " & COL2
CreateObject("WScript.Shell").run("cmd /c @echo %date% %time% " & aux & " >> C:\SCRIPT\PlOrCreationLog.txt")
next

msgbox "Process Completed"

关于ScriptMan