Ejemplo n.º 1
0
        public InvoiceValueModel GetInvoiceValue(RfcDestination rfcDest)
        {
            InvoiceValueModel invoiceValueModel = new InvoiceValueModel();
            RfcDestination    SAPRfcDestination = RfcDestinationManager.GetDestination("accelyides");

            RfcRepository rfcrep = SAPRfcDestination.Repository;
            IRfcFunction  BapiGetCompanyDetail = null;


            BapiGetCompanyDetail = rfcrep.CreateFunction("BAPI_INCOMINGINVOICE_GETDETAIL");
            BapiGetCompanyDetail.SetValue("INVOICEDOCNUMBER", "1000000020");
            BapiGetCompanyDetail.SetValue("FISCALYEAR", "2013");
            BapiGetCompanyDetail.Invoke(rfcDest);
            IRfcTable tblReturn = BapiGetCompanyDetail.GetTable("ITEMDATA");
            DataTable TBL       = tblReturn.ToDataTable("TBL");

            for (int i = 0; i < TBL.Rows.Count; i++)
            {
                InvoiceValueModel invoiceValueModel1 = new InvoiceValueModel();

                invoiceValueModel1.REF_DOC = TBL.Rows[i]["REF_DOC"].ToString();
                // invoiceValueModel.lstInvoiceValue.Add(invoiceValueModel1);
            }

            IRfcStructure IRS_OS_HEADER = BapiGetCompanyDetail.GetStructure("HEADERDATA");

            invoiceValueModel.Value = IRS_OS_HEADER.GetValue("USERNAME").ToString();
            //Console.WriteLine(invoiceValueModel.Value);
            //Console.ReadKey();
            RfcSessionManager.EndContext(rfcDest);

            return(invoiceValueModel);
        }
Ejemplo n.º 2
0
        public string test()
        {
            try
            {
                if (Connect())
                {
                    string        text   = "";
                    RfcRepository repo   = oRFC.Repository;
                    IRfcFunction  testfn = repo.CreateFunction("BAPI_COMPANYCODE_GETLIST");
                    testfn.Invoke(oRFC);
                    var companyCodeList = testfn.GetTable("COMPANYCODE_LIST");

                    // turn it into a DataTable..
                    DataTable companyDataTable = companyCodeList.ToDataTable("companycodelist");
                    foreach (DataRow oRow in companyDataTable.Rows)
                    {
                        text += "CompanyCode:" + oRow[0].ToString() + "-" + oRow[1].ToString() + " ";
                    }

                    text = string.Empty;
                    //consultaTabela
                    IRfcFunction funcaoRT = repo.CreateFunction("RFC_READ_TABLE");
                    // Define parametros da função
                    funcaoRT.SetValue("query_table", "T001W");
                    funcaoRT.SetValue("delimiter", "|");
                    // Chama função
                    funcaoRT.Invoke(oRFC);
                    // Recupera Dados cru, você precisa trata-los para
                    // que sejam humanamente legivel
                    IRfcTable tabela          = funcaoRT.GetTable("DATA");
                    DataTable retornoConsulta = tabela.ToDataTable("T001");
                    foreach (DataRow oRow in retornoConsulta.Rows)
                    {
                        string linha     = oRow[0].ToString().Trim();
                        string codCentro = linha.Split('|')[1].Trim();
                        string dsCentro  = linha.Split('|')[2].Trim();
                        text += codCentro + "-" + dsCentro + " ";
                    }

                    return(text.Trim());
                }

                throw new Exception("nao rolou");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Ejemplo n.º 3
0
        public override DataTable GetTableRFC(string name)
        {
            IRfcTable table = this.function.GetTable(name);

            return(table.ToDataTable());
        }
Ejemplo n.º 4
0
        public InvoiceValueModel GetInvoiceValue(RfcDestination rfcDest, string InvoiceDocNumber, string FISCALYEAR)
        {
            List <InvoiceValueModel> lstInvoiceValueDet = new List <InvoiceValueModel>();
            InvoiceValueModel        invoiceValueModel  = new InvoiceValueModel();
            RfcDestination           SAPRfcDestination  = RfcDestinationManager.GetDestination("accelyides");

            RfcRepository rfcrep = SAPRfcDestination.Repository;
            IRfcFunction  BapiGetCompanyDetail = null;


            BapiGetCompanyDetail = rfcrep.CreateFunction("BAPI_INCOMINGINVOICE_GETDETAIL");
            BapiGetCompanyDetail.SetValue("INVOICEDOCNUMBER", InvoiceDocNumber);
            BapiGetCompanyDetail.SetValue("FISCALYEAR", FISCALYEAR);
            BapiGetCompanyDetail.Invoke(rfcDest);
            IRfcTable tblReturn = BapiGetCompanyDetail.GetTable("ITEMDATA");
            DataTable TBL       = tblReturn.ToDataTable("TBL");

            IRfcTable tblTAXReturn = BapiGetCompanyDetail.GetTable("TAXDATA");
            DataTable TBLTaxReturn = tblTAXReturn.ToDataTable("TBL");

            IRfcTable tblWithTAXReturn = BapiGetCompanyDetail.GetTable("WITHTAXDATA");
            DataTable DtWithTAXReturn  = tblWithTAXReturn.ToDataTable("TBL");

            IRfcTable tblVendorSplitData = BapiGetCompanyDetail.GetTable("VENDORITEMSPLITDATA");
            DataTable DtVendorSplitData  = tblVendorSplitData.ToDataTable("TBL");

            //for (int i = 0; i < TBL.Rows.Count; i++)
            //{
            //    InvoiceValueModel InvoiceValueModel = new InvoiceValueModel();

            //    InvoiceValueModel.REF_DOC = TBL.Rows[i]["REF_DOC"].ToString();
            //   // invoiceValueModel.lstInvoiceValue.Add(InvoiceValueModel);
            //}
            invoiceValueModel.lstItemInvoiceDet = (from DataRow row in TBL.Rows
                                                   select new InvoiceValueModel
            {
                INVOICE_DOC_ITEM = row["INVOICE_DOC_ITEM"].ToString(),
                PO_NUMBER = row["INVOICE_DOC_ITEM"].ToString(),
                PO_ITEM = row["PO_ITEM"].ToString(),
                SERIAL_NO = row["SERIAL_NO"].ToString(),
                REF_DOC = row["REF_DOC"].ToString(),
                REF_DOC_YEAR = row["REF_DOC_YEAR"].ToString(),
                REF_DOC_IT = row["REF_DOC_IT"].ToString(),
                TAX_CODE = row["TAX_CODE"].ToString(),
                ITEM_AMOUNT = row["ITEM_AMOUNT"].ToString(),
                QUANTITY = row["QUANTITY"].ToString(),
                PO_UNIT = row["PO_UNIT"].ToString(),
                PO_UNIT_ISO = row["PO_UNIT_ISO"].ToString()
            }).ToList();

            invoiceValueModel.lstInvoiceTAXDet = (from DataRow row in TBLTaxReturn.Rows
                                                  select new InvoiceValueModel
            {
                TAX_CODE = row["TAX_CODE"].ToString(),
                TAX_AMOUNT = row["TAX_AMOUNT"].ToString(),
                VEND_ERROR = row["VEND_ERROR"].ToString(),
                TAX_ERROR = row["TAX_ERROR"].ToString(),
            }).ToList();

            invoiceValueModel.lstWithTAXInvoiceDet = (from DataRow row in DtWithTAXReturn.Rows
                                                      select new InvoiceValueModel
            {
                SPLIT_KEY = row["SPLIT_KEY"].ToString(),
                WI_TAX_TYPE = row["WI_TAX_TYPE"].ToString()
            }).ToList();

            invoiceValueModel.lstVEndorItemSolitData = (from DataRow row in DtVendorSplitData.Rows
                                                        select new InvoiceValueModel
            {
                SPLIT_KEY = row["SPLIT_KEY"].ToString(),
                SPLIT_AMOUNT = row["SPLIT_AMOUNT"].ToString()
            }).ToList();

            IRfcStructure IRS_OS_HEADER = BapiGetCompanyDetail.GetStructure("HEADERDATA");

            invoiceValueModel.INV_DOC_NO     = IRS_OS_HEADER.GetValue("INV_DOC_NO").ToString();
            invoiceValueModel.USERNAME       = IRS_OS_HEADER.GetValue("FISC_YEAR").ToString();
            invoiceValueModel.FISC_YEAR      = IRS_OS_HEADER.GetValue("USERNAME").ToString();
            invoiceValueModel.INVOICEE_IND   = IRS_OS_HEADER.GetValue("INVOICE_IND").ToString();
            invoiceValueModel.DOC_TYPE       = IRS_OS_HEADER.GetValue("DOC_TYPE").ToString();
            invoiceValueModel.DOC_DATE       = DateTime.Parse(IRS_OS_HEADER.GetValue("DOC_DATE").ToString());
            invoiceValueModel.PSTNG_DATE     = DateTime.Parse(IRS_OS_HEADER.GetValue("PSTNG_DATE").ToString());
            invoiceValueModel.USERNAME       = IRS_OS_HEADER.GetValue("USERNAME").ToString();
            invoiceValueModel.REF_DOC_NO     = IRS_OS_HEADER.GetValue("REF_DOC_NO").ToString();
            invoiceValueModel.COMP_CODE      = IRS_OS_HEADER.GetValue("COMP_CODE").ToString();
            invoiceValueModel.DIFF_INV       = IRS_OS_HEADER.GetValue("DIFF_INV").ToString();
            invoiceValueModel.CURRENCY       = IRS_OS_HEADER.GetValue("CURRENCY").ToString();
            invoiceValueModel.CURRENCY_ISO   = IRS_OS_HEADER.GetValue("CURRENCY_ISO").ToString();
            invoiceValueModel.EXCH_RATE      = IRS_OS_HEADER.GetValue("EXCH_RATE").ToString();
            invoiceValueModel.EXCH_RATE_V    = IRS_OS_HEADER.GetValue("EXCH_RATE_V").ToString();
            invoiceValueModel.GROSS_AMT      = IRS_OS_HEADER.GetValue("GROSS_AMNT").ToString();
            invoiceValueModel.BLINE_DATE     = DateTime.Parse(IRS_OS_HEADER.GetValue("BLINE_DATE").ToString());
            invoiceValueModel.ENTRY_DATE     = DateTime.Parse(IRS_OS_HEADER.GetValue("ENTRY_DATE").ToString());
            invoiceValueModel.ENTRY_TIME     = DateTime.Parse(IRS_OS_HEADER.GetValue("ENTRY_TIME").ToString());
            invoiceValueModel.DISCNT         = IRS_OS_HEADER.GetValue("DISCNT").ToString();
            invoiceValueModel.INVOICE_STATUS = IRS_OS_HEADER.GetValue("INVOICE_STATUS").ToString();

            //Console.WriteLine(invoiceValueModel.Value);
            //Console.ReadKey();
            RfcSessionManager.EndContext(rfcDest);

            return(invoiceValueModel);
        }