cancel
Showing results for 
Search instead for 
Did you mean: 

Blank value check in Table

Former Member
0 Kudos

Hi All,

How can I check for the Empty value in a Input table.

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

{

StrMat = wdContext.nodeItemTab().getItemTabElementAt(i).getMatlist();

}

**If I am using StrMat.length(), system is throwing the exception if the value is empty.

Regards,

Prakash

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

helo Prakash,

firstly i think instead of using DropdownByKey it would be better if u use DropdownByIndex if u have made that as a column of ur table.

now to check for a null or empty field:

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

{

if((wdContext.nodeItemTab().getItemTabElementAt(i).getMatlist()!=null))

{

.....

}

{

if wdContext.nodeItemTab().getItemTabElementAt(i).getMatlist() code throws nullpointException then there is no element in ur table ie its returning a null element.

Regards,

Piyush.

Former Member
0 Kudos

Thanks to all it get solved.

Former Member
0 Kudos

Hi,

The following should work .

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

{

String StrMat=new String();

if(wdContext.nodeItemTab().getItemTabElementAt(i).getMatlist() !=null)

StrMat = wdContext.nodeItemTab().getItemTabElementAt(i).getMatlist();

}

Regards, Anilkumar

Former Member
0 Kudos

hi ,

wdContext.nodeItemTab().size will give u the no of elements.. i.e if the table is empty or not.(Isnt this the ABAP equivalent )

If u want to check if a particular value is empty i guess u can check if it is equal to null.. instead of going for its length..

Regards

Bharathwaj

Former Member
0 Kudos

Dear Bharathwaj,

I have a Dropdonbykey field in a table, table is already assigned with 5 rows, also I had set the leadselectio(-1) for that field. Now I want to check whether the field is blank , .lenght() is giving error when it is actually blank and null is not working.

Pl. suggest..

Regards,

Prakash

Former Member
0 Kudos

Hi Bharathwaj,

wdContext.nodeItemTab().size is equivalent to

ItemTab[] IS INITIAL.

and not equivalent to

ItemTab IS INITIAL.

I wrote "Table Row is INITIAL"

I really feel the need for a method like

wdContext.nodeItemTab().getCurrentItemTabElementAt(index).isInitial()

Now this should return true or false depending on whether a particular row is at its initial state or there are some values inside some of its columns.

Please correct me if I am wrong

___________________________________________

Hi Prakash,

Please clarify what is that you want to achieve.

1) Do you want to check that a table row is all empty or at its initial state?

2) OR you want to check the value of DropDownByKey UI element is null/blank?

To check DropDownByKey is null or "" you can use

(null == wdContext.currentContextElement().getSelectedKey() || "".equals(wdContext.currentContextElement().getSelectedKey()))

Here SelectedKey is the context attribute bind to the selectedKey property of the DropDownByKey.

Now since you have the dropdown in a table you can have the code accordingly.

Hope this is helpful.

Regards,

Shubham

Former Member
0 Kudos

Hi Shubham,

It still throwing Null Pointer exception if value is blank.

null == wdContext.nodeItemTab().getItemTabElementAt(i).getMatlist() || "".equals(wdContext.nodeItemTab().getItemTabElementAt(i).getMatlist()))

Regards,

Prakash

Former Member
0 Kudos

Hi Prakash,

Can you please cut and paste the code of your complete method marking the line on which it gives the null pointer exception. It will be easier to understand.

Thanks,

Shubham

Former Member
0 Kudos

Hi Prakash,

As far as I know there is no method in WebDynpro that is equivalent to "Table Row is INITIAL" in ABAP.

So you have two option.

1) If a loop, check if all the columns in a table row are ""/null/0.

2) Pass the empty rows to R/3 via RFC and then delete the Empty rows from the Internal Table in ABAP.

Regards,

Shubham