Ejemplo n.º 1
0
        public IRfcStructure GetStructure(RfcRepository repository)
        {
            IRfcStructure structure = repository.GetStructureMetadata("BAPIACPC09").CreateStructure();

            structure.SetValue("ITEMNO_ACC", this.Itemno_Acc);
            structure.SetValue("CC_GLACCOUNT", this.Cc_Glaccount);
            structure.SetValue("CC_TYPE", this.Cc_Type);
            structure.SetValue("CC_NUMBER", this.Cc_Number);
            structure.SetValue("CC_SEQ_NO", this.Cc_Seq_No);
            structure.SetValue("CC_VALID_F", this.Cc_Valid_F);
            structure.SetValue("CC_VALID_T", this.Cc_Valid_T);
            structure.SetValue("CC_NAME", this.Cc_Name);
            structure.SetValue("DATAORIGIN", this.Dataorigin);
            structure.SetValue("AUTHAMOUNT", Math.Round(this.Authamount, 4, MidpointRounding.AwayFromZero));
            structure.SetValue("CURRENCY", this.Currency);
            structure.SetValue("CURRENCY_ISO", this.Currency_Iso);
            structure.SetValue("CC_AUTTH_NO", this.Cc_Autth_No);
            structure.SetValue("AUTH_REFNO", this.Auth_Refno);
            structure.SetValue("AUTH_DATE", this.Auth_Date);
            structure.SetValue("AUTH_TIME", this.Auth_Time);
            structure.SetValue("MERCHIDCL", this.Merchidcl);
            structure.SetValue("POINT_OF_RECEIPT", this.Point_Of_Receipt);
            structure.SetValue("TERMINAL", this.Terminal);
            structure.SetValue("CCTYP", this.Cctyp);

            return(structure);
        }
Ejemplo n.º 2
0
        public IRfcStructure GetStructure(RfcRepository repository)
        {
            IRfcStructure structure = repository.GetStructureMetadata("BAPIACHE09").CreateStructure();

            structure.SetValue("OBJ_TYPE", this.Obj_Type);
            structure.SetValue("OBJ_KEY", this.Obj_Key);
            structure.SetValue("OBJ_SYS", this.Obj_Sys);
            structure.SetValue("BUS_ACT", this.Bus_Act);
            structure.SetValue("USERNAME", this.Username);
            structure.SetValue("HEADER_TXT", this.Header_Txt);
            structure.SetValue("COMP_CODE", this.Comp_Code);
            structure.SetValue("DOC_DATE", this.Doc_Date);
            structure.SetValue("PSTNG_DATE", this.Pstng_Date);
            structure.SetValue("TRANS_DATE", this.Trans_Date);
            structure.SetValue("FISC_YEAR", this.Fisc_Year);
            structure.SetValue("FIS_PERIOD", this.Fis_Period);
            structure.SetValue("DOC_TYPE", this.Doc_Type);
            structure.SetValue("REF_DOC_NO", this.Ref_Doc_No);
            structure.SetValue("AC_DOC_NO", this.Ac_Doc_No);
            structure.SetValue("OBJ_KEY_R", this.Obj_Key_R);
            structure.SetValue("REASON_REV", this.Reason_Rev);
            structure.SetValue("COMPO_ACC", this.Compo_Acc);
            structure.SetValue("REF_DOC_NO_LONG", this.Ref_Doc_No_Long);
            structure.SetValue("ACC_PRINCIPLE", this.Acc_Principle);
            structure.SetValue("NEG_POSTNG", this.Neg_Postng);
            structure.SetValue("OBJ_KEY_INV", this.Obj_Key_Inv);

            return(structure);
        }
Ejemplo n.º 3
0
        public IRfcStructure GetStructure(RfcRepository repository)
        {
            IRfcStructure structure = repository.GetStructureMetadata("YGETFIDOC_I").CreateStructure();

            structure.SetValue("BUZEI", this.Buzei);
            structure.SetValue("BSCHL", this.Bschl);
            structure.SetValue("KOSTL", this.Kostl);
            structure.SetValue("MWSKZ", this.Mwskz);
            structure.SetValue("ZUONR", this.Zuonr);
            structure.SetValue("ZLSCH", this.Zlsch);
            structure.SetValue("ACCOUNT", this.Account);
            structure.SetValue("HKONT", this.Hkont);
            structure.SetValue("DESCRIPTION", this.Description);
            structure.SetValue("SAKNR", this.Saknr);
            structure.SetValue("WRBTR", this.Wrbtr);
            structure.SetValue("DMBTR", this.Dmbtr);
            structure.SetValue("WERKS", this.Werks);
            structure.SetValue("AUFNR", this.Aufnr);
            structure.SetValue("SHKZG", this.Shkzg);
            structure.SetValue("KOART", this.Koart);
            structure.SetValue("WHT_CODE", this.Wht_Code);
            structure.SetValue("WHT_TYPE", this.Wht_Type);
            structure.SetValue("WHT_BASE", this.Wht_Base);
            structure.SetValue("KIDNO", this.Kidno);
            structure.SetValue("BVTYP", this.Bvtyp);
            structure.SetValue("ZFBDT", this.Zfbdt);
            structure.SetValue("ZTERM", this.Zterm);
            structure.SetValue("ADDRESS", this.Address);
            structure.SetValue("SGTXT", this.Sgtxt);
            structure.SetValue("ZLSPR", this.Zlspr);
            structure.SetValue("BANK_ACC", this.Bank_Acc);

            return(structure);
        }
Ejemplo n.º 4
0
        public IRfcStructure GetStructure(RfcRepository repository)
        {
            IRfcStructure structure = repository.GetStructureMetadata("BAPIACKEC9").CreateStructure();

            structure.SetValue("ITEMNO_ACC", this.Itemno_Acc);
            structure.SetValue("FIELDNAME", this.Fieldname);
            structure.SetValue("CHARACTER", this.Character);

            return(structure);
        }
Ejemplo n.º 5
0
        public IRfcStructure GetStructure(RfcRepository repository)
        {
            IRfcStructure structure = repository.GetStructureMetadata("BAPIACEXTC").CreateStructure();

            structure.SetValue("FIELD1", this.Field1);
            structure.SetValue("FIELD2", this.Field2);
            structure.SetValue("FIELD3", this.Field3);
            structure.SetValue("FIELD4", this.Field4);

            return(structure);
        }
Ejemplo n.º 6
0
        public IRfcStructure GetStructure(RfcRepository repository)
        {
            IRfcStructure structure = repository.GetStructureMetadata("BAPIACAP09").CreateStructure();

            structure.SetValue("ITEMNO_ACC", this.Itemno_Acc);
            structure.SetValue("VENDOR_NO", this.Vendor_No);
            structure.SetValue("GL_ACCOUNT", this.Gl_Account);
            structure.SetValue("REF_KEY_1", this.Ref_Key_1);
            structure.SetValue("REF_KEY_2", this.Ref_Key_2);
            structure.SetValue("REF_KEY_3", this.Ref_Key_3);
            structure.SetValue("COMP_CODE", this.Comp_Code);
            structure.SetValue("BUS_AREA", this.Bus_Area);
            structure.SetValue("PMNTTRMS", this.Pmnttrms);
            structure.SetValue("BLINE_DATE", this.Bline_Date);
            structure.SetValue("DSCT_DAYS1", this.Dsct_Days1);
            structure.SetValue("DSCT_DAYS2", this.Dsct_Days2);
            structure.SetValue("NETTERMS", this.Netterms);
            structure.SetValue("DSCT_PCT1", Math.Round(this.Dsct_Pct1, 3, MidpointRounding.AwayFromZero));
            structure.SetValue("DSCT_PCT2", Math.Round(this.Dsct_Pct2, 3, MidpointRounding.AwayFromZero));
            structure.SetValue("PYMT_METH", this.Pymt_Meth);
            structure.SetValue("PMTMTHSUPL", this.Pmtmthsupl);
            structure.SetValue("PMNT_BLOCK", this.Pmnt_Block);
            structure.SetValue("SCBANK_IND", this.Scbank_Ind);
            structure.SetValue("SUPCOUNTRY", this.Supcountry);
            structure.SetValue("SUPCOUNTRY_ISO", this.Supcountry_Iso);
            structure.SetValue("BLLSRV_IND", this.Bllsrv_Ind);
            structure.SetValue("ALLOC_NMBR", this.Alloc_Nmbr);
            structure.SetValue("ITEM_TEXT", this.Item_Text);
            structure.SetValue("PO_SUB_NO", this.Po_Sub_No);
            structure.SetValue("PO_CHECKDG", this.Po_Checkdg);
            structure.SetValue("PO_REF_NO", this.Po_Ref_No);
            structure.SetValue("W_TAX_CODE", this.W_Tax_Code);
            structure.SetValue("BUSINESSPLACE", this.Businessplace);
            structure.SetValue("SECTIONCODE", this.Sectioncode);
            structure.SetValue("INSTR1", this.Instr1);
            structure.SetValue("INSTR2", this.Instr2);
            structure.SetValue("INSTR3", this.Instr3);
            structure.SetValue("INSTR4", this.Instr4);
            structure.SetValue("BRANCH", this.Branch);
            structure.SetValue("PYMT_CUR", this.Pymt_Cur);
            structure.SetValue("PYMT_AMT", Math.Round(this.Pymt_Amt, 4, MidpointRounding.AwayFromZero));
            structure.SetValue("PYMT_CUR_ISO", this.Pymt_Cur_Iso);
            structure.SetValue("SP_GL_IND", this.Sp_Gl_Ind);
            structure.SetValue("TAX_CODE", this.Tax_Code);
            structure.SetValue("TAX_DATE", this.Tax_Date);
            structure.SetValue("TAXJURCODE", this.Taxjurcode);
            structure.SetValue("ALT_PAYEE", this.Alt_Payee);
            structure.SetValue("ALT_PAYEE_BANK", this.Alt_Payee_Bank);
            structure.SetValue("PARTNER_BK", this.Partner_Bk);
            structure.SetValue("BANK_ID", this.Bank_Id);
            structure.SetValue("PARTNER_GUID", this.Partner_Guid);

            return(structure);
        }
Ejemplo n.º 7
0
        public IRfcStructure GetStructure(RfcRepository repository)
        {
            IRfcStructure structure = repository.GetStructureMetadata("BAPIACCAHD").CreateStructure();

            structure.SetValue("DOC_NO", this.Doc_No);
            structure.SetValue("DOC_TYPE_CA", this.Doc_Type_Ca);
            structure.SetValue("RES_KEY", this.Res_Key);
            structure.SetValue("FIKEY", this.Fikey);
            structure.SetValue("PAYMENT_FORM_REF", this.Payment_Form_Ref);

            return(structure);
        }
Ejemplo n.º 8
0
        public IRfcStructure GetStructure(RfcRepository repository)
        {
            IRfcStructure structure = repository.GetStructureMetadata("BAPIPAREX").CreateStructure();

            structure.SetValue("STRUCTURE", this.Structure0);
            structure.SetValue("VALUEPART1", this.Valuepart1);
            structure.SetValue("VALUEPART2", this.Valuepart2);
            structure.SetValue("VALUEPART3", this.Valuepart3);
            structure.SetValue("VALUEPART4", this.Valuepart4);

            return(structure);
        }
Ejemplo n.º 9
0
        public IRfcStructure GetStructure(RfcRepository repository)
        {
            IRfcStructure structure = repository.GetStructureMetadata("ZACCKEY").CreateStructure();

            structure.SetValue("BUKRS", this.Bukrs);
            structure.SetValue("BELNR", this.Belnr);
            structure.SetValue("GJAHR", this.Gjahr);
            structure.SetValue("BUZEI", this.Buzei);
            structure.SetValue("APP_TYPE", this.App_Type);
            structure.SetValue("APPV_TYPE", this.Appv_Type);

            return(structure);
        }
Ejemplo n.º 10
0
        public IRfcStructure GetStructure(RfcRepository repository)
        {
            IRfcStructure structure = repository.GetStructureMetadata("BAPIACKEV9").CreateStructure();

            structure.SetValue("ITEMNO_ACC", this.Itemno_Acc);
            structure.SetValue("FIELDNAME", this.Fieldname);
            structure.SetValue("CURR_TYPE", this.Curr_Type);
            structure.SetValue("CURRENCY", this.Currency);
            structure.SetValue("CURRENCY_ISO", this.Currency_Iso);
            structure.SetValue("AMT_VALCOM", Math.Round(this.Amt_Valcom, 4, MidpointRounding.AwayFromZero));
            structure.SetValue("BASE_UOM", this.Base_Uom);
            structure.SetValue("BASE_UOM_ISO", this.Base_Uom_Iso);
            structure.SetValue("QUA_VALCOM", this.Qua_Valcom);

            return(structure);
        }
Ejemplo n.º 11
0
        public IRfcStructure GetStructure(RfcRepository repository)
        {
            IRfcStructure structure = repository.GetStructureMetadata("BAPIACCR09").CreateStructure();

            structure.SetValue("ITEMNO_ACC", this.Itemno_Acc);
            structure.SetValue("CURR_TYPE", this.Curr_Type);
            structure.SetValue("CURRENCY", this.Currency);
            structure.SetValue("CURRENCY_ISO", this.Currency_Iso);
            structure.SetValue("AMT_DOCCUR", Math.Round(this.Amt_Doccur, 4, MidpointRounding.AwayFromZero));
            structure.SetValue("EXCH_RATE", Math.Round(this.Exch_Rate, 5, MidpointRounding.AwayFromZero));
            structure.SetValue("EXCH_RATE_V", Math.Round(this.Exch_Rate_V, 5, MidpointRounding.AwayFromZero));
            structure.SetValue("AMT_BASE", Math.Round(this.Amt_Base, 4, MidpointRounding.AwayFromZero));
            structure.SetValue("DISC_BASE", Math.Round(this.Disc_Base, 4, MidpointRounding.AwayFromZero));
            structure.SetValue("DISC_AMT", Math.Round(this.Disc_Amt, 4, MidpointRounding.AwayFromZero));
            structure.SetValue("TAX_AMT", Math.Round(this.Tax_Amt, 4, MidpointRounding.AwayFromZero));

            return(structure);
        }
Ejemplo n.º 12
0
        public IRfcStructure GetStructure(RfcRepository repository)
        {
            IRfcStructure structure = repository.GetStructureMetadata("RTAX1U15").CreateStructure();

            structure.SetValue("WMWST", Math.Round(this.Wmwst, 2, MidpointRounding.AwayFromZero));
            structure.SetValue("MSATZ", Math.Round(this.Msatz, 3, MidpointRounding.AwayFromZero));
            structure.SetValue("KTOSL", this.Ktosl);
            structure.SetValue("TXJCD", this.Txjcd);
            structure.SetValue("KNUMH", this.Knumh);
            structure.SetValue("KBETR", Math.Round(this.Kbetr, 2, MidpointRounding.AwayFromZero));
            structure.SetValue("KAWRT", Math.Round(this.Kawrt, 2, MidpointRounding.AwayFromZero));
            structure.SetValue("HKONT", this.Hkont);
            structure.SetValue("KSCHL", this.Kschl);
            structure.SetValue("TXJCD_DEEP", this.Txjcd_Deep);
            structure.SetValue("TXJLV", this.Txjlv);

            return(structure);
        }
Ejemplo n.º 13
0
        private double ProductInfoGetRealtimeStock(string branchCode, string warehouseCode, string productCode, string uom)
        {
            RfcDestination sapRfcDestination = SapHelper.Destination;
            RfcRepository  sapRfcRepository  = sapRfcDestination.Repository;

            RfcRepository repo       = sapRfcRepository;
            string        bapiName   = "BAPI_MATERIAL_AVAILABILITY";
            IRfcFunction  exportBapi = repo.CreateFunction(bapiName);

            exportBapi.SetValue("PLANT", "");
            exportBapi.SetValue("MATERIAL", "");
            exportBapi.SetValue("UNIT", "");
            exportBapi.SetValue("CHECK_RULE", "");
            exportBapi.SetValue("STGE_LOC", "");
            exportBapi.SetValue("BATCH", "");
            exportBapi.SetValue("CUSTOMER", "");
            exportBapi.SetValue("DOC_NUMBER", "");
            exportBapi.SetValue("ITM_NUMBER", "");
            exportBapi.SetValue("WBS_ELEM", "");
            exportBapi.SetValue("STOCK_IND", "");
            exportBapi.SetValue("DEC_FOR_ROUNDING", 0);
            exportBapi.SetValue("DEC_FOR_ROUNDING_X", "");
            exportBapi.SetValue("READ_ATP_LOCK", "");
            exportBapi.SetValue("READ_ATP_LOCK_X", "");

            IRfcStructure        articol;
            RfcStructureMetadata am = repo.GetStructureMetadata("BAPIMGVMATNR");

            articol = am.CreateStructure();
            exportBapi.SetValue("MATERIAL_EVG", articol);

            exportBapi.SetValue("MATERIAL", FormatedProductCode(productCode));
            exportBapi.SetValue("PLANT", branchCode);
            exportBapi.SetValue("UNIT", uom);
            exportBapi.SetValue("STGE_LOC", warehouseCode);
            exportBapi.SetValue("CHECK_RULE", "B");
            exportBapi.SetValue("ITM_NUMBER", "000000");

            exportBapi.Invoke(sapRfcDestination);
            IRfcTable detail = exportBapi.GetTable("WMDVEX");


            return(detail.RowCount);
        }
Ejemplo n.º 14
0
        public IRfcStructure GetStructure(RfcRepository repository)
        {
            IRfcStructure structure = repository.GetStructureMetadata("BAPIACRE09").CreateStructure();

            structure.SetValue("ITEMNO_ACC", this.Itemno_Acc);
            structure.SetValue("BUSINESS_ENTITY", this.Business_Entity);
            structure.SetValue("BUILDING", this.Building);
            structure.SetValue("PROPERTY", this.Property);
            structure.SetValue("RENTAL_OBJECT", this.Rental_Object);
            structure.SetValue("SERV_CHARGE_KEY", this.Serv_Charge_Key);
            structure.SetValue("SETTLEMENT_UNIT", this.Settlement_Unit);
            structure.SetValue("CONTRACT_NO", this.Contract_No);
            structure.SetValue("FLOW_TYPE", this.Flow_Type);
            structure.SetValue("CORR_ITEM", this.Corr_Item);
            structure.SetValue("REF_DATE", this.Ref_Date);
            structure.SetValue("OPTION_RATE", Math.Round(this.Option_Rate, 6, MidpointRounding.AwayFromZero));

            return(structure);
        }
Ejemplo n.º 15
0
        public IRfcStructure GetStructure(RfcRepository repository)
        {
            IRfcStructure structure = repository.GetStructureMetadata("BAPIACTX09").CreateStructure();

            structure.SetValue("ITEMNO_ACC", this.Itemno_Acc);
            structure.SetValue("GL_ACCOUNT", this.Gl_Account);
            structure.SetValue("COND_KEY", this.Cond_Key);
            structure.SetValue("ACCT_KEY", this.Acct_Key);
            structure.SetValue("TAX_CODE", this.Tax_Code);
            structure.SetValue("TAX_RATE", Math.Round(this.Tax_Rate, 3, MidpointRounding.AwayFromZero));
            structure.SetValue("TAX_DATE", this.Tax_Date);
            structure.SetValue("TAXJURCODE", this.Taxjurcode);
            structure.SetValue("TAXJURCODE_DEEP", this.Taxjurcode_Deep);
            structure.SetValue("TAXJURCODE_LEVEL", this.Taxjurcode_Level);
            structure.SetValue("ITEMNO_TAX", this.Itemno_Tax);
            structure.SetValue("DIRECT_TAX", this.Direct_Tax);

            return(structure);
        }
Ejemplo n.º 16
0
        public IRfcStructure GetStructure(RfcRepository repository)
        {
            IRfcStructure structure = repository.GetStructureMetadata("YGETFIDOC_H").CreateStructure();

            structure.SetValue("BELNR", this.Belnr);
            structure.SetValue("BUKRS", this.Bukrs);
            structure.SetValue("BUDAT", this.Budat);
            structure.SetValue("XBLNR", this.Xblnr);
            structure.SetValue("BKTXT", this.Bktxt);
            structure.SetValue("BRNCH", this.Brnch);
            structure.SetValue("STBLG", this.Stblg);
            structure.SetValue("BUTXT", this.Butxt);
            structure.SetValue("CPUDT", this.Cpudt);
            structure.SetValue("CPUTM", this.Cputm);
            structure.SetValue("BLDAT", this.Bldat);
            structure.SetValue("BLART", this.Blart);
            structure.SetValue("WAERS", this.Waers);

            return(structure);
        }
Ejemplo n.º 17
0
        public IRfcStructure GetStructure(RfcRepository repository)
        {
            IRfcStructure structure = repository.GetStructureMetadata("BAPIACCAIT").CreateStructure();

            structure.SetValue("ITEMNO_ACC", this.Itemno_Acc);
            structure.SetValue("CONT_ACCT", this.Cont_Acct);
            structure.SetValue("MAIN_TRANS", this.Main_Trans);
            structure.SetValue("SUB_TRANS", this.Sub_Trans);
            structure.SetValue("FUNC_AREA", this.Func_Area);
            structure.SetValue("FM_AREA", this.Fm_Area);
            structure.SetValue("CMMT_ITEM", this.Cmmt_Item);
            structure.SetValue("FUNDS_CTR", this.Funds_Ctr);
            structure.SetValue("FUND", this.Fund);
            structure.SetValue("AGREEMENT_GUID", this.Agreement_Guid);
            structure.SetValue("FUNC_AREA_LONG", this.Func_Area_Long);
            structure.SetValue("CMMT_ITEM_LONG", this.Cmmt_Item_Long);
            structure.SetValue("GRANT_NBR", this.Grant_Nbr);

            return(structure);
        }
Ejemplo n.º 18
0
        public IRfcStructure GetStructure(RfcRepository repository)
        {
            IRfcStructure structure = repository.GetStructureMetadata("BAPIRET2").CreateStructure();

            structure.SetValue("TYPE", this.Type);
            structure.SetValue("ID", this.Id);
            structure.SetValue("NUMBER", this.Number);
            structure.SetValue("MESSAGE", this.Message);
            structure.SetValue("LOG_NO", this.Log_No);
            structure.SetValue("LOG_MSG_NO", this.Log_Msg_No);
            structure.SetValue("MESSAGE_V1", this.Message_V1);
            structure.SetValue("MESSAGE_V2", this.Message_V2);
            structure.SetValue("MESSAGE_V3", this.Message_V3);
            structure.SetValue("MESSAGE_V4", this.Message_V4);
            structure.SetValue("PARAMETER", this.Parameter);
            structure.SetValue("ROW", this.Row);
            structure.SetValue("FIELD", this.Field);
            structure.SetValue("SYSTEM", this.System);

            return(structure);
        }
Ejemplo n.º 19
0
        private StructureModel LoadStructureMetadata(RfcRepository repository, string structureName)
        {
            var fields = new List <FieldModel>();
            var meta   = repository.GetStructureMetadata(structureName);

            for (int i = 0; i < meta.FieldCount; i++)
            {
                var field = new FieldModel()
                {
                    Name          = meta[i].Name,
                    DataType      = meta[i].DataType.ToString(),
                    Length        = meta[i].NucLength,
                    Decimals      = meta[i].Decimals,
                    Documentation = meta[i].Documentation
                };

                fields.Add(field);
            }

            return(new StructureModel(structureName, fields));
        }
Ejemplo n.º 20
0
        public IRfcStructure GetStructure(RfcRepository repository, bool useEcc)
        {
            IRfcStructure structure = repository.GetStructureMetadata("BAPIACPA09").CreateStructure();

            structure.SetValue("NAME", this.Name);
            structure.SetValue("NAME_2", this.Name_2);
            structure.SetValue("NAME_3", this.Name_3);
            structure.SetValue("NAME_4", this.Name_4);
            structure.SetValue("POSTL_CODE", this.Postl_Code);
            structure.SetValue("CITY", this.City);
            structure.SetValue("COUNTRY", this.Country);
            structure.SetValue("STREET", this.Street);
            structure.SetValue("COUNTRY_ISO", this.Country_Iso);
            structure.SetValue("PO_BOX", this.Po_Box);
            structure.SetValue("POBX_PCD", this.Pobx_Pcd);
            structure.SetValue("POBK_CURAC", this.Pobk_Curac);
            structure.SetValue("BANK_ACCT", this.Bank_Acct);
            structure.SetValue("BANK_NO", this.Bank_No);
            structure.SetValue("BANK_CTRY", this.Bank_Ctry);
            structure.SetValue("BANK_CTRY_ISO", this.Bank_Ctry_Iso);
            structure.SetValue("TAX_NO_1", this.Tax_No_1);
            structure.SetValue("TAX_NO_2", this.Tax_No_2);

            if (useEcc)
            {
                structure.SetValue("TAX_NO_3", this.Tax_No_3);
                structure.SetValue("TAX_NO_4", this.Tax_No_4);
            }

            structure.SetValue("TAX", this.Tax);
            structure.SetValue("EQUAL_TAX", this.Equal_Tax);
            structure.SetValue("REGION", this.Region);
            structure.SetValue("CTRL_KEY", this.Ctrl_Key);
            structure.SetValue("INSTR_KEY", this.Instr_Key);
            structure.SetValue("DME_IND", this.Dme_Ind);
            structure.SetValue("LANGU_ISO", this.Langu_Iso);
            structure.SetValue("ANRED", this.Anred);

            return(structure);
        }
Ejemplo n.º 21
0
Archivo: PO.cs Proyecto: radtek/QM
        public async Task BAPI_PRODORD_CLOSE(IList <string> dt)
        {
            RfcDestination dest       = GetDestination();
            RfcRepository  repository = dest.Repository;
            IRfcFunction   func       = repository.CreateFunction("BAPI_PRODORD_CLOSE");

            IRfcStructure rfcStruct = null;
            IRfcTable     rfcTable  = func.GetTable("ORDERS");

            IRfcStructure stru;
            IRfcTable     result;

            //set parm
            rfcStruct = repository.GetStructureMetadata("BAPI_ORDER_KEY").CreateStructure();
            foreach (var item in dt)
            {
                rfcStruct.SetValue("ORDER_NUMBER", item);
            }
            rfcTable.Insert(rfcStruct);

            //call function
            log.Debug("BAPI_PRODORD_CLOSE => Start");
            func.Invoke(dest);
            log.Debug("BAPI_PRODORD_CLOSE => Done");

            //log result
            result = func.GetTable("DETAIL_RETURN");
            for (int k = 0; k < result.RowCount; k++)
            {
                stru = result[k];
                log.Debug(string.Format("SYSTEM:{0},PPNUMBER:{1},Type:{2},Message:{3}", stru.GetValue("SYSTEM").ToString(),
                                        stru.GetValue("ORDER_NUMBER").ToString(), stru.GetValue("TYPE").ToString(), stru.GetValue("MESSAGE").ToString())
                          );
            }
            rfcTable.Clear();
        }
Ejemplo n.º 22
0
        public Location LocationGetByCode(string locationCode, string warehouseCode)
        {
            Location location = null;

            //using (var db = new DbManager("HandHeldDB"))
            //{
            //    var reader = db.SetCommand(GetSql(43),
            //   db.Parameter("@LocationCode", locationCode),
            //   db.Parameter("@WarehouseCode", warehouseCode))
            //   .ExecuteReader();
            //    while (reader.Read())
            //    {
            //        location = new Location { Code = (string)reader["LocationCode"], WarehouseCode = (string)reader["WarehouseCode"] };
            //    }
            //}
            //var conn = new DBCon.DBSQLDataContext();
            //var locationli = conn.ProductLocations.Where(x => x.LocationCode == locationCode && x.WarehouseCode == warehouseCode).ToList();
            //foreach (var item in locationli)
            //{
            //    location = new Location { Code = item.LocationCode, WarehouseCode = item.WarehouseCode };
            //}
            if (location == null)
            {
                RfcDestination sapRfcDestination = SapHelper.Destination;
                RfcRepository  sapRfcRepository  = sapRfcDestination.Repository;

                char          delimiter  = ':';
                RfcRepository repo       = sapRfcRepository;
                string        bapiName   = "RFC_READ_TABLE";
                IRfcFunction  exportBapi = repo.CreateFunction(bapiName);
                exportBapi.SetValue("QUERY_TABLE", "ZLOCSTRC");
                exportBapi.SetValue("DELIMITER", delimiter);
                exportBapi.SetValue("NO_DATA", "");
                exportBapi.SetValue("ROWSKIPS", 0);
                exportBapi.SetValue("ROWCOUNT", 0);

                RfcStructureMetadata rfcDbOpt = repo.GetStructureMetadata("RFC_DB_OPT");
                var opt = rfcDbOpt.CreateStructure();
                //opt.SetValue("TEXT", @"(APRVFLAG = 'C') AND (USEFLAG = 'X')");
                opt.SetValue("TEXT", string.Format(" (BINLOC = '{0}') ", locationCode));
                var tableOptions = exportBapi.GetTable("OPTIONS");
                tableOptions.Append(opt);

                var                  table = exportBapi.GetTable("FIELDS");
                IRfcStructure        articol;
                RfcStructureMetadata am = repo.GetStructureMetadata("RFC_DB_FLD");
                articol = am.CreateStructure();
                articol.SetValue("FIELDNAME", "BINLOC");
                table.Append(articol);
                articol = am.CreateStructure();
                articol.SetValue("FIELDNAME", "LGORT");
                table.Append(articol);
                articol = am.CreateStructure();
                articol.SetValue("FIELDNAME", "USEFLAG");
                table.Append(articol);

                exportBapi.SetValue("FIELDS", table);
                exportBapi.SetValue("OPTIONS", tableOptions);
                exportBapi.Invoke(sapRfcDestination);
                IRfcTable detail2 = exportBapi.GetTable("DATA");

                string[] value;
                foreach (var item in detail2)
                {
                    value = item.GetString("WA").Replace(" ", "").Split(delimiter);
                    if (((string)value.GetValue(0)).Length != 10)
                    {
                        continue;
                    }
                    if ((string)value.GetValue(2) != "X")
                    {
                        continue;
                    }
                    if (((string)value.GetValue(1)).ToUpper() != warehouseCode.ToUpper())
                    {
                        continue;
                    }
                    location               = new Location();
                    location.Code          = (string)value.GetValue(0);
                    location.WarehouseCode = (string)value.GetValue(1);

                    //using (var db = new DbManager("HandHeldDB"))
                    //{
                    //    //insert new data
                    //    db.SetCommand(GetSql(88),
                    //    db.Parameter("@LocationCode", location.Code),
                    //    db.Parameter("@WarehouseCode", location.WarehouseCode),
                    //    db.Parameter("@isUse", location.IsUse)
                    //    ).ExecuteNonQuery();
                    //}

                    break;
                }
            }


            return(location);

            //List<SAPProxyII.ZLOCSTRC> locations;
            //string key = string.Format(LOCATION_ALL_KEY, DateTime.Now.Date.Day);
            //string keyOld = string.Format(LOCATION_ALL_KEY, DateTime.Now.AddDays(-1).Day);
            //object obj1 = _cacheManager.Get(keyOld);
            //object obj2 = _cacheManager.Get(key);

            //if (obj1 != null)
            //    _cacheManager.Remove(keyOld);

            //if (obj2 != null)
            //    locations = (List<SAPProxyII.ZLOCSTRC>)obj2;
            //else
            //{
            //    using (var sapConnection = new SAP.Connector.SAPConnection(GlobalContext.SapDestination))
            //    {
            //        using (var prx = new SAPProxyII.UWProxy())
            //        {
            //            prx.Connection = sapConnection;

            //            SAPProxyII.ZLOCSTRCTable Tables = new SAPProxyII.ZLOCSTRCTable();
            //            prx.Zdd_Handheld_Get_Zlockstrc(ref Tables);

            //            locations = (List<SAPProxyII.ZLOCSTRC>)CollectionHelper.ConvertTo<SAPProxyII.ZLOCSTRC>(Tables.ToADODataTable());
            //            _cacheManager.Add(key, locations);
            //        }
            //    }
            //}

            //var location = locations.Find(p => p.Binloc == locationCode);
            //if (location != null)
            //{
            //    var locat = new Location();
            //    locat.Code = location.Binloc;
            //    locat.LocationType = location.Loctype;
            //    return locat;
            //}
            //else
            //    return null;
        }
Ejemplo n.º 23
0
        public string doAction()
        {
            try
            {
                SqlConnection sqlconn = new SqlConnection(__conn);
                string        sqlstr  = @"SELECT ObjectId FROM WF_Object WHERE BaseId='" + __flowId + "'";

                SqlDataAdapter sda = new SqlDataAdapter(sqlstr, sqlconn);
                //获取
                DataSet ds = new DataSet();
                sda.Fill(ds);
                DataTable dt = new DataTable();
                dt = ds.Tables[0];

                // 链接
                RfcConfigParameters rfcPar = new RfcConfigParameters();
                rfcPar.Add(RfcConfigParameters.Name, "DEV");
                rfcPar.Add(RfcConfigParameters.AppServerHost, "10.98.0.22");
                rfcPar.Add(RfcConfigParameters.Client, "400");
                rfcPar.Add(RfcConfigParameters.User, "USER01");
                rfcPar.Add(RfcConfigParameters.Password, "1234567890");
                rfcPar.Add(RfcConfigParameters.SystemNumber, "00");//SAP实例
                rfcPar.Add(RfcConfigParameters.Language, "ZH");
                RfcDestination dest   = RfcDestinationManager.GetDestination(rfcPar);
                RfcRepository  rfcrep = dest.Repository;

                IRfcFunction myfun = dest.Repository.CreateFunction("Z_RFC_PLM_SAP_BOM_CREATE");

                IRfcStructure  import = null;
                IRfcTable      table  = myfun.GetTable("ZT_PP0011");
                IRfcTable      retable;
                SqlDataAdapter sda2;
                DataTable      dt2;
                DataTable      dt3;
                bool           wrong = true;
                string         error = "";
                DataRow        dr;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    sqlstr = @"exec GETBOM_woo  '" + dt.Rows[i][0] + "'";
                    sda2   = new SqlDataAdapter(sqlstr, sqlconn);

                    dt2 = new DataTable();
                    sda2.Fill(dt2);

                    for (int j = 0; j < dt2.Rows.Count; j++)
                    {
                        import = rfcrep.GetStructureMetadata("ZPP0011").CreateStructure();

                        import.SetValue("MATNR", dt2.Rows[j][0]);   //物料编号
                        import.SetValue("DATUV", dt2.Rows[j][1]);   //有效起始日期
                        import.SetValue("IDNRK", dt2.Rows[j][2]);   //BOM 组件
                        import.SetValue("BMENG", dt2.Rows[j][3]);   //基本数量
                        import.SetValue("STLST", dt2.Rows[j][4]);   //BOM 状态
                        import.SetValue("MENGE", dt2.Rows[j][5]);   //组件数量
                        import.SetValue("MEINS", dt2.Rows[j][6]);   //组件计量单位
                        import.SetValue("DATUV_I", dt2.Rows[j][7]); //有效起始日期
                        import.SetValue("DATUB_I", dt2.Rows[j][8]); //有效截止日期
                        table.Append(import);
                    }
                    myfun.Invoke(dest);
                }
                dt3 = new DataTable();
                dt3.Columns.Add("MATNR", typeof(string));
                dt3.Columns.Add("POSNR", typeof(string));
                dt3.Columns.Add("IDNRK", typeof(string));
                dt3.Columns.Add("FLAG", typeof(string));
                dt3.Columns.Add("ZRESULTS", typeof(string));
                retable = myfun.GetTable("ZT_PP0011_RLT");

                //re1 = re1 + " kmax=" + Convert.ToString(retable.RowCount) + " ; table= " + Convert.ToString(table.RowCount);
                for (int k = 0; k < retable.Count; k++)
                {
                    retable.CurrentIndex = k;
                    dr = dt3.NewRow();

                    dr["MATNR"]    = retable[k].GetValue("MATNR").ToString();
                    dr["POSNR"]    = retable[k].GetValue("POSNR").ToString();
                    dr["IDNRK"]    = retable[k].GetValue("IDNRK").ToString();
                    dr["FLAG"]     = retable[k].GetValue("FLAG").ToString();
                    dr["ZRESULTS"] = retable[k].GetValue("ZRESULTS").ToString();

                    if (Convert.ToString(dr["FLAG"]) == "E")
                    {
                        if (dr["ZRESULTS"].ToString() == "" || dr["ZRESULTS"].ToString().Contains("创建过程中"))
                        {
                            continue;
                        }

                        wrong = false;
                        error = error + "第" + (k + 1) + "行子物料" + retable[k].GetValue("MATNR").ToString() + "<出错原因:" + dr["ZRESULTS"].ToString() + ">;";
                    }
                    dt3.Rows.Add(dr);
                }
                if (wrong == false)
                {
                    return(error);
                }
                else
                {
                    return("");
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Ejemplo n.º 24
0
        public string doActions()
        {
            try
            {
                SqlConnection sqlconn = new SqlConnection(__conn);
                string        sqlstr  = "SELECT ObjectId FROM WF_Object WHERE BaseId='" + __flowId + "'";


                SqlDataAdapter sda = new SqlDataAdapter(sqlstr, sqlconn);
                //获取
                DataSet ds = new DataSet();
                sda.Fill(ds);
                DataTable dt3 = new DataTable();
                dt3 = ds.Tables[0];

                // 链接
                RfcConfigParameters rfcPar = new RfcConfigParameters();
                rfcPar.Add(RfcConfigParameters.Name, "DEV");
                rfcPar.Add(RfcConfigParameters.AppServerHost, "10.98.0.22");
                rfcPar.Add(RfcConfigParameters.Client, "400");
                rfcPar.Add(RfcConfigParameters.User, "USER01");
                rfcPar.Add(RfcConfigParameters.Password, "1234567890");
                rfcPar.Add(RfcConfigParameters.SystemNumber, "00");//SAP实例
                rfcPar.Add(RfcConfigParameters.Language, "ZH");
                RfcDestination dest   = RfcDestinationManager.GetDestination(rfcPar);
                RfcRepository  rfcrep = dest.Repository;
                IRfcFunction   myfun  = dest.Repository.CreateFunction("ZSET_MATERIEL_MARA");
                myfun.SetValue("P_CODE", "N");//SAP里面的传入参数        // N 新增;M 修改

                IRfcStructure import = null;
                IRfcTable     table;
                bool          wrong = true;
                string        error = "";
                DataRow       dr;

                DataTable dt2 = new DataTable();
                dt2.Columns.Add("DATA1", typeof(string));
                dt2.Columns.Add("DATA2", typeof(string));
                dt2.Columns.Add("DATA3", typeof(string));
                dt2.Columns.Add("DATA4", typeof(string));
                dt2.Columns.Add("DATA5", typeof(string));
                table = myfun.GetTable("T_ZMARA");
                string         strsql2 = "";
                DataTable      dt      = new DataTable();
                SqlDataAdapter sda2;

                if (dt3.Rows.Count <= 0)
                {
                    return("Error:流程行不足1");
                }

                for (int k = 0; k < dt3.Rows.Count; k++)
                {
                    strsql2 = "exec  GETmat_woo  '" + dt3.Rows[k]["ObjectId"] + "'";
                    sda2    = new SqlDataAdapter(strsql2, sqlconn);
                    sqlconn.Open();
                    ds.Clear();
                    dt.Clear();
                    sda2.Fill(ds);
                    dt = ds.Tables[0];
                    sqlconn.Close();

                    if (dt.Rows.Count <= 0)
                    {
                        continue;
                    }
                    else
                    if (k != 0)
                    {
                        loopstr2 = loopstr2 + " union";
                    }

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        import = rfcrep.GetStructureMetadata("ZMARA").CreateStructure();

                        //赋值
                        import.SetValue("MATNR", dt.Rows[i]["物料编码"].ToString()); //物料编码
                        import.SetValue("LTEXT", dt.Rows[i]["物料長描述"]);           //物料描述长文本
                        import.SetValue("MAKTX", dt.Rows[i]["物料短描述"]);           //物料描述
                        import.SetValue("MATKL", dt.Rows[i]["物料组"]);             // dt.Rows[0][2]);   //物料组


                        table.Append(import);
                    }
                }
                myfun.Invoke(dest);

                table = myfun.GetTable("T_ZMARA_RESULT");

                for (int j = 0; j < table.Count; j++)
                {
                    table.CurrentIndex = j;
                    dr = dt2.NewRow();

                    dr["DATA1"] = table[j].GetValue("MANDT").ToString();
                    dr["DATA2"] = table[j].GetValue("MATNR").ToString();
                    dr["DATA3"] = table[j].GetValue("MAKTX").ToString();
                    dr["DATA4"] = table[j].GetValue("ZRESULT").ToString();
                    dr["DATA5"] = table[j].GetValue("ZRESULT_TEXT").ToString();

                    if (Convert.ToString(dr["DATA4"]) == "N" && (!(table[j].GetValue("ZRESULT_TEXT").ToString().Contains("已在创建过程"))) && (table[j].GetValue("ZRESULT_TEXT").ToString() != ""))
                    {
                        wrong = false;
                        error = error + "第" + (j + 1) + "行物料[" + (j + 1) + "]" + table[j].GetValue("MATNR").ToString() + "[" + table[j].GetValue("MAKTX").ToString() + "]" + "<出错原因:" + table[j].GetValue("ZRESULT_TEXT").ToString() + ">;\r\n";
                    }

                    dt2.Rows.Add(dr);
                }

                // dt 包含返回结果
                if (wrong == false)
                {
                    return(error);
                }
                else
                {
                    return("");
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Ejemplo n.º 25
0
        /// <summary>执行按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 函数执行ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                ttbFunName.Focus();
                //指定函数名称
                dsRFC.DataSetName = ttbFunName.Text.Trim();
                myfun             = SapRfcRepository.CreateFunction(ttbFunName.Text.Trim());//根据输入的函数名获取函数对象
                //传入值赋值
                foreach (DataTable item in dsRFC.Tables)
                {
                    //传入值赋值
                    if (item.Namespace == "IM")
                    {
                        int imrowindex = 0;
                        foreach (DataRow item1 in item.Rows)
                        {
                            if (myfun.Metadata[item1["Code"].ToString()].DataType != RfcDataType.TABLE && myfun.Metadata[item1["Code"].ToString()].DataType != RfcDataType.STRUCTURE)
                            {
                                if (!string.IsNullOrEmpty(item1["Value"].ToString()))
                                {
                                    myfun.SetValue(item1["Code"].ToString(), item1["Value"].ToString());
                                }
                            }
                            if (myfun.Metadata[item1["Code"].ToString()].DataType == RfcDataType.TABLE)
                            {
                                if (dsRFC.Tables.Contains("IMT." + item1["Code"].ToString() + "[R" + (imrowindex + 1).ToString() + ",C3]"))
                                {
                                    //setStructureByFun(myfun, myfun.Metadata[item1["Code"].ToString()].DataType.ToString(), "IMT." + item1["Code"].ToString(), "IMT." + item1["Code"].ToString() + "[R" + (imrowindex + 1).ToString() + ",C3]");
                                    setStructureByFun(myfun,
                                                      myfun.Metadata[item1["Code"].ToString()].DataType.ToString(),
                                                      "IMT." + item1["Code"].ToString() + "[R" + (imrowindex + 1).ToString() + ",C3]",
                                                      "IMT." + item1["Code"].ToString());
                                }
                            }
                            imrowindex++;
                        }
                    }
                    //传入结构赋值
                    if (item.Namespace == "IMS")
                    {
                        if (item.Rows.Count > 0)
                        {
                            setStructureByFun(myfun, "STRUCTURE", item.Namespace, item.TableName);
                        }
                    }
                    //表赋值
                    if (item.Namespace == "Tables")
                    {
                        if (item.Rows.Count > 0)
                        {
                            IRfcStructure import = null;
                            IRfcTable     table  = myfun.GetTable(item.TableName);
                            foreach (DataRow item1 in item.Rows)
                            {
                                import = SapRfcRepository.GetStructureMetadata(myfun.Metadata[item.TableName].ValueMetadataAsTableMetadata.LineType.Name).CreateStructure();
                                foreach (DataColumn item2 in item.Columns)
                                {
                                    item2.Namespace = "String";
                                    if (!string.IsNullOrEmpty(item1[item2.ColumnName].ToString()))
                                    {
                                        import.SetValue(item2.ColumnName, item1[item2.ColumnName]);
                                    }
                                }
                                table.Insert(import);
                            }
                        }
                    }
                }
                Stopwatch = new System.Diagnostics.Stopwatch();
                CWaitForm b = new CWaitForm();
                b._wtVoid = 执行;
                b.ShowDialog();
                toolStripMenuItem1.Text = "SAP端执行时间:" + Stopwatch.Elapsed.ToString();
                int exrowindex = -1;
                //获取返回值
                foreach (DataRow item in dtEX.Rows)
                {
                    exrowindex++;
                    string flag = "";
                    if (item["Value"].ToString().Length >= 4)
                    {
                        flag = item["Value"].ToString().Substring(0, 4);
                    }
                    if (flag == "点击赋值")
                    {
                        if (dsRFC.Tables.Contains("EXT." + item["Code"].ToString()))
                        {
                            DataTable dt = new DataTable();
                            if (!dsRFC.Tables.Contains("EXT." + item["Code"].ToString() + "[R" + (exrowindex + 1).ToString() + ",C3]"))
                            {
                                dt           = dsRFC.Tables["EXT." + item["Code"].ToString()].Clone();
                                dt.Namespace = "EXT." + item["Code"].ToString();
                                dt.TableName = "EXT." + item["Code"].ToString() + "[R" + (exrowindex + 1).ToString() + ",C3]";
                                dsRFC.Tables.Add(dt);
                            }
                            else
                            {
                                dt = dsRFC.Tables["EXT." + item["Code"].ToString() + "[R" + (exrowindex + 1).ToString() + ",C3]"];
                                dt.Clear();
                            }

                            IRfcTable irtb;
                            irtb = (IRfcTable)myfun.GetValue(item["Code"].ToString());
                            if (irtb.RowCount > 0)
                            {
                                for (int i = 0; i < irtb.RowCount; i++)
                                {
                                    DataRow dr = dt.NewRow();
                                    foreach (DataColumn item1 in dt.Columns)
                                    {
                                        item1.Namespace      = "String";
                                        irtb.CurrentIndex    = i;
                                        dr[item1.ColumnName] = irtb.CurrentRow[item1.ColumnName].GetValue();
                                    }
                                    dt.Rows.Add(dr);
                                }
                            }
                        }



                        //if (!dsRFC.Tables.Contains(linetablename))
                        //{
                        //    //不存在则创建
                        //    DataTable dt = new DataTable();
                        //    dt = dsRFC.Tables[linetabletypename].Clone();
                        //    dt.Namespace = linetabletypename;
                        //    dt.TableName = linetablename;
                        //    dsRFC.Tables.Add(dt);
                        //}
                    }
                    else
                    {
                        item["Value"] = myfun.GetValue(item["Code"].ToString());
                    }
                }
                //获取表结果,结构结果
                foreach (DataTable item in dsRFC.Tables)
                {
                    if (item.Namespace == "Tables")
                    {
                        IRfcTable irtb;
                        irtb = (IRfcTable)myfun.GetValue(item.TableName);
                        if (irtb.RowCount > 0)
                        {
                            item.Clear();
                            for (int i = 0; i < irtb.RowCount; i++)
                            {
                                DataRow dr = item.NewRow();
                                foreach (DataColumn item1 in item.Columns)
                                {
                                    item1.Namespace      = "String";
                                    irtb.CurrentIndex    = i;
                                    dr[item1.ColumnName] = irtb.CurrentRow[item1.ColumnName].GetValue();
                                }
                                item.Rows.Add(dr);
                            }
                        }
                    }
                    else if (item.Namespace == "EXS")
                    {
                        IRfcStructure irs;
                        String[]      ssname = item.TableName.Split('.');
                        irs = (IRfcStructure)myfun.GetValue(ssname[1]);
                        if (irs.Count > 0)
                        {
                            item.Clear();
                            DataRow dr = item.NewRow();
                            foreach (DataColumn item1 in item.Columns)
                            {
                                if (item1.Namespace == "STRUCTURE")
                                {
                                    dr[item1.ColumnName.ToString()] = "点击赋值";
                                }
                                else if (item1.Namespace == "TABLE")
                                {
                                    dr[item1.ColumnName.ToString()] = "点击赋值";
                                }
                                else
                                {
                                    dr[item1.ColumnName.ToString()] = irs.GetValue(item1.ColumnName.ToString());
                                }
                            }
                            item.Rows.Add(dr);
                        }
                    }
                }
                string filepath = "";
                filepath = System.Environment.CurrentDirectory +
                           "\\RFCFunConfig\\" +
                           dsRFC.DataSetName.ToString() +
                           "\\" + DateTime.Now.Year.ToString() +
                           DateTime.Now.Month.ToString() +
                           DateTime.Now.Day.ToString() +
                           DateTime.Now.Hour.ToString() +
                           DateTime.Now.Minute.ToString() +
                           DateTime.Now.Second.ToString() +
                           DateTime.Now.Millisecond.ToString() +
                           "\\";
                if (!File.Exists(filepath))
                {
                    FileInfo oInfo = new FileInfo(filepath);
                    if (!Directory.Exists(oInfo.DirectoryName))
                    {
                        Directory.CreateDirectory(oInfo.DirectoryName);
                    }
                }
                dsRFC.WriteXmlSchema(filepath + "\\JieGou.XML");
                dsRFC.WriteXml(filepath + "\\ShuZhi.XML");
                MessageBox.Show("执行成功,结果保存在" + filepath);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 26
0
Archivo: BATCH.cs Proyecto: radtek/QM
        public async Task BAPI_GOODSMVT_CREATE(IList <GOODSMVT_ITEM> dt)
        {
            try
            {
                RfcDestination dest       = GetDestination();
                RfcRepository  repository = dest.Repository;
                RfcSessionManager.BeginContext(dest);
                IRfcFunction func    = repository.CreateFunction("BAPI_GOODSMVT_CREATE");
                string       message = null;

                IRfcStructure rfcStructGMItem = null;
                IRfcTable     rfcTableGMItem  = func.GetTable("GOODSMVT_ITEM");

                IRfcStructure stru;
                IRfcTable     result;

                //set parm
                rfcStructGMItem = repository.GetStructureMetadata("BAPI2017_GM_ITEM_CREATE").CreateStructure();
                foreach (var item in dt)
                {
                    rfcStructGMItem.SetValue("MATERIAL", item.material);
                    rfcStructGMItem.SetValue("PLANT", item.plant);
                    rfcStructGMItem.SetValue("STGE_LOC", item.stge_loc);
                    rfcStructGMItem.SetValue("BATCH", item.batch);
                    rfcStructGMItem.SetValue("MOVE_TYPE", item.move_type);
                    rfcStructGMItem.SetValue("ENTRY_QNT", item.entry_qnt);
                    rfcStructGMItem.SetValue("COST_OBJ", item.cost_obj);
                    rfcStructGMItem.SetValue("ENTRY_UOM", item.entry_uom);
                }
                rfcTableGMItem.Insert(rfcStructGMItem);

                IRfcStructure rfcStructGMCode = null;
                rfcStructGMCode = func.GetStructure("GOODSMVT_CODE");

                if (dt.Count > 0)
                {
                    if (dt[0].move_type == "291")
                    {
                        rfcStructGMCode.SetValue("GM_CODE", "03");
                    }
                    else if (dt[0].move_type == "292")
                    {
                        rfcStructGMCode.SetValue("GM_CODE", "06");
                    }
                }

                IRfcStructure rfcStructGMHeader = null;
                rfcStructGMHeader = func.GetStructure("GOODSMVT_HEADER");
                rfcStructGMHeader.SetValue("PSTNG_DATE", "20191028");
                rfcStructGMHeader.SetValue("DOC_DATE", "20191028");



                //call function
                log.Debug("BAPI_GOODSMVT_CREATE => Start");
                func.Invoke(dest);
                log.Debug("BAPI_GOODSMVT_CREATE => Done");

                //log result
                result = func.GetTable("RETURN");

                for (int k = 0; k < result.RowCount; k++)
                {
                    stru    = result[k];
                    message = stru.GetValue("MESSAGE").ToString();
                    log.Debug(string.Format("MESSAGE:{0}", message));
                }

                if (result.RowCount == 0)
                {
                    string doc  = func.GetValue("MATERIALDOCUMENT").ToString();
                    string year = func.GetValue("MATDOCUMENTYEAR").ToString();

                    func = repository.CreateFunction("BAPI_TRANSACTION_COMMIT");
                    func.SetValue("WAIT", "X");
                    func.Invoke(dest);

                    stru = func.GetStructure("RETURN");
                    MessageBox.Show(doc);
                }
                else
                {
                    func = repository.CreateFunction("BAPI_TRANSACTION_ROLLBACK");
                    func.Invoke(dest);
                    MessageBox.Show(message);
                }

                RfcSessionManager.EndContext(dest);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }