public void setCustomers(SAPWS.ZFSS_S_MUSTERI[] E) { Domino.NotesDocumentClass doc; Domino.NotesDatabaseClass database = (Domino.NotesDatabaseClass)session.GetDatabase("", DB_CUSTOMER, false); for (int n = 0; n < E.Length; n++) { Domino.NotesDocumentCollectionClass docs = (Domino.NotesDocumentCollectionClass)database.Search("Kunden_Nummer = '" + Sap.shiftLeft(E[n].KUNNR, "0") + "'", null, 99999); if (E[n].CHANGE_IND == "I" && (docs == null || docs.Count <= 0)) { doc = (Domino.NotesDocumentClass)database.CreateDocument(); doc.AppendItemValue("FORM", "Kunde"); doc.AppendItemValue("Kunden_Nummer", Sap.shiftLeft(E[n].KUNNR, "0")); doc.AppendItemValue("txtkdnr", Sap.shiftLeft(E[n].KUNNR, "0")); doc.AppendItemValue("Suchname", E[n].NAME1); doc.AppendItemValue("txtkdkrzbez", E[n].NAME1); doc.AppendItemValue("CompanyCity", E[n].BEZEI); doc.AppendItemValue("State", E[n].VKBEZ); doc.AppendItemValue("CompanyMainZIP", E[n].BRTXT); doc.AppendItemValue("CompanyAddress", E[n].STRAS + " " + E[n].PSTLZ + " " + E[n].ORT01); doc.AppendItemValue("SalesGroup", Sap.shiftLeft(E[n].PERNR_Y2, "0")); doc.AppendItemValue("SalesGroupTemp", Sap.shiftLeft(E[n].PERNR_Y2, "0")); doc.AppendItemValue("TSRVan", E[n].VORNA_Y2 + " " + E[n].NACHN_Y2); doc.AppendItemValue("TSRName", E[n].VORNA_Y2 + " " + E[n].NACHN_Y2); doc.AppendItemValue("Region", SAP_TERRITORY); doc.AppendItemValue("BodySymbol", 0); doc.AppendItemValue("SalesOffice", SAP_TERRITORY); doc.AppendItemValue("SalesOfficeTemp", SAP_TERRITORY); doc.AppendItemValue("SAPStatus", "No"); doc.AppendItemValue("SAPTerritory", "NO"); doc.AppendItemValue("SAPTSRID", "0101"); doc.AppendItemValue("TeamReaderStandAlone", TEAM_READER_STAND_ALONE); doc.AppendItemValue("ReadAll", READ_ALL); doc.Save(false, false, false); } else if ((E[n].CHANGE_IND == "I" && (docs != null && docs.Count > 0)) || (E[n].CHANGE_IND == "U")) { for (int m = 0; m < docs.Count; m++) { doc = (Domino.NotesDocumentClass)docs.GetNthDocument(m); doc.ReplaceItemValue("Kunden_Nummer", Sap.shiftLeft(E[n].KUNNR, "0")); doc.ReplaceItemValue("txtkdnr", Sap.shiftLeft(E[n].KUNNR, "0")); doc.ReplaceItemValue("Suchname", E[n].NAME1); doc.ReplaceItemValue("txtkdkrzbez", E[n].NAME1); doc.ReplaceItemValue("CompanyCity", E[n].BEZEI); doc.ReplaceItemValue("State", E[n].VKBEZ); doc.ReplaceItemValue("CompanyMainZIP", E[n].BRTXT); doc.ReplaceItemValue("CompanyAddress", E[n].STRAS + " " + E[n].PSTLZ + " " + E[n].ORT01); doc.ReplaceItemValue("SalesGroup", Sap.shiftLeft(E[n].PERNR_Y2, "0")); doc.ReplaceItemValue("SalesGroupTemp", Sap.shiftLeft(E[n].PERNR_Y2, "0")); doc.ReplaceItemValue("TSRVan", E[n].VORNA_Y2 + " " + E[n].NACHN_Y2); doc.ReplaceItemValue("TSRName", E[n].VORNA_Y2 + " " + E[n].NACHN_Y2); doc.Save(false, false, false); } } } }
public void setMaterials(SAPWS.ZFSS_S_MALZEME[] E) { Domino.NotesDocumentClass doc; Domino.NotesDatabaseClass database = (Domino.NotesDatabaseClass)session.GetDatabase("", DB_MATERIAL, false); for (int n = 0; n < E.Length; n++) { Domino.NotesDocumentCollectionClass docs = (Domino.NotesDocumentCollectionClass)database.Search("txtartsachnr = '" + Sap.shiftLeft(E[n].MATNR, "0") + "'", null, 99999); if (E[n].CHANGE_IND == "I" && (docs == null || docs.Count <= 0)) { doc = (Domino.NotesDocumentClass)database.CreateDocument(); doc.AppendItemValue("FORM", "frm_art"); doc.AppendItemValue("txtartsachnr", Sap.shiftLeft(E[n].MATNR, "0")); doc.AppendItemValue("numartme", E[n].MEINS); doc.AppendItemValue("txtartbenenn", E[n].MAKTX); doc.AppendItemValue("txtarterzeuggruppe", E[n].MATKL); doc.AppendItemValue("Bcrit", E[n].XCHPF == "X" ? "Yes" : "No"); doc.AppendItemValue("BodySymbol", 0); doc.AppendItemValue("SAPTerritory", SAP_TERRITORY); doc.AppendItemValue("txtartleihgeraet", "0"); doc.Save(false, false, false); } else if ((E[n].CHANGE_IND == "I" && (docs != null && docs.Count > 0)) || (E[n].CHANGE_IND == "U")) { for (int m = 0; m < docs.Count; m++) { doc = (Domino.NotesDocumentClass)docs.GetNthDocument(m); doc.ReplaceItemValue("FORM", "frm_art"); doc.ReplaceItemValue("txtartsachnr", Sap.shiftLeft(E[n].MATNR, "0")); doc.ReplaceItemValue("numartme", E[n].MEINS); doc.ReplaceItemValue("txtartbenenn", E[n].MAKTX); doc.ReplaceItemValue("txtarterzeuggruppe", E[n].MATKL); doc.ReplaceItemValue("Bcrit", E[n].XCHPF == "X" ? "Yes" : "No"); doc.ReplaceItemValue("BodySymbol", 0); doc.ReplaceItemValue("SAPTerritory", SAP_TERRITORY); doc.ReplaceItemValue("txtartleihgeraet", "0"); doc.Save(false, false, false); } } } }
public Domino.NotesDocumentClass getMaterial(String Matnr) { Domino.NotesDatabaseClass database = (Domino.NotesDatabaseClass)session.GetDatabase("", DB_MATERIAL, false); Domino.NotesDocumentCollectionClass docs = (Domino.NotesDocumentCollectionClass)database.Search("txtartsachnr = '" + Sap.shiftLeft(Matnr, "0") + "'", null, 1); if (docs == null) { return(null); } if (docs.Count <= 0) { return(null); } return((Domino.NotesDocumentClass)docs.GetFirstDocument()); }
private String buildChildAufnr(String Aufnr) { return(Sap.shiftLeft(Aufnr, "0") + "01"); }
private Domino.NotesDocumentClass getParentDispatch(String Aufnr, Domino.NotesDatabaseClass Database) { String aufnr = Aufnr; Domino.NotesDocumentCollectionClass docs = (Domino.NotesDocumentCollectionClass)Database.Search("numeanr = '" + Sap.shiftLeft(aufnr, "0") + "'", null, 99999); for (int n = 0; n < docs.Count; n++) { Domino.NotesDocumentClass doc = (Domino.NotesDocumentClass)docs.GetNthDocument(n); if (getItemValue(doc, "FORM") == DISPATCH_PARENT_FORM) { return(doc); } } return(null); }
private void replaceDispatchFields(ref Domino.NotesDocumentClass doc, SAPWS.ZFSS_S_DISPATCH E, SAPWS.ZFSS_S_DISPATCH_TEXT[] T, SAPWS.ZFSS_S_DISPATCH_Z7[] Z7, SAPWS.ZFSS_S_DISPATCH_EQUIPMENT[] DE, DISPATCH_TYPE DispatchType) { String text; // Child? if (DispatchType == DISPATCH_TYPE.CHILD) { // Genel bilgiler doc.ReplaceItemValue("FORM", "frm_gzea"); doc.ReplaceItemValue("SAPtxtNo", Sap.shiftLeft(buildChildAufnr(E.AUFNR), "0")); // Ekipmana özel bilgiler for (int n = 0; n < DE.Length; n++) { if (DE[n].AUFNR == E.AUFNR) { doc.ReplaceItemValue("txtartpkid", getMaterialPmsId(Sap.shiftLeft(DE[n].MATNR, "0"))); doc.ReplaceItemValue("numeqnr", Sap.shiftLeft(DE[n].EQUNR, "0")); doc.ReplaceItemValue("txtfabriknr", Sap.shiftLeft(DE[n].SERNR, "0")); doc.ReplaceItemValue("txteqsoftwareversion", DE[n].ZZSWVER); doc.ReplaceItemValue("txteqstandort", DE[n].ZZLOCAT); doc.ReplaceItemValue("dateqletztewartung", parseSapDate(DE[n].ZZLASTDATE)); doc.ReplaceItemValue("txtartsachnr", Sap.shiftLeft(DE[n].MATNR, "0")); } } } else { doc.ReplaceItemValue("FORM", "frm_ea"); doc.ReplaceItemValue("numeaicon", 25); } doc.ReplaceItemValue("numeanr", Sap.shiftLeft(E.AUFNR, "0")); doc.ReplaceItemValue("anzeige1", E.NAME1); doc.ReplaceItemValue("txtartbenenn", E.NAME1); doc.ReplaceItemValue("txtTSR", E.ZFSE_VORNA + " " + E.ZFSE_NACHN); doc.ReplaceItemValue("SAPTSRID", Sap.shiftLeft(E.ZFSE, "0")); doc.ReplaceItemValue("txtpriority", E.ZJOBTYPE); doc.ReplaceItemValue("dateabestelltam", parseSapDate(E.AUFK_ERDAT)); doc.ReplaceItemValue("dateeadue", parseSapDate(E.GSTRP)); doc.ReplaceItemValue("txteabesteller", E.ZCONTACT_NAME1); doc.ReplaceItemValue("txtcontacttel", E.TEL_NUMBER); text = ""; for (int x = 0; x < T.Length; x++) { if (T[x].AUFNR == E.AUFNR && T[x].DTTYP == "R") { text += (text.Length > 0 ? "\r\n" + T[x].TLINE : T[x].TLINE); } } doc.ReplaceItemValue("txteakrztxt", text); text = ""; for (int x = 0; x < T.Length; x++) { if (T[x].AUFNR == E.AUFNR && T[x].DTTYP == "I") { text += (text.Length > 0 ? "\r\n" + T[x].TLINE : T[x].TLINE); } } doc.ReplaceItemValue("txtinfoIntern", text); text = ""; for (int x = 0; x < T.Length; x++) { if (T[x].AUFNR == E.AUFNR && T[x].DTTYP == "W") { text += (text.Length > 0 ? "\r\n" + T[x].TLINE : T[x].TLINE); } } doc.ReplaceItemValue("WorkPerformed", text); doc.ReplaceItemValue("txteanrUS", Sap.shiftLeft(E.AUFNR, "0")); doc.ReplaceItemValue("CreatedBy", E.ERNAM_NAME_FIRST + " " + E.ERNAM_NAME_LAST); doc.ReplaceItemValue("txteajobtype", E.VAPLZ + " - " + E.VAPLZ_KTEXT); //doc.ReplaceItemValue("txteastatus", "0"); --> Bunu yapmıyoruz, trafik lambasıyla Update sırasında oynamasak daha iyi doc.ReplaceItemValue("Invoice", E.ZINVOICE == "X" ? "1" : "0"); doc.ReplaceItemValue("numeaestvalue", Sap.shiftLeft(E.QMNUM, "0")); doc.ReplaceItemValue("txtkdkrzbez", E.NAME1); doc.ReplaceItemValue("txtkdnr", Sap.shiftLeft(E.KUNNR, "0")); doc.ReplaceItemValue("txtCustomerAddress", E.STRAS + " " + E.PSTLZ + " " + E.ORT01); //doc.ReplaceItemValue("ReadAll", READ_ALL); //doc.ReplaceItemValue("TeamReader", TEAM_READER); // Additional Readers doc.RemoveItem("AdditionalReaders"); doc.RemoveItem("AdditionalReadersCN"); for (int n = 0; n < Z7.Length; n++) { if (Z7[n].AUFNR == E.AUFNR) { String lname = ""; String cname = ""; getLotusUser(Z7[n].PARNR, out lname, out cname); if (lname != null) { doc.AppendItemValue("AdditionalReaders", lname); doc.AppendItemValue("AdditionalReadersCN", cname); } } } }
public void setDispatchs(SAPWS.ZFSS_S_DISPATCH[] E, SAPWS.ZFSS_S_DISPATCH_TEXT[] T, SAPWS.ZFSS_S_DISPATCH_Z7[] Z7, SAPWS.ZFSS_S_DISPATCH_EQUIPMENT[] DE) { String text; Domino.NotesDocumentClass doc; Domino.NotesDatabaseClass database = (Domino.NotesDatabaseClass)session.GetDatabase("", DB_DISPATCH, false); for (int n = 0; n < E.Length; n++) { Domino.NotesDocumentCollectionClass docs = (Domino.NotesDocumentCollectionClass)database.Search("numeanr = '" + Sap.shiftLeft(E[n].AUFNR, "0") + "'", null, 99999); if (E[n].CHANGE_IND == "I" && (docs == null || docs.Count <= 0)) { // Parent Dispatch doc = (Domino.NotesDocumentClass)database.CreateDocument(); appendDispatchFields(ref doc, E[n], T, Z7, DE, DISPATCH_TYPE.PARENT, database); doc.Save(true, true, true); // Child Dispatch doc = (Domino.NotesDocumentClass)database.CreateDocument(); appendDispatchFields(ref doc, E[n], T, Z7, DE, DISPATCH_TYPE.CHILD, database); doc.Save(true, true, true); } else if ((E[n].CHANGE_IND == "I" && (docs != null && docs.Count > 0)) || (E[n].CHANGE_IND == "U")) { for (int m = 0; m < docs.Count; m++) { doc = (Domino.NotesDocumentClass)docs.GetNthDocument(m); switch (getItemValue(doc, "FORM")) { case DISPATCH_PARENT_FORM: replaceDispatchFields(ref doc, E[n], T, Z7, DE, DISPATCH_TYPE.PARENT); doc.Save(true, true, true); break; case DISPATCH_CHILD_FORM: replaceDispatchFields(ref doc, E[n], T, Z7, DE, DISPATCH_TYPE.CHILD); doc.Save(true, true, true); break; } } } } }
public void setEquipments(SAPWS.ZFSS_S_EQUIPMENT[] E) { Domino.NotesDocumentClass doc; Domino.NotesDatabaseClass database = (Domino.NotesDatabaseClass)session.GetDatabase("", DB_EQUIPMENT, false); for (int n = 0; n < E.Length; n++) { //txtkdnr Domino.NotesDocumentCollectionClass docs = (Domino.NotesDocumentCollectionClass)database.Search("numeqnr = '" + Sap.shiftLeft(E[n].EQUNR, "0") + "'", null, 99999); if (E[n].CHANGE_IND == "I" && (docs == null || docs.Count <= 0)) { doc = (Domino.NotesDocumentClass)database.CreateDocument(); doc.AppendItemValue("FORM", "frm_eq"); //doc.AppendItemValue("KundenInfo", "KK KundenInfo"); doc.AppendItemValue("numeqicon", "78"); doc.AppendItemValue("numeqnr", Sap.shiftLeft(E[n].EQUNR, "0")); doc.AppendItemValue("numsort", "2"); doc.AppendItemValue("txtartbenenn", E[n].EQKTX); doc.AppendItemValue("txtkdnr", Sap.shiftLeft(E[n].PARNR, "0")); doc.AppendItemValue("txtfabriknr", Sap.shiftLeft(E[n].SERNR, "0")); doc.AppendItemValue("txtartsachnr", Sap.shiftLeft(E[n].MATNR, "0")); doc.AppendItemValue("txtartpkid", getMaterialPmsId(Sap.shiftLeft(E[n].MATNR, "0"))); doc.AppendItemValue("numsvnr", Sap.shiftLeft(E[n].ZZVBELN, "0")); doc.AppendItemValue("txtkdkrzbez", E[n].NAME1); doc.AppendItemValue("dateqinbetriebnahme", E[n].DRTBAS); doc.AppendItemValue("dateqgarantieende", E[n].DRTBTS); doc.AppendItemValue("txtsvstatus", parseSapDate(E[n].ZZVNDAT)); doc.AppendItemValue("dateqletztewartung", parseSapDate(E[n].ZZLASTDATE)); doc.AppendItemValue("txtkdinventarnr", E[n].ZZEXTWG); doc.AppendItemValue("txtBillingPartnerNo", E[n].Y2TEKNIK); doc.AppendItemValue("ReadAll", READ_ALL); doc.AppendItemValue("TeamReaderStandAlone", TEAM_READER_STAND_ALONE); doc.AppendItemValue("SalesOfficeTemp", SAP_TERRITORY); doc.Save(false, false, false); } else if ((E[n].CHANGE_IND == "I" && (docs != null && docs.Count > 0)) || (E[n].CHANGE_IND == "U")) { for (int m = 0; m < docs.Count; m++) { doc = (Domino.NotesDocumentClass)docs.GetNthDocument(m); doc.ReplaceItemValue("FORM", "frm_eq"); doc.ReplaceItemValue("numeqicon", "78"); doc.ReplaceItemValue("numsort", "2"); doc.ReplaceItemValue("numeqnr", Sap.shiftLeft(E[n].EQUNR, "0")); doc.ReplaceItemValue("txtartbenenn", E[n].EQKTX); doc.ReplaceItemValue("txtkdnr", Sap.shiftLeft(E[n].PARNR, "0")); doc.ReplaceItemValue("txtfabriknr", Sap.shiftLeft(E[n].SERNR, "0")); doc.ReplaceItemValue("txtartsachnr", Sap.shiftLeft(E[n].MATNR, "0")); doc.ReplaceItemValue("txtartpkid", getMaterialPmsId(Sap.shiftLeft(E[n].MATNR, "0"))); doc.ReplaceItemValue("numsvnr", Sap.shiftLeft(E[n].ZZVBELN, "0")); doc.ReplaceItemValue("dateqletztewartung", E[n].ZZLASTDATE); doc.ReplaceItemValue("dateqinbetriebnahme", E[n].DRTBAS); doc.ReplaceItemValue("dateqgarantieende", E[n].DRTBTS); doc.ReplaceItemValue("txtkdkrzbez", E[n].NAME1); doc.ReplaceItemValue("txtsvstatus", E[n].ZZVNDAT); doc.ReplaceItemValue("txtkdinventarnr", Sap.shiftLeft(E[n].ZZEXTWG, "0")); doc.ReplaceItemValue("txtBillingPartnerNo", Sap.shiftLeft(E[n].Y2TEKNIK, "0")); //doc.ReplaceItemValue("ReadAll", READ_ALL); //doc.ReplaceItemValue("TeamReaderStandAlone", TEAM_READER_STAND_ALONE); //doc.ReplaceItemValue("SalesOfficeTemp", SAP_TERRITORY); doc.Save(false, false, false); } } } }
private void getLotusUser(String Pernr, out String Lname, out String Cname) { Lname = null; Cname = null; Domino.NotesDatabaseClass database = (Domino.NotesDatabaseClass)session.GetDatabase("", DB_USER, false); Domino.NotesDocumentCollectionClass docs = (Domino.NotesDocumentCollectionClass)database.Search("txttetechid = '" + Sap.shiftLeft(Pernr, "0") + "'", null, 99999); for (int n = 0; n < docs.Count; n++) { Domino.NotesDocumentClass doc = (Domino.NotesDocumentClass)docs.GetNthDocument(n); Lname = getItemValue(doc, "benutzer"); Cname = getItemValue(doc, "benutzerInterface"); } }
static void Main(string[] args) { try { // Ön hazırlıklar appendLog("SAP FSS Integration v" + version); appendLog("Cozumevi Consulting"); appendLog("www.cozumevi.com"); config = new Config(); lotus = new Lotus(); lotus.connect(config.lotusPassword); sap = new Sap(); // Müşteriler //if (paramExists(args, "-mus")) { appendLog("Müşteriler SAP -> FSS yönünde aktariliyor"); lotus.setCustomers(sap.getCustomers()); sap.setStatu(); appendLog("Müşteriler FSS -> SAP yönünde aktariliyor"); sap.setCustomers(lotus.getCustomers()); } // Malzemeler if (paramExists(args, "-mal")) { appendLog("Malzemeler SAP -> FSS yönünde aktariliyor"); lotus.setMaterials(sap.getMaterials()); sap.setStatu(); appendLog("Malzemeler FSS -> SAP yönünde aktariliyor"); sap.setMaterials(lotus.getMaterials()); } // Ekipmanlar if (paramExists(args, "-eki")) { appendLog("Ekipmanlar SAP -> FSS yönünde aktariliyor"); lotus.setEquipments(sap.getEquipments()); sap.setStatu(); appendLog("Ekipmanlar FSS -> SAP yönünde aktariliyor"); sap.setEquipments(lotus.getEquipments()); } // Siparişler (Dispatch) /// Burada özellikle önce FSS -> SAP yaptık /// Zira Dispatch'lerin alanlarının neredeyse tamamı iki tarafta da değişebilir /// Ve biz FSS'te yapılan değişiklikleri daha doğru diye varsayıyoruz if (paramExists(args, "-sip")) { appendLog("Siparişler FSS -> SAP yönünde aktariliyor"); sap.setDispatchs(lotus.getDispatchs()); } /*appendLog("Siparişler SAP -> FSS yönünde aktariliyor"); * SAPWS.ZFSS_S_DISPATCH[] sapDis; * SAPWS.ZFSS_S_DISPATCH_TEXT[] sapDist; * SAPWS.ZFSS_S_DISPATCH_Z7[] sapZ7; * SAPWS.ZFSS_S_DISPATCH_EQUIPMENT[] sapDispEqui; * sap.getDispatchs(out sapDis, out sapDist, out sapZ7, out sapDispEqui); * lotus.setDispatchs(sapDis, sapDist, sapZ7, sapDispEqui); * sap.setStatu();*/ // Teyitler if (paramExists(args, "-tey")) { appendLog("Teyitler FSS -> SAP yönünde aktariliyor"); sap.setConfirmations(lotus.getDispatchs()); } // Bileşenler if (paramExists(args, "-bil")) { appendLog("Bileşenler FSS -> SAP yönünde aktariliyor"); sap.setComponents(lotus.getDispatchs()); } // Final lotus.disconnect(); appendLog("Program bitti"); } catch (Exception ex) { appendLog(ex.ToString()); Console.ReadKey(); } }