Skip to Content
avatar image
Former Member

How to change 2nd row field in WebDynpro

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?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 04, 2008 at 02:31 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • avatar image
    Former Member
    Sep 03, 2008 at 09:24 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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.

  • avatar image
    Former Member
    Sep 03, 2008 at 07:18 AM

    Hi ,

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

    thanks

    Suresh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 03, 2008 at 07:35 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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!

  • avatar image
    Former Member
    Sep 05, 2008 at 07:12 AM

    Thank you very much!

    Add comment
    10|10000 characters needed characters exceeded