Sie sind auf Seite 1von 22

Code for init

try { String userId=new String(); IWDClientUser wduser= WDClientUser.getCurrentUser(); com.sap.security.api.IUser user=wduser.getSAPUser(); if(user != null) { IUserAccount[] acc=user.getUserAccounts(); if(acc[0] != null) { String fname=user.getFirstName(); if(fname==null)fname=""; String lname = user.getLastName(); if(lname==null)lname=""; String name = fname+lname; // String username=user.getFirstName().concat(user.getLastName() wdContext.currentSFREQUESTORElement().setNAME(name); // wdContext.currentContextElement().setReName(username); String userEmail = user.getEmail(); wdContext.currentSFREQUESTORElement().setEMAIL(userEmail); // wdContext.currentContextElement().setReEmail(userEmail); } } //code for documenttype dropdownlist. String[] count={"NB - Purch.requis. Stand","EC - Purch.requis.EBP","FO - Framework requisn","IN - Purch.requis,I-Comm","MV - Model specification","RV - Outl.agmt.requisn"}; Arrays.sort(count); List elements=new ArrayList(); IPublicPRCompInterface.IDOCUMENTTYPEElement ele; // IPrivateVenkatapproverComp.IDocumentTypeElement ele; for(int i=0;i<=count.length-1;i++) { ele=wdContext.createDOCUMENTTYPEElement(); ele.setVALUE(count[i]); ele.setKEY(count[i]); elements.add(ele); } wdContext.nodeDOCUMENTTYPE().bind(elements); wdContext.nodeDOCUMENTTYPE().setLeadSelection(0);

// PurchaseGroupElement

code for

Rfc_Read_Table_Input purchaseinput = new Rfc_Read_Table_Input (); wdContext.nodeRfc_Read_Table_Input().bind(purchaseinput); purchaseinput.setQuery_Table("T024"); purchaseinput.setDelimiter(":"); wdContext.nodeRfc_Read_Table_Input().bind(purchaseinput); wdContext.currentRfc_Read_Table_InputElement().modelObject().execute(); IPublicPRCompInterface.IPURCHASEGROUPElement purchaseGroupElement; for(int i=0;i<wdContext.nodeData1().size();i++) { String strWa = wdContext.nodeData1().getData1ElementAt(i).getWa(); String[] arrayWa = strWa.split(":"); purchaseGroupElement = wdContext.createPURCHASEGROUPElement(); purchaseGroupElement.setKEY(arrayWa[1]); purchaseGroupElement.setVALUE(arrayWa[2]); wdContext.nodePURCHASEGROUP().addElement(purchaseGroupElement);

wdContext.nodePURCHASEGROUP().setLeadSelection(0); // MasterGroupElement Rfc_Read_Table_Input masterinput = code for

new Rfc_Read_Table_Input();

wdContext.nodeRfc_Read_Table_Input().bind(masterinput); masterinput.setQuery_Table("T023T"); masterinput.setDelimiter(":");

wdContext.currentRfc_Read_Table_InputElement().modelObject().execute(); IPublicPRCompInterface.IMATERIALGROUPElement masterGroupElement;

i=0;i<wdContext.nodeData1().size();i++) strWa = wdContext.nodeData1().getData1ElementAt(i).getWa(); String[] arrayWa = strWa.split(":");

for(int { String

masterGroupElement=wdContext.createMATERIALGROUPElement(); masterGroupElement.setKEY(arrayWa[2]); masterGroupElement.setVALUE(arrayWa[3]); wdContext.nodeMATERIALGROUP().addElement(masterGroupElement); } wdContext.nodeMATERIALGROUP().setLeadSelection(0); // code for plant Element Rfc_Read_Table_Input plantinput = new Rfc_Read_Table_Input(); wdContext.nodeRfc_Read_Table_Input().bind(plantinput); plantinput.setQuery_Table("T001W"); plantinput.setDelimiter(":");

wdContext.currentRfc_Read_Table_InputElement().modelObject().execute(); IPublicPRCompInterface.IPLANTElement plantElement;

for(int i=0;i<wdContext.nodeData1().size();i++)

String strWa = wdContext.nodeData1().getData1ElementAt(i).getWa(); String[] arrayWa = strWa.split(":");

plantElement = wdContext.createPLANTElement(); plantElement.setKEY(arrayWa[1]); plantElement.setVALUE(arrayWa[2]); wdContext.nodePLANT().addElement(plantElement); } wdContext.nodePLANT().setLeadSelection(0);

//

storage loction Rfc_Read_Table_Input input =

new Rfc_Read_Table_Input ();

input.setQuery_Table("T001L"); input.setDelimiter(":"); //Rfc_Db_Opt rfcOpt = new

Rfc_Db_Opt();

//String strText = "WERKS = '"+wdContext.currentPLANTElement().getKEY()+"'"; //rfcOpt.setText(strText); //input.addOptions(rfcOpt);

wdContext.nodeRfc_Read_Table_Input().bind(input);

wdContext.currentRfc_Read_Table_InputElement().modelObject().execute();

IPublicPRCompInterface.ISTORAGELOCATIONElement

storageLocationElement;

//wdContext.nodeSTORAGELOCATION().invalidate(); for(int

i=0;i<wdContext.nodeData1().size();i++)

{ String strWa = wdContext.nodeData1().getData1ElementAt(i).getWa(); String[] arrayWa = strWa.split(":");

storageLocationElement = wdContext.createSTORAGELOCATIONElement();

storageLocationElement.setKEY(arrayWa[2]);

storageLocationElement.setVALUE(arrayWa[3]);

wdContext.nodeSTORAGELOCATION().addElement(storageLocationElement); } // code for Item Catagory

Rfc_Read_Table_Input itemcatagory = new Rfc_Read_Table_Input(); wdContext.nodeRfc_Read_Table_Input().bind(itemcatagory); itemcatagory.setQuery_Table("T163Y"); itemcatagory.setDelimiter(":");

wdContext.currentRfc_Read_Table_InputElement().modelObject().execute(); IPublicPRCompInterface.IITEMCATEGORYElement itemcatagoryElement; for(int i=0;i<wdContext.nodeData1().size();i++) strWa = wdContext.nodeData1().getData1ElementAt(i).getWa(); arrayWa = strWa.split(":"); { String String[]

// IWDAttributeInfo iteminfo = wdContext.nodeITEMCATEGORY().getNodeInfo().getAttribute("VALUE"); // IModifiableSimpleValueSet valueSet = iteminfo.getModifiableSimpleType().getSVServices().getModifiableSimpleV alueSet(); //for(int j=0;j<strWa.length();j++) //{ // valueSet.put(arrayWa[2],arrayWa[3]); // } itemcatagoryElement = wdContext.createITEMCATEGORYElement(); itemcatagoryElement.setKEY(arrayWa[2]); itemcatagoryElement.setVALUE(arrayWa[3]); wdContext.nodeITEMCATEGORY().addElement(itemcatagoryElement);

} wdContext.nodeITEMCATEGORY().setLeadSelection(0); wdContext.currentSFSUBMITFORAPPROVELElement().setFORMVIEW("REQUESTER "); //this.generatePD F(); }catch(Exception e) { wdComponentAPI.getMessageManager().reportSuccess(e.toString()); e.printStackTrace(); } $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

Code for getdescription


IGPTechnicalDescription technicalDescription = null; try { IWDTextAccessor textAccessor = wdComponentAPI.getTextAccessor(); GPWebDynproResourceAccessor resourceAccessor =new GPWebDynproResourceAccessor(textAccessor); technicalDescription =GPCallableObjectFactory.createTechnicalDescription("Test CO for purchase Requisition","Test CO for purchase Requisition",resourceAccessor,locale); wdComponentAPI.getMessageManager().reportSuccess("1t"); IGPStructureInfo input =technicalDescription.getInputStructureInfo(); IGPStructureInfo output = technicalDescription.getOutputStructureInfo();

IGPAttributeInfo inputPdfContent = input.addAttribute("PDF_CONTENT",IGPAttributeInfo.BASE_BASE64BINARY);

inputPdfContent.setMultiplicity(IGPAttributeInfo.MULITIPLICITY_1_1);

IGPAttributeInfo inputLineItemCount = input.addAttribute("LINE_ITEM_COUNT",IGPAttributeInfo.BASE_SIGNED_INT);

inputLineItemCount.setMultiplicity(IGPAttributeInfo.MULITIPLICITY_1_1); wdComponentAPI.getMessageManager().reportSuccess("2t");

// defining output parameters IGPAttributeInfo outputPrNumber = output.addAttribute("PR_NUMBER",IGPAttributeInfo.BASE_STRING);

outputPrNumber.setMultiplicity(IGPAttributeInfo.MULITIPLICITY_1_1); //defining ResultState

IGPCOResultStateInfo approve =technicalDescription.addResultState("APPROVED"); approve.setDescriptionKey("APPROVED"); wdComponentAPI.getMessageManager().reportSuccess("3t"); IGPCOResultStateInfo reject = technicalDescription.addResultState("REJECTED"); reject.setDescriptionKey("REJECTED"); wdComponentAPI.getMessageManager().reportSuccess("4t"); } catch(GPInvocationException e) { e.printStackTrace(); wdComponentAPI.getMessageManager().reportSuccess("5t"); } catch (Exception e) { e.printStackTrace(); } return technicalDescription;

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

Code for execute

IContextElement contextElement = wdContext.currentContextElement(); contextElement.setExecutioncontext(executionContext);

try{ wdContext.currentPDFSOURCEElement().setPDFSOURCE(null);

wdComponentAPI.getMessageManager().reportSuccess("1e"); IGPStructure input = executionContext.getInputStructure();

wdComponentAPI.getMessageManager().reportSuccess("2e");

wdContext.currentPDFSOURCEElement().setPDFSOURCE(input.getAttributeAsBy teArray("PDF_CONTENT")); wdComponentAPI.getMessageManager().reportSuccess("3e"); int lineItem = input.getAttributeAsInt("LINE_ITEM_COUNT");

wdContext.currentSFSUBMITFORAPPROVELElement().setLINEITEM(Integer.toStr ing(lineItem)); wdComponentAPI.getMessageManager().reportSuccess("4e"); for(int i=0;i<lineItem;i++) {

wdContext.nodeSFITEMLIST().addElement(wdContext.createSFITEMLISTElement ()); wdComponentAPI.getMessageManager().reportSuccess("4e1"); } //IGPStructure output = executionContext.getOutputStructure(); //String prnumber = output.getAttributeAsString("PR_NUMBER"); //wdContext.currentOutput1Element().setExppurchaseord er(prnumber); //tranfer pdf data to context

WDInteractiveFormHelper.transferPDFDataIntoContext(wdContext.currentPDF SOURCEElement().getPDFSOURCE(),wdContext.nodePURCHASEREQUISITIONFORM()); wdComponentAPI.getMessageManager().reportSuccess("5e");

wdContext.currentSFSUBMITFORAPPROVELElement().setFORMVIEW("APPROVER");

wdComponentAPI.getMessageManager().reportSuccess("6e"); //prefileDropDowns(); //merge context data to pdf //wdContext.currentSFSUBMITFORAPPROVELElement().setFO RMVIEW("APPROVER"); IWDPDFDocumentAccessibleContext ctx = WDPDFDocumentFactory.getDocumentHandler().getDocumentAccessibleContext( ); wdComponentAPI.getMessageManager().reportSuccess("14e"); ctx.setPDF(wdContext.currentPDFSOURCEElement().getPDFSOURCE()); wdComponentAPI.getMessageManager().reportSuccess("15e");

ctx.setData(WDInteractiveFormHelper.getContextDataAsStream(wdContext.no dePURCHASEREQUISITIONFORM())); IWDPDFDocument doc = ctx.execute(); wdContext.currentPDFSOURCEElement().setPDFSOURCE(doc.getPDF()); wdComponentAPI.getMessageManager().reportSuccess("16e"); }catch(Exception e) {

wdComponentAPI.getMessageManager().reportException(e.getMessage(),false ); } $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

Code for generate PDf


public void generatePDF( ) { //@@begin generatePDF() wdContext.nodeSFITEMLIST().addElement(wdContext.createSFITEMLISTElement ()); try{ IWDPDFDocumentCreationContext ctx = WDPDFDocumentFactory.getDocumentHandler().getDocumentCreationContext(); ctx.setDynamic(true);

wdComponentAPI.getMessageManager().reportSuccess("1g"); ctx.setTemplate(getTemplate("PurchaseRequisitionForm1.xdp")); wdComponentAPI.getMessageManager().reportSuccess("2g"); ctx.setData(WDInteractiveFormHelper.getContextDataAsStream(wdContext.no dePURCHASEREQUISITIONFORM())); IWDPDFDocument doc = ctx.execute(); wdContext.currentPDFSOURCEElement().setPDFSOURCE(doc.getPDF()); wdComponentAPI.getMessageManager().reportSuccess("3g"); } catch(Exception e) { wdComponentAPI.getMessageManager().reportException("Error Occurred while crating pdf Document.please contact system administrator:" ,false); wdComponentAPI.getMessageManager().reportSuccess("4g"); e.printStackTrace(); } //@@end }

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

Code for submit


String formAction = wdContext.currentSFSUBMITFORAPPROVELElement().getFORMACTION(); if(formAction.equalsIgnoreCase("SUBMIT")) { return startWorkFlow(); } else if(formAction.equalsIgnoreCase("APPROVE")) { return approve(); } else if(formAction.equalsIgnoreCase("REJECT")) { return reject(); } return false ;

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

Code for Approve


try {

wdComponentAPI.getMessageManager().reportSuccess("1"); Bapi_Po_Create1_Input bapiPoCreate1Input = new Bapi_Po_Create1_Input(); wdContext.nodeBapi_Po_Create1_Input().bind(bapiPoCreate1Input);

wdComponentAPI.getMessageManager().reportSuccess("2"); Bapimepoheader bapimepoheader = new

Bapimepoheader();

wdComponentAPI.getMessageManager().reportSuccess("3"); bapimepoheader.setComp_Code("4000"); String doc_Type = wdContext.nodeDOCUMENTTYPE().currentDOCUMENTTYPEElement().getVALUE(); if(doc_Type != null && doc_Type != "") bapimepoheader.setDoc_Type("NB"); wdComponentAPI.getMessageManager().reportSuccess("4"); bapimepoheader.setStatus("9"); wdComponentAPI.getMessageManager().reportSuccess("5"); Calendar cal = Calendar.getInstance(); java.sql.Date sqldate =new java.sql.Date(cal.getTimeInMillis()); wdComponentAPI.getMessageManager().reportSuccess("6"); bapimepoheader.setCreat_Date(sqldate); bapimepoheader.setItem_Intvl("00010"); wdComponentAPI.getMessageManager().reportSuccess("9" + sqldate.toString()); bapimepoheader.setVendor("DELL"); bapimepoheader.setLangu("EN"); wdComponentAPI.getMessageManager().reportSuccess("10"); bapimepoheader.setPurch_Org("4000");

String pur_Group = wdContext.nodePURCHASEGROUP().currentPURCHASEGROUPElement().getVALUE(); // if(pur_Group != null && pur_Group != "") //bapimepoheader.setPur_Group(pur_Group); bapimepoheader.setPur_Group("400");

wdComponentAPI.getMessageManager().reportSuccess("10" + pur_Group); bapimepoheader.setCurrency("USD"); bapimepoheader.setCurrency_Iso("USD"); wdComponentAPI.getMessageManager().reportSuccess("11"); bapimepoheader.setExch_Rate(new BigDecimal("1.00000")); DateFormat d1 = new SimpleDateFormat("MM/dd/yyyy"); wdComponentAPI.getMessageManager().reportSuccess("12"); Date date1 = new Date(System.currentTimeMillis()); bapimepoheader.setDoc_Date(sqldate); bapimepoheader.setSubitemint("00001"); bapimepoheader.setVat_Cntry("US"); bapimepoheader.setVat_Cntry_Iso("US"); wdComponentAPI.getMessageManager().reportSuccess("13" + date1); bapiPoCreate1Input.setPoheader(bapimepoheader);

wdComponentAPI.getMessageManager().reportSuccess("14"); Bapimepoheaderx bapimepoheaderx = new Bapimepoheaderx(); bapimepoheaderx.setComp_Code(true); bapimepoheaderx.setDoc_Type(true); bapimepoheaderx.setStatus(true); wdComponentAPI.getMessageManager().reportSuccess("15"); bapimepoheaderx.setCreat_Date(true); bapimepoheaderx.setItem_Intvl(true); wdComponentAPI.getMessageManager().reportSuccess("17"); bapimepoheaderx.setVendor(true); wdComponentAPI.getMessageManager().reportSuccess("18"); bapimepoheaderx.setLangu(true); bapimepoheaderx.setPurch_Org(true); bapimepoheaderx.setPur_Group(true); wdComponentAPI.getMessageManager().reportSuccess("16"); bapimepoheaderx.setCurrency(true); bapimepoheaderx.setCurrency_Iso(true);

wdComponentAPI.getMessageManager().reportSuccess("19"); bapimepoheaderx.setExch_Rate(true); bapimepoheaderx.setDoc_Date(true); bapimepoheaderx.setSubitemint(true); bapimepoheaderx.setVat_Cntry(true); bapimepoheaderx.setVat_Cntry_Iso(true); wdComponentAPI.getMessageManager().reportSuccess("20"); bapiPoCreate1Input.setPoheaderx(bapimepoheaderx); for(int i =0; i<wdContext.nodeSFITEMLIST().size();i++) { //code for Bapimepoitem wdComponentAPI.getMessageManager().reportSuccess("21"); Bapimepoitem poitem = new Bapimepoitem(); String item_Attr =wdContext.nodeSFITEMLIST().getSFITEMLISTElementAt(i).getITEM(); if(item_Attr != null && item_Attr != "") poitem.setPo_Item(item_Attr); wdComponentAPI.getMessageManager().reportSuccess("22 " + item_Attr); poitem.setShort_Text("BROTHER PRINTER MFC 1360C"); poitem.setMaterial("PRINTER01"); poitem.setEmaterial("PRINTER01"); wdComponentAPI.getMessageManager().reportSuccess("23"); //String plant = wdContext.nodePLANT().currentPLANTElement().getVALUE(); // if(plant != null && plant != "") //poitem.setPlant(plant); poitem.setPlant("4200"); String material_Attr =wdContext.nodeMATERIALGROUP().getMATERIALGROUPElementAt(i).getVALUE(); if(material_Attr != null && material_Attr != "") poitem.setMatl_Group(material_Attr); wdComponentAPI.getMessageManager().reportSuccess("24"); poitem.setInfo_Rec("5300000002"); wdComponentAPI.getMessageManager().reportSuccess("25"); int quantity_Attr = wdContext.nodeSFITEMLIST().getSFITEMLISTElementAt(i).getQUANTITY().intV alue(); if(quantity_Attr > 0 )

BigDecimal(quantity_Attr));

poitem.setQuantity(new

wdComponentAPI.getMessageManager().reportSuccess("26 " + quantity_Attr); String units_Attr = wdContext.nodeSFITEMLIST().getSFITEMLISTElementAt(i).getUNITS(); if(units_Attr != null && units_Attr != "") { poitem.setPo_Unit(units_Attr); wdComponentAPI.getMessageManager().reportSuccess("27 " + units_Attr); poitem.setPo_Unit_Iso(units_Attr); poitem.setOrderpr_Un(units_Attr); wdComponentAPI.getMessageManager().reportSuccess("28" units_Attr); poitem.setOrderpr_Un_Iso(units_Attr); } poitem.setConv_Den1(new BigDecimal("1")); poitem.setConv_Num1(new BigDecimal("1")); poitem.setInfo_Upd("c"); poitem.setGr_Ind(true); DateFormat df2 = new SimpleDateFormat("MM/dd/yyyy"); wdComponentAPI.getMessageManager().reportSuccess("12"); Date date2 = new Date(System.currentTimeMillis()); Calendar cal1 = Calendar.getInstance(); java.sql.Date sqldate1 =new java.sql.Date(cal1.getTimeInMillis()); poitem.setPrice_Date(sqldate1); poitem.setPeriod_Ind_Expiration_Date("D"); bapiPoCreate1Input.addPoitem(poitem); wdComponentAPI.getMessageManager().reportSuccess("29"); //code for Bapimepoitemx Bapimepoitemx(); Bapimepoitemx poitemX = new +

wdComponentAPI.getMessageManager().reportSuccess("30"); String po_itemx = wdContext.nodeSFITEMLIST().getSFITEMLISTElementAt(i).getITEM();

"")

if(po_itemx != null && po_itemx != poitemX.setPo_Item(po_itemx);

wdComponentAPI.getMessageManager().reportSuccess("31 " +po_itemx); poitemX.setPo_Itemx(true); poitemX.setShort_Text(true); poitemX.setMaterial(true); poitemX.setEmaterial(true); poitemX.setPlant(true); poitemX.setMatl_Group(true); poitemX.setInfo_Rec(true); poitemX.setQuantity(true); //poitemX.setPo_Unit(true); //poitemX.setPo_Unit_Iso(true); poitemX.setOrderpr_Un(true); poitemX.setOrderpr_Un_Iso(true); poitemX.setConv_Den1(true); poitemX.setConv_Num1(true); poitemX.setPrice_Unit(true); poitemX.setGr_Ind(true); poitemX.setUntil_Date(true); wdComponentAPI.getMessageManager().reportSuccess("32"); bapiPoCreate1Input.addPoitemx(poitemX); //code for schedule new Bapimeposchedule(); Bapimeposchedule bapimeposchedule=

wdComponentAPI.getMessageManager().reportSuccess("33"); String po_items =wdContext.nodeSFITEMLIST().getSFITEMLISTElementAt(i).getITEM(); if(po_items != null && po_items != "") bapimeposchedule.setPo_Item(po_items); wdComponentAPI.getMessageManager().reportSuccess("34"); bapimeposchedule.setSched_Line("0001"); Date date3 = new Date(System.currentTimeMillis()); wdComponentAPI.getMessageManager().reportSuccess("35"); Calendar cal2 = Calendar.getInstance(); java.sql.Date sqldate2 =new java.sql.Date(cal2.getTimeInMillis()); bapimeposchedule.setDelivery_Date(sqldate2.toString());

int squantity = wdContext.nodeSFITEMLIST().getSFITEMLISTElementAt(i).getQUANTITY().intV alue(); if(squantity >0) bapimeposchedule.setQuantity(new BigDecimal(squantity)); wdComponentAPI.getMessageManager().reportSuccess("36 " + squantity); bapimeposchedule.setStat_Date(sqldate2); bapimeposchedule.setPo_Date(sqldate2); wdComponentAPI.getMessageManager().reportSuccess("36"); //int squantity = wdContext.nodeItemTable().getItemTableElementAt(i).getQuantityattr(); //if(squantity >0)

wdComponentAPI.getMessageManager().reportSuccess("37"); String delivery_date = wdContext.nodeSFITEMLIST().getSFITEMLISTElementAt(i).getDELIVERYDATE(). toString(); //if(delivery_date != null && delivery_date != "") Calendar cal3 = Calendar.getInstance(); java.sql.Date sqldate3 =new java.sql.Date(cal2.getTimeInMillis()); //bapimeposchedule.setDelivery_Date (sqldate3); bapiPoCreate1Input.addPoschedule(bapimeposchedule); wdComponentAPI.getMessageManager().reportSuccess("38"); //code for schedulex new Bapimeposchedulx(); Bapimeposchedulx bapimeposchedulx=

wdComponentAPI.getMessageManager().reportSuccess("39"); String spo_itemx = wdContext.nodeSFITEMLIST().getSFITEMLISTElementAt(i).getITEM(); if(spo_itemx != null && spo_itemx ! ="") bapimeposchedulx.setPo_Item(spo_itemx); wdComponentAPI.getMessageManager().reportSuccess("39 spo_itemx); bapimeposchedulx.setSched_Line("0001"); " +

wdComponentAPI.getMessageManager().reportSuccess("40"); bapimeposchedulx.setPo_Itemx(true); bapimeposchedulx.setDelivery_Date(true); bapimeposchedulx.setQuantity(true); bapimeposchedulx.setSched_Linex(true); bapimeposchedulx.setStat_Date(true); bapimeposchedulx.setPo_Date(true); bapiPoCreate1Input.addPoschedulex(bapimeposchedulx); } wdComponentAPI.getMessageManager().reportSuccess("41");

wdContext.currentBapi_Po_Create1_InputElement().modelObject().execute(); if(wdContext.nodeOutput1() != null) wdComponentAPI.getMessageManager().reportSuccess("PO :"+wdContext.currentOutput1Element().getExppurchaseorder()); wdComponentAPI.getMessageManager().reportSuccess("42");

Number

IContextElement contextElement = wdContext.currentContextElement(); wdComponentAPI.getMessageManager().reportSuccess("43"); IGPExecutionContext executionContext = contextElement.getExecutioncontext(); // define Output Structure wdComponentAPI.getMessageManager().reportSuccess("44"); IGPStructure output = executionContext.getOutputStructure(); try { // set output wdComponentAPI.getMessageManager().reportSuccess("45"); output.setAttributeValue("PR_NUMBER",wdContext.currentOutput1Element(). getExppurchaseorder()); // success Vector resulrState = new Vector(); resulrState.add("APPROVED"); executionContext.setResultState(resulrState.toString()); // executionContext.setResultState("APPROVED");

// wdComponentAPI.getMessageManager().reportSuccess("46"); executionContext.processingComplete(); } catch (GPInvocationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (GPEngineException e) { // TODO Auto-generated catch block e.printStackTrace(); } wdComponentAPI.getMessageManager().reportSuccess("47"); // wdContext.currentCONFORMATIONVIEWElement().setMESSAGEATTR("PurchaseRequ isition "+ wdContext.currentOutput1Element().getExppurchaseorder() + "created successfully"); wdComponentAPI.getMessageManager().reportSuccess("48"); bapiPoCreate1Input.execute(); wdComponentAPI.getMessageManager().reportSuccess("49"); wdContext.nodeOutput().invalidate(); } catch(Exception e) { e.printStackTrace(); wdComponentAPI.getMessageManager().reportException("Exception during Approve the Process-->" + e.getMessage(), true); wdComponentAPI.getMessageManager().reportException( +e.getCause(),true); ""

wdComponentAPI.getMessageManager().reportException("" + e.getMessage(),true); wdComponentAPI.getMessageManager().reportException( e.getLocalizedMessage(),true); } catch (Throwable e) { wdComponentAPI.getMessageManager().reportSuccess("40exe"); wdComponentAPI.getMessageManager().reportException("Exception during Approve the Proces-->" + e.getMessage(), true); wdComponentAPI.getMessageManager().reportException("" + e.getMessage(),true); StackTraceElement[] stackTrace = e.getStackTrace();

wdComponentAPI.getMessageManager().reportSuccess("41exe"); = 0; i < stackTrace.length; i++)

for (int i {

wdComponentAPI.getMessageManager().reportSuccess("42"); wdComponentAPI.getMessageManager().reportException("" + stackTrace[i], true); } } while(wdContext.nodeSFITEMLIST().size()<Integer.parseInt(wdContext.curr entSFSUBMITFORAPPROVELElement().getLINEITEM())) {

wdContext.nodeSFSUBMITFORAPPROVEL().addElement(wdContext.createSFSUBMIT FORAPPROVELElement()); } wdComponentAPI.getMessageManager().reportSuccess("Approved"); return true;

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

Code for Rejection


wdComponentAPI.getMessageManager().reportSuccess("Rejected"); IContextElement contextElement = wdContext.currentContextElement(); //wdComponentAPI.getMessageManager( ).reportSuccess("43"); IGPExecutionContext executionContext = contextElement.getExecutioncontext(); try{ executionContext.setResultState("REJECTED"); executionContext.processingComplete(); // wdContext.currentCONFORMATIONVIEWElement().setMESSAGEATTR("your PurchaseRequisition Application Has been Rejected By Approver"); }catch (GPInvocationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (GPEngineException e) { // TODO Auto-generated catch block e.printStackTrace(); } return true;

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Code for startworkflow


private IGPExecutionContext executionContext; private String processID; private String taskId; private byte[] getTemplate(String fileName) { FileInputStream fis = null; byte[] b = null; try { File f = new File( WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(), fileName)); fis = new FileInputStream(f); b = new byte[(int) f.length()]; fis.read(b); } catch (Exception e) {

wdComponentAPI.getMessageManager().reportException("Error occurred while reading form template.", false); e.printStackTrace(); } finally { try { if (fis != null) fis.close(); } catch (IOException e) { wdComponentAPI.getMessageManager().reportException("Application error occurred in getTemplate.", false); e.printStackTrace(); } } return b; } private boolean startWorkFlow() { try { wdComponentAPI.getMessageManager().reportSuccess("1sw"); IGPRuntimeManager rtm = GPProcessFactory.getRuntimeManager(); wdComponentAPI.getMessageManager().reportSuccess("2sw"); IUser initiator = WDClientUser.getLoggedInClientUser().getSAPUser();

wdComponentAPI.getMessageManager().reportSuccess("3sw"); IGPContextManager contextManager = GPContextFactory.getContextManager(); wdComponentAPI.getMessageManager().reportSuccess("4sw"); IGPUserContext userContext = contextManager.createUserContext(initiator,initiator.getLocale()); wdComponentAPI.getMessageManager().reportSuccess("5sw"); IGPProcess process = GPProcessFactory.getDesigntimeManager().getActiveTemplate("BD6DC9FB6A6C 11E082A700137285C4E4",userContext); wdComponentAPI.getMessageManager().reportSuccess("6sw"); IGPStructure input=GPStructureFactory.getStructure(process.getInputParameters()); wdComponentAPI.getMessageManager().reportSuccess("7sw");

input.setAttributeValue("PDF_CONTENT",wdContext.currentPDFSOURCEElement ().getPDFSOURCE()); wdComponentAPI.getMessageManager().reportSuccess("8sw");

input.setAttributeValue("LINE_ITEM_COUNT",wdContext.currentSFSUBMITFORA PPROVELElement().getLINEITEM()); String PROCESS_DESC = "Process Description"; IGPProcessRoleInstanceList roles = rtm.createProcessRoleInstanceList(); IGPProcessInstance instance = rtm.startProcess(process,"Process Name",PROCESS_DESC, initiator, roles, input,initiator);

wdContext.currentCONFORMATIONVIEWElement().setMESSAGEATTR("Purchase Requisition Submited Successfully"); } catch (Throwable e) { //logger.logT(Severity.ERROR, Category.APPLICATIONS,e.getMessage()); wdComponentAPI.getMessageManager().reportException("Exception -->" + e.getMessage(), true); StackTraceElement[] stackTrace = e.getStackTrace(); wdComponentAPI.getMessageManager().reportSuccess("10"); for (int i = 0; i < stackTrace.length; i++) {

wdComponentAPI.getMessageManager().reportException("" + stackTrace[i], true); } return false; } return true; }

Das könnte Ihnen auch gefallen