public virtual void Add(IdocStatus NewStatus)
 {
     base.List.Add(NewStatus);
 }
 public virtual void Add(IdocStatus NewStatus)
 {
     base.List.Add(NewStatus);
 }
        private IdocStatus GetCurrentStatus()
        {
            try
            {
                if (this.des == null)
                {
                    throw new SAPException(Messages.NoConnectionAssigned);
                    //throw new Exception("NoconnectionAssigned");
                }
                if (this._DOCNUM.Trim().Equals(""))
                {
                    throw new SAPException(Messages.NoIdocnumbergiven);
                    //throw new Exception("No Idoc number given");
                }
                RfcSessionManager.BeginContext(des);
                // RFCFunction function = RFCFunctionFactory.GenerateFunctionObjectForEDI_DOCUMENT_OPEN_FOR_READ(this.con.IsUnicode);
                IRfcFunction function = des.Repository.CreateFunction("EDI_DOCUMENT_OPEN_FOR_READ");
                // function.Connection = this.con;
                function["DOCUMENT_NUMBER"].SetValue(this._DOCNUM);
                function.Invoke(des);
                //RFCFunction function2 = RFCFunctionFactory.GenerateFunctionObjectForEDI_DOCUMENT_READ_LAST_STATUS(this.con.IsUnicode);
                IRfcFunction function2 = des.Repository.CreateFunction("EDI_DOCUMENT_READ_LAST_STATUS");
                //function2.Connection = this.con;
                function2["DOCUMENT_NUMBER"].SetValue(this._DOCNUM);
                function2.Invoke(des);
                IRfcStructure structure = function2.GetStructure("STATUS");
                IdocStatus status = new IdocStatus
                {
                    UserName = structure["UNAME"].GetValue().ToString(),
                    Status = structure["STATUS"].GetValue().ToString(),
                    Description = Converts.FormatMessage(
                        structure["STATXT"].GetValue().ToString(),
                        structure["STAPA1"].GetValue().ToString(),
                        structure["STAPA2"].GetValue().ToString(),
                        structure["STAPA3"].GetValue().ToString(),
                        structure["STAPA4"].GetValue().ToString()),
                    StatusVar1 = structure["STAPA1"].GetValue().ToString(),
                    StatusVar2 = structure["STAPA2"].GetValue().ToString(),
                    StatusVar3 = structure["STAPA3"].GetValue().ToString(),
                    StatusVar4 = structure["STAPA4"].GetValue().ToString()
                };

                //注意要用GetValue来获取原始值。

                //DateTime time = new DateTime(
                //    Convert.ToInt32(structure["CREDAT"].GetValue().ToString().Substring(0, 4)),
                //    Convert.ToInt32(structure["CREDAT"].GetValue().ToString().Substring(4, 2)),
                //    Convert.ToInt32(structure["CREDAT"].GetValue().ToString().Substring(6, 2)),
                //    Convert.ToInt32(structure["CRETIM"].GetValue().ToString().Substring(0, 2)),
                //    Convert.ToInt32(structure["CRETIM"].GetValue().ToString().Substring(2, 2)),
                //    Convert.ToInt32(structure["CRETIM"].GetValue().ToString().Substring(4, 2)));
                //status.CreationDateTime = time;
                status.CreationDate = structure["CREDAT"].GetValue().ToString();
                status.CreationTime = structure["CRETIM"].GetValue().ToString();
                //RFCFunction function3 = RFCFunctionFactory.GenerateFunctionObjectForEDI_DOCUMENT_CLOSE_READ(this.con.IsUnicode);
                IRfcFunction function3 = des.Repository.CreateFunction("EDI_DOCUMENT_CLOSE_READ");
                //function3.Connection = this.con;
                function3["DOCUMENT_NUMBER"].SetValue(this._DOCNUM);
                function3.Invoke(des);
                RfcSessionManager.EndContext(des);
                return status;
            }
            catch (RfcAbapException rfcException)
            {

                throw new SAPException(rfcException.Key + rfcException.Message);
            }
        }