示例#1
0
        /// <summary>
        /// BAPI_PO_GETDETAIL-取得PO資料
        /// </summary>
        /// <param name="PURCHASEORDER"></param>
        /// <param name="ITEMS"></param>
        /// <param name="ACCOUNT_ASSIGNMENT"></param>
        /// <param name="SCHEDULES"></param>
        /// <param name="HISTORY"></param>
        /// <param name="ITEM_TEXTS"></param>
        /// <param name="HEADER_TEXTS"></param>
        /// <param name="SERVICES"></param>
        /// <param name="CONFIRMATIONS"></param>
        /// <param name="SERVICES_TEXTS"></param>
        /// <param name="EXTENSIONS"></param>
        /// <returns></returns>
        public DataSet Send(string PURCHASEORDER, bool ITEMS = true
                            , bool ACCOUNT_ASSIGNMENT        = false, bool SCHEDULES = false, bool HISTORY    = false
                            , bool ITEM_TEXTS    = false, bool HEADER_TEXTS          = false, bool SERVICES   = false
                            , bool CONFIRMATIONS = false, bool SERVICE_TEXTS         = false, bool EXTENSIONS = false
                            )
        {
            const string X = "X";

            DataSet ds = new DataSet();

            //PO處理
            PURCHASEORDER = ValueProcess(PURCHASEORDER, 10);

            IRfcFunction rfcFunction = GetRfcFunction(FunName);

            rfcFunction.SetValue("PURCHASEORDER", PURCHASEORDER);

            rfcFunction.SetValue("ITEMS", ITEMS ? X : string.Empty);

            rfcFunction.SetValue("ACCOUNT_ASSIGNMENT", ACCOUNT_ASSIGNMENT ? X : string.Empty);
            rfcFunction.SetValue("SCHEDULES", SCHEDULES ? X : string.Empty);
            rfcFunction.SetValue("HISTORY", HISTORY ? X : string.Empty);
            rfcFunction.SetValue("ITEM_TEXTS", ITEM_TEXTS ? X : string.Empty);
            rfcFunction.SetValue("HEADER_TEXTS", HEADER_TEXTS ? X : string.Empty);
            rfcFunction.SetValue("SERVICES", SERVICES ? X : string.Empty);
            rfcFunction.SetValue("CONFIRMATIONS", CONFIRMATIONS ? X : string.Empty);
            rfcFunction.SetValue("SERVICE_TEXTS", SERVICE_TEXTS ? X : string.Empty);
            rfcFunction.SetValue("EXTENSIONS", EXTENSIONS ? X : string.Empty);

            rfcFunction.Invoke(Destination);

            IRfcStructure PO_HEADER   = rfcFunction.GetStructure("PO_HEADER");
            DataTable     dtPO_HEADER = RfcStructureToDataTable(PO_HEADER);

            dtPO_HEADER.TableName = "PO_HEADER";
            ds.Tables.Add(dtPO_HEADER);

            IRfcStructure PO_ADDRESS   = rfcFunction.GetStructure("PO_ADDRESS");
            DataTable     dtPO_ADDRESS = RfcStructureToDataTable(PO_ADDRESS);

            dtPO_ADDRESS.TableName = "PO_ADDRESS";
            ds.Tables.Add(dtPO_ADDRESS);


            IRfcTable PO_ITEMS   = rfcFunction.GetTable("PO_ITEMS");
            DataTable dtPO_ITEMS = RfcTableToDataTable(PO_ITEMS);

            dtPO_ITEMS.TableName = "PO_ITEMS";
            ds.Tables.Add(dtPO_ITEMS);


            IRfcTable RETURN   = rfcFunction.GetTable("RETURN");
            DataTable dtRETURN = RfcTableToDataTable(RETURN);

            dtRETURN.TableName = "RETURN";
            ds.Tables.Add(dtRETURN);

            return(ds);
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string dateStr = "";
            string timeStr = "";

            dateStr = dtDate.Text.Substring(6, 4) + "" + dtDate.Text.Substring(3, 2) + "" + dtDate.Text.Substring(0, 2);
            timeStr = dtTime.Text.Substring(0, 2) + "" + dtTime.Text.Substring(3, 2) + "" + dtTime.Text.Substring(6, 2);

            rfc_Connector cfg = null;

            cfg = new rfc_Connector();

            IRfcFunction getDataSAP = GlobalData.rfcRepository.CreateFunction("ZPM_NOTIF_01");

            IRfcStructure ls_ticketdata = getDataSAP.GetStructure("TICKED_DATA");
            IRfcStructure ls_result     = getDataSAP.GetStructure("RESULT");

            ls_ticketdata.SetValue("EQFNR", txt01.Text);
            ls_ticketdata.SetValue("QMART", cb01.Text);
            ls_ticketdata.SetValue("QMTXT", txt02.Text);
            ls_ticketdata.SetValue("TPLNR", txt03.Text);
            ls_ticketdata.SetValue("EQUNR", txt04.Text);
            ls_ticketdata.SetValue("QMNAM", txt05.Text);
            ls_ticketdata.SetValue("QMDAT", dateStr);
            ls_ticketdata.SetValue("MZEIT", timeStr);

            ls_ticketdata.SetValue("PRIOK", cbPriok.Text);
            ls_ticketdata.SetValue("STRMN", dateStr);
            ls_ticketdata.SetValue("LTRMN", dateStr);
            ls_ticketdata.SetValue("STRUR", timeStr);
            ls_ticketdata.SetValue("LTRUR", timeStr);

            ls_ticketdata.SetValue("ZBEBER", txt06.Text);
            ls_ticketdata.SetValue("ZBEBER2", txt07.Text);
            ls_ticketdata.SetValue("ZTPLNR2", txt08.Text);
            ls_ticketdata.SetValue("ZKOSTL", txt09.Text);

            try
            {
                getDataSAP.Invoke(GlobalData.rfcDestination);
                RfcSessionManager.EndContext(GlobalData.rfcDestination);

                IRfcStructure exStructure = getDataSAP.GetStructure("RESULT");
                MessageBox.Show(exStructure.GetValue("MESSAGE") + " - " + exStructure.GetValue("DOCNUM"));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#3
0
        public int VALIDATE_MAIL(string UIDL, SharedSettings.Settings settings)
        {
            string value = string.Empty;

            try
            {
                //Establecemos conexion con SAP
                RfcConfigParameters rfc = SAP_Connection.GetParameters(settings);

                RfcDestination rfcDest = null;
                rfcDest = RfcDestinationManager.GetDestination(rfc);

                //Creamos repositorio para la función
                RfcRepository repo          = rfcDest.Repository;
                IRfcFunction  validate_mail = repo.CreateFunction("Z_MAIL_VALIDATE");


                validate_mail.SetValue("UIDL", UIDL);

                //Ejecutamos la consulta
                validate_mail.Invoke(rfcDest);

                IRfcStructure ret = validate_mail.GetStructure("RETURN");
                value = ret.GetValue("NUMBER").ToString();
                if (value == "004")
                {
                    //Encontró correo previamente guardado
                    return(0);
                }
                else
                {
                    //No encontró correo return
                    return(4);
                }
            }
            catch (RfcCommunicationException e)
            {
                throw e;
            }
            catch (RfcLogonException e)
            {
                // user could not logon...
                throw e;
            }
            catch (RfcAbapRuntimeException e)
            {
                // serious problem on ABAP system side...
                throw e;
            }
            catch (RfcAbapBaseException e)
            {
                // The function module returned an ABAP exception, an ABAP message
                // or an ABAP class-based exception...
                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#4
0
        public List <string> Get_Z_RFC_GD_DELIVERY(string I_VBELN)
        {
            List <string> LsMsg = new List <string>();

            try
            {
                RfcDestination destination = RfcDestinationManager.GetDestination(this.GetCfgParameters());
                IRfcFunction   rfcFunction = destination.Repository.CreateFunction("Z_RFC_GD_DELIVERY");
                rfcFunction.SetValue("I_VBELN", I_VBELN);
                rfcFunction.Invoke(destination);

                IRfcStructure E_RETURN  = rfcFunction.GetStructure("E_RETURN");
                string        SAP_TYPE  = E_RETURN.GetValue("TYPE").ToString(); //是否成功 S 表示成功
                string        SAP_E_ID  = E_RETURN.GetValue("ID").ToString();
                string        SAP_E_NUM = E_RETURN.GetValue("NUMBER").ToString();
                string        SAP_MSG   = E_RETURN.GetValue("MESSAGE").ToString();
                LsMsg.Add(SAP_TYPE);
                LsMsg.Add(SAP_E_ID);
                LsMsg.Add(SAP_E_NUM);
                LsMsg.Add(SAP_MSG);
            }
            catch (Exception ex)
            {
                LsMsg.Add("ERR:" + ex.Message);
            }

            return(LsMsg);
        }
示例#5
0
        public static void GetFieldList(String system, string prog, string dynum)
        {
            try
            {
                RfcDestination destination = SAPDestination.GetDesByName(system);
                IRfcFunction   function    = destination.Repository.CreateFunction("ZVI_RFC_READ_SCREEN");
                function.SetValue("I_PROG", prog);
                function.SetValue("I_DYNNR", dynum);
                function.Invoke(destination);

                IRfcTable     fields = function.GetTable("ET_FELD");
                IRfcStructure rs37a  = function.GetStructure("E_HEADER");

                Fields    = CScreenField.getScreenFieldAsDt(fields);
                UsedLine  = rs37a.GetInt("BZMX");
                TotalLine = rs37a.GetInt("NOLI");
                TotalCol  = rs37a.GetInt("NOCO");
                UsedCol   = rs37a.GetInt("BZBR");

                ScreenType = rs37a.GetString("TYPE");
                Title      = function.GetString("E_TITLE");
            }
            catch (RfcAbapException rfce)
            {
                throw new SAPException(rfce.Key + rfce.Message);
            }
            catch (Exception e)
            {
                throw new SAPException(e.Message);
            }
        }
示例#6
0
        public DataSet RetrieveSociety(string sociedad, string destinationName)
        {
            DataSet dsSociedad = new DataSet();

            try
            {
                if (RfcDestination == null)
                {
                    RfcDestination = RfcDestinationManager.GetDestination(destinationName);
                }
                RfcRepository rfcRepository = RfcDestination.Repository;
                IRfcFunction  rfcFunction   = rfcRepository.CreateFunction("ZRFC_SOCIEDAD_CENTRO_ALMACEN");
                rfcFunction.SetValue("BUKRS", sociedad);

                rfcFunction.Invoke(RfcDestination);
                IRfcStructure sociedadesData = rfcFunction.GetStructure("BUTXT");
                RfcDestination.Repository.GetTableMetadata("ZRFC_SOCIEDAD_CENTRO_ALMACEN").CreateTable();
                IRfcTable SociedadesSummary = sociedadesData.GetTable("ET_SOCIEDADES");
                dsSociedad.Tables.Add(ConvertToDotNetTable(SociedadesSummary));
                ShowFunction(rfcFunction);
            }
            catch (Exception ex)
            {
                throw new Exception("RetrieveSociety Error: " + ex.Message);
            }
            return(dsSociedad);
        }
示例#7
0
文件: UTL.cs 项目: pfs-haibv/projpscd
        // Modify by ManhTV3 on 5/12/2011 - START
        // Kiểm tra dữ liệu nợ
        public static string Prc_check_data_no(string p_short_name, DataRow p_dr, RfcDestination p_sap)
        {
            RfcRepository v_repo = p_sap.Repository;

            IRfcFunction v_babi = v_repo.CreateFunction("ZFM_PSCD_MAPPING_DC");

            IRfcStructure v_struc = v_babi.GetStructure("I_SOURCE");

            v_struc.SetValue("ROW_NUM", p_dr["STT"].ToString());
            v_struc.SetValue("DOC_TYPE", p_dr["LOAI"].ToString());
            v_struc.SetValue("TAX_OFFICE_CODE", p_dr["MA_CQT"]);
            v_struc.SetValue("TIN", p_dr["TIN"].ToString());
            v_struc.SetValue("PROFIT_CENTER", p_dr["MA_CHUONG"].ToString());
            v_struc.SetValue("BUSINESS_AREA", p_dr["MA_KHOAN"].ToString());
            v_struc.SetValue("SEGMENT", p_dr["TMT_MA_TMUC"].ToString());
            v_struc.SetValue("PAY_GROUP", p_dr["TKHOAN"].ToString());
            v_struc.SetValue("POSTING_DATE", p_dr["NGAY_HACH_TOAN"].ToString());
            v_struc.SetValue("START_PERIOD", p_dr["KYKK_TU_NGAY"].ToString());
            v_struc.SetValue("END_PERIOD", p_dr["KYKK_DEN_NGAY"].ToString());
            v_struc.SetValue("DUE_DATE", p_dr["HAN_NOP"].ToString());
            v_struc.SetValue("RETURN_CODE", p_dr["DKT_MA"].ToString());
            v_struc.SetValue("AMOUNT", p_dr["NO_CUOI_KY"].ToString());

            v_babi.Invoke(p_sap);

            return(v_babi.GetString("E_ERROR_CODE"));
        }
示例#8
0
        public static string CheckMaterialsInBOM(Item materialPart)
        {
            Item relationships = materialPart.getRelationships("Part BOM");
            bool materialExist = false;

            foreach (Item partRel in relationships.Enumerate())
            {
                Item   part           = partRel.getRelatedItem();
                string partNumber     = part.getProperty("item_number");
                string partRevision   = part.getProperty("major_rev");
                string materialNumber = partNumber + "-" + partRevision;

                IRfcFunction documentCheckMaterial = destination.Repository.CreateFunction("BAPI_MATERIAL_GET_DETAIL");
                documentCheckMaterial.SetValue("MATERIAL", materialNumber);
                documentCheckMaterial.Invoke(destination);

                IRfcStructure returnMsg     = documentCheckMaterial.GetStructure("RETURN");
                string        messageOutput = returnMsg.GetString("TYPE");
                if (messageOutput == "S")
                {
                    materialExist = false;
                }
                else
                {
                    materialExist = true;
                    break;
                }
            }

            return(materialExist ? "Failure" : "Success");
        }
示例#9
0
文件: UTL.cs 项目: pfs-haibv/projpscd
        // Kiểm tra dữ liệu phát sinh
        public static string Prc_check_data_ps(string p_short_name, DataRow p_dr, RfcDestination p_sap)
        {
            string v_error_code = "";
            // Need a repository for the metadata from the ABAP Dictionary
            // of the corresponding destination system.
            RfcRepository v_repo  = p_sap.Repository;
            IRfcFunction  v_babi  = v_repo.CreateFunction("ZFM_PSCD_MAPPING_TK_DC");
            IRfcStructure v_struc = v_babi.GetStructure("I_SOURCE");

            v_struc.SetValue("ROW_NUM", p_dr["STT"].ToString());
            v_struc.SetValue("DOC_TYPE", p_dr["LOAI"].ToString());
            v_struc.SetValue("TAX_OFFICE_CODE", p_dr["MA_CQT"].ToString());
            v_struc.SetValue("TIN", p_dr["TIN"].ToString());
            v_struc.SetValue("PROFIT_CENTER", p_dr["MA_CHUONG"].ToString());
            v_struc.SetValue("BUSINESS_AREA", p_dr["MA_KHOAN"].ToString());
            v_struc.SetValue("SEGMENT", p_dr["MA_TMUC"].ToString());
            v_struc.SetValue("PAY_GROUP", p_dr["TKHOAN"].ToString());
            v_struc.SetValue("POSTING_DATE", p_dr["NGAY_HTOAN"].ToString());
            v_struc.SetValue("START_PERIOD", p_dr["KY_PSINH_TU"].ToString());
            v_struc.SetValue("END_PERIOD", p_dr["KY_PSINH_DEN"].ToString());
            v_struc.SetValue("DUE_DATE", p_dr["HAN_NOP"].ToString());
            v_struc.SetValue("RETURN_CODE", p_dr["MA_TKHAI"].ToString());
            v_struc.SetValue("AMOUNT", p_dr["SO_TIEN"].ToString());

            v_babi.Invoke(p_sap);

            v_error_code = v_babi.GetString("E_ERROR_CODE");

            return(v_error_code);
        }
        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);
        }
示例#11
0
        public RFC_OUT_Message Rfc_Rmu_Dal(List <RFC_RMU_Model.RFC_RMU_ITEM_Model> rmuItemModel, RFC_RMU_Model.RFC_RMU_HEADER_Model rmuHeaderModel)
        {
            RFC_OUT_Message rfcMessage = new RFC_OUT_Message();

            try
            {
                _configurationId = new RFC_SetUp();
                RfcDestinationManager.RegisterDestinationConfiguration(_configurationId);
                _dest       = RfcDestinationManager.GetDestination("SAPMS");
                _repository = _dest.Repository;
                IRfcFunction  rfc       = _repository.CreateFunction("Z_PP_MES_OUT_RMU"); //调用函数名
                IRfcTable     table     = rfc.GetTable(rmuHeaderModel.E_SAP_RMU);         //RFC表数据
                IRfcStructure structure = rfc.GetStructure("I_HEADER");                   //RFC表头数据
                structure.SetValue("ZMESKEY", rmuHeaderModel.ZMESKEY);
                structure.SetValue("BLDAT", rmuHeaderModel.BLDAT);
                structure.SetValue("BUDAT", rmuHeaderModel.BUDAT);
                structure.SetValue("ZCOUNT", rmuHeaderModel.ZCOUNT);
                structure.SetValue("ZUSER", rmuHeaderModel.ZUSER);
                structure.SetValue("ZUNPLAN", rmuHeaderModel.ZUNPLAN);
                try
                {
                    structure.SetValue("BKTXT", rmuHeaderModel.BKTXT);
                }
                catch  {}

                foreach (var _rmuItemModel in rmuItemModel)
                {
                    table.Insert();
                    table.CurrentRow.SetValue("ZMESITEM", _rmuItemModel.ZMESITEM);
                    table.CurrentRow.SetValue("AUFNR", _rmuItemModel.AUFNR);
                    table.CurrentRow.SetValue("POSNR", _rmuItemModel.POSNR);
                    table.CurrentRow.SetValue("BWART", _rmuItemModel.BWART);
                    table.CurrentRow.SetValue("MATNR", _rmuItemModel.MATNR);
                    table.CurrentRow.SetValue("WERKS", _rmuItemModel.WERKS);
                    table.CurrentRow.SetValue("LGORT", _rmuItemModel.LGORT);
                    table.CurrentRow.SetValue("MENGE", _rmuItemModel.MENGE);
                    table.CurrentRow.SetValue("MEINS", _rmuItemModel.MEINS);
                    table.CurrentRow.SetValue("CHARG", _rmuItemModel.CHARG);
                    table.CurrentRow.SetValue("ITEM_TEXT", _rmuItemModel.ITEM_TEXT);

                    // rmuHeaderModel.ZSUM += _rmuItemModel.MENGE;//所有数据全部相加,取总数
                }
                structure.SetValue("ZSUM", rmuHeaderModel.ZSUM);
                rfc.Invoke(_dest);
                rfcMessage.E_RETURN_CODE    = rfc.GetString("E_RETURN_CODE").ToString();
                rfcMessage.E_RETURN_MESSAGE = rfc.GetString("E_RETURN_MESSAGE").ToString();
                rfcMessage.E_EXPROC         = rfc.GetString("E_MAT_DOC").ToString();
                return(rfcMessage);
            }
            catch (Exception exception)
            {
                rfcMessage.E_RETURN_MESSAGE = "接口RMU 错误:" + exception.ToString();
                return(null);
            }
            finally
            {
                RfcDestinationManager.UnregisterDestinationConfiguration(_configurationId);
            }
        }
示例#12
0
        public int SAVE_MAIL_DATA(List <MAIL_DATA_BE> mail_data, SharedSettings.Settings settings)
        {
            try
            {
                //Establecemos conexion con SAP
                RfcConfigParameters rfc = SAP_Connection.GetParameters(settings);

                RfcDestination rfcDest = null;
                rfcDest = RfcDestinationManager.GetDestination(rfc);

                //Creamos repositorio para la función
                RfcRepository repo      = rfcDest.Repository;
                IRfcFunction  save_mail = repo.CreateFunction("Z_MAIL_SAVE");

                IRfcTable p_maildata = save_mail.GetTable("P_MAILDATA");
                get_maildata_saptab(mail_data, ref p_maildata);

                save_mail.Invoke(rfcDest);

                IRfcStructure bapiret = save_mail.GetStructure("BAPIRET");

                //Ejecutamos la consulta
                //save_mail.Invoke(rfcDest);

                //Revisamos que la consulta haya sido exitosa
                if (bapiret.GetString("TYPE") == "E")
                {
                    return(4); //Hubo un error
                }
                else
                {
                    return(0); //Guardado exitoso
                }
            }
            catch (RfcCommunicationException e)
            {
                throw e;
            }
            catch (RfcLogonException e)
            {
                // user could not logon...
                throw e;
            }
            catch (RfcAbapRuntimeException e)
            {
                // serious problem on ABAP system side...
                throw e;
            }
            catch (RfcAbapBaseException e)
            {
                // The function module returned an ABAP exception, an ABAP message
                // or an ABAP class-based exception...
                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#13
0
        public RFC_OUT_Message  Rfc_Fgo_Dal(List <RFC_FGO_Model.RFC_FGO_ITEM_Model> fgoItemModel, RFC_FGO_Model.RFC_FGO_HEADER_Model fgoHeaderModel)
        {
            RFC_OUT_Message rfcMessage = new RFC_OUT_Message();

            try
            {
                _configurationId = new RFC_SetUp();
                RfcDestinationManager.RegisterDestinationConfiguration(_configurationId);
                _dest       = RfcDestinationManager.GetDestination("SAPMS");
                _repository = _dest.Repository;
                IRfcFunction  rfc       = _repository.CreateFunction("Z_PP_MES_OUT_FGO"); //调用函数名
                IRfcTable     table     = rfc.GetTable("T_DATA");                         //RFC表数据
                IRfcStructure structure = rfc.GetStructure("I_HEADER");                   //RFC表头数据
                structure.SetValue("ZMESKEY", fgoHeaderModel.ZMESKEY);
                structure.SetValue("AUFNR", fgoHeaderModel.AUFNR);
                structure.SetValue("BUDAT", fgoHeaderModel.BUDAT);
                structure.SetValue("ZCOUNT", fgoHeaderModel.ZCOUNT);
                //structure.SetValue("ZSUM", fgoHeaderModel.ZSUM);
                structure.SetValue("ZUSER", fgoHeaderModel.ZUSER);

                fgoHeaderModel.ZSUM = 0;

                foreach (var _fgoItemModel in fgoItemModel)
                {
                    table.Insert();
                    table.CurrentRow.SetValue("ZMESITEM", _fgoItemModel.ZMESITEM);
                    table.CurrentRow.SetValue("BWART", _fgoItemModel.BWART);
                    table.CurrentRow.SetValue("WERKS", _fgoItemModel.WERKS);
                    table.CurrentRow.SetValue("LGORT", _fgoItemModel.LGORT);
                    table.CurrentRow.SetValue("MENGE", _fgoItemModel.MENGE);
                    table.CurrentRow.SetValue("MEINS", _fgoItemModel.MEINS);
                    table.CurrentRow.SetValue("ZINBOXNO_MIN", _fgoItemModel.ZINBOXNO_MIN);
                    table.CurrentRow.SetValue("ZINBOXNO_MAX", _fgoItemModel.ZINBOXNO_MIN);
                    table.CurrentRow.SetValue("ZLOTNO", _fgoItemModel.ZLOTNO);
                    table.CurrentRow.SetValue("ZINBOXNO", _fgoItemModel.ZINBOXNO);
                    fgoHeaderModel.ZSUM += _fgoItemModel.MENGE;//所有数据全部相加,取总数
                }
                structure.SetValue("ZSUM", fgoHeaderModel.ZSUM);
                rfc.Invoke(_dest);
                rfcMessage.E_RETURN_CODE    = rfc.GetString("E_RETURN_CODE").ToString();
                rfcMessage.E_RETURN_MESSAGE = rfc.GetString("E_RETURN_MESSAGE").ToString();
                //rfcMessage.E_PO_NUMBER = rfc.GetInt("E_COUNT").ToString();
                //rfcMessage.E_EXPROC = rfc.GetInt("E_SUM").ToString();
                rfcMessage.E_MAT_DOC = rfc.GetString("E_MAT_DOC").ToString();
                rfcMessage.E_EXPROC  = rfc.GetString("E_EXPROC").ToString();
                return(rfcMessage);
            }
            catch (Exception exception)
            {
                rfcMessage.E_RETURN_MESSAGE = "接口FGO 错误:" + exception.ToString();
                return(null);
            }
            finally
            {
                RfcDestinationManager.UnregisterDestinationConfiguration(_configurationId);
            }
        }
示例#14
0
        public RFC_OUT_Message Rfc_Gpr_Dal(List <RFC_GPR_Model.RFC_GPR_ITEM_Model> gprItemModel, RFC_GPR_Model.RFC_GPR_HEADER_Model gprHeaderModel)
        {
            RFC_OUT_Message rfcMessage = new RFC_OUT_Message();

            try
            {
                _configurationId = new RFC_SetUp();
                RfcDestinationManager.RegisterDestinationConfiguration(_configurationId);
                _dest       = RfcDestinationManager.GetDestination("SAPMS");
                _repository = _dest.Repository;
                IRfcFunction  rfc       = _repository.CreateFunction(gprHeaderModel.FunctionModule); //调用函数名
                IRfcTable     table     = rfc.GetTable(gprHeaderModel.E_SAP_GRP);                    //RFC表数据
                IRfcStructure structure = rfc.GetStructure("I_HEADER");                              //RFC表头数据
                structure.SetValue("ZMESKEY", gprHeaderModel.ZMESKEY);
                structure.SetValue("EBELN", gprHeaderModel.EBELN);
                structure.SetValue("BUKRS", gprHeaderModel.BUKRS);
                structure.SetValue("BSART", gprHeaderModel.BSART);
                structure.SetValue("EKORG", gprHeaderModel.EKORG);
                structure.SetValue("AEDAT", gprHeaderModel.AEDAT);
                structure.SetValue("LIFNR", gprHeaderModel.LIFNR);
                structure.SetValue("ZCOUNT", gprHeaderModel.ZCOUNT);
                structure.SetValue("ZUSER", gprHeaderModel.ZUSER);
                foreach (var _gprItemModel in gprItemModel)
                {
                    table.Insert();
                    table.CurrentRow.SetValue("ZMESITEM", _gprItemModel.ZMESITEM);
                    table.CurrentRow.SetValue("EBELP", _gprItemModel.EBELP);
                    table.CurrentRow.SetValue("LOEKZ", _gprItemModel.LOEKZ);
                    table.CurrentRow.SetValue("MATNR", _gprItemModel.MATNR);
                    table.CurrentRow.SetValue("WERKS", _gprItemModel.WERKS);
                    table.CurrentRow.SetValue("LGORT", _gprItemModel.LGORT);
                    table.CurrentRow.SetValue("MENGE", _gprItemModel.MENGE);
                    table.CurrentRow.SetValue("MEINS", _gprItemModel.MEINS);
                    table.CurrentRow.SetValue("EINDT", _gprItemModel.EINDT);
                    table.CurrentRow.SetValue("LICHA", _gprItemModel.LICHA);
                    table.CurrentRow.SetValue("ZJPSONO", _gprItemModel.ZJPSONO);
                    table.CurrentRow.SetValue("ZJPSOITEM", _gprItemModel.ZJPSOITEM);
                    gprHeaderModel.ZSUM += _gprItemModel.MENGE;//所有数据全部相加,取总数
                }
                structure.SetValue("ZSUM", gprHeaderModel.ZSUM);
                rfc.Invoke(_dest);
                rfcMessage.E_RETURN_CODE = rfc.GetString("E_RETURN_CODE").ToString();
                //rfcMessage.E_RETURN_MESSAGE = rfc.GetString("E_RETURN_MESSAGE").ToString();
                rfcMessage.E_PO_NUMBER = rfc.GetInt("E_COUNT").ToString();
                rfcMessage.E_EXPROC    = rfc.GetInt("E_SUM").ToString();
                return(rfcMessage);
            }
            catch (Exception exception)
            {
                rfcMessage.E_RETURN_MESSAGE = "接口GPR 错误:" + exception.ToString();
                return(null);
            }
            finally
            {
                RfcDestinationManager.UnregisterDestinationConfiguration(_configurationId);
            }
        }
示例#15
0
        public RFC_OUT_Message Rfc_Stu_Dal(List <RFC_STU_Model.RFC_STU_ITEM_Model> stuItemModel, RFC_STU_Model.RFC_STU_HEADER_Model stuHeaderModel)
        {
            RFC_OUT_Message rfcMessage = new RFC_OUT_Message();

            try
            {
                _configurationId = new RFC_SetUp();
                RfcDestinationManager.RegisterDestinationConfiguration(_configurationId);
                _dest       = RfcDestinationManager.GetDestination("SAPMS");
                _repository = _dest.Repository;
                IRfcFunction  rfc       = _repository.CreateFunction(stuHeaderModel.FunctionModule); //调用函数名
                IRfcTable     table     = rfc.GetTable("T_DATA");                                    //RFC表数据
                IRfcStructure structure = rfc.GetStructure("I_HEADER");                              //RFC表头数据
                structure.SetValue("ZMESKEY", stuHeaderModel.ZMESKEY);
                structure.SetValue("BUDAT", stuHeaderModel.BUDAT);
                structure.SetValue("ZCOUNT", stuHeaderModel.ZCOUNT);
                structure.SetValue("ZSUM", stuHeaderModel.ZSUM);
                structure.SetValue("ZUSER", stuHeaderModel.ZUSER);
                structure.SetValue("BKTXT", stuHeaderModel.BKTXT);

                table.Clear();
                foreach (var _stuItemModel in stuItemModel)
                {
                    table.Insert();
                    table.CurrentRow.SetValue("ZMESITEM", _stuItemModel.ZMESITEM);
                    table.CurrentRow.SetValue("BWART", _stuItemModel.BWART);
                    table.CurrentRow.SetValue("MATNR", _stuItemModel.MATNR);
                    table.CurrentRow.SetValue("WERKS", _stuItemModel.WERKS);
                    table.CurrentRow.SetValue("LGORT", _stuItemModel.LGORT);
                    table.CurrentRow.SetValue("MENGE", _stuItemModel.MENGE);
                    table.CurrentRow.SetValue("MEINS", _stuItemModel.MEINS);
                    table.CurrentRow.SetValue("CHARG", _stuItemModel.CHARG);
                    table.CurrentRow.SetValue("ZEILE", _stuItemModel.ZEILE);
                    table.CurrentRow.SetValue("UMLGO", _stuItemModel.UMLGO);
                    table.CurrentRow.SetValue("LIFNR", _stuItemModel.LIFNR);
                    table.CurrentRow.SetValue("SOBKZ", _stuItemModel.SOBKZ);
                    //stuHeaderModel.ZSUM += _stuItemModel.MENGE;//所有数据全部相加,取总数
                }
                structure.SetValue("ZSUM", stuHeaderModel.ZSUM);
                rfc.Invoke(_dest);
                rfcMessage.E_RETURN_CODE    = rfc.GetString("E_RETURN_CODE").ToString();
                rfcMessage.E_RETURN_MESSAGE = rfc.GetString("E_RETURN_MESSAGE").ToString();
                //rfcMessage.E_PO_NUMBER = rfc.GetInt("E_COUNT").ToString();
                //rfcMessage.E_EXPROC = rfc.GetInt("E_SUM").ToString();
                rfcMessage.E_MAT_DOC = rfc.GetString("E_MAT_DOC").ToString();
                return(rfcMessage);
            }
            catch (Exception exception)
            {
                rfcMessage.E_RETURN_MESSAGE = "接口STU 错误:" + exception.ToString();
                return(null);
            }
            finally
            {
                RfcDestinationManager.UnregisterDestinationConfiguration(_configurationId);
            }
        }
示例#16
0
        public RFC_OUT_Message Rfc_Fgu_Dal(List <RFC_FGU_Model.RFC_FGU_ITEM_Model> fguItemModel, RFC_FGU_Model.RFC_FGU_HEADER_Model fguHeaderModel)
        {
            RFC_OUT_Message rfcMessage = new RFC_OUT_Message();

            try
            {
                _configurationId = new RFC_SetUp();
                RfcDestinationManager.RegisterDestinationConfiguration(_configurationId);
                _dest       = RfcDestinationManager.GetDestination("SAPMS");
                _repository = _dest.Repository;
                IRfcFunction  rfc       = _repository.CreateFunction(fguHeaderModel.FunctionModule); //调用函数名
                IRfcTable     table     = rfc.GetTable(fguHeaderModel.E_SAP_FGU);                    //RFC表数据
                IRfcStructure structure = rfc.GetStructure("I_HEADER");                              //RFC表头数据
                structure.SetValue("ZMESKEY", fguHeaderModel.ZMESKEY);
                structure.SetValue("VBELN", fguHeaderModel.VBELN);
                structure.SetValue("WADAT_IST", fguHeaderModel.WADAT_IST);
                structure.SetValue("ZCOUNT", fguHeaderModel.ZCOUNT);
                structure.SetValue("ZSUM", fguHeaderModel.ZSUM);
                structure.SetValue("ZUSER", fguHeaderModel.ZUSER);
                structure.SetValue("ZSTEP", fguHeaderModel.ZSTEP);

                foreach (var _fguItemModel in fguItemModel)
                {
                    table.Insert();
                    table.CurrentRow.SetValue("ZMESITEM", _fguItemModel.ZMESITEM);
                    table.CurrentRow.SetValue("POSNR", _fguItemModel.POSNR);
                    table.CurrentRow.SetValue("MATNR", _fguItemModel.MATNR);
                    table.CurrentRow.SetValue("MENGE", _fguItemModel.MENGE);
                    table.CurrentRow.SetValue("MEINS", _fguItemModel.MEINS);
                    table.CurrentRow.SetValue("CHARG", _fguItemModel.CHARG);
                    table.CurrentRow.SetValue("ZLOTNO", _fguItemModel.ZLOTNO);
                    table.CurrentRow.SetValue("ZINBOXNO", _fguItemModel.ZINBOXNO);
                    table.CurrentRow.SetValue("LOTQTY", _fguItemModel.LOTQTY);
                    //fguHeaderModel.ZSUM += _fguItemModel.MENGE;//所有数据全部相加,取总数
                }
                structure.SetValue("ZSUM", fguHeaderModel.ZSUM);
                rfc.Invoke(_dest);
                rfcMessage.E_RETURN_CODE    = rfc.GetString("E_RETURN_CODE").ToString();
                rfcMessage.E_RETURN_MESSAGE = rfc.GetString("E_RETURN_MESSAGE").ToString();
                rfcMessage.E_MAT_DOC        = rfc.GetString("E_MAT_DOC").ToString();
                //rfcMessage.E_PO_NUMBER = rfc.GetInt("E_COUNT").ToString();
                //rfcMessage.E_EXPROC = rfc.GetInt("E_SUM").ToString();
                return(rfcMessage);
            }
            catch (Exception exception)
            {
                rfcMessage.E_RETURN_MESSAGE = "接口FGU 错误:" + exception.ToString();
                return(null);
            }
            finally
            {
                RfcDestinationManager.UnregisterDestinationConfiguration(_configurationId);
            }
        }
示例#17
0
        public string InsertaSolicitud(Cabecera c, List <Detalle> ds)
        {
            string folio = "";

            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_008");//Módulo de función

                IRfcStructure header = bapi.GetStructure("HEADER");
                header.SetValue("ID_SOLICITUD", c.folio);
                //header.SetValue("TIPO", c.tipo);
                header.SetValue("FECHA", c.fecha);
                header.SetValue("HORA", c.hora);
                header.SetValue("USUARIO", c.usuario);
                header.SetValue("PERNR", c.pernr);
                header.SetValue("ESTATUS", c.estatus);
                //header.SetValue("VISTO", c.visto);
                header.SetValue("COMMENTS", c.comentario);

                IRfcTable detail = bapi.GetTable("IT_DETALLE");
                foreach (Detalle d in ds)
                {
                    detail.Append();
                    detail.SetValue("ID_SOLICITUD", d.folio);
                    detail.SetValue("POS", d.pos);
                    detail.SetValue("VKORG", d.vkorg);
                    detail.SetValue("VTWEG", d.vtweg);
                    detail.SetValue("SPART", d.spart);
                    detail.SetValue("KUNNR", d.kunnr);
                    detail.SetValue("LP_ANT", d.pltyp);
                    detail.SetValue("LP_NVO", d.pltyp_n);
                    //detail.SetValue("MATNR", d.matnr);
                    //detail.SetValue("MATKL", d.matkl);
                    //detail.SetValue("EBELN", d.ebeln);
                    //detail.SetValue("PR_ANT", d.pr_ant);
                    //detail.SetValue("PR_NVO", d.pr_nvo);
                    //detail.SetValue("PORCENTAJE", d.porcentaje);
                    detail.SetValue("ESTATUS", d.estatus);
                    detail.SetValue("FECHA", d.date);
                }

                bapi.Invoke(oDestino);

                ////folio = bapi.GetString("FOLIO");
                IRfcTable folios = bapi.GetTable("IT_FOLIO");
                for (int i = 0; i < folios.Count; i++)
                {
                    folios.CurrentIndex = i;
                    folio += folios.GetString("ID_SOLICITUD") + ", ";
                }
            }
            return(folio);
        }
示例#18
0
        public string chamaBAPI(string CODCLI)
        {
            IRfcFunction funcBAPI = repo.CreateFunction("BAPI_CUSTOMER_GETDETAIL");

            funcBAPI.SetValue("CUSTOMERNO", CODCLI);
            funcBAPI.SetValue("PI_SALESORG", "1000");
            funcBAPI.Invoke(dest);
            IRfcStructure structCode = funcBAPI.GetStructure("RETURN");
            string        detail     = new string(funcBAPI.GetCharArray("RETURN"));

            return(structCode.GetString("NAME").ToString());
        }
        public string ChangePassword(string destinationName, string username)
        {
            try
            {
                RfcDestination rfcDestination = RfcDestinationManager.GetDestination(destinationName);
                RfcRepository  rfcRepository  = rfcDestination.Repository;
                IRfcFunction   rfcFunction    = rfcRepository.CreateFunction("BAPI_USER_CHANGE");
                rfcFunction.Invoke(rfcDestination);
                rfcFunction.SetValue("Username", username);
                string randomString = RandomString.Generate();
                rfcFunction.GetStructure("Password").SetValue("BAPIPWD", randomString);
                rfcFunction.GetStructure("Passwordx").SetValue("BAPIPWD", "X");
                rfcFunction.Invoke(rfcDestination);
                return(randomString);
            }

            catch (Exception)
            {
                throw new Exception();
            }
        }
示例#20
0
        /// <summary>
        /// 调用RFC,返回一个SAP Structure
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="rfcName"></param>
        /// <param name="IRfcStructureName"></param>
        /// <returns></returns>
        public IRfcStructure GetRfcStructure(string conn, string rfcName, string IRfcStructureName)
        {
            //1.登录SAP
            RfcConfigParameters parameters = GetRfcLoginParameters(conn);//获取登录参数
            RfcDestination      rd         = RfcDestinationManager.GetDestination(parameters);

            RfcRepository repo = rd.Repository;
            IRfcFunction  f    = repo.CreateFunction(rfcName); //调用函数名


            //f.Invoke(rd); //执行函数
            return(f.GetStructure(IRfcStructureName)); //获取执行RFC后返回的结构
        }
示例#21
0
        /// <summary>
        /// create bp data by job table:BUT000
        /// no use
        /// </summary>
        /// <returns></returns>
        public string CreateBusinessPartner()
        {
            if (rfcDestination == null)
            {
                rfcDestination = RfcDestinationManager.GetDestination(WebApiApplication.destinationConfigName);
            }
            RfcRepository repo             = rfcDestination.Repository;
            IRfcFunction  _BusinessPartner = repo.CreateFunction("BAPI_BUPA_CREATE_FROM_DATA");
            IRfcFunction  _Commit          = repo.CreateFunction("BAPI_TRANSACTION_COMMIT");

            _BusinessPartner.SetValue("PARTNERCATEGORY", 2); //2:org
            _BusinessPartner.SetValue("PARTNERGROUP", 1000); //1000:buyer
            IRfcStructure _CentralData = _BusinessPartner.GetStructure("CENTRALDATA");

            _CentralData.SetValue("SEARCHTERM1", "測試國度");
            _CentralData.SetValue("SEARCHTERM2", "測試資料");
            // _CentralData.SetValue("PARTNERLANGUAGEISO", "EN");

            IRfcStructure _CentraldataOrganization = _BusinessPartner.GetStructure("CENTRALDATAORGANIZATION");

            _CentraldataOrganization.SetValue("NAME1", "LLLLL");
            IRfcStructure _Address = _BusinessPartner.GetStructure("ADDRESSDATA");

            _Address.SetValue("COUNTRY", "TW");
            //_Address.SetValue("LANGU", "EN");
            _Address.SetValue("REGION", "TPE");
            RfcSessionManager.BeginContext(rfcDestination);
            _BusinessPartner.Invoke(rfcDestination);
            _Commit.Invoke(rfcDestination);
            RfcSessionManager.EndContext(rfcDestination);

            string          _BusinessPartnerNumber = _BusinessPartner.GetString("BUSINESSPARTNER");
            DataTable       dtReturn   = ConvertToDotNetTable(_BusinessPartner.GetTable("RETURN"));
            List <ErrorLog> _ErrorList = SetErrorLog(dtReturn, "BAPI_BUPA_CREATE_FROM_DATA", _BusinessPartnerNumber, "");
            List <string>   _Error     = this._errorLogService.MiltiCreate(_ErrorList);

            return(_BusinessPartnerNumber);
        }
示例#22
0
        /// <summary>
        /// 调用RFC,返回一个SAP Structure
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="rfcName"></param>
        /// <param name="IRfcStructureName"></param>
        /// <returns></returns>
        public IRfcStructure GetRfcStructure(string conn, string rfcName, string IRfcStructureName)
        {
            //1.登录SAP
            RfcConfigParameters parameters = GetRfcLoginParameters(conn);//获取登录参数
            RfcDestination      rd         = RfcDestinationManager.GetDestination(parameters);

            RfcRepository repo = rd.Repository;
            IRfcFunction  f    = repo.CreateFunction(rfcName); //调用函数名

            IRfcStructure istr = f.GetStructure(IRfcStructureName);


            return(istr);
        }
示例#23
0
文件: UTL.cs 项目: pfs-haibv/projpscd
        // Kiểm tra dữ liệu tờ khai 10/KK-TNCN
        public static string Prc_check_data_tk10(string p_short_name, string p_tax_code, DataRow p_dr, RfcDestination p_sap, string p_ky_chot_dl)
        {
            // Bắt đầu một session
            RfcSessionManager.BeginContext(p_sap);
            RfcRepository v_repo  = p_sap.Repository;
            IRfcFunction  v_babi  = v_repo.CreateFunction("ZBAPI_DETAIL_10_CHECK");
            IRfcStructure v_struc = v_babi.GetStructure("I_DATA");

            v_struc.SetValue("TAXPAYER_ID", p_dr["TIN"].ToString());
            v_struc.SetValue("START_PERIOD", p_dr["KYKK_TU_NGAY"].ToString());
            v_struc.SetValue("END_PERIOD", p_dr["KYKK_DEN_NGAY"].ToString());
            v_struc.SetValue("DUE_DATE", p_dr["KYLB_TU_NGAY"].ToString());
            v_struc.SetValue("A_F08_DOANH_THU_DU_KIEN", p_dr["DTHU_DKIEN"].ToString());
            v_struc.SetValue("A_F09_TY_LE_TNCT_DU_KIEN", p_dr["TL_THNHAP_DKIEN"].ToString());
            v_struc.SetValue("C_F10_TNCT_DU_KIEN", p_dr["THNHAP_CTHUE_DKIEN"].ToString());
            v_struc.SetValue("C_F11_GIAM_TRU_GC", p_dr["GTRU_GCANH"].ToString());
            v_struc.SetValue("A_F12_GIAM_TRU_BAN_THAN", p_dr["BAN_THAN"].ToString());
            v_struc.SetValue("A_F13_GIAM_TRU_NPT", p_dr["PHU_THUOC"].ToString());
            v_struc.SetValue("C_F14_THU_NHAP_TINH_THUE", p_dr["THNHAP_TTHUE_DKIEN"].ToString());
            v_struc.SetValue("C_F15_THUE_TNCN_DU_KIEN", p_dr["TNCN"].ToString());
            v_struc.SetValue("C_F16_THUE_PN_Q1", p_dr["PB01"].ToString());
            v_struc.SetValue("C_F16_KY_TINH_THUE_Q1", p_dr["KYTT01"].ToString());
            v_struc.SetValue("C_F16_KY_HACH_TOAN_Q1", p_dr["HT01"].ToString());
            v_struc.SetValue("C_F16_HAN_NOP_Q1", p_dr["HN01"].ToString());
            v_struc.SetValue("C_F17_THUE_PN_Q2", p_dr["PB02"].ToString());
            v_struc.SetValue("C_F17_KY_TINH_THUE_Q2", p_dr["KYTT02"].ToString());
            v_struc.SetValue("C_F17_KY_HACH_TOAN_Q2", p_dr["HT02"].ToString());
            v_struc.SetValue("C_F17_HAN_NOP_Q2", p_dr["HN02"].ToString());
            v_struc.SetValue("C_F18_THUE_PN_Q3", p_dr["PB03"].ToString());
            v_struc.SetValue("C_F18_KY_TINH_THUE_Q3", p_dr["KYTT03"].ToString());
            v_struc.SetValue("C_F18_KY_HACH_TOAN_Q3", p_dr["HT03"].ToString());
            v_struc.SetValue("C_F18_HAN_NOP_Q3", p_dr["HN03"].ToString());
            v_struc.SetValue("C_F19_THUE_PN_Q4", p_dr["PB04"].ToString());
            v_struc.SetValue("C_F19_KY_TINH_THUE_Q4", p_dr["KYTT04"].ToString());
            v_struc.SetValue("C_F19_KY_HACH_TOAN_Q4", p_dr["HT04"].ToString());
            v_struc.SetValue("C_F19_HAN_NOP_Q4", p_dr["HN04"].ToString());
            v_struc.SetValue("TAX_OFFICE_CODE", p_dr["MA_CQT"].ToString());
            v_struc.SetValue("ROW_NUM", p_dr["STT"].ToString());
            v_struc.SetValue("F13_MST_DLT", p_dr["MST_DTK"].ToString());
            v_struc.SetValue("F20_HOP_DONG_DLT_SO", p_dr["HD_DLT_SO"].ToString());
            v_struc.SetValue("F_HOP_DONG_DLT_NGAY", p_dr["HD_DLT_NGAY"].ToString());
            v_struc.SetValue("REVERSE_AMOUNT", p_dr["RV_SO_TIEN"].ToString());

            v_babi.SetValue("I_FILE", randomFileName(p_tax_code, p_ky_chot_dl));

            v_babi.Invoke(p_sap);
            // Kết thúc một session
            RfcSessionManager.EndContext(p_sap);
            return(v_babi.GetString("E_ERROR_CODE"));
        }
示例#24
0
        public static string CheckMaterial(Item materialPart)
        {
            string materialNumber = materialPart.getProperty("item_number") + "-" + materialPart.getProperty("major_rev");

            IRfcFunction documentCheckMaterial = destination.Repository.CreateFunction("BAPI_MATERIAL_GET_DETAIL");

            documentCheckMaterial.SetValue("MATERIAL", materialNumber);
            documentCheckMaterial.Invoke(destination);

            IRfcStructure returnMsg     = documentCheckMaterial.GetStructure("RETURN");
            string        messageOutput = returnMsg.GetString("TYPE");

            return(messageOutput == "S" ? "Success" : "Failure");
        }
示例#25
0
        /// <summary>
        /// Getting vendor details from SAP
        /// Date: 20 June 2019
        /// Developer: Shreyans Khandelwal (0538)
        /// </summary>
        /// <param name="rfcDest"></param>
        /// <returns></returns>
        public VendorDetail GetVendorDetail(RfcDestination rfcDest)
        {
            try
            {
                VendorDetail vendorDetModel = new VendorDetail();

                RfcDestination SAPRfcDestination = RfcDestinationManager.GetDestination("accelyides");

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


                BapiGetCompanyDetail = rfcrep.CreateFunction("BAPI_VENDOR_GETDETAIL");
                BapiGetCompanyDetail.SetValue("VENDORNO", "VBX");
                BapiGetCompanyDetail.SetValue("COMPANYCODE", "0001");
                BapiGetCompanyDetail.Invoke(rfcDest);

                IRfcStructure IRS_OS_GeneralDet = BapiGetCompanyDetail.GetStructure("GENERALDETAIL");
                vendorDetModel.CompanyName   = IRS_OS_GeneralDet.GetValue("VENDOR").ToString();
                vendorDetModel.ContactName   = IRS_OS_GeneralDet.GetValue("NAME").ToString();
                vendorDetModel.ContactMobile = IRS_OS_GeneralDet.GetValue("TELEPHONE").ToString();
                vendorDetModel.Address       = IRS_OS_GeneralDet.GetValue("FORMOFADDR").ToString();
                //vendorDetModel.NAME_2 = IRS_OS_GeneralDet.GetValue("NAME_2").ToString();
                //vendorDetModel.NAME_3 = IRS_OS_GeneralDet.GetValue("NAME_3").ToString();
                //vendorDetModel.NAME_4 = IRS_OS_GeneralDet.GetValue("NAME_4").ToString();
                //vendorDetModel.CITY = IRS_OS_GeneralDet.GetValue("CITY").ToString();
                //vendorDetModel.DISTRICT = IRS_OS_GeneralDet.GetValue("DISTRICT").ToString();
                //vendorDetModel.PO_BOX = IRS_OS_GeneralDet.GetValue("PO_BOX").ToString();
                //vendorDetModel.POBX_PCD = IRS_OS_GeneralDet.GetValue("POBX_PCD").ToString();
                //vendorDetModel.POSTL_CODE = IRS_OS_GeneralDet.GetValue("POSTL_CODE").ToString();
                //vendorDetModel.REGION = IRS_OS_GeneralDet.GetValue("REGION").ToString();
                ////vendorDetModel.Address = IRS_OS_GeneralDet.GetValue("STREET").ToString();
                //vendorDetModel.COUNTRY = IRS_OS_GeneralDet.GetValue("STREET").ToString();
                //vendorDetModel.COUNTRYISO = IRS_OS_GeneralDet.GetValue("COUNTRYISO").ToString();
                //vendorDetModel.POBX_CTY = IRS_OS_GeneralDet.GetValue("POBX_CTY").ToString();
                //vendorDetModel.LANGU = IRS_OS_GeneralDet.GetValue("LANGU").ToString();
                //vendorDetModel.LANGU_ISO = IRS_OS_GeneralDet.GetValue("LANGU_ISO").ToString();
                //vendorDetModel.TELEPHONE2 = IRS_OS_GeneralDet.GetValue("TELEPHONE2").ToString();

                RfcSessionManager.EndContext(rfcDest);

                return(vendorDetModel);
            }
            catch (Exception ex)
            {
                logger.WriteLog(ex);
                throw ex;
            }
        }
示例#26
0
        public static List <SapClassModel> GetAllTablesClass(IRfcFunction function)
        {
            foreach (var tableName in GetResultTableNames(function.Metadata.ToString()))
            {
                var rfcTable = function.GetTable(tableName);
                classModel.Add(GetClassBuilder(rfcTable));
            }

            foreach (var structureName in GetResultStructureNames(function.Metadata.ToString()))
            {
                var rfcStructure = function.GetStructure(structureName);
                classModel.Add(GetClassBuilder(rfcStructure));
            }

            return(classModel);
        }
示例#27
0
        /*Exemplo de Envio para o SAP, usando estrutura*/
        public String RegistraAbastecimento(string Equipamento, string Posto, string Data, string Hora, string Trajeto_consumo, string Consumo, string Posicao_contador)
        {
            IRfcFunction  objRfc       = repo.CreateFunction("ZRFC_FROTAWEB_ABASTECE");
            IRfcStructure objEstrutura = objRfc.GetStructure("I_DADOS");

            objEstrutura.SetValue("equip", Equipamento);
            objEstrutura.SetValue("POSTO_ABAST", Posto);
            objEstrutura.SetValue("DATA", Data);
            objEstrutura.SetValue("HORA", Hora);
            objEstrutura.SetValue("TRAJETO", Trajeto_consumo);
            objEstrutura.SetValue("CONSUMO", Consumo);
            objEstrutura.SetValue("CONTADOR", Posicao_contador);

            objRfc.Invoke(dest);

            return(objRfc.GetValue(0).ToString());
        }
示例#28
0
        public IRfcStructure ConvertDataTabletoRFCStructure(DataRow dr, string tableName)
        {
            try
            {
                IRfcFunction function = null;
                message  = FunctionName + " CreateFunction:";
                function = destination.Repository.CreateFunction(FunctionName);
                message  = FunctionName + " GetStructure:";
                IRfcStructure ROFStrcture = function.GetStructure(tableName);

                //ROFTable.Insert();
                for (int i = 0; i < dr.Table.Columns.Count; i++)
                {
                    ROFStrcture.SetValue(dr.Table.Columns[i].ColumnName, dr[i].ToString());
                }

                return(ROFStrcture);
            }
            catch (RfcCommunicationException e)
            {
                // network problem...
                //throw new Exception("network problem", e);
                throw new Exception(e.Message, e);
            }
            catch (RfcAbapRuntimeException e)
            {
                // serious problem on ABAP system side...
                //throw new Exception("serious problem on ABAP system side", e);
                throw new Exception(e.Message, e);
            }
            catch (RfcAbapBaseException e)
            {
                // The function module returned an ABAP exception, an ABAP message
                // or an ABAP class-based exception...
                //throw new Exception("The function module returned an ABAP exception, an ABAP message or an ABAP class-based exception...",e);
                throw new Exception(e.Message, e);
            }
            catch (RfcBaseException e)
            {
                throw e;
            }
            catch (Exception ex)
            {
                throw new Exception(message + ex.Message);
            }
        }
示例#29
0
        public RFC_OUT_Message Rfc_Wtc_Dal(RFC_WTC_Model.RFC_WTC_HEADER_Model wtcHeaderModels)
        {
            RFC_OUT_Message rfcMessage = new RFC_OUT_Message();

            try
            {
                _configurationId = new RFC_SetUp();
                RfcDestinationManager.RegisterDestinationConfiguration(_configurationId);
                _dest       = RfcDestinationManager.GetDestination("SAPMS");
                _repository = _dest.Repository;
                IRfcFunction rfc = _repository.CreateFunction(wtcHeaderModels.FunctionModule); //调用函数名
                //RFC表数据
                IRfcStructure structure = rfc.GetStructure("I_HEADER");                        //RFC表头数据
                structure.SetValue("ZMESKEY", wtcHeaderModels.ZMESKEY);
                structure.SetValue("AUFNR", wtcHeaderModels.AUFNR);
                structure.SetValue("AUART", wtcHeaderModels.AUART);
                structure.SetValue("MATNR", wtcHeaderModels.MATNR);
                structure.SetValue("WERKS", wtcHeaderModels.WERKS);
                structure.SetValue("MENGE", wtcHeaderModels.MENGE);
                structure.SetValue("MEINS", wtcHeaderModels.MEINS);
                structure.SetValue("GLTRP", wtcHeaderModels.GLTRP);
                structure.SetValue("GSTRP", wtcHeaderModels.GSTRP);
                structure.SetValue("ZCOUNT", wtcHeaderModels.ZCOUNT);
                structure.SetValue("ZSUM", wtcHeaderModels.ZSUM);
                structure.SetValue("ZUSER", wtcHeaderModels.ZUSER);
                structure.SetValue("ZDELFLAG", wtcHeaderModels.ZDELFLAG);

                rfc.Invoke(_dest);
                rfcMessage.E_RETURN_CODE    = rfc.GetString("E_RETURN_CODE").ToString();
                rfcMessage.E_RETURN_MESSAGE = rfc.GetString("E_RETURN_MESSAGE").ToString();
                rfcMessage.E_PRD_ORD_NO     = rfc.GetString("E_PRD_ORD_NO").ToString();
                rfcMessage.E_EXPROC         = rfc.GetString("E_EXPROC").ToString();
                rfcMessage.E_PRD_CHARG      = rfc.GetString("E_PRD_CHARG").ToString();
                return(rfcMessage);
            }
            catch (Exception exception)
            {
                rfcMessage.E_RETURN_MESSAGE = "接口WTC 错误:" + exception.ToString();
                return(null);
            }
            finally
            {
                RfcDestinationManager.UnregisterDestinationConfiguration(_configurationId);
            }
        }
示例#30
0
        /// <summary>
        ///  #region call rfc 得到Sap 结构体并转换成Dictionary
        /// </summary>
        /// <param name="fmName">rfc调用方法名称</param>
        /// <param name="hsTable">传入参数</param>
        /// <param name="structName">结构体名称</param>
        /// <returns></returns>
        public Dictionary <string, string> CallRfcForStructure(string fmName, Hashtable hsTable, string structName)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();
            IRfcFunction  fm        = InvokeRFC(fmName, hsTable);
            IRfcStructure tmpStruct = fm.GetStructure(structName);

            if (tmpStruct != null)
            {
                for (int i = 0; i < tmpStruct.ElementCount; i++)
                {
                    // get column name from position
                    RfcElementMetadata colMeta = tmpStruct.GetElementMetadata(i);
                    dic.Add(colMeta.Name, tmpStruct.GetString(colMeta.Name));//get value from column name
                }
            }

            return(dic);
        }
示例#31
0
        /// <summary>
        /// Get teh response from SAP and dynamically generate DataTables based on the responses metadata
        /// </summary>
        /// <param name="function"></param>
        /// <param name="meta"></param>
        /// <param name="rfc"></param>
        private void ProcessResults(SAPFunction function, RfcFunctionMetadata meta, IRfcFunction rfc)
        {
            foreach (var output in function.OutputParameters)
            {
                String paramName = output;
                String secondLevelStructure = string.Empty;
                int index = -1;

                string[] paramDetail = paramName.Split(':');
                if (paramDetail.Length == 1)
                {
                    index = meta.TryNameToIndex(paramName);
                }
                else if (paramDetail.Length == 2)
                {
                    secondLevelStructure = paramDetail[0];
                    paramName = paramDetail[1];
                    index = meta.TryNameToIndex(secondLevelStructure);
                }

                if (index != -1)
                {
                    RfcElementMetadata elementMeta = rfc.GetElementMetadata(index);
                    RfcDataType type = elementMeta.DataType;
                    String dataType = type.ToString();
                    if (dataType.Equals(SAPFunction.STRUCTURE))
                    {
                        DataTable table = null;
                        if (function.Results.Tables[secondLevelStructure] == null)
                        {
                            table = function.Results.Tables.Add(secondLevelStructure);

                            IRfcStructure rfcStructure = rfc.GetStructure(secondLevelStructure);
                            RfcStructureMetadata structureMetaData = rfcStructure.Metadata;
                            for (int x = 0; x < rfcStructure.ElementCount; x++)
                            {
                                DataColumn dc = table.Columns.Add(structureMetaData[x].Name, typeof(String));
                                dc.DataType = ConvertDataType(type);
                            }

                            DataRow dr = table.NewRow();
                            foreach (var column in table.Columns)
                            {
                                dr[column.ToString()] = rfcStructure.GetValue(column.ToString());
                            }
                            table.Rows.Add(dr);
                        }
                    }
                    else if (dataType.Equals(SAPFunction.TABLE))
                    {
                        DataTable table = null;
                        if (function.Results.Tables[secondLevelStructure] == null)
                        {
                            table = function.Results.Tables.Add(secondLevelStructure);

                            IRfcTable rfcTable = rfc.GetTable(secondLevelStructure);
                            RfcTableMetadata tableMetaData = rfcTable.Metadata;
                            for (int x = 0; x < tableMetaData.LineType.FieldCount; x++)
                            {
                                DataColumn dc = table.Columns.Add(tableMetaData.LineType[x].Name, typeof(String));
                                dc.DataType = ConvertDataType( type );
                            }

                            foreach(var row in rfcTable)
                            {
                                DataRow dr = table.NewRow();
                                foreach(var column in table.Columns)
                                {
                                    dr[column.ToString()] = row.GetValue(column.ToString());
                                }
                                table.Rows.Add(dr);
                            }
                        }
                    }
                    else
                    {
                        DataTable table = null;
                        if (function.Results.Tables["Root"] == null)
                        {
                            table = function.Results.Tables.Add("Root");
                            function.Results.Tables["Root"].NewRow();
                        }
                        else
                        {
                            table = function.Results.Tables[paramName];
                        }

                        table.Columns.Add(paramName);
                        table.Rows[0][paramName] = rfc;
                    }
                }
            }
        }
示例#32
0
        /// <summary>
        /// Notify SAP which output parameters are required i.e. SAP will only respond with the data that has been requested
        /// </summary>
        /// <param name="function"></param>
        /// <param name="meta"></param>
        /// <param name="rfc"></param>
        private void PrepareOutputParameters(SAPFunction function, RfcFunctionMetadata meta, IRfcFunction rfc)
        {
            foreach (var iout in function.OutputParameters)
            {
                String paramName = iout;
                String secondLevelStructure = string.Empty;
                int index = -1;

                string[] paramDetail = paramName.Split(':');
                if (paramDetail.Length == 1)
                {
                    index = meta.TryNameToIndex(paramName);
                }
                else if (paramDetail.Length == 2)
                {
                    secondLevelStructure = paramDetail[0];
                    paramName = paramDetail[1];
                    index = meta.TryNameToIndex(secondLevelStructure);
                }

                if (index != -1)
                {
                    RfcElementMetadata elementMeta = rfc.GetElementMetadata(index);
                    RfcDataType type = elementMeta.DataType;
                    String dataType = type.ToString();
                    function.DataType.Add(paramName + ":" + secondLevelStructure, ConvertDataType(type));

                    IRfcDataContainer container = null;
                    if (dataType.Equals(SAPFunction.STRUCTURE))
                    {
                        RfcStructureMetadata structureMeta = elementMeta.ValueMetadataAsStructureMetadata;
                        container = rfc.GetStructure(secondLevelStructure);
                    }
                    else if (dataType.Equals(SAPFunction.TABLE))
                    {
                        RfcTableMetadata tableMeta = elementMeta.ValueMetadataAsTableMetadata;
                        container = rfc.GetTable(secondLevelStructure);

                        if (tableMeta.Name.Equals(String.Empty))
                        {
                            String lineType = tableMeta.LineType.ContainerType.ToString();
                            if (lineType.Equals("STRUCTURE"))
                            {
                                container = tableMeta.LineType.CreateStructure();
                            }
                        }
                    }
                    else
                    {
                        rfc.GetString(secondLevelStructure);
                    }
                }
            }
        }
示例#33
0
        /// <summary>
        /// Pass input parameters to SAP remote function call
        /// </summary>
        /// <param name="function"></param>
        /// <param name="meta"></param>
        /// <param name="rfc"></param>
        private void PrepareInputParameters( SAPFunction function, RfcFunctionMetadata meta, IRfcFunction rfc)
        {
            Dictionary<String,IRfcTable> _table = new Dictionary<String,IRfcTable>();
            Dictionary<String,IRfcStructure> _structure = new Dictionary<String,IRfcStructure>();
            foreach (var iin in function.InputParameters)
            {
                String paramName = iin.Key;
                String paramValue = iin.Value;
                String secondLevelStructure = string.Empty;
                int sapFieldIndex = -1;
                int tableRowIndex = -1;

                string[] paramDetail = paramName.Split(':');
                if(paramDetail.Length == 1) {
                    sapFieldIndex = meta.TryNameToIndex(paramName);
                } else if (paramDetail.Length == 2) {
                    secondLevelStructure = paramDetail[0];
                    paramName = paramDetail[1];

                    if (secondLevelStructure.Contains('[') && secondLevelStructure.Contains(']'))
                    {
                        sapFieldIndex = meta.TryNameToIndex(secondLevelStructure.Split('[')[0]);
                        string arrayIndex = secondLevelStructure.Split('[')[1].Split(']')[0];
                        Int32.TryParse(arrayIndex, out tableRowIndex);
                    }
                    else
                    {
                        sapFieldIndex = meta.TryNameToIndex(secondLevelStructure);
                    }
                }

                if (sapFieldIndex != -1)
                {
                    RfcElementMetadata elementMeta = rfc.GetElementMetadata(sapFieldIndex);
                    RfcDataType type = elementMeta.DataType;
                    String dataType = type.ToString();
                    function.DataType.Add(secondLevelStructure + ":" + paramName, ConvertDataType(type));
                    if (dataType.Equals(SAPFunction.STRUCTURE))
                    {
                        IRfcStructure structure;
                        if (!_structure.TryGetValue(secondLevelStructure, out structure))
                        {
                            structure = rfc.GetStructure(secondLevelStructure);
                            _structure.Add(secondLevelStructure, structure);
                        }
                        structure.SetValue(paramName, paramValue);
                        function.Length.Add(paramName + ":" + secondLevelStructure, structure.GetElementMetadata(paramName).NucLength);
                    }
                    else if (dataType.Equals(SAPFunction.TABLE))
                    {
                        if (secondLevelStructure.Contains('[') && secondLevelStructure.Contains(']'))
                        {
                            IRfcTable table;
                            if (!_table.TryGetValue(secondLevelStructure.Split('[')[0], out table))
                            {
                                table = rfc.GetTable(secondLevelStructure.Split('[')[0]);
                                _table.Add(secondLevelStructure.Split('[')[0], table);
                            }

                            try
                            {
                                table.ElementAt(tableRowIndex);
                            }
                            catch (ArgumentOutOfRangeException)
                            {
                                table.Insert(1, tableRowIndex);
                            }
                            table.CurrentIndex = tableRowIndex;

                            //rfc.Invoke(this.Destination);

                            RfcElementMetadata em = table.GetElementMetadata(paramName);

                            string s = String.Format("{0, " + table.GetElementMetadata(paramName).NucLength + "}", paramValue);

                            table.SetValue(paramName, s.Trim());
                            function.Length.Add(paramName + ":" + secondLevelStructure, table.GetElementMetadata(paramName).NucLength);
                        }
                    }
                    else
                    {
                        rfc.SetValue(paramName, paramValue);
                        function.Length.Add(paramName, rfc.GetElementMetadata( paramName ).NucLength);
                    }
                }
            }
        }