return null; } } //这个方法将字符串line中的子串oldString全部替换为newString public static final String replace( String line, String oldString, String newString ) { if (line == null) { return null; } int i=0; if ( ( i=line.indexOf( oldString, i ) ) >= 0 ) { char [] line2 = line.toCharArray(); char [] newString2 = newString.toCharArray(); int oLength = oldString.length(); StringBuffer buf = new StringBuffer(line2.length); buf.append(line2, 0, i).append(newString2); i += oLength; int j = i; while( ( i=line.indexOf( oldString, i ) ) > 0 ) { buf.append(line2, j, i-j).append(newString2); i += oLength; j = i; } buf.append(line2, j, line2.length - j); return buf.toString(); } return line; } public void creatlog(Database db, Session session ,Document doc ,AgentContext agentContext,DateTime writetime,String tcode,String bh,String pzh,String memo,String action) { try { //--------------------------------------------------------------------- ///////////////在OA中记录开始写SAP的日志start String logDbPath = "oadata/write_sap_log.nsf"; Database saplogdb = session.getDatabase(db.getServer(),logDbPath,true); if (saplogdb.isOpen()){}else{ saplogdb.open(); } if (saplogdb!=null){ //String REQUESTNUMBER = ""; // REQUESTNUMBER = doc.getItemValueString("REQUESTNUMBER"); Document logdoc = saplogdb.createDocument(); logdoc.replaceItemValue("Form", "f_or_saplog"); logdoc.replaceItemValue("TCODE",tcode); /////记录tcode logdoc.replaceItemValue("DOCUNID", doc.getUniversalID()); //当前文档UNID logdoc.replaceItemValue("OADbName", db.getFileName()); //当前库 logdoc.replaceItemValue("RequestNum",bh); //文档REQUESTNUMBER logdoc.replaceItemValue("dealaction",action); //处理动作 logdoc.replaceItemValue("dealuser",doc.getItemValueString("SelfName").trim()); //记录处理人 logdoc.replaceItemValue("dealuserID",doc.getItemValueString("SelfWorkID").trim()); //记录处理人ID logdoc.replaceItemValue("dealuserCom", doc.getItemValueString("SelfcompanyShortName").trim()); //处理人所在公司 logdoc.replaceItemValue("dealuserDep", doc.getItemValueString("SelfdepartmentShortName").trim()); //处理人所在部门 logdoc.replaceItemValue("dealDate",writetime.getDateOnly()); //处理日期 logdoc.replaceItemValue("dealtime",writetime.getTimeOnly()); //处理时间 logdoc.replaceItemValue("SAPPingZheng",pzh); //sap凭证号 logdoc.replaceItemValue("Memo",memo); //备注 logdoc.replaceItemValue("Creater","*"); logdoc.getFirstItem("Creater").setAuthors(true); logdoc.save(); } ///////////////在OA中记录开始写S |