cancel
Showing results for 
Search instead for 
Did you mean: 

How to change 2nd row field in WebDynpro

Former Member
0 Kudos

Dear All,

When Bapi have create a table ,example as (part field):

name


age


Paper_Receipt

Anne -


20 -


1

Andy -


22 -


0

now, WebDnypro call this Bapi and display this table in portal

as this rule :

1. if paper_Receipt is "1" then display "Y"

2. if paper_Receipt is "0" then display "N"

Result :

name


age


Paper_Receipt

Anne -


20 -


Y

Andy -


22 -


N

I want come out this funtion ,but have can't transfer the 2nd record , can't turn 0 to N

there are my code (part)

public void onPlugMain_In_Detail

{

int rowsize_ER;

rowsize_ER = wdContext.nodeZtrip_Receipt().size();

if (rowsize_ER > 0)

{

if (Integer.parseInt(wdContext.currentZtrip_ReceiptElement().getPaper_Receipt().toString()) == 1)

wdContext.currentContextElement().setAtt_ment("Y");

if (Integer.parseInt(wdContext.currentZtrip_ReceiptElement().getPaper_Receipt().toString()) == 0)

wdContext.currentContextElement().setAtt_ment("N");

}

}

and the value of table field Paper_Receipt I set is Att_ment

but the result is

name


age


Paper_Receipt

Anne -


20 -


Y

Andy -


22 -


Y

can you help me how to change can succee?

Accepted Solutions (1)

Accepted Solutions (1)

former_member197348
Active Contributor
0 Kudos

Hi Doke,

Try out this code:

Create a child node Attach in node Ztrip_Receipt

Set node properties cardinality 1..1

singleton false

in the node Attach create an attribute att_ment.

Like this you can create any number of elements in he node that you want to show in the table.

public void onPlugMain_In_Detail()

{
int rowsize_ER = wdContext.nodeZtrip_Receipt().size();
for(int i=0;i< rowsize_ER; i++)
{

if (Integer.parseInt(wdContext.nodeZtrip_Receipt().getZtrip_ReceiptElementAt(i).getPaper_Receipt().toString()) == 1)
wdContext.nodeZtrip_Receipt().getZtrip_ReceiptElementAt(i).nodeAttach().currentAttachElement().setAtt_ment("Y");

else
if (Integer.parseIntwdContext.nodeZtrip_Receipt().getZtrip_ReceiptElementAt(i).getPaper_Receipt().toString()) == 0)
wdContext.nodeZtrip_Receipt().getZtrip_ReceiptElementAt(i).nodeAttach().currentAttachElement().setAtt_ment("N");

}

}

Regards

Siva

Former Member
0 Kudos

Dear Siva,

I feel you method is right, I do some operation according to

your said,

but there have a error with redline under the node nodeAttach() in code ,and error message is

" the method nodeAttach is underfind for the type IPrivateTrip_Detail.IztripZtrip_ReceiptElement "

you can see these pices

http://www.anydesign.cn/UpFile/UpAttachment/2008-9/200894113059.gif

http://www.anydesign.cn/UpFile/UpAttachment/2008-9/200894113048.gif

can you give me some way ?

thanks!

former_member197348
Active Contributor
0 Kudos

Hi Doke,

We are almost at the solution. Just try with these changes.

Please create a value node (Attach) instead of model node.

i.e. Delete the model node Attach and create a value node with cardinality 1...1

singleton false

Rebuild then all the errors disappear.

Regards,

Siva

Answers (4)

Answers (4)

Former Member
0 Kudos

Thank you very much!

sureshmandalapu6
Active Contributor
0 Kudos

Hi Doke,

Then it must the problem with loop. Keep the code seperated by each and every brace and check it.

See the below code

int rowsize_ER;

rowsize_ER = wdContext.nodeZtrip_Receipt().size();

for (int i = 0;i<rowsize_ER ;i++)

{

if (Integer.parseInt(wdContext.currentZtrip_ReceiptElement().getPaper_Receipt().toString()) == 1)

{

wdContext.currentContextElement().setAtt_ment("Y");

}

else

{

wdContext.currentContextElement().setAtt_ment("N");

}

}

This will help u

Thanks

Suresh

Former Member
0 Kudos

Dear Suresh.

after I use you code , the result is error , i find the " i "can't use

table result :

Anne -


20 -


Y

Andy -


22 -


Y

I want table result is :

Anne -


20 -


Y

Andy -


22 -


N

because the dada from BAPI is

Anne -


20 -


1

Andy -


22 -


0

can you know my idea? I feel the code have some error on

deal with the 3st col .

Thanks!

Former Member
0 Kudos

Hi,

Do you have the model node directly bound as the data source of the table UI element? What is your context structure? If you are using this code


wdContext.currentContextElement().setAtt_ment("Y")

then all the rows in the Paper_Receipt column will have "Y" (basically they'll all have the same value), because the root node has cardinality 1...1, but for table you need a node of cardinality 0...n or 1...n.

Regards,

Satyajit.

sureshmandalapu6
Active Contributor
0 Kudos

Hi Doke,

The below code

public void onPlugMain_In_Detail

{

int rowsize_ER;

rowsize_ER = wdContext.nodeZtrip_Receipt().size();

if (rowsize_ER > 0)

{

if (Integer.parseInt(wdContext.currentZtrip_ReceiptElement().getPaper_Receipt().toString()) == 1)

wdContext.currentContextElement().setAtt_ment("Y");

if (Integer.parseInt(wdContext.currentZtrip_ReceiptElement().getPaper_Receipt().toString()) == 0)

wdContext.currentContextElement().setAtt_ment("N");

}

}

Are you using any loops and putting the above code in loop ? If so , why don't you use the else instead of two "if()" conditions.

public void onPlugMain_In_Detail

{

int rowsize_ER;

rowsize_ER = wdContext.nodeZtrip_Receipt().size();

if (rowsize_ER > 0)

{

if (Integer.parseInt(wdContext.currentZtrip_ReceiptElement().getPaper_Receipt().toString()) == 1)

wdContext.currentContextElement().setAtt_ment("Y");

else

{

wdContext.currentContextElement().setAtt_ment("N");

}

}

}

try this

thanks

Suresh

Former Member
0 Kudos

Dear Suresh,

I can change if -


> if .....else......

but this can't change the result.

can you said to me how to transfer the 2nd record.use loop method.?

for (int i = 0; i < rowsize_ER; i++)

{

?

}

Thanks!

sureshmandalapu6
Active Contributor
0 Kudos

Hi ,

Can u make it simple and more clearer what u need and what u have done ?

thanks

Suresh

Former Member
0 Kudos

Hi!

I want change Y to N, Y is wrong , bcz front is 0

Andy -


22 -


Y

Thanks!

Former Member
0 Kudos

Dear All,

I add some relatively pictures on this link

http://www.anydesign.cn/ShowPost.asp?ThreadID=278