on 02-11-2011 12:49 PM
Hi,
I get a response structure from an RFC and needs to send the status from the Response to target structure.
Response
RETURN
Row 0.....unbounded
Status 0.....1
Target
STATUS 0.....1
The Row value repeats to unbounded where the Status field gets the Value E or S.If all the values in the Repeated Rows are S then i need to send the status in a target field File Transfer Success .If all the values or E or some rows have Status E and some have S i need to send the status as File Transfer Failed.
The Output should be a single Value comparing all the Values in the Input and should return a single value FileTransferSuccess or FileTransfer OK.
How to write UDF for the above requirement
Thanks and Regards,
Rajesh
Hi Rajesh,
Create a context UDF with input as an array for Status fields,then your UDF should look something like:
boolean flag = true;
for(int i=0;i<Status.length;i++)
{
if(Status<i>.equals("E"))
flag = false;
}
if(flag == false)
result.addValue("FileTransferFailed");
else
result.addValue("FileTransferSuccess");
Best Regards,
Shweta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@ Shweta: Small correction in the code
flag is declared as boolean, so dont use equal sign to check boolean. (Not a good practice)
boolean flag = true;
for(int i=0;i<Status.length;i++)
{
if(Status.equals("E"))
flag = false;
}
if(flag){
result.addValue("FileTransferSuccess");
}
else{
result.addValue("FileTransferFailed");
}
if should work with standard function also.
something like this:
status - removecontexts - equals (constant(E)) - createif - exists - if(E/S) - status
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First of all you need to map the output of the Status field from the source structure to node function removeContext to bring all the Status values in a single context. Then pass the output of this removeContext function to the UDF that I have written below.
Pass the output of this UDF to the target side STATUS field. Its as simple as that.
THE COMPLETE CODE OF THE UDF IS AS FOLLOWS:
public void func(String[] instr,ResultList result,Container c)
{
int len=instr.length;int flag=0;
for(int i=0;i<len;i++)
{
if(instr<i>.equalsIgnoreCase("S"))
{}
else
{flag=1;}
}
if(flag==1)
result.addValue("File Transfer Failed");
else
result.addValue("File Transfer Success");
}
Edited by: 007biswa on Feb 11, 2011 2:25 PM
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 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
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.