整体的思想

在开发中要学会把方法封装,整体把握。下面是个valuehelp:


// ---------------------------------------------------------------------------
// This file has been generated partially by the Web Dynpro Code Generator.
// MODIFY CODE ONLY IN SECTIONS ENCLOSED BY @@begin AND @@end.
// ALL OTHER CHANGES WILL BE LOST IF THE FILE IS REGENERATED.
// ---------------------------------------------------------------------------
package com.jxep;

//
// IMPORTANT NOTE:
// _ALL_ IMPORT STATEMENTS MUST BE PLACED IN THE FOLLOWING SECTION ENCLOSED
// BY @@begin imports AND @@end. FURTHERMORE, THIS SECTION MUST ALWAYS CONTAIN
// AT LEAST ONE IMPORT STATEMENT (E.G. THAT FOR IPrivateCtr_I02_M01).
// OTHERWISE, USING THE ECLIPSE FUNCTION "Organize Imports" FOLLOWED BY
// A WEB DYNPRO CODE GENERATION (E.G. PROJECT BUILD) WILL RESULT IN THE LOSS
// OF IMPORT STATEMENTS.
//
//@@begin imports
import java.util.List;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;

import com.jxep.models.Zjxeppm_I02_M01_Input;
import com.jxep.utils.Reporter;
import com.jxep.utils.StringUtils;
import com.jxep.wdp.IPrivateCtr_I02_M01;
import com.jxep.wdp.IPublicCtr_I02_M01.ICostcenter_ListElement;
import com.jxep.wdp.IPublicCtr_I02_M01.ICostcenter_ListNode;
import com.jxep.wdp.IPublicCtr_I02_M01.IOrdtype_ListElement;
import com.jxep.wdp.IPublicCtr_I02_M01.IOrdtype_ListNode;
import com.jxep.wdp.IPublicCtr_I02_M01.IPernr_InputElement;
import com.jxep.wdp.IPublicCtr_I02_M01.IPernr_ListElement;
import com.jxep.wdp.IPublicCtr_I02_M01.IPernr_ListNode;
import com.jxep.wdp.IPublicCtr_I02_M01.IPernr_OutputElement;
import com.jxep.wdp.IPublicCtr_I02_M01.IPernr_OutputNode;
import com.jxep.wdp.IPublicCtr_I02_M01.IPlangrp_ListElement;
import com.jxep.wdp.IPublicCtr_I02_M01.IPlangrp_ListNode;
import com.jxep.wdp.IPublicCtr_I02_M01.IPlant_InputElement;
import com.jxep.wdp.IPublicCtr_I02_M01.IPlant_ListElement;
import com.jxep.wdp.IPublicCtr_I02_M01.IPlant_ListNode;
import com.jxep.wdp.IPublicCtr_I02_M01.IPlant_OutputElement;
import com.jxep.wdp.IPublicCtr_I02_M01.IPlant_OutputNode;
import com.jxep.wdp.IPublicCtr_I02_M01.IPmacti_ListElement;
import com.jxep.wdp.IPublicCtr_I02_M01.IPmacti_ListNode;
import com.jxep.wdp.IPublicCtr_I02_M01.IWork_Center_InputElement;
import com.jxep.wdp.IPublicCtr_I02_M01.IWork_Center_ListElement;
import com.jxep.wdp.IPublicCtr_I02_M01.IWork_Center_ListNode;
import com.jxep.wdp.IPublicCtr_I02_M01.IWork_Center_OutputElement;
import com.jxep.wdp.IPublicCtr_I02_M01.IWork_Center_OutputNode;
import com.sap.tc.webdynpro.modelimpl.dynamicrfc.WDDynamicRFCExecuteException;
import com.sap.tc.webdynpro.progmodel.api.IWDNode;
import com.sap.tc.webdynpro.progmodel.api.IWDNodeElement;
import com.sap.tc.webdynpro.progmodel.api.IWDOVSContextNotificationListener;
import com.sap.tc.webdynpro.progmodel.api.WDCopyService;
import com.sap.tc.webdynpro.progmodel.api.WDValueServices;
//@@end

//@@begin documentation
//@@end

public class Ctr_I02_M01
{
/**
* Logging location.
*/
private static final com.sap.tc.logging.Location logger =
com.sap.tc.logging.Location.getLocation(Ctr_I02_M01.class);

static
{
//@@begin id
String id = "$Id$";
//@@end
com.sap.tc.logging.Location.getLocation("ID.com.sap.tc.webdynpro").infoT(id);
}

/**
* Private access to the generated Web Dynpro counterpart
* for this controller class. </p>
*
* Use <code>wdThis</code> to gain typed access to the context,
* to trigger navigation via outbound plugs, to get and enable/disable
* actions, fire declared events, and access used controllers and/or
* component usages.
*
* @see com.jxep.wdp.IPrivateCtr_I02_M01 for more details
*/
private final IPrivateCtr_I02_M01 wdThis;

/**
* Root node of this controller's context. </p>
*
* Provides typed access not only to the elements of the root node
* but also to all nodes in the context (methods node<i>XYZ</i>())
* and their currently selected element (methods current<i>XYZ</i>Element()).
* It also facilitates the creation of new elements for all nodes
* (methods create<i>XYZ</i>Element()). </p>
*
* @see com.jxep.wdp.IPrivateCtr_I02_M01.IContextNode for more details.
*/
private final IPrivateCtr_I02_M01.IContextNode wdContext;

/**
* A shortcut for <code>wdThis.wdGetAPI()</code>. </p>
*
* Represents the generic API of the generic Web Dynpro counterpart
* for this controller. </p>
*/
private final com.sap.tc.webdynpro.progmodel.api.IWDController wdControllerAPI;

/**
* A shortcut for <code>wdThis.wdGetAPI().getComponent()</code>. </p>
*
* Represents the generic API of the Web Dynpro component this controller
* belongs to. Can be used to access the message manager, the window manager,
* to add/remove event handlers and so on. </p>
*/
private final com.sap.tc.webdynpro.progmodel.api.IWDComponent wdComponentAPI;

public Ctr_I02_M01(IPrivateCtr_I02_M01 wdThis)
{
this.wdThis = wdThis;
this.wdContext = wdThis.wdGetContext();
this.wdControllerAPI = wdThis.wdGetAPI();
this.wdComponentAPI = wdThis.wdGetAPI().getComponent();
}

//@@begin javadoc:wdDoInit()
/** Hook method called to initialize controller. */
//@@end
public void wdDoInit()
{
//@@begin wdDoInit()
reporter = new Reporter(wdComponentAPI);
getI02_M01();
//@@end
}

//@@begin javadoc:wdDoExit()
/** Hook method called to clean up controller. */
//@@end
public void wdDoExit()
{
//@@begin wdDoExit()
//@@end
}

//@@begin javadoc:addPernrOVSExtension()
/** Declared method. */
//@@end
public void addPernrOVSExtension( com.sap.tc.webdynpro.progmodel.api.IWDAttributeInfo[] infos, java.lang.String[] paramNames )
{
//@@begin addPernrOVSExtension()
WDValueServices.addOVSExtension(
"Pernr Selection",
infos,
(IWDNode) wdContext.nodePernr_Input(),
(IWDNode) wdContext.nodePernr_Output(),
getPernrOVSListener(paramNames));
//@@end
}

//@@begin javadoc:addPlantOVSExtension()
/** Declared method. */
//@@end
public void addPlantOVSExtension( com.sap.tc.webdynpro.progmodel.api.IWDAttributeInfo[] infos, java.lang.String[] paramNames )
{
//@@begin addPlantOVSExtension()
WDValueServices.addOVSExtension(
"Plant Selection",
infos,
(IWDNode) wdContext.nodePlant_Input(),
(IWDNode) wdContext.nodePlant_Output(),
getPlantOVSListener(paramNames));
//@@end
}

//@@begin javadoc:addWcOVSExtension()
/** Declared method. */
//@@end
public void addWcOVSExtension( com.sap.tc.webdynpro.progmodel.api.IWDAttributeInfo[] infos, java.lang.String[] paramNames )
{
//@@begin addWcOVSExtension()
WDValueServices.addOVSExtension(
"Work Center Selection",
infos,
(IWDNode) wdContext.nodeWork_Center_Input(),
(IWDNode) wdContext.nodeWork_Center_Output(),
getWcOVSListener(paramNames));
//@@end
}

//@@begin javadoc:getCostcener()
/** Declared method. */
//@@end
public java.lang.String getCostcener( java.lang.String key )
{
//@@begin getCostcener()
if (key != null) {
return StringUtils.null2Empty(this.costcenterIndex.get(key));
} else {
return "";
}
//@@end
}

//@@begin javadoc:getI02_M01()
/** Declared method. */
//@@end
public void getI02_M01( )
{
//@@begin getI02_M01()
try {
Zjxeppm_I02_M01_Input input = new Zjxeppm_I02_M01_Input();

input.setUname(StringUtils.getLoggedUser());
//input.setUname("P00181901");
input.execute();
wdContext.nodeZjxeppm_I02_M01_Output().bind(input.getOutput());
IPernr_ListNode nodePernr = wdContext.nodePernr_List();
for (int i = 0; i < nodePernr.size(); i++) {
IPernr_ListElement element = nodePernr.getPernr_ListElementAt(i);
pernrIndex.put(StringUtils.null2Empty(element.getPernr()),
StringUtils.null2Empty(element.getPname()));
}
IPlant_ListNode nodePlant = wdContext.nodePlant_List();
for (int i = 0; i < nodePlant.size(); i++) {
IPlant_ListElement element = nodePlant.getPlant_ListElementAt(i);
plantIndex.put(StringUtils.null2Empty(element.getWerks()),
StringUtils.null2Empty( element.getName1()));
}
IWork_Center_ListNode nodeWc = wdContext.nodeWork_Center_List();
for (int i = 0; i < nodeWc.size(); i++) {
IWork_Center_ListElement element = nodeWc.getWork_Center_ListElementAt(i);
wcIndex.put(StringUtils.null2Empty(element.getArbpl()),
StringUtils.null2Empty( element.getKtext()));
}

IOrdtype_ListNode nodeOrd = wdContext.nodeOrdtype_List();
for (int i = 0; i < nodeOrd.size(); i++) {
IOrdtype_ListElement element = nodeOrd.getOrdtype_ListElementAt(i);
ordtypeIndex.put(StringUtils.null2Empty(element.getAuart()),
StringUtils.null2Empty( element.getTxt()));
//ordtypeIndex.put(element.getAuart(), element.getTxt());
}
//reporter.info(String.valueOf(nodeOrd.size()));
//reporter.info(String.valueOf(ordtypeIndex.size()));
ICostcenter_ListNode nodeCostCenter = wdContext.nodeCostcenter_List();
for (int i = 0; i < nodeCostCenter.size(); i++) {
ICostcenter_ListElement element =
nodeCostCenter.getCostcenter_ListElementAt(i);
costcenterIndex.put(StringUtils.null2Empty(element.getKostl()),
StringUtils.null2Empty( element.getKtext()));
}
IPlangrp_ListNode nodePlangrp = wdContext.nodePlangrp_List();
for (int i = 0; i < nodePlangrp.size(); i++) {
IPlangrp_ListElement element = nodePlangrp.getPlangrp_ListElementAt(i);
plangrpIndex.put(
StringUtils.null2Empty( element.getIwerk() )
+ StringUtils.null2Empty( element.getIngrp() ),
StringUtils.null2Empty(element.getInnam()) );
}
IPmacti_ListNode nodePmacti = wdContext.nodePmacti_List();
for (int i = 0; i < nodePmacti.size(); i++) {
IPmacti_ListElement element = nodePmacti.getPmacti_ListElementAt(i);
pmactiIndex.put(
StringUtils.null2Empty( element.getAuart() )
+ StringUtils.null2Empty( element.getIlart() ),
StringUtils.null2Empty(element.getIlatx()) );
}

} catch (WDDynamicRFCExecuteException e) {
reporter.error("Exception:get I02_M01 info|" + e.getMessage());
}
//@@end
}

//@@begin javadoc:getOrdType()
/** Declared method. */
//@@end
public java.lang.String getOrdType( java.lang.String key )
{
//@@begin getOrdType()
if (key != null) {
return StringUtils.null2Empty(this.ordtypeIndex.get(key));
} else {
return "";
}
//@@end
}

//@@begin javadoc:getPernrDesc()
/** Declared method. */
//@@end
public java.lang.String getPernrDesc( java.lang.String key )
{
//@@begin getPernrDesc()
return getDesc(key, 'P');
//@@end
}

//@@begin javadoc:getPlangrp()
/** Declared method. */
//@@end
public java.lang.String getPlangrp( java.lang.String key )
{
//@@begin getPlangrp()
if (key != null) {
return StringUtils.null2Empty(this.plangrpIndex.get(key));
} else {
return "";
}
//@@end
}

//@@begin javadoc:getPlantDesc()
/** Declared method. */
//@@end
public java.lang.String getPlantDesc( java.lang.String key )
{
//@@begin getPlantDesc()
return getDesc(key, 'F');
//@@end
}

//@@begin javadoc:getPmacti()
/** Declared method. */
//@@end
public java.lang.String getPmacti( java.lang.String key )
{
//@@begin getPmacti()
if (key != null) {
return StringUtils.null2Empty(this.pmactiIndex.get(key));
} else {
return "";
}
//@@end
}

//@@begin javadoc:getWcDesc()
/** Declared method. */
//@@end
public java.lang.String getWcDesc( java.lang.String key )
{
//@@begin getWcDesc()
return getDesc(key, 'W');
//@@end
}

/*
* The following code section can be used for any Java code that is
* not to be visible to other controllers/views or that contains constructs
* currently not supported directly by Web Dynpro (such as inner classes or
* member variables etc.). </p>
*
* Note: The content of this section is in no way managed/controlled
* by the Web Dynpro Designtime or the Web Dynpro Runtime.
*/
//@@begin others
private Reporter reporter = null;
private Hashtable pernrIndex = new Hashtable();
private Hashtable plantIndex = new Hashtable();
private Hashtable wcIndex = new Hashtable();

private Hashtable ordtypeIndex = new Hashtable();
private Hashtable plangrpIndex = new Hashtable();
private Hashtable pmactiIndex = new Hashtable();
private Hashtable costcenterIndex = new Hashtable();

private String getDesc(String key, char type) {
String ret = key;
Object obj = null;
if (key != null && key.length() > 0) {
switch (type) {
case 'P' :
obj = this.pernrIndex.get(key);
break;
case 'F' :
obj = this.plantIndex.get(key);
break;
case 'W' :
obj = this.wcIndex.get(key);
break;
default :
break;
}
}
if (obj != null)
ret = obj.toString();
return ret;
}
private com.sap.tc.webdynpro.progmodel.api.IWDOVSContextNotificationListener getPernrOVSListener(String[] paramNames) {
List pernrLst = new ArrayList();
IPernr_ListNode node = wdContext.nodePernr_List();
for (int i = 0; i < node.size(); i++) {
IPernr_OutputElement item =
wdContext
.nodePernr_Output()
.createPernr_OutputElement();

IPernr_ListElement el = node.getPernr_ListElementAt(i);
WDCopyService.copyCorresponding(el, item);
pernrLst.add(item);
}
return new PernrOVSListener(pernrLst, paramNames);
}
private com.sap.tc.webdynpro.progmodel.api.IWDOVSContextNotificationListener getPlantOVSListener(String[] paramNames) {
List list = new ArrayList();
IPlant_ListNode node = wdContext.nodePlant_List();
for (int i = 0; i < node.size(); i++) {
IPlant_OutputElement element = wdContext.nodePlant_Output().createPlant_OutputElement();
IPlant_ListElement el = node.getPlant_ListElementAt(i);
WDCopyService.copyCorresponding(el, element);
list.add(element);
}
return new PlantOVSListener(list, paramNames);
}
private com.sap.tc.webdynpro.progmodel.api.IWDOVSContextNotificationListener getWcOVSListener(String[] paramNames) {
List list = new ArrayList();
IWork_Center_ListNode node = wdContext.nodeWork_Center_List();
for (int i = 0; i < node.size(); i++) {
IWork_Center_OutputElement element = wdContext.nodeWork_Center_Output().createWork_Center_OutputElement();
IWork_Center_ListElement el = node.getWork_Center_ListElementAt(i);
WDCopyService.copyCorresponding(el, element);
list.add(element);
}
return new WcOVSListener(list, paramNames);
}

private class PernrOVSListener implements IWDOVSContextNotificationListener {
/* @see com.sap.tc.webdynpro.progmodel.api
* .IWDOVSContextNotificationListener#onQuery(...) */
private List pernrLst = null;
private String[] paramNames = null;
public PernrOVSListener(List pernrLst, String[] paramNames){
this.pernrLst = pernrLst;
this.paramNames = paramNames;
}
public void onQuery(
IWDNodeElement queryInputNodeElement,
IWDNode queryOutputNode) {
IPernr_InputElement input =
(
IPernr_InputElement) queryInputNodeElement;
IPernr_OutputNode ovsOutput =
(IPernr_OutputNode) queryOutputNode;
ovsOutput.invalidate();
// String btrtl = StringUtils.format(input.getBtrtl());
String pernr = StringUtils.format(input.getPernr());
// String kostl = StringUtils.format(input.getKostl());
String pname = StringUtils.format(input.getPname());
for (Iterator iter = pernrLst.iterator(); iter.hasNext();) {
IPernr_OutputElement element =
(IPernr_OutputElement) iter.next();
if (element.getPernr().matches(pernr)
// && element.getBtrtl().matches(btrtl)
// && element.getKostl().matches(kostl)
&& element.getPname().matches(pname)) {
ovsOutput.addElement(element);
}
}
}
/* @see com.sap.tc.webdynpro.progmodel.api
* .IWDOVSContextNotificationListener#applyResult(...)*/
public void applyResult(
IWDNodeElement applicationNodeElement,
IWDNodeElement queryOutputNodeElement) {
IPernr_OutputElement output =
(IPernr_OutputElement) queryOutputNodeElement;

try {
applicationNodeElement
.getClass()
.getMethod("set" + paramNames[0], new Class[] { String.class })
.invoke(
applicationNodeElement,
new Object[] { output.getPernr()});
} catch (Exception e) {
reporter.alert(e.getMessage());
}
if (paramNames.length > 1) {
try {
applicationNodeElement
.getClass()
.getMethod(
"set" + paramNames[1],
new Class[] { String.class })
.invoke(
applicationNodeElement,
new Object[] { output.getPname()});
} catch (Exception e) {
reporter.alert(e.getMessage());
}
}
}
/* @see com.sap.tc.webdynpro.progmodel.api
* .IWDOVSContextNotificationListener#applyInputValues(...) */
public void applyInputValues(
IWDNodeElement applicationNodeElement,
IWDNodeElement queryInputNodeElement) {
IPernr_InputElement input = (IPernr_InputElement) queryInputNodeElement;
Object pernr = null;
try {
pernr =
applicationNodeElement
.getClass()
.getMethod("get" + paramNames[0], new Class[] {
}).invoke(applicationNodeElement, new Object[] {
});
} catch (Exception e) {
reporter.alert(e.getMessage());
}
if (pernr != null) {
input.setPernr(pernr.toString());
}
}
}

private class PlantOVSListener implements IWDOVSContextNotificationListener {
/* @see com.sap.tc.webdynpro.progmodel.api
* .IWDOVSContextNotificationListener#onQuery(...) */
private List plantLst = null;
private String[] paramNames = null;
public PlantOVSListener(List plantLst, String[] paramNames){
this.plantLst = plantLst;
this.paramNames = paramNames;
}
public void onQuery(
IWDNodeElement queryInputNodeElement,
IWDNode queryOutputNode) {
IPlant_InputElement input =
(
IPlant_InputElement) queryInputNodeElement;
IPlant_OutputNode ovsOutput =
(IPlant_OutputNode) queryOutputNode;
ovsOutput.invalidate();

String plant = StringUtils.format(input.getWerks());
String pname = StringUtils.format(input.getName1());
for (Iterator iter = plantLst.iterator(); iter.hasNext();) {
IPlant_OutputElement element =
(IPlant_OutputElement) iter.next();
if (element.getWerks().matches(plant)
&& element.getName1().matches(pname)) {
ovsOutput.addElement(element);
}
}
}
/* @see com.sap.tc.webdynpro.progmodel.api
* .IWDOVSContextNotificationListener#applyResult(...)*/
public void applyResult(
IWDNodeElement applicationNodeElement,
IWDNodeElement queryOutputNodeElement) {
IPlant_OutputElement output =
(IPlant_OutputElement) queryOutputNodeElement;

try {
applicationNodeElement
.getClass()
.getMethod("set" + paramNames[0], new Class[] { String.class })
.invoke(
applicationNodeElement,
new Object[] { output.getWerks()});
} catch (Exception e) {
reporter.alert(e.getMessage());
}
}
/* @see com.sap.tc.webdynpro.progmodel.api
* .IWDOVSContextNotificationListener#applyInputValues(...) */
public void applyInputValues(
IWDNodeElement applicationNodeElement,
IWDNodeElement queryInputNodeElement) {
IPlant_InputElement input = (IPlant_InputElement) queryInputNodeElement;
Object plant = null;
try {
plant =
applicationNodeElement
.getClass()
.getMethod("get" + paramNames[0], new Class[] {
}).invoke(applicationNodeElement, new Object[] {
});
} catch (Exception e) {
reporter.alert(e.getMessage());
}
if (plant != null) {
input.setWerks(plant.toString());
}

}
}

private class WcOVSListener implements IWDOVSContextNotificationListener {
/* @see com.sap.tc.webdynpro.progmodel.api
* .IWDOVSContextNotificationListener#onQuery(...) */
private List wcLst = null;
private String[] paramNames = null;
public WcOVSListener(List wcLst, String[] paramNames){
this.wcLst = wcLst;
this.paramNames = paramNames;
}
public void onQuery(
IWDNodeElement queryInputNodeElement,
IWDNode queryOutputNode) {
IWork_Center_InputElement input =
(
IWork_Center_InputElement) queryInputNodeElement;
IWork_Center_OutputNode ovsOutput =
(IWork_Center_OutputNode) queryOutputNode;
ovsOutput.invalidate();
String ktext = StringUtils.format(input.getKtext());
String arbpl = StringUtils.format(input.getArbpl());
String objid = StringUtils.format(input.getObjid());
String werks = StringUtils.format(input.getWerks());
for (Iterator iter = wcLst.iterator(); iter.hasNext();) {
IWork_Center_OutputElement element =
(IWork_Center_OutputElement) iter.next();
if (element.getArbpl().matches(arbpl)
&& element.getKtext().matches(ktext)
&& element.getObjid().matches(objid)
&& element.getWerks().matches(werks)) {
ovsOutput.addElement(element);
}
}
}
/* @see com.sap.tc.webdynpro.progmodel.api
* .IWDOVSContextNotificationListener#applyResult(...)*/
public void applyResult(
IWDNodeElement applicationNodeElement,
IWDNodeElement queryOutputNodeElement) {
IWork_Center_OutputElement output =
(IWork_Center_OutputElement) queryOutputNodeElement;

try {
applicationNodeElement
.getClass()
.getMethod("set" + paramNames[0], new Class[] { String.class })
.invoke(
applicationNodeElement,
new Object[] { output.getArbpl()});
} catch (Exception e) {
reporter.alert(e.getMessage());
}
}
/* @see com.sap.tc.webdynpro.progmodel.api
* .IWDOVSContextNotificationListener#applyInputValues(...) */
public void applyInputValues(
IWDNodeElement applicationNodeElement,
IWDNodeElement queryInputNodeElement) {
IWork_Center_InputElement input = (IWork_Center_InputElement) queryInputNodeElement;
Object pernr = null;
try {
pernr =
applicationNodeElement
.getClass()
.getMethod("get" + paramNames[0], new Class[] {
}).invoke(applicationNodeElement, new Object[] {
});
} catch (Exception e) {
reporter.alert(e.getMessage());
}
if (pernr != null) {
input.setArbpl(pernr.toString());
}

}
}
//@@end
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值