コード例 #1
0
 public static SapConnection GetObject()
 {
     if (SapConnection.m_sapConnection == null)
     {
         lock (syncRoot)
         {
             if (SapConnection.m_sapConnection == null)
             {
                 SapConnection.m_sapConnection = new SapConnection();
             }
         }
     }
     return(SapConnection.m_sapConnection);
 }
コード例 #2
0
        public static void ValidateSAPData(PlanningFunctionGroup activityPlanGroup, int functionCount)
        {
            lock (m_syncObject)
            {
                if (activityPlanGroup.FunctionList.Count > 0)
                {
                    IRfcFunction sapValidateCostPlanFunction = SapConnection.GetObject().CurrentDestination.Repository.CreateFunction("BAPI_ACT_PRICE_CHECK_AND_POST");
                    IRfcTable    returnTable = null;

                    try
                    {
                        ///*** --- IMPORT (SAP TAB) -------------------------------***//

                        IRfcStructure headerInfoStructure = sapValidateCostPlanFunction.GetStructure("HEADER_INFO"); // HEADER_INFO


                        headerInfoStructure.SetValue("CO_AREA", ((ActivityPlan)activityPlanGroup.FunctionList[0]).ControllingArea);           // 3
                        headerInfoStructure.SetValue("FISC_YEAR", ((ActivityPlan)activityPlanGroup.FunctionList[0]).FiscalYear);              // 4
                        headerInfoStructure.SetValue("PERIOD_FROM", ((ActivityPlan)activityPlanGroup.FunctionList[0]).PeriodFrom);            // 5
                        headerInfoStructure.SetValue("PERIOD_TO", ((ActivityPlan)activityPlanGroup.FunctionList[0]).PeriodTo);                // 6
                        headerInfoStructure.SetValue("VERSION", ((ActivityPlan)activityPlanGroup.FunctionList[0]).Version);                   // 8
                        headerInfoStructure.SetValue("DOC_HDR_TX", ((ActivityPlan)activityPlanGroup.FunctionList[0]).DocumentHeaderText);     // 9
                        headerInfoStructure.SetValue("PLAN_CURRTYPE", ((ActivityPlan)activityPlanGroup.FunctionList[0]).PlanningCurrency);    // 10

                        sapValidateCostPlanFunction.SetValue("DELTA", ((ActivityPlan)activityPlanGroup.FunctionList[0]).Delta);               // 11
                        sapValidateCostPlanFunction.SetValue("TESTRUN", "X");                                                                 // "X" - Validate Only, " " - Post

                        foreach (IPlanningFunction myFunction in activityPlanGroup.FunctionList)
                        {
                            try
                            {
                                /*** --- IDX_STRUCTURE -- CO Planning: Plan Activity BAPIs -------------- ***/

                                IRfcTable indexTable = sapValidateCostPlanFunction.GetTable("IDX_STRUCTURE");
                                indexTable.Append();

                                indexTable.SetValue("OBJECT_INDEX", ((ActivityPlan)myFunction).ObjectIndex.ToString("000000"));
                                indexTable.SetValue("VALUE_INDEX", ((ActivityPlan)myFunction).ValueIndex.ToString("000000"));
                                indexTable.SetValue("ATTRIB_INDEX", "000000");


                                /*** --- OBJECT -- CO Planning: Objects for Plan Activity BAPIs --------- ***/

                                IRfcTable coObjectTable = sapValidateCostPlanFunction.GetTable("OBJECT");
                                coObjectTable.Append();

                                string objectIndex = ((ActivityPlan)myFunction).ObjectIndex.ToString("000000");
                                string valueIndex  = ((ActivityPlan)myFunction).ValueIndex.ToString("000000");

                                try
                                {
                                    if (coObjectTable.GetValue("OBJECT_INDEX") != null)
                                    {
                                        if (coObjectTable.GetValue("OBJECT_INDEX").ToString() != objectIndex)
                                        {
                                            coObjectTable.SetValue("OBJECT_INDEX", ((ActivityPlan)myFunction).ObjectIndex.ToString("000000"));  // Calculated
                                        }
                                    }
                                    else
                                    {
                                        coObjectTable.SetValue("OBJECT_INDEX", ((ActivityPlan)myFunction).ObjectIndex.ToString("000000"));      // Calculated
                                    }
                                }
                                catch (Exception ex)
                                {
                                    coObjectTable.SetValue("OBJECT_INDEX", ((ActivityPlan)myFunction).ObjectIndex.ToString("000000"));
                                }

                                coObjectTable.SetValue("COSTCENTER", ((ActivityPlan)myFunction).CostCenter);                                    // 12
                                coObjectTable.SetValue("ACTTYPE", ((ActivityPlan)myFunction).ActivityType);                                     // 13


                                /*** --- ACCOUNT_PLAN_TOTVALUE -- CO Planning: Objects for Primary Cost BAPIs --------- ***/

                                IRfcTable totValueTable = sapValidateCostPlanFunction.GetTable("TOT_VALUE");
                                totValueTable.Append();

                                totValueTable.SetValue("VALUE_INDEX", ((ActivityPlan)myFunction).ValueIndex.ToString("000000"));              // Calculated

                                if (((ActivityPlan)myFunction).Price != string.Empty)
                                {
                                    totValueTable.SetValue("PRICE_FIX", ((ActivityPlan)myFunction).Price);                            // 2
                                    totValueTable.SetValue("DIST_KEY_PRICE_FIX", ((ActivityPlan)myFunction).DistributionKey);
                                    totValueTable.SetValue("PRICE_UNIT", "00001");
                                }
                                else
                                {
                                    totValueTable.SetValue("PRICE_FIX", "0");
                                }

                                totValueTable.SetValue("ACTVTY_QTY", ((ActivityPlan)myFunction).Quantity);                            // 1
                                totValueTable.SetValue("DIST_KEY_QUAN", ((ActivityPlan)myFunction).DistributionKey);                  // 7

                                //// ToDo

                                totValueTable.SetValue("CURRENCY", ((ActivityPlan)myFunction).TransactionCurrency);                   // 14


                                myFunction.Updated = true;
                            }
                            catch (Exception ex)
                            {
                                myFunction.ValidationResult = ex.Message;
                            }
                        }
                    }
                    catch (Exception exp)
                    {
                        foreach (IPlanningFunction myFunction in activityPlanGroup.FunctionList)
                        {
                            myFunction.ValidationResult = exp.Message;
                        }
                    }

                    try
                    {
                        sapValidateCostPlanFunction.Invoke(SapConnection.GetObject().CurrentDestination);
                    }
                    catch (Exception ex)
                    {
                        DialogResult r = MessageBox.Show("SAP Authorization Error: " + ex.Message, "Error",
                                                         System.Windows.Forms.MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                        if (r == DialogResult.OK)
                        {
                        }

                        ReturnProgressDataForm.CancelProcess();

                        return;
                    }


                    returnTable = sapValidateCostPlanFunction.GetTable("RETURN");


                    foreach (IPlanningFunction myFunction in activityPlanGroup.FunctionList)
                    {
                        if (!SAPRequest.ReturnValuesList.ContainsKey(myFunction.Signature))
                        {
                            SAPRequest.ReturnValuesList.Add(myFunction.Signature, myFunction);
                        }
                    }

                    if (returnTable.RowCount > 0)
                    {
                        try
                        {
                            string logPath = LogFile.CheckCreateLogFolder() + "\\PWLogValOnly" + DateTime.Now.ToString("(dd-MMM-yyyy-HH-mm-ss-f)") + ".txt";
                            if (!File.Exists(logPath))
                            {
                                using (TextWriter writer = File.CreateText(logPath))
                                {
                                    writer.WriteLine("VALIDATION ONLY: " + DateTime.Now.ToString("(dd-MMM-yyyy-HH-mm-ss-f)"));
                                    writer.WriteLine(" ");
                                    for (int y = 0; y <= (returnTable.RowCount - 1); y += 1)
                                    {
                                        for (int z = 0; z <= (returnTable[y].ElementCount - 1); z += 1)
                                        {
                                            string par = returnTable[y][z].Metadata.Name;
                                            string val = returnTable[y].GetString(z);

                                            string messageLine = par + " : " + val;
                                            writer.WriteLine(messageLine);
                                        }
                                        writer.WriteLine(" ");
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            //MessageBox.Show(ex.Message)
                        }

                        for (int j = 0; j <= (returnTable.RowCount - 1); j++)
                        {
                            int    row     = Convert.ToInt32(returnTable[j].GetString("ROW")) - 1;
                            string message = returnTable[j].GetString("MESSAGE");

                            if (row < 0)
                            {
                                row = 0;
                            }

                            string rType     = string.Empty;
                            string messageV1 = string.Empty;
                            string messageV2 = string.Empty;
                            string messageV3 = string.Empty;
                            string messageV4 = string.Empty;
                            string rNumber   = string.Empty;

                            rType     = returnTable[j].GetString("TYPE");
                            messageV1 = returnTable[j].GetString("MESSAGE_V1");
                            messageV2 = returnTable[j].GetString("MESSAGE_V2");

                            for (int i = 0; i <= (activityPlanGroup.FunctionList.Count - 1); i++)
                            {
                                int elementLocation = SAPRequest.GetObject().TotalProcessedBySAP + i;
                                if (elementLocation < 0)
                                {
                                    elementLocation = 0;
                                }

                                string activityType = ((ActivityPlan)SAPRequest.ReturnValuesList.Values.ElementAt(elementLocation)).ActivityType;
                                string costCenter   = ((ActivityPlan)SAPRequest.ReturnValuesList.Values.ElementAt(elementLocation)).CostCenter;

                                try
                                {
                                    messageV1 = messageV1.TrimStart('0');
                                    messageV2 = messageV2.TrimStart('0');
                                }
                                catch (Exception ex)
                                {
                                }

                                try
                                {
                                    if (i == row && !string.IsNullOrEmpty(message))
                                    {
                                        SAPRequest.ReturnValuesList.Values.ElementAt(elementLocation).Result = message;
                                    }
                                    else if (i != row && rType == "E")
                                    {
                                        try
                                        {
                                            if (messageV1 == activityType || messageV2 == activityType)
                                            {
                                                // account for incrementing batch number
                                                SAPRequest.ReturnValuesList.Values.ElementAt(elementLocation).Result = message;
                                            }
                                            else if (messageV1 != activityType && messageV1 != costCenter && row == 0)
                                            {
                                                rNumber = returnTable[j].GetString("NUMBER");
                                                if (rNumber != string.Empty)
                                                {
                                                    SAPRequest.ReturnValuesList.Values.ElementAt(elementLocation).Result = message;
                                                    if (ReturnProgressDataForm.OperationCancelled)
                                                    {
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                        }
                                    }
                                    else if (rType == "I")
                                    {
                                        foreach (IPlanningFunction myFunction in activityPlanGroup.FunctionList)
                                        {
                                            SAPRequest.ReturnValuesList[myFunction.Signature].Result = message;
                                            if (ReturnProgressDataForm.OperationCancelled)
                                            {
                                                break;
                                            }
                                        }
                                        return;
                                    }
                                }
                                catch (Exception ex)
                                {
                                }
                                if (ReturnProgressDataForm.OperationCancelled)
                                {
                                    break;
                                }
                            }
                            if (ReturnProgressDataForm.OperationCancelled)
                            {
                                break;
                            }
                        }


                        foreach (IPlanningFunction myFunction in activityPlanGroup.FunctionList)
                        {
                            if ((SAPRequest.ReturnValuesList[myFunction.Signature].Result == null) || (SAPRequest.ReturnValuesList[myFunction.Signature].Result == string.Empty))
                            {
                                SAPRequest.ReturnValuesList[myFunction.Signature].Result = "pwValidated";
                            }
                            if (ReturnProgressDataForm.OperationCancelled)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        foreach (IPlanningFunction myFunction in activityPlanGroup.FunctionList)
                        {
                            SAPRequest.ReturnValuesList[myFunction.Signature].Result = "pwValidated";
                            if (ReturnProgressDataForm.OperationCancelled)
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
        private void uxLogonButton_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(this.uxUserNameTextBox.Text))
            {
                DataCache.GetObject().SapUserName = this.uxUserNameTextBox.Text;
            }
            else
            {
                MessageBox.Show("Please enter a valid User Name"); return;
            }

            if (!String.IsNullOrEmpty(this.uxPasswordTextBox.Text))
            {
                DataCache.GetObject().SapLogonPassword = this.uxPasswordTextBox.Text;
            }
            else
            {
                MessageBox.Show("Please enter a valid Password"); return;
            }

            if (!String.IsNullOrEmpty(this.uxSystemHostTextBox.Text))
            {
                DataCache.GetObject().SapHost = this.uxSystemHostTextBox.Text;
            }
            else
            {
                MessageBox.Show("Please enter an SAP Host (Server)"); return;
            }

            if (!String.IsNullOrEmpty(this.uxSystemIDTextBox.Text))
            {
                DataCache.GetObject().SapSystemID = this.uxSystemIDTextBox.Text;
            }
            else
            {
                MessageBox.Show("Please enter an SAP System ID"); return;
            }

            if (!String.IsNullOrEmpty(this.uxSystemNumberTextBox.Text))
            {
                DataCache.GetObject().SapSystemNumber = this.uxSystemNumberTextBox.Text;
            }
            else
            {
                MessageBox.Show("Please enter an SAP System Number"); return;
            }

            if (!String.IsNullOrEmpty(this.uxClientTextBox.Text))
            {
                DataCache.GetObject().SapClient = this.uxClientTextBox.Text;
            }
            else
            {
                MessageBox.Show("Please enter an SAP Client"); return;
            }

            if (!String.IsNullOrEmpty(this.uxLanguageTextBox.Text))
            {
                DataCache.GetObject().SapLanguage = this.uxLanguageTextBox.Text;
            }
            else
            {
                MessageBox.Show("Please enter an SAP Language"); return;
            }

            DataCache.GetObject().SapLanguage = this.uxLanguageTextBox.Text;

            if (SapConnection.GetObject().IsConnected)
            {
                SapConnection.GetObject().ResetSAPConnection();
            }

            try
            {
                SapConnection.GetObject().connectSAPserver(this.uxUserNameTextBox.Text, this.uxPasswordTextBox.Text, this.uxClientTextBox.Text, this.uxLanguageTextBox.Text,
                                                           this.uxSystemNumberTextBox.Text, this.uxSystemHostTextBox.Text, this.uxSystemIDTextBox.Text, true);

                if (SapConnection.GetObject().connectSAPserver())
                {
                    MessageBox.Show("SAP Connected", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("SAP Connection Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show("SAP Connection Error: \r\n" + exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.OnLogonComplete?.Invoke();
                this.Close();
            }
        }
コード例 #4
0
        public static void PostSAPData(PlanningFunctionGroup costPlanGroup, int functionCount)
        {
            lock (m_syncObject)
            {
                if (costPlanGroup.FunctionList.Count > 0)
                {
                    IRfcFunction sapPostCostPlanFunction = SapConnection.GetObject().CurrentDestination.Repository.CreateFunction("BAPI_COSTACTPLN_POSTPRIMCOST");
                    IRfcFunction sapCommitWorkFunction   = SapConnection.GetObject().CurrentDestination.Repository.CreateFunction("BAPI_TRANSACTION_COMMIT");
                    IRfcTable    returnTable             = null;

                    try
                    {
                        IRfcStructure headerInfoStructure = sapPostCostPlanFunction.GetStructure("HEADERINFO");                       // HEADER_INFO

                        headerInfoStructure.SetValue("CO_AREA", ((CostPlan)costPlanGroup.FunctionList[0]).ControllingArea);           // 3
                        headerInfoStructure.SetValue("FISC_YEAR", ((CostPlan)costPlanGroup.FunctionList[0]).FiscalYear);              // 4
                        headerInfoStructure.SetValue("PERIOD_FROM", ((CostPlan)costPlanGroup.FunctionList[0]).PeriodFrom);            // 5
                        headerInfoStructure.SetValue("PERIOD_TO", ((CostPlan)costPlanGroup.FunctionList[0]).PeriodTo);                // 6
                        headerInfoStructure.SetValue("VERSION", ((CostPlan)costPlanGroup.FunctionList[0]).Version);                   // 8
                        headerInfoStructure.SetValue("DOC_HDR_TX", ((CostPlan)costPlanGroup.FunctionList[0]).DocumentHeaderText);     // 9
                        headerInfoStructure.SetValue("PLAN_CURRTYPE", ((CostPlan)costPlanGroup.FunctionList[0]).PlanningCurrency);    // 10
                        sapPostCostPlanFunction.SetValue("DELTA", ((CostPlan)costPlanGroup.FunctionList[0]).Delta);                   // 11

                        foreach (IPlanningFunction myFunction in costPlanGroup.FunctionList)
                        {
                            try
                            {
                                IRfcTable coObjectTable = sapPostCostPlanFunction.GetTable("COOBJECT");                                   // OBJECT

                                string objectIndex = ((CostPlan)myFunction).ObjectIndex.ToString("000000");
                                string valueIndex  = ((CostPlan)myFunction).ValueIndex.ToString("000000");

                                coObjectTable.Append();

                                try
                                {
                                    if (coObjectTable.GetValue("OBJECT_INDEX") != null)
                                    {
                                        if (((string)coObjectTable.GetValue("OBJECT_INDEX")) != objectIndex)
                                        {
                                            coObjectTable.SetValue("OBJECT_INDEX", ((CostPlan)myFunction).ObjectIndex.ToString("000000"));  // Calculated
                                        }
                                    }
                                    else
                                    {
                                        coObjectTable.SetValue("OBJECT_INDEX", ((CostPlan)myFunction).ObjectIndex.ToString("000000"));     // Calculated
                                    }
                                }
                                catch (Exception ex)
                                {
                                    coObjectTable.SetValue("OBJECT_INDEX", ((CostPlan)myFunction).ObjectIndex.ToString("000000"));
                                }

                                coObjectTable.SetValue("COSTCENTER", ((CostPlan)myFunction).CostCenter);                    // 11
                                coObjectTable.SetValue("ACTTYPE", ((CostPlan)myFunction).ActivityType);                     // 13
                                coObjectTable.SetValue("ORDERID", ((CostPlan)myFunction).OrderID);                          // 14
                                coObjectTable.SetValue("WBS_ELEMENT", ((CostPlan)myFunction).WBSElement);                   // 15

                                IRfcTable totValueTable = sapPostCostPlanFunction.GetTable("TOTVALUE");                     // TOT_VALUE

                                totValueTable.Append();
                                totValueTable.SetValue("VALUE_INDEX", ((CostPlan)myFunction).ValueIndex.ToString("000000"));     // Calculated

                                if (((CostPlan)myFunction).FixedInputValue != string.Empty)
                                {
                                    totValueTable.SetValue("FIX_VALUE", ((CostPlan)myFunction).FixedInputValue);                // 2
                                }
                                else
                                {
                                    totValueTable.SetValue("FIX_VALUE", "0");
                                }

                                totValueTable.SetValue("DIST_KEY_FIX_VAL", ((CostPlan)myFunction).DistributionKey);         // 6
                                totValueTable.SetValue("COST_ELEM", ((CostPlan)myFunction).CostElement);                    // 12
                                totValueTable.SetValue("FUNCTION", ((CostPlan)myFunction).FunctionalArea);                  // 16
                                totValueTable.SetValue("FUND", ((CostPlan)myFunction).Fund);                                // 17
                                totValueTable.SetValue("GRANT_NBR", ((CostPlan)myFunction).Grant);                          // 18
                                totValueTable.SetValue("TRANS_CURR", ((CostPlan)myFunction).TransactionCurrency);           // 19


                                IRfcTable indexTable = sapPostCostPlanFunction.GetTable("INDEXSTRUCTURE");
                                // IDX_STRUCTURE

                                indexTable.Append();
                                indexTable.SetValue("OBJECT_INDEX", ((CostPlan)myFunction).ObjectIndex.ToString("000000"));
                                indexTable.SetValue("VALUE_INDEX", ((CostPlan)myFunction).ValueIndex.ToString("000000"));
                                indexTable.SetValue("ATTRIB_INDEX", "000000");

                                myFunction.Updated = true;
                            }
                            catch (Exception ex)
                            {
                                myFunction.ValidationResult = ex.Message;
                            }
                        }
                    }
                    catch (Exception exp)
                    {
                        foreach (IPlanningFunction myFunction in costPlanGroup.FunctionList)
                        {
                            myFunction.ValidationResult = exp.Message;
                        }
                    }

                    try
                    {
                        RfcSessionManager.BeginContext(SapConnection.GetObject().CurrentDestination);

                        sapPostCostPlanFunction.Invoke(SapConnection.GetObject().CurrentDestination);
                        sapCommitWorkFunction.Invoke(SapConnection.GetObject().CurrentDestination);

                        RfcSessionManager.EndContext(SapConnection.GetObject().CurrentDestination);
                    }
                    catch (Exception ex)
                    {
                        DialogResult r = MessageBox.Show("SAP Authorization Error: " + ex.Message, "Error",
                                                         System.Windows.Forms.MessageBoxButtons.OK, MessageBoxIcon.Error,
                                                         MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                        if (r == DialogResult.OK)
                        {
                        }

                        ReturnProgressDataForm.CancelProcess();

                        return;
                    }


                    returnTable = sapPostCostPlanFunction.GetTable("RETURN");


                    foreach (IPlanningFunction myFunction in costPlanGroup.FunctionList)
                    {
                        if (!SAPRequest.ReturnValuesList.ContainsKey(myFunction.Signature))
                        {
                            SAPRequest.ReturnValuesList.Add(myFunction.Signature, myFunction);
                        }
                    }

                    if (returnTable.RowCount > 0)
                    {
                        try
                        {
                            string logPath = LogFile.CheckCreateLogFolder() + "\\PWLogValOnly" + DateTime.Now.ToString("(dd-MMM-yyyy-HH-mm-ss-f)") + ".txt";
                            if (!File.Exists(logPath))
                            {
                                using (TextWriter writer = File.CreateText(logPath))
                                {
                                    writer.WriteLine("VALIDATION AND POST: " + DateTime.Now.ToString("(dd-MMM-yyyy-HH-mm-ss-f)"));
                                    writer.WriteLine(" ");
                                    for (int y = 0; y <= (returnTable.RowCount - 1); y += 1)
                                    {
                                        for (int z = 0; z <= (returnTable[y].ElementCount - 1); z += 1)
                                        {
                                            string par = returnTable[y][z].Metadata.Name;
                                            string val = returnTable[y].GetString(z);

                                            string messageLine = par + " : " + val;
                                            writer.WriteLine(messageLine);
                                        }
                                        writer.WriteLine(" ");
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            //MessageBox.Show(ex.Message)
                        }


                        for (int j = 0; j <= (returnTable.RowCount - 1); j++)
                        {
                            int    row     = Convert.ToInt32(returnTable[j].GetString("ROW")) - 1;
                            string message = returnTable[j].GetString("MESSAGE");

                            if (row < 0)
                            {
                                row = 0;
                            }

                            string rType     = string.Empty;
                            string messageV1 = string.Empty;
                            string messageV2 = string.Empty;
                            string messageV3 = string.Empty;
                            string messageV4 = string.Empty;
                            string rNumber   = string.Empty;

                            rType     = returnTable[j].GetString("TYPE");
                            messageV1 = returnTable[j].GetString("MESSAGE_V1");
                            messageV2 = returnTable[j].GetString("MESSAGE_V2");

                            for (int i = 0; i <= (costPlanGroup.FunctionList.Count - 1); i++)
                            {
                                int elementLocation = SAPRequest.GetObject().TotalProcessedBySAP + i;
                                if (elementLocation < 0)
                                {
                                    elementLocation = 0;
                                }

                                string costElement = ((CostPlan)SAPRequest.ReturnValuesList.Values.ElementAt(elementLocation)).CostElement;
                                string costCenter  = ((CostPlan)SAPRequest.ReturnValuesList.Values.ElementAt(elementLocation)).CostCenter;

                                try
                                {
                                    messageV1 = messageV1.TrimStart('0');
                                    messageV2 = messageV2.TrimStart('0');
                                }
                                catch (Exception ex)
                                {
                                }

                                try
                                {
                                    if (i == row && !string.IsNullOrEmpty(message))
                                    {
                                        SAPRequest.ReturnValuesList.Values.ElementAt(elementLocation).Result = message;
                                    }
                                    else if (i != row && rType == "E")
                                    {
                                        try
                                        {
                                            if (messageV1 == costElement || messageV2 == costElement)
                                            {
                                                // account for incrementing batch number
                                                SAPRequest.ReturnValuesList.Values.ElementAt(elementLocation).Result = message;
                                            }
                                            else if (messageV1 != costElement && messageV1 != costCenter && row == 0)
                                            {
                                                rNumber = returnTable[j].GetString("NUMBER");
                                                if (rNumber != string.Empty)
                                                {
                                                    SAPRequest.ReturnValuesList.Values.ElementAt(elementLocation).Result = message;
                                                    if (ReturnProgressDataForm.OperationCancelled)
                                                    {
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                        }
                                    }
                                    else if (rType == "I")
                                    {
                                        foreach (IPlanningFunction myFunction in costPlanGroup.FunctionList)
                                        {
                                            SAPRequest.ReturnValuesList[myFunction.Signature].Result = message;
                                            if (ReturnProgressDataForm.OperationCancelled)
                                            {
                                                break;
                                            }
                                        }
                                        return;
                                    }
                                }
                                catch (Exception ex)
                                {
                                }
                                if (ReturnProgressDataForm.OperationCancelled)
                                {
                                    break;
                                }
                            }
                            if (ReturnProgressDataForm.OperationCancelled)
                            {
                                break;
                            }
                        }
                        foreach (IPlanningFunction myFunction in costPlanGroup.FunctionList)
                        {
                            if (SAPRequest.ReturnValuesList[myFunction.Signature].Result == null | SAPRequest.ReturnValuesList[myFunction.Signature].Result == string.Empty)
                            {
                                SAPRequest.ReturnValuesList[myFunction.Signature].Result = "pwValidated";
                            }
                            if (ReturnProgressDataForm.OperationCancelled)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        foreach (IPlanningFunction myFunction in costPlanGroup.FunctionList)
                        {
                            SAPRequest.ReturnValuesList[myFunction.Signature].Result = "pwValidated";
                            if (ReturnProgressDataForm.OperationCancelled)
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }