cancel
Showing results for 
Search instead for 
Did you mean: 

Error handling in Table records

Former Member
0 Kudos

hai to everyone ,

i have one table in madatory field is there , enter records 5 records in 5 of 3 records are not entered mandatory records.

i written message for incase not entered filed.

but here problem is , It showing for each record showing message that is 3 lines are coming.

instead of 3 lines we can make in single line which are records are not given madatory fileds.

is it possible in message pool..

below is i written code .

if(TableElement.getClientName()!=null&&TableElement.getClientName()!="")
   
  	{
wdThis.wdGetTaskManagerCompController().insertClient(clientName,region,vertical);

}
else{
	wdComponentAPI.getMessageManager().reportException(TableElement.getClientName()+ ":ClientNames"+"fields are mandatory",false);  
		
	}

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Eswar..

In order to display a message only once what you can do is,

in ur else stmt where you r displaying the exception msg, you can jst set a boolean flag to true.

Outside the for loop of the table u can chck for that boolean flag and accordingly display the

error msg. U can create a separate function for such error msg dislay so that they can be called wherever

u have to make such missing input validations.

example:


{
boolean flag = false;
for(i=0;i<wdcontext.nodetable.size;i++)
{
.......
........
if(TableElement.getClientName()!=null&&TableElement.getClientName()!="")
    	{
wdThis.wdGetTaskManagerCompController().insertClient(clientName,region,vertical);
 }
else{
flag = true;
	}
........
.......
} // end of for loop

if(flag)
{
checkmandatory(wdcontext.node<table node>,Ipublic<Component name>.I<table element which is empty>,"<label u want to display>");

}
}

 public boolean checkMandatory( com.sap.tc.webdynpro.progmodel.api.IWDNode currentNode, java.lang.String attributeName, java.lang.String fieldLabel )
  {

    IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
    IWDAttributeInfo attributeInfo = currentNode.getNodeInfo().getAttribute(attributeName);
	Object attributeValue =currentNode.getCurrentElement().getAttributeValue(attributeName);

	msgMgr.reportContextAttributeMessage(currentNode.getCurrentElement(), attributeInfo,IMessageGenClmApp.MISSING_INPUT,new Object[] {fieldLabel},true);
			return true;
}	

the MISSING_INPUT here is the msg maintained in the component msg pool.

Hopefully i have answered ur question.

Regards

Asha

Former Member
0 Kudos

Yes Asha !

you are Right !

Exactly you catched my requirement.

it s great thanks to you

!

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Eswar,

As I understand from you question is that you have a table in which 5 records can be entered. Out of these 5 records 3 records are mandatory, what you want is if these 3 mandatory record are left empty then one line of exception should be raised saying 3 records are empty.

What you can do is on your action copy the mandatory fields into a new node, and find out the size of the new node (if the size is 0 that means all the records are empty) then you can iterate over the new node to find out which attribute is empty.

You may use the following code:

suppose DisplayRow is your new node with attributes as attributes1, attributes2 and attributes3 and node1 is your node with which the 5 records are maaped. ROWS_SELECTED is the message constant.

wdContext.nodeDisplayRow().invalidate();

IPrivateFlightList.IRowsSelectedElement element = wdContext.nodeRowsSelected().createRowsSelectedElement();

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

{

String str1 = wdContext.node1().getnode1ElementAt(i).getAttribute1();

String str2 = wdContext.node1().getnode1ElementAt(i).getAttribute2();

String str3 = wdContext.node1().ggetnode1ElementAt(i).getAttribute3();

if(str1 != null)

element.setAttribute1(str1);

if(str2 != null)

element.setAttribute2(str2);

if(str3 != null)

element.setAttribute3(str3);

}

wdContext.nodeRowsSelected().addElement(element);

int listSize = wdContext.nodeRowsSelected().size();

String size = String.valueOf(listSize);

IWDMessageManager msmgr = wdComponentAPI.getMessageManager();

msmgr.raiseMessage(IMessage<ComponentName>Component.ROWS_SELECTED,new Object[],true);

Edited by: Aishwarya Sharma on Oct 10, 2008 7:41 AM

Former Member
0 Kudos

Hi Eswar,

In message pooling it will show you 3 different lines of exception for 3 different records.

One work around can be that you write the exception message display inside the lead selection action.

Edited by: Aishwarya Sharma on Oct 8, 2008 2:09 PM

Former Member
0 Kudos

Thanks Sharma for giving reply,

i understand , u r are not catch exact issue.

Table is there. i entered 5 records of data.

in 3 records of data i missed the one filed.

message raised for each record each line .

i.e 3 messages are raised .

i want instead of 3 message , in single line we can show the" 3 records are miss the filed" .

Former Member
0 Kudos

Hai ,

Aishwarya, if u need clarification on any piont ask me .

if u know any blogs regarding to this tell me , i will go with that

i waiting for reply