on 08-19-2020 4:00 PM
HI Guys,
I need to implement a logic in an interface where below is the logic:
we need to check how many times a empld is repeating and count the amount. For an example in the file the price is different so we need to count and send the output as 15000.
i have written the logic like below but am not getting the expected result can you help me please where am going wrong.
import com.sap.it.api.mapping.*;
def void countValues(String[] EmpID, String[] Price, Output resPrice, MappingContext context){
int gPrice = 0;
boolean flag = false;
for(int i=0;i<EmpID.length;i++)
{
int tEmpID = 0;
int tPrice = 0;
try
{
tEmpID = Integer.parseInt(EmpID[i]);
}
catch(Exception e)
{
tEmpID = 0;
}
try
{
tPrice = Integer.parseInt(Price[i]);
}
catch(Exception e)
{
tPrice = 0;
}
// Price Logic
if(tEmpID == )
{
gPrice = tPrice;
flag = true;
}
if(flag==true)
{ break;
}
}
for(int i=0;i<EmpID.length;i++)
{
int tEmpID = 0;
int tPrice = 0;
//int tPrice = 0;
try
{
tEmpID = Integer.parseInt(EmpID[i]);
}
catch(Exception e)
{
tEmpID = 0;
}
try
{
tPrice = Integer.parseInt(Price[i]);
}
catch(Exception e)
{
tPrice = 0;
}
// sectionWeight Logic
if(tEmpID == )
{
resPrice.addValue(""+tPrice);
}
}
}
Regards,
Sandhya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you use the content modifier after you read the file, the XML data will go as body to the content modifier, inside content modifier we are using xpath to count and add the values in xml and updating the value in the property variable, this property variable you can use later in your process.
HI yatanveersingh ,
Thanks for this ! but in my requirement there will be multiple empld so i need to group them at a place and then count the price value how it is possible for this in content modifier for an example i have attached the source file.
file.txt
Regards,
Sandhya
mm.jpgHi Sandhya,
If you are using Mapping you could use standard mapping functions to achieve this. If i understood correctly you want to send total price value on target side? something like this ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Sandya,
Please share the expected output also so that its easy to suggest some solution.
Regards,
Sriprasad Shivaram Bhat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.