Skip to Content
avatar image
Former Member

ESS: LOC_FROM and LOC_TO as required fields in VcTreMileageTable DC

Hello,

I was trying make LOC_FROM and LOC_TO as required fields in VcTreMileageTable DC (package ess/tre/tre), but I didn't be successful.

I inserted this code in wdDoModifyView method:

IFieldControlNode nodeFieldControl = 
		(IFieldControlNode) wdThis.wdGetCustomizeController().getFieldControl();
		
for (int i = 0; i < nodeFieldControl.size(); i++)
{
	IFieldControlElement element = nodeFieldControl.getFieldControlElementAt(i);
						  
	if (element.getFieldname().equals("LOC_FROM") || element.getFieldname().equals("LOC_TO"))
		element.setRequired(true);
}

and in CustomController I had set:

startLocationField.setState(WDState.REQUIRED);
endLocationField.setState(WDState.REQUIRED);

but they didn't work.

If anyone have any input on this highly appreciated.

Thanks,

Damiano

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Mar 18, 2009 at 02:09 PM

    Hi Damiano,

    We have done this requirement recently. I have used the following code for making the two fields mandatory. Have a look and let me know if you have any other issues.

    public void checkNoFirstDestination( java.lang.String Location )
      {
        //@@begin checkNoFirstDestination()
        try{
    		IWDMessageManager msgMan = wdComponentAPI.getMessageManager();
    		String value = wdContext.nodeGeneralData().currentGeneralDataElement().getLocation();
    	
    		IWDAttributeInfo valueAttr = wdContext.nodeGeneralData().getNodeInfo().getAttribute(Location);
    	
    		if(value.length()==0){
    			msgMan.reportContextAttributeMessage(wdContext.currentGeneralDataElement(), valueAttr,
    			IMessageVcTreGeneralData.NO_FIRST_DESTINATION , new Object[] {Location}, true);
    		}
        }
        catch(NullPointerException e){
    		IWDMessageManager msgMan = wdComponentAPI.getMessageManager();
    		msgMan.reportMessage(IMessageVcTreGeneralData.REQUIRED_FIELDS, new Object[] {Location}, true);
        }
        //@@end
      }
    
      //@@begin javadoc:checkNoReasonForTrip()
      /** Declared method. */
      //@@end
      public void checkNoReasonForTrip( java.lang.String Customer )
      {
        //@@begin checkNoReasonForTrip()
        try{
    		IWDMessageManager msgMan = wdComponentAPI.getMessageManager();
    		String value = wdContext.nodeGeneralData().currentGeneralDataElement().getCustomer();
    	
    		IWDAttributeInfo valueAttr = wdContext.nodeGeneralData().getNodeInfo().getAttribute(Customer);
    			
    		if(value.length()==0){
    			msgMan.reportContextAttributeMessage(wdContext.currentGeneralDataElement(), valueAttr,
    			IMessageVcTreGeneralData.NO_REASON_FOR_TRIP , new Object[] {Customer}, true);
    		}
        }
        catch(NullPointerException e){
    		IWDMessageManager msgMan = wdComponentAPI.getMessageManager();
    		msgMan.reportMessage(IMessageVcTreGeneralData.REQUIRED_FIELDS, new Object[] {Customer}, true);
        }
        //@@end
      }
    
    

    I hope this helps. Rewar d point s if helped...

    Regards,

    Gopal.

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 18, 2009 at 01:38 PM

    Hi

    1.getFieldControl(); is this one method in CompCont which return type is integer?

    2. and getFieldControl() also contain information about "LOC_FROM and LOC_TO what i mean is these are the field are processed in this method ?

    provide the explanations

    Best Regards

    Satish Kumar

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      FieldControl is a node context of the Customize Custom Controller.

      infact I had imported:

      import com.sap.xss.tra.tre.vc.mileage.table.wdp.IPublicCustomize.IFieldControlElement;
      import com.sap.xss.tra.tre.vc.mileage.table.wdp.IPublicCustomize.IFieldControlNode;

      in TableView iView code.

      so...

      getFieldControl() returns the FieldControl node in Customize Custom Controller. I used nodeFieldControl as name of this variable.

      This node contains more elements...

      IFieldControlElement element = nodeFieldControl.getFieldControlElementAt(i);

      A element contains more attributes. One of these is "Fieldname" that contain a string, also "LOC_FROM" and "LOC_TO".

      LOC_FROM is the departure place, LOC_TO is the destination place.

      I had processed it in wdDoModifyView because I would like these fields required in TableView iView.

      Damiano