cancel
Showing results for 
Search instead for 
Did you mean: 

Remove leading Zeros from the mapped context node(Table)

vishal_gupta15
Contributor
0 Kudos

HI,

I have he following requirement:

In the Leave approval application , in the Approver worklist we have the coloumn to display the resuqester's Perner.

The perner starts with leading zeros. We have to remove these leading zeros.

I have refer the following threads:

and wiki document:

https://www.sdn.sap.com/irj/scn/wiki?path=/display/java/remove%252bleading%252band%252btrailing%252b...

but I am not able to create the calculated attribute in the Mapped Node( NWDS is not allowing indicating it is not allowed for mapped nodes.)

Any pointer how I can remove leading Zeros from existing column?

If I create the calculated attribute outside the mapped node then it is taking only the first value of the mapped node.

Please note we do not want to modify the RFC.

_vishal

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Create context node under your target node with cardinality 1..1 and singlton = false and creat calculated attributes under that new node

vishal_gupta15
Contributor
0 Kudos

Hi,

Thanks for inputs,

Now I created a test application where the original structure is as follows in the View Controller:

1) Context -> Z_Portal_Test_Input (mapped Node/folder) -> IT_Tab_Input(mapped Node/folder) -> Eid(Mapped attribute)

note: this attribute Eid has the values (01, 02,03,04,05)

2)Context -> Z_Portal_Test_Input (mapped Node/folder) -> Output(mapped Node/folder) ->IT_Tab_Input(mapped Node/folder) -> Eid(Mapped attribute)

Now as per your suggestion I created another node like this

Context -> Z_Portal_Test_Input (mapped Node/folder) ->testnode(value node) ->testValue(value attribute)

testnode cardinality is 1..1 and singlton = false

In the Layout

The tablecell editor of one coloumn is mapped to text Z_Portal_Test_Input.testnode.testvalue

It is expected that this will show the values like(1,2,3,4,5) but it is showing value(1,1,1,1,1)

The code of get method is:

public java.lang.String getTestnodeTestvalue(IPrivateTestpernerView.ITestnodeElement element)

{

//@@begin getTestnodeTestvalue(IPrivateTestpernerView.ITestnodeElement)

String msg =wdContext.nodeZ_Portal_Test_Input().nodeOutput().nodeIt_Itab().currentIt_ItabElement().getEid();

return removeLeadingZeroes(msg);

//@@end

}

the functon removeLeadingZeroes(msg) is implemented as per the wiki link.

What wrong I am doing/ missing....

_vishal

vishal_gupta15
Contributor
0 Kudos

any inputs...

Qualiture
Active Contributor
0 Kudos

It obviously fails because you're not using the ITestnodeElement element argument from the calculated attribute, but instead you used the current lead selection (which in your case has value 1).

In your declared method, you need to use something like:

String msg = ((It_ItabElement)element.node().getParentElement()).getEid()

Hope this explains

Robin

vishal_gupta15
Contributor
0 Kudos

Hi Robin,

Thanks for inputs.

when I am using (It_ItabElement) the NWDS is not able to organize import for this.

when I use (IIt_ItabElement), It gives me the error :

java.lang.ClassCastException

_vishal

Qualiture
Active Contributor
0 Kudos

I was merely using it as an example, as I thought you would be able to figure out the exact code yourself

However, what I meant was the element argument being the child element of the element which holds the value you need to trim, you thus need to refer to the parent element of this child element

So,

element.node().getParentElement()

gives you the parent IWDNodeElement, and you need to cast it to the proper type -- I thought it was IIt_ItabElement, but should be the parent element of course -- so you could retrieve the value of Eid:

((IWhateverParentElementYouHave)element.node().getParentElement()).getEid()

Answers (0)