tahsinanarat
Altın Üye
- Katılım
- 14 Mart 2005
- Mesajlar
- 2,164
- Excel Vers. ve Dili
- Ofis 2019 Türkçe
- Altın Üyelik Bitiş Tarihi
- 27-05-2028
Kod:
Option Explicit
Public SapGuiAuto
Public objGui As GuiApplication
Public objConn As GuiConnection
Public session As GuiSession
Public objSheet As Worksheet
Sub SapMalzeme_cikis()
Set SapGuiAuto = GetObject("SAPGUI")
Set objGui = SapGuiAuto.GetScriptingEngine
Set objConn = objGui.Children(0)
Set session = objConn.Children(0)
Dim selectedCountry As String
Dim folderPath As String
Dim i As Integer
Dim ara As String
session.FindById("wnd[0]").Maximize
session.FindById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").selectedNode = "0000000046"
session.FindById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "0000000046"
session.FindById("wnd[0]/usr/subGC_HEAD_SCA:ZMMIGA_P006:0301/ctxtGS_HEADER-BUKRS").text = "1000"
session.FindById("wnd[0]/usr/subGC_HEAD_SCA:ZMMIGA_P006:0301/ctxtGS_HEADER-REQUESTING").text = "7556"
session.FindById("wnd[0]/usr/subGC_HEAD_SCA:ZMMIGA_P006:0301/ctxtGS_HEADER-FLDOFCR").text = "103"
session.FindById("wnd[0]/usr/subGC_HEAD_SCA:ZMMIGA_P006:0301/ctxtGS_HEADER-DISCPLN").text = "2000000100"
session.FindById("wnd[0]/usr/subGC_HEAD_SCA:ZMMIGA_P006:0301/ctxtGS_HEADER-DISCPLN").SetFocus
session.FindById("wnd[0]/usr/subGC_HEAD_SCA:ZMMIGA_P006:0301/ctxtGS_HEADER-DISCPLN").caretPosition = 10
session.FindById("wnd[0]").sendVKey 0
session.FindById("wnd[0]/usr/subGC_HEAD_SCA:ZMMIGA_P006:0301/ctxtGS_HEADER-RECTYP").SetFocus
session.FindById("wnd[0]/usr/subGC_HEAD_SCA:ZMMIGA_P006:0301/ctxtGS_HEADER-RECTYP").caretPosition = 0
session.FindById("wnd[0]").sendVKey 4
session.FindById("wnd[1]/usr/lbl[1,5]").SetFocus
session.FindById("wnd[1]/usr/lbl[1,5]").caretPosition = 8
session.FindById("wnd[1]").sendVKey 2
session.FindById("wnd[0]/usr/subGC_HEAD_SCA:ZMMIGA_P006:0301/ctxtGS_HEADER-MATNRCODE").SetFocus
session.FindById("wnd[0]/usr/subGC_HEAD_SCA:ZMMIGA_P006:0301/ctxtGS_HEADER-MATNRCODE").caretPosition = 0
session.FindById("wnd[0]").sendVKey 4
session.FindById("wnd[1]/usr/lbl[12,5]").SetFocus
session.FindById("wnd[1]/usr/lbl[12,5]").caretPosition = 5
session.FindById("wnd[1]").sendVKey 2
session.FindById("wnd[0]/usr/subGC_HEAD_SCA:ZMMIGA_P006:0301/cmbGS_HEADER-URGENT").SetFocus
session.FindById("wnd[0]/usr/subGC_HEAD_SCA:ZMMIGA_P006:0301/cmbGS_HEADER-URGENT").Key = "N"
session.FindById("wnd[0]/usr/subGC_DETAIL_SCA:ZMMIGA_P006:0302/cntlCONTAINER/shellcont/shell").PressToolbarButton "XSTOCK"
session.FindById("wnd[1]/usr/sub:SAPLSPO4:0300/ctxtSVALD-VALUE[0,21]").text = "2015"
session.FindById("wnd[1]/usr/sub:SAPLSPO4:0300/ctxtSVALD-VALUE[0,21]").caretPosition = 4
session.FindById("wnd[1]").sendVKey 0
session.FindById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").CurrentCellRow = -1
session.FindById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").SelectColumn "MATNR"
session.FindById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").PressToolbarButton "&SORT_ASC"
'ayrı pencerede açılan stoklu malzeme listesinin 1.sunununu küçükten büyüğe doğru sıralama yaptırdım
'bundan sonrasını döngüye alarak sayfamın a sutunundaki kodları stoklu malzeme listesinden aratıp 7.sunununa sayfamın H sutunundaki adet kısmını giriyorum
'döngü ile nasıl yaptırabilirim.
session.FindById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").PressToolbarButton "&FIND"
session.FindById("wnd[2]/usr/txtGS_SEARCH-VALUE").text = "1000018"
session.FindById("wnd[2]/usr/txtGS_SEARCH-VALUE").caretPosition = 7
session.FindById("wnd[2]/tbar[0]/btn[0]").press
session.FindById("wnd[2]/tbar[0]/btn[12]").press
session.FindById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").ModifyCell 4, "TLP_LABST", "25"
session.FindById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").CurrentCellColumn = "TLP_LABST"
session.FindById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").TriggerModified
session.FindById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").PressToolbarButton "&FIND"
session.FindById("wnd[2]/usr/txtGS_SEARCH-VALUE").text = "1000034"
session.FindById("wnd[2]/usr/txtGS_SEARCH-VALUE").caretPosition = 7
session.FindById("wnd[2]/tbar[0]/btn[0]").press
session.FindById("wnd[2]/tbar[0]/btn[12]").press
session.FindById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").ModifyCell 12, "TLP_LABST", "35"
session.FindById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").CurrentCellColumn = "TLP_LABST"
session.FindById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").TriggerModified
session.FindById("wnd[1]/tbar[0]/btn[0]").press
session.FindById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").TriggerModified
End Sub
Ben bunu açık olan excel sayfamdan döngüye bağlayıp a sutununda yazılı kodların hepsini buldurup H sutunundaki miktarlarını SAP ın açık olan sayfasının 7.sutununa girmek istiyorum, bu konuda bilgisi olan arkadaşlarımdan, hocalarımdan destek bekliyorum. Teşekkürler