cancel
Showing results for 
Search instead for 
Did you mean: 

ESS: LOC_FROM and LOC_TO as required fields in VcTreMileageTable DC

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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.

Former Member
0 Kudos

thanks for your answer.

Where do you recall this method?

VcTreMileageTable create dinamically more rows... Do your method work in this case?

Former Member
0 Kudos

Hi Damiano,

Where do you recall this method?

I have created these methods in the view of the DC under the "methods" tab and then wrote the code that I have given you within the methods.

Let me know if you have any issues.

I hope this helps you.

Regards,

Gopal.

Former Member
0 Kudos

This is in creation but... where do you inserted the call to your method?

for example:

...
String location = wdContext.currentXXXElement().getLoc_FROM();
checkNoFirstDestination( str );
...

damiano

Former Member
0 Kudos

I tested your solution bat I have more rows with more locations... so I can not use your methods.

damiano

Former Member
0 Kudos

Hi Damiano,

I tested your solution bat I have more rows with more locations... so I can not use your methods

If you do the Field validation for the fields in "VcTreGeneralData" DC, then it applies to all the rows as a general rule. I have had similar requirement and it is working for me.

I hope this helps. Let me know if you have any issues.

Regards,

Gopal.

Former Member
0 Kudos

Hi Damiano,

I have inserted the call to my method in the "onActionNextStep" method. Look at the following code. I hope this helps you.


public void onActionNextStep(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionNextStep(ServerEvent)
    
    LOGGER.traceEnter("onActionNextStep");
	wdThis.wdGetFcTraUtilsInterface().viewValidation(wdControllerAPI).validate(true);
                this.checkNoFirstDestination("Location");
                wdComponentAPI.getMessageManager().raisePendingException();
	this.checkNoReasonForTrip("Customer");
                wdComponentAPI.getMessageManager().raisePendingException();
    wdComponentController.raiseFPMEvent(TravelConstants.EVENT_NAVIGATE_NEXT);
    
    LOGGER.traceExit("onActionNextStep");
    //@@end
  }

Let me know if you have any issues.

Regards,

Gopal.

Former Member
0 Kudos

Hi Gopal,

If you do the Field validation for the fields in "VcTreGeneralData" DC, then it applies to all the rows as a general rule. I have had similar requirement and it is working for me.

This is true for LOC_TO field but in "VcTreGeneralData" DC I don't have the LOC_FROM field... so I can not set it as mandatory.

have you an other solution for my problem?

thanks

Damiano

Edited by: Damiano Callegari on Mar 19, 2009 9:44 AM

Former Member
0 Kudos

Hi Damiano,

I might not be able to give you the exact solution. But, I can advise you little bit.

Just write a logic for finding out the number of rows in the table by the time the user clicks on the "Accept Button" in the MileageDetails table and put an "IF" condition by enclosing my code within it. But, again it all depends on how you write your Logic. Sorry, I might not be able to help you anymore.

All the Best,

Gopal.

Former Member
0 Kudos

hello Damiano!

i had a similar problem and i solved whit this:

i hope this can help u

Answers (1)

Answers (1)

former_member185086
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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