public static GuiConnection CreateConnection(string description, string user, string password, string language)
        {
            CSapROTWrapper sapROTWrapper = new CSapROTWrapper();
            object         SapGuilRot    = sapROTWrapper.GetROTEntry("SAPGUI");
            object         engine        = SapGuilRot.GetType().InvokeMember("GetSCriptingEngine", System.Reflection.BindingFlags.InvokeMethod,
                                                                             null, SapGuilRot, null);

            GuiApplication app = (GuiApplication)engine;
            GuiConnection  conn;

            if (app.Connections.Count == 0)
            {
                conn = app.OpenConnection(description);
                GuiSession       session     = conn.Children.ElementAt(0) as GuiSession;
                GuiTextField     name        = (GuiTextField)session.FindById("wnd[0]/usr/txtRSYST-BNAME");
                GuiPasswordField pass        = (GuiPasswordField)session.FindById("wnd[0]/usr/pwdRSYST-BCODE");
                GuiTextField     lang        = (GuiTextField)session.FindById("wnd[0]/usr/txtRSYST-LANGU");
                GuiMainWindow    mainWindows = (GuiMainWindow)session.FindById("wnd[0]");

                name.Text = user;
                pass.Text = password;
                lang.Text = language;
                mainWindows.SendVKey(0);
            }
            else
            {
                conn = (GuiConnection)app.Connections.ElementAt(0);
            }

            return(conn);
        }
Exemple #2
0
        void _session_EndRequest(GuiSession Session)
        {
            GuiStatusbar status = _session.FindById <GuiStatusbar>("wnd[0]/sbar");

            if (status != null)
            {
                switch (status.MessageType)
                {
                case "E":
                    if (RequestError != null)
                    {
                        RequestError();

                        Thread.Sleep(1000);
                    }

                    break;

                case "S":

                    break;

                default:

                    break;
                }
            }
        }
Exemple #3
0
 public static T GetSAPComponentById <T>(this GuiSession session, string id) where T : class
 {
     try
     {
         return(session.FindById(id) as T);
     }
     catch
     {
         return(null);
     }
 }
 public T GetSAPComponentById <T>(string id) where T : class
 {
     try
     {
         return(_sapGuiSession.FindById(id) as T);
     }
     catch
     {
         return(null);
     }
 }
        public bool logoff()
        {
            GuiSession SapSession = getCurrentSession();

            //Log Off the SAP
            SapSession.ActiveWindow.Close();
            GuiButton btnLogOffOk = (GuiButton)SapSession.FindById("/app/con[0]/ses[0]/wnd[1]/usr/btnSPOP-OPTION1");

            btnLogOffOk.SetFocus();
            btnLogOffOk.Press();

            return(true);
        }
        public void Login(string UserName, string Password, string Client, string Language)
        {
            if (BeforeLogin != null)
            {
                BeforeLogin(_sapGuiSession, new EventArgs());
            }

            _sapGuiSession.FindById <GuiTextField>("wnd[0]/usr/txtRSYST-BNAME").Text = UserName;
            _sapGuiSession.FindById <GuiTextField>("wnd[0]/usr/pwdRSYST-BCODE").Text = Password;
            _sapGuiSession.FindById <GuiTextField>("wnd[0]/usr/txtRSYST-MANDT").Text = Client;
            _sapGuiSession.FindById <GuiTextField>("wnd[0]/usr/txtRSYST-LANGU").Text = Language;


            var window = _sapGuiSession.FindById <GuiFrameWindow>("wnd[0]");

            window.SendVKey(0);

            GuiStatusbar status = _sapGuiSession.FindById <GuiStatusbar>("wnd[0]/sbar");

            if (status != null && status.MessageType.ToLower() == "e")
            {
                _sapGuiConnection.CloseSession(_sapGuiSession.Id);
                if (FailLogin != null)
                {
                    FailLogin(_sapGuiSession, new EventArgs());
                }
                return;
            }

            if (AfterLogin != null)
            {
                AfterLogin(_sapGuiSession, new EventArgs());
            }

            GuiRadioButton rb_Button = _sapGuiSession.FindById <GuiRadioButton>("wnd[1]/usr/radMULTI_LOGON_OPT2");

            if (rb_Button != null)
            {
                rb_Button.Select();
                window.SendVKey(0);
            }
        }
        public string login_SSO(string servername)
        {
            //Close the SAP if its opened, then open the new process
            KillProcess("saplogon");

            //Set the Exe Path and SAP Window name
            string          strSAPLoginPadPath = @"C:\Program Files (x86)\SAP\FrontEnd\SapGui\saplogon.exe";
            FileVersionInfo fi2                = FileVersionInfo.GetVersionInfo(strSAPLoginPadPath);
            string          strVersion         = fi2.ProductVersion.Substring(0, 3);
            String          strloginWindowName = "SAP Logon " + strVersion;

            //Start SAP Login Window
            StartProcess(strSAPLoginPadPath);

            //Wait for the window to be loaded.
            System.Threading.Thread.Sleep(1000);
            AutomationElement desktop = AutomationElement.RootElement;
            AutomationElement ele     = null;

            while (ele is null)
            {
                try
                {
                    ele = desktop.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, strloginWindowName));
                }
                catch { }
            }

            CSapROTWrapper sapROTWrapper = new CSapROTWrapper();
            object         rot           = sapROTWrapper.GetROTEntry("SAPGUI");
            object         engine        = rot.GetType().InvokeMember("GetScriptingEngine", System.Reflection.BindingFlags.InvokeMethod, null, rot, null);
            GuiConnection  connection    = (engine as GuiApplication).OpenConnection(servername);
            GuiSession     SapSession    = connection.Children.ElementAt(0) as GuiSession;

            //Validate whether the login successfull or Not
            //If the error is "Already logged in by the same user, then click
            GuiStatusbar statusBar  = (GuiStatusbar)SapSession.FindById("wnd[0]/sbar");
            string       strMsg     = statusBar.Text;
            string       strMsgType = statusBar.MessageType;

            if (strMsg.Contains("User already logged on at another terminal") == true || strMsg.Contains("用户已经登录到其它终端") == true)//(strMsg == "W" || strMsgType == "E" ) //'Warning or Error
            {
                //Check whether is it showing the same terminal or different terminal
                string strWinText = ((GuiFrameWindow)SapSession.FindById("wnd[1]")).Text;
                strWinText = Environment.MachineName;
                if (strWinText.Contains(Environment.MachineName) == true)
                {
                    //This represents, the login in the same machine, then click continue with current login option
                    ((GuiRadioButton)SapSession.FindById("wnd[1]/usr/radMULTI_LOGON_OPT1")).Select();
                    ((GuiButton)SapSession.FindById("wnd[1]/tbar[0]/btn[0]")).Press();
                }
                else
                {
                    //SapSession.ActiveWindow.Close();
                    throw new Exception("SAP Error while logging in the SAP system, Error:\n" + strMsg);
                }
            }
            else if (strMsg.Length > 0 && strMsgType == "E")
            {
                //SapSession.ActiveWindow.Close();
                throw new Exception("SAP Error while logging in the SAP system, Error:\n" + strMsg);
            }

            return("success");
        }
        /// <summary>
        /// This function will login into the SAP with provided credentials(same as manual login)
        /// </summary>
        /// <param name="SapSession"></param>
        /// <param name="myclient"></param>
        /// <param name="mylogin"></param>
        /// <param name="mypass"></param>
        /// <param name="mylang"></param>
        public string login(string servername, string myclient, string mylogin, System.Security.SecureString mypass, string mylang)
        {
            //GuiApplication appSAP = (GuiApplication)Marshal.GetActiveObject("SAPGUI");
            //GuiConnection connSAP = appSAP.OpenConnection(server, Sync: true);
            //GuiSession SapSession = (GuiSession)connSAP.Sessions.Item(0);

            //    System.IO.StreamWriter m_fswLogFile;
            //DateTime m_dtLastTimeLog = DateTime.MinValue;
            //int m_intTimeLogInterVal;

            //String strFilePath = "D:\\AA_Log_SAPAUto_Metabot.txt";

            //if (!System.IO.File.Exists(strFilePath)) {
            //    System.IO.File.Create(strFilePath).Close();
            //}
            ////Open the log file
            //m_fswLogFile = new System.IO.StreamWriter(strFilePath, true);
            //m_fswLogFile.AutoFlush = true;
            //m_fswLogFile.WriteLine("Parameters");
            //m_fswLogFile.WriteLine(server);
            //m_fswLogFile.WriteLine(mylogin);
            //m_fswLogFile.WriteLine(mypass);
            //m_fswLogFile.WriteLine(mylang);
            //m_fswLogFile.WriteLine(SAPWindowName);
            //m_fswLogFile.Close();
            //m_fswLogFile = null;

            //Close the SAP if its opened, then open the new process
            KillProcess("saplogon");

            //Set the Exe Path and SAP Window name
            string          strSAPLoginPadPath = @"C:\Program Files (x86)\SAP\FrontEnd\SapGui\saplogon.exe";
            FileVersionInfo fi2                = FileVersionInfo.GetVersionInfo(strSAPLoginPadPath);
            string          strVersion         = fi2.ProductVersion.Substring(0, 3);
            String          strloginWindowName = "SAP Logon " + strVersion;

            //Open the SAP Logon Window
            StartProcess(strSAPLoginPadPath);

            //Wait for the window to be loaded.
            System.Threading.Thread.Sleep(1000);
            AutomationElement desktop = AutomationElement.RootElement;
            AutomationElement ele     = null;

            while (ele is null)
            {
                try
                {
                    ele = desktop.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, strloginWindowName));
                }
                catch { }
            }

            CSapROTWrapper sapROTWrapper = new CSapROTWrapper();
            object         rot           = sapROTWrapper.GetROTEntry("SAPGUI");
            object         engine        = rot.GetType().InvokeMember("GetScriptingEngine", System.Reflection.BindingFlags.InvokeMethod, null, rot, null);
            GuiConnection  connection    = (engine as GuiApplication).OpenConnection(servername);
            GuiSession     SapSession    = connection.Children.ElementAt(0) as GuiSession;

            //m_fswLogFile = new System.IO.StreamWriter(strFilePath, true);
            //m_fswLogFile.AutoFlush = true;
            //m_fswLogFile.WriteLine("Going to get the controls for login");

            //m_fswLogFile.Close();
            //m_fswLogFile = null;

            GuiTextField client   = (GuiTextField)SapSession.ActiveWindow.FindByName("RSYST-MANDT", "GuiTextField");
            GuiTextField login    = (GuiTextField)SapSession.ActiveWindow.FindByName("RSYST-BNAME", "GuiTextField");
            GuiTextField pass     = (GuiTextField)SapSession.ActiveWindow.FindByName("RSYST-BCODE", "GuiPasswordField");
            GuiTextField language = (GuiTextField)SapSession.ActiveWindow.FindByName("RSYST-LANGU", "GuiTextField");

            //m_fswLogFile = new System.IO.StreamWriter(strFilePath, true);
            //m_fswLogFile.AutoFlush = true;
            //m_fswLogFile.WriteLine("Enter credentials for login");

            //m_fswLogFile.Close();
            //m_fswLogFile = null;
            client.SetFocus();
            client.Text = myclient;
            login.SetFocus();
            login.Text = mylogin;
            pass.SetFocus();
            pass.Text = new System.Net.NetworkCredential(string.Empty, mypass).Password;
            language.SetFocus();
            language.Text = mylang;

            //m_fswLogFile = new System.IO.StreamWriter(strFilePath, true);
            //m_fswLogFile.AutoFlush = true;
            //m_fswLogFile.WriteLine("click login");

            //m_fswLogFile.Close();
            //m_fswLogFile = null;
            //Press the green checkmark button which is about the same as the enter key
            GuiButton btn = (GuiButton)SapSession.FindById("/app/con[0]/ses[0]/wnd[0]/tbar[0]/btn[0]");

            btn.SetFocus();
            btn.Press();

            //Validate whether the login successfull or Not
            //If the error is "Already logged in by the same user, then click
            GuiStatusbar statusBar  = (GuiStatusbar)SapSession.FindById("wnd[0]/sbar");
            string       strMsg     = statusBar.Text;
            string       strMsgType = statusBar.MessageType;

            if (strMsg.Contains("User already logged on at another terminal") == true || strMsg.Contains("用户已经登录到其它终端") == true)//(strMsg == "W" || strMsgType == "E" ) //'Warning or Error
            {
                //Check whether is it showing the same terminal or different terminal
                string strWinText = ((GuiFrameWindow)SapSession.FindById("wnd[1]")).Text;
                strWinText = Environment.MachineName;
                if (strWinText.Contains(Environment.MachineName) == true)
                {
                    //This represents, the login in the same machine, then click continue with current login option
                    ((GuiRadioButton)SapSession.FindById("wnd[1]/usr/radMULTI_LOGON_OPT1")).Select();
                    ((GuiButton)SapSession.FindById("wnd[1]/tbar[0]/btn[0]")).Press();
                }
                else
                {
                    SapSession.ActiveWindow.Close();
                    return("SAP Error while logging in the SAP system, Error:\n" + strMsg);
                }
            }
            else if (strMsg.Length > 0 && strMsgType == "E")
            {
                SapSession.ActiveWindow.Close();
                return("SAP Error while logging in the SAP system, Error:\n" + strMsg);
            }

            return("success");
        }
Exemple #9
0
        private static void EUpdateAssetDescription(int i)
        {
            Equipments[i].New.AssetDescription = Equipments[i].New.EquipmentDescription;

            ((GuiMainWindow)session.FindById("wnd[0]")).Maximize();
            ((GuiOkCodeField)session.FindById("wnd[0]/tbar[0]/okcd")).Text = "/NAS02";
            ((GuiMainWindow)session.FindById("wnd[0]")).SendVKey(0);
            ((GuiTextField)session.FindById("wnd[0]/usr/ctxtANLA-ANLN1")).Text = Equipments[i].AssetNumber;
            ((GuiMainWindow)session.FindById("wnd[0]")).SendVKey(0);
            ((GuiTextField)session.FindById(
                 "wnd[0]/usr/subTABSTRIP:SAPLATAB:0100/tabsTABSTRIP100/tabpTAB01/ssubSUBSC:SAPLATAB:0200/subAREA1:SAPLAIST:1140/txtANLA-TXT50")
            ).Text = Equipments[i].New.AssetDescription;
            ;
            ((GuiTextField)session.FindById(
                 "wnd[0]/usr/subTABSTRIP:SAPLATAB:0100/tabsTABSTRIP100/tabpTAB01/ssubSUBSC:SAPLATAB:0200/subAREA1:SAPLAIST:1140/txtANLA-TXA50")
            ).Text = Equipments[i].New.AssetDescription;
            ((GuiTextField)session.FindById(
                 "wnd[0]/usr/subTABSTRIP:SAPLATAB:0100/tabsTABSTRIP100/tabpTAB01/ssubSUBSC:SAPLATAB:0200/subAREA1:SAPLAIST:1140/txtANLH-ANLHTXT")
            ).Text = Equipments[i].New.AssetDescription;
            ((GuiMainWindow)session.FindById("wnd[0]")).SendVKey(0);
            ((GuiMainWindow)session.FindById("wnd[0]")).SendVKey(11);

            Equipments[i].Old.AssetDescription = Equipments[i].New.AssetDescription;
            var l = new Transaction();

            l.Equipment = Equipments[i];
            l.Remarks   = ((GuiStatusbar)session.FindById("wnd[0]/sbar")).Text;
            l.Type      = Transaction.TransactionTypes.AssetDescription;
            l.OldValue  = Equipments[i].Old.AssetDescription;
            l.NewValue  = Equipments[i].New.AssetDescription;

            Database.Transactions.Add(l);
            Database.SaveChanges();
        }
Exemple #10
0
        public GuiComponent GetElementById(string id)
        {
            GuiComponent component = _sapGuiSession.FindById(id);

            return(component);
        }
Exemple #11
0
        private void btn_run_Click(object sender, EventArgs e)
        {
            if (tb_id.Text == "" || tb_plant.Text == "")
            {
                return;
            }
            if (tb_id.TextLength > 4)
            {
                MessageBox.Show("ID item not valid", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (tb_plant.TextLength != 4)
            {
                MessageBox.Show("Centro inválido", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }


            //INICIAR ALTERAÇÃO

            #region
            if (dataGridView1.RowCount == 1)
            {
                return;
            }

            try
            {
                //Get the Windows Running Object Table
                SapROTWr.CSapROTWrapper sapROTWrapper = new SapROTWr.CSapROTWrapper();
                //Get the ROT Entry for the SAP Gui to connect to the COM
                object SapGuilRot = sapROTWrapper.GetROTEntry("SAPGUI");
                //Get the reference to the Scripting Engine
                object engine = SapGuilRot.GetType().InvokeMember("GetScriptingEngine", System.Reflection.BindingFlags.InvokeMethod, null, SapGuilRot, null);
                //Get the reference to the running SAP Application Window
                GuiApplication GuiApp = (GuiApplication)engine;
                //Get the reference to the first open connection
                GuiConnection connection = (GuiConnection)GuiApp.Connections.ElementAt(0);
                //get the first available session
                GuiSession session = (GuiSession)connection.Children.ElementAt(0);
                //Get the reference to the main "Frame" in which to send virtual key commandss
                //GuiFrameWindow frame = session.ActiveWindow;
                GuiFrameWindow frame = (GuiFrameWindow)session.FindById("wnd[0]");
                //((GuiFrameWindow)frame.FindById("wnd[0]"));
                ((GuiOkCodeField)frame.FindById("wnd[0]/tbar[0]/okcd")).Text = "/nztvc025";
                frame.SendVKey(0);


                int linhas1 = dataGridView1.RowCount;
                int i;


                ((GuiTextField)frame.FindById("wnd[0]/usr/ctxtP_PRFID")).Text = "0001";
                ((GuiTextField)frame.FindById("wnd[0]/usr/ctxtP_WERKS")).Text = tb_plant.Text;


                for (i = 0; i < linhas1 - 1; i++)
                {
                    try
                    {
                        ((GuiButton)frame.FindByName("btn[8]", "GuiButton")).Press();


                        string material   = dataGridView1.Rows[i].Cells[0].Value.ToString();
                        int    tam        = material.Length;
                        string component1 = dataGridView1.Rows[i].Cells[1].Value.ToString();

                        if (tam == 11)
                        {
                            ((GuiTextField)session.ActiveWindow.FindById("wnd[1]/usr/sub:SAPLSPO4:0300/ctxtSVALD-VALUE[1,21]")).Text = material;
                        }

                        else
                        {
                            ((GuiTextField)session.ActiveWindow.FindById("wnd[1]/usr/sub:SAPLSPO4:0300/ctxtSVALD-VALUE[0,21]")).Text = material;
                        }

                        ((GuiButton)frame.FindByName("btn[0]", "GuiButton")).Press();

                        ((GuiToolbarControl)frame.FindById("wnd[0]/usr/subSUBSCR_TIPOS:SAPLZRVC_ZBOM_POS_ESP:0200/cntlCONT_TIPOS/shellcont/shell/shellcont[1]/shell[0]")).PressButton("&FIND");
                        ((GuiTextField)session.ActiveWindow.FindById("wnd[1]/usr/txtLVC_S_SEA-STRING")).Text = tb_id.Text.ToString();
                        ((GuiButton)frame.FindByName("btn[0]", "GuiButton")).Press();
                        ((GuiButton)frame.FindByName("btn[0]", "GuiButton")).Press();

                        if (session.Children.Count != 2)
                        {
                            dataGridView1.Rows[i].Cells[2].Value = "N/A";
                            goto acabou;
                        }

                        ((GuiButton)frame.FindByName("btn[0]", "GuiButton")).Press();

                        for (int j = 1; j < 100; j++)
                        {
                            string esp;
                            if (j < 10)
                            {
                                esp = "          ";
                            }
                            else
                            {
                                esp = "         ";
                            }

                            ((GuiTree)frame.FindById("wnd[0]/usr/subSUBSCR_TIPOS:SAPLZRVC_ZBOM_POS_ESP:0200/cntlCONT_TIPOS/shellcont/shell/shellcont[1]/shell[1]")).SelectItem(esp + j, "&Hierarchy");
                            ((GuiTree)frame.FindById("wnd[0]/usr/subSUBSCR_TIPOS:SAPLZRVC_ZBOM_POS_ESP:0200/cntlCONT_TIPOS/shellcont/shell/shellcont[1]/shell[1]")).EnsureVisibleHorizontalItem(esp + j, "&Hierarchy");
                            ((GuiTree)frame.FindById("wnd[0]/usr/subSUBSCR_TIPOS:SAPLZRVC_ZBOM_POS_ESP:0200/cntlCONT_TIPOS/shellcont/shell/shellcont[1]/shell[1]")).DoubleClickItem(esp + j, "&Hierarchy");


                            if (((GuiCTextField)session.ActiveWindow.FindByName("ZTBVC_657-ID_ITEM", "GuiCTextField")).Text == tb_id.Text.ToString())
                            {
                                ((GuiToolbarControl)frame.FindById("wnd[0]/usr/subSUBSCR_TIPOS:SAPLZRVC_ZBOM_POS_ESP:0200/cntlCONT_TIPOS/shellcont/shell/shellcont[1]/shell[0]")).PressButton("EDIT_ESP");
                                ((GuiTextField)frame.FindById("wnd[0]/usr/subSUBSCR_ESPEC:SAPLZRVC_ZBOM_POS_ESP:0300/subSUBSCR_ESP:SAPLZRVC_ZBOM_POS_ESP:0340/ctxtZTBVC_658-IDNRK")).Text = component1;
                                ((GuiButton)frame.FindByName("btn[8]", "GuiButton")).Press();
                                dataGridView1.Rows[i].Cells[2].Value = "OK";
                                break;
                            }
                        }



                        acabou : ((GuiButton)frame.FindByName("btn[2]", "GuiButton")).Press();
                    }
                    catch
                    {
                        ((GuiButton)frame.FindByName("btn[2]", "GuiButton")).Press();
                    }

                    #endregion
                }

                MessageBox.Show("Alteração Concluída", "Alteração Concluída", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            catch
            {
                MessageBox.Show("Erro ao conectar com SAP", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }
        }
Exemple #12
0
        private static void EUpdateEquipmentLocation(int i)
        {
            ((GuiMainWindow)session.FindById("wnd[0]")).Maximize();
            ((GuiOkCodeField)session.FindById("wnd[0]/tbar[0]/okcd")).Text = "/niw21";
            ((GuiMainWindow)session.FindById("wnd[0]")).SendVKey(0);
            ((GuiTextField)session.FindById("wnd[0]/usr/ctxtRIWO00-QMART")).Text = "ZS";
            ((GuiMainWindow)session.FindById("wnd[0]")).SendVKey(0);
            ((GuiTextField)session.FindById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_1:SAPLIQS0:7710/txtRIWO00-HEADKTXT")).Text = "EQUIPMENT MOVEMENT";
            ((GuiTextField)session.FindById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_3:SAPLIQS0:7330/ctxtVIQMEL-STRMN")).Text   = DateTime.Today.ToString("dd.MM.yyyy");
            ((GuiMainWindow)session.FindById("wnd[0]")).SendVKey(0);
            ((GuiMainWindow)session.FindById("wnd[0]")).SendVKey(0);
            ((GuiComboBox)session.FindById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_4:SAPLIQS0:7900/ssubUSER0001:SAPLXQQM:0105/cmbZCBS_ETM_EMR_H-RECEIVER_TYP")).Key = GetLocationType(AssetMaster[i].New.EquipmentLocation);
            ((GuiMainWindow)session.FindById("wnd[0]")).SendVKey(0);
            ((GuiCTextField)session.FindById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_4:SAPLIQS0:7900/ssubUSER0001:SAPLXQQM:0105/ctxtZCBS_ETM_EMR_H-REFERENCE_R")).Text = AssetMaster[i].New.EquipmentLocation;
            ((GuiMainWindow)session.FindById("wnd[0]")).SendVKey(0);
            ((GuiComboBox)session.FindById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_4:SAPLIQS0:7900/ssubUSER0001:SAPLXQQM:0105/cmbZCBS_ETM_EMR_H-SENDER_TYPE")).Key = GetLocationType(AssetMaster[i].Old.EquipmentLocation);
            ((GuiMainWindow)session.FindById("wnd[0]")).SendVKey(0);
            ((GuiCTextField)session.FindById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_4:SAPLIQS0:7900/ssubUSER0001:SAPLXQQM:0105/ctxtZCBS_ETM_EMR_H-REFERENCE_S")).Text = AssetMaster[i].Old.EquipmentLocation;
            ((GuiMainWindow)session.FindById("wnd[0]")).SendVKey(0);

            ((GuiMainWindow)session.FindById("wnd[0]")).SendVKey(0);
            ((GuiMainWindow)session.FindById("wnd[0]")).SendVKey(0);
            ((GuiTab)session.FindById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\\TAB19")).Select();
            ((GuiGridView)session.FindById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\\TAB19/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_1:SAPLIQS0:7900/ssubUSER0001:SAPLXQQM:0103/cntlALV_GRID_CONT/shellcont/shell")).ModifyCell(0, "EQUNR", AssetMaster[i].EquipmentNumber);
            ((GuiGridView)session.FindById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\\TAB19/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_1:SAPLIQS0:7900/ssubUSER0001:SAPLXQQM:0103/cntlALV_GRID_CONT/shellcont/shell")).TriggerModified();
            ((GuiGridView)session.FindById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\\TAB19/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_1:SAPLIQS0:7900/ssubUSER0001:SAPLXQQM:0103/cntlALV_GRID_CONT/shellcont/shell")).PressEnter();
            ((GuiMainWindow)session.FindById("wnd[0]")).SendVKey(11);

            if (!((GuiStatusbar)session.FindById("wnd[0]/sbar")).Text.Contains("saved"))
            {
                var l = new LoggingSystem();
                l.EquipmentNumber = AssetMaster[i].EquipmentNumber;
                l.Message         = ((GuiStatusbar)session.FindById("wnd[0]/sbar")).Text;
                l.Type            = "EMR FAIL";
                l.OldValue        = AssetMaster[i].Old.EquipmentLocation;
                l.NewValue        = AssetMaster[i].New.EquipmentLocation;
                //AssetMaster[i].Old.EquipmentLocation = AssetMaster[i].New.EquipmentLocation;

                log.Add(l);
                // Console.ReadLine();
            }
            else
            {
                ((GuiOkCodeField)session.FindById("wnd[0]/tbar[0]/okcd")).Text = "/niw22";
                ((GuiMainWindow)session.FindById("wnd[0]")).SendVKey(0);
                ((GuiMainWindow)session.FindById("wnd[0]")).SendVKey(0);
                ((GuiButton)session.FindById("wnd[0]/tbar[1]/btn[13]")).Press();
                ((GuiButton)session.FindById("wnd[0]/tbar[1]/btn[16]")).Press();
                if (((GuiStatusbar)session.FindById("wnd[0]/sbar")).Text.Contains("Reference date for completion will be determined by notification type"))
                {
                    ((GuiMainWindow)session.FindById("wnd[0]")).SendVKey(0);
                }


                if (((GuiStatusbar)session.FindById("wnd[0]/sbar")).Text.Contains("completed"))
                {
                    var l = new LoggingSystem();
                    l.EquipmentNumber = AssetMaster[i].EquipmentNumber;
                    l.Message         = ((GuiStatusbar)session.FindById("wnd[0]/sbar")).Text;
                    l.Type            = "EMR SUCCESS";
                    l.OldValue        = AssetMaster[i].Old.EquipmentLocation;
                    l.NewValue        = AssetMaster[i].New.EquipmentLocation;
                    AssetMaster[i].Old.EquipmentLocation = AssetMaster[i].New.EquipmentLocation;

                    log.Add(l);
                }
                else
                {
                    var l = new LoggingSystem();
                    l.EquipmentNumber = AssetMaster[i].EquipmentNumber;
                    l.Message         = ((GuiStatusbar)session.FindById("wnd[0]/sbar")).Text;
                    l.Type            = "EMR FAIL";
                    l.OldValue        = AssetMaster[i].Old.EquipmentLocation;
                    l.NewValue        = AssetMaster[i].New.EquipmentLocation;
                    //AssetMaster[i].Old.EquipmentLocation = AssetMaster[i].New.EquipmentLocation;

                    log.Add(l);
                }
            }
        }