on 06-17-2009 6:26 PM
Dear friends,
I have a scnario where i need to uploade the sumary of financial entries.
For every one line item i need to create a target side as 2 line item for debit and credit entry.
I achived this by using duplicatesubtree.
Now the issue is for all the entries there should only one debit entry by summing all the line item amout and all the credit item entries.
Even this is achived by using the context change at the sum function.
In fico we can uploade only 900 line item not more that. for this i have make use of counter and udf to resolve this.
But now for context change i need to genarate one debit entry for every 899 credit entrries(input line items).
It mean for 899 input item sum to be taken in to one debit line item at target in the duplicatesubtree
For this i have a udf it gives a counter change after 899 line items.
Now on this change how should i change the context..for sum and create the debit item after every 899.
I have refered this thread .
Regards
Vijay
You can create one extra conext where you need based on input array value
EX:
for(int i=0;i<a.length;i++)
{
if((i==***)
{ result.addValue(ResultList.CC);
}
result.addValue(a<i>);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vijay,
Under Item (0..unbound)
u have (Credit) (0 ..outbound)
(Debit) (0..outbound)
1) Duplicate item
For Item1 / Item 2 === Pass Contant (Null) , Always create
For Credit Node use below UDF
If u have 6 records it wud create 3 records
public void NodeCredit(String[] a,ResultList result,Container container){
float count = a.length;
float c = count/2;
int d = (int)c;
for(int i=0;i<=d-1;i++)
result.addValue("");
}
For node Debit
Under each 3 reords one records would be inserted
public void NodeDebit(String[] a,ResultList result,Container container){
float count = a.length;
float c = count/2;
int d = (int)c;
int e = 1;
for(int i=0;i<=e-1;i++)
result.addValue("");
}
hope this helps u
regards
Srini
Edited by: Venkateswarlu Srinivas on Jun 22, 2009 8:22 AM
Hi Srinivas,
This helped me alot.
But i required the sum of 3 credit amount value into one debit value element in that item.
The change of the context depends on the counter value which i have given the code in screen shots.
All the same counter value amount should be added and when ever the counter changes the again sum loop should start for the new counter value.
Regards
Vijay G
Hi Vijay,
To get Sum
Source item (0 .. outbound)
line1 (0..1)
line2 (0..1)
line3 (0..1)
line4 (0..1)
line5 (0..1)
line6 (0..1)
Now map Line6 --> (RemoveContext) u will get all values ===> Write UDF1 ===> Map to first element under Item1
===> Write UDF2 ===> Map to first element under Item1
UDF1
public void CreditSum(String[] a,ResultList result,Container container){
float count = a.length;
float c = count/2;
int d = (int)c;
int sum=0;
String Sum_str = " ";
for(int i=0;i<=d-1;i++)
{
sum = sum+Integer.parseInt(a<i>);
Sum_str =Integer.toString(sum);
}
result.addValue(Sum_str);
}
UDF2
public void Credit2Sum(String[] a,ResultList result,Container container){
//write your code here
//write your code here
float count = a.length;
float c = count/2;
int d = (int)c;
int sum=0;
String Sum_str = " ";
for(int i=d;i<=count-1;i++)
{
sum = sum+Integer.parseInt(a<i>);
Sum_str =Integer.toString(sum);
}
result.addValue(Sum_str);
}
Thx
Srini
Hi Srinivas,
I have writen one UDF for the same by using your logic. And at last i got the required output.
But i have one issue now.
The out queue is not reflecting to all the output nodes of item2. it reflecting to only first item2 .
Please check this code and Screen shot and rectify me.
String[] b;
b = new String[a.length];
float[] c;
c = new float[100];
float e=3;
for(int j=0; j<a.length; j++)
{
float f = j/e;
int g = (int)f;
g = g+1;
String h = Integer.toString(g);
b[j]= h;
}
int s=0;
int y=0;
for (int x=0;x<b.length;x++) {
if((x+1)<b.length && b[x]==b[x+1])
s++;
else {
float sum=0;
for(int i=x-s;i<=x;i++){
sum = sum+Float.parseFloat(a<i>);
String Sum_str = Float.toString(sum);
///System.out.println (sum);
if(i==x){
//c<i> = sum;
result.addValue(Sum_str);
//System.out.println(c<i>);
}
else{
//c<i> = 0;
String zz = "0";
result.addValue(zz);
//System.out.println(c<i>);
}
}
s=0;
}
}
and screen shot link is
[http://picasaweb.google.co.in/vmail.sap/Context_change#]
Regards
Vijay
Edited by: vijay Kumar on Jun 24, 2009 11:14 AM
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.