on 09-02-2013 11:53 AM
Dear Experts,
I am new to PI and want to build one logic using UDF in sap PI 7.1.
I have attached the payload, where input data is coming in multiple segments, so I need to capture the data For SUMME based condition on SUMID
If SUMID == "011'
then
SUMME == " " (In the given payload valuse is "2612.00").
Please provide the UDF code for this requirement..
Hello,
Why u want a UDF for this? It can be easily handle using graphical mapping?
Just for your reference, i have attached the UDF code, but don't use this as stated above use graphical mapping.
int count = 0;
for(int i=0;i<var1.length;i++)
{
if(var1[i].equals("011"))
{
result.addValue(var2[i]);
count = count+1;
break;
}
}
if(count==0)
result.addSuppress();
Thanks
Amit Srivastava
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amit,
If I have captured the requirement correctly then sumit S wants the value of the field
SUMME to be propagated to the target if the value of the field SUMID in the same segment is not equal to "011". In your code you are propagating the value of SUMME to target if SUMID=011.
if(var1[i].equals("011"))
{
result.addValue(var2[i]);
count = count+1;
break;
}
So this made me little confused here.
If I have understood the requirement properly then in target the SUMME node value becomes "" but it exists if SUMID="011". Then following mapping should suffice
after test
If no SUMME node is to be generated in target at all if value of SUMID="011" then mapping will change slightly as follows
The test results will be as shown below
Please correct me in case I am wrong, but if I go by what sumit S has asked then this might be the graphical mapping solution I guess.
Regards
Anupam
Hi Anupam,
Thanks for the reply,, As u said i treid the mapping and its working fine but if u see in test result, I am getting 5 line items in that one line item has the actual values(please refer screen shot) and i have a soap at receiver side and i want to avoid the multiple line items which has no values.
basically from source if it is coming n line itmes and in target also it is getting created with n line items please refer my mapping scren shot. I have just mapped source node to target node, hence it is creating same line items in the target. but i want only field in target which the value is picking( in ex : 999)
Hi Sumit,
I assume you don't need the source value for SUMME in case if SUMID 011.
Normally in case of FIDC02 IDocs, the values are calculated in ECC based on tax codes/country codes and not from source and this is the reason you are doing this.
So just right click on the target segment E1EDS01. Do duplicate subtree. map the additional segment E1EDS01 created to a constant null. Map SUMID to constant 011 and SUMME to constant null.
Isn't it what you need ?
Ambrish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sumit,
I have faced this issue of suppressing the values in the target structure based on conditions.
I use the below java code to suppress the empty values. These empty values are produced upon using "if" standard function.
public void removeEmptyValues(String[] inputQ, ResultList result, Container container) throws StreamTransformationException{
// beginning of removeEmptyValues
for(int i=0; i<inputQ.length; i++)
{
if( inputQ[i].equals("") )
{
}else{
result.addValue(inputQ[i]);
}
}
// end of removeEmptyValues
}
Hope it helps!
Best Regards,
Anand Patil
Hi Sumit,
As Amit said is better to use a standard function, it's easier to maintain and you avoid further problems in a PI upgrade.
You can use the standard booelan functions IF or IFwithoutElse depending if you need to map SUMME tag in the case that SUMID != "011':
http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/5d/db0e83e8e74202a5bff527055ab7e5/content.htm
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
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.