Hello,
I have a code that inserts new materials in an order in SAP:
It takes the information in row 3 and inserts it in SAP, then deletes that row and goes on with the next. Always taking information of whats in row 3. My problem is when i have 2 insert 2 or more materials in the same order.
This is my code:
Right now it will go into order 1, insert material and amount and save. then it deletes that row and goes again into order 1 inserts the other maerial and the other amount. What i want it to do is to recognize the first 3 rows are the same order number so it copies those 3 materials and those 3 amounts and inserts them on SAP.
I have a code that inserts new materials in an order in SAP:
It takes the information in row 3 and inserts it in SAP, then deletes that row and goes on with the next. Always taking information of whats in row 3. My problem is when i have 2 insert 2 or more materials in the same order.
This is my code:
VBA Code:
A = 2
B = 1
Do While A > B
Orden = Range("A3").Value
Material = Range("B3").Value
Cant = Range("C3").Value
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/ctxtVBAK-VBELN").Text = Orden
session.findById("wnd[0]/usr/ctxtVBAK-VBELN").caretPosition = 9
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/subSUBSCREEN_BUTTONS:SAPMV45A:4050/btnBT_POAN").press
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/ctxtRV45A-MABNR[1,1]").Text = Material
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/txtRV45A-KWMENG[2,1]").Text = Cant
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]").sendVKey 11
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]").sendVKey 0
Rows("3:3").Select
Selection.Delete Shift:=xlUp
Loop
Right now it will go into order 1, insert material and amount and save. then it deletes that row and goes again into order 1 inserts the other maerial and the other amount. What i want it to do is to recognize the first 3 rows are the same order number so it copies those 3 materials and those 3 amounts and inserts them on SAP.
Order | Material | CS |
1 | 37702191663319 | 40 |
1 | 47702191162734 | 30 |
1 | 27702006299101 | 20 |
2 | 47702006206028 | 10 |
2 | 47702006202815 | 50 |
2 | 27702006299071 | 30 |
3 | 77702047040033 | 20 |
3 | 47702191162697 | 10 |
3 | 47702191162734 | 20 |