Skip to Content
avatar image
Former Member

Mapping logic required-UDF

Hi,

My sender structure is as follows

<zaction>(1:1)

--Trans

<Zcode>(0:999)

--Code

--Id

My target field is

<code>(0:999)

--ID

My requirement is

if code= CE,CB,CH,CJ,CI,CO then don't create target field ID.

else

if code=AF and Trans=01 then ID=axv0001

or

if code=AF and Trans=02 then ID=axv0002

if none of the above conditions matches pass ID received from sender.

I am confused at using context type UDF. As suppress result is completely supressing the target field. it's not looking into the rest of logic. Can you provide me an appropraite UDF for this logic please.

TIA,

Mahesh

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Nov 09, 2011 at 02:47 AM

    Hello,

    You can use this context type UDF:

    Arguments: inTrans
    inCode
    inID
    
    for(int a=0;a<inCode.length;a++){
    	if(inCode[a].equals("CE")|inCode[a].equals("CB")|inCode[a].equals("CH")|inCode[a].equals("CJ")|inCode[a].equals("CI")|inCode[a].equals("CO")){
    		result.addSuppress();
    	}
    	else if(inCode[a].equals("AF")&inTrans[0].equals("01")){
    		result.addValue("axv0001");
    	}
    	else if(inCode[a].equals("AF")&inTrans[0].equals("02")){
    		result.addValue("axv0002");
    	}
    	else{
    		result.addValue(inID[a]);
    	}
    }
    

    Logic is like this:

    For code

    Trans -> removeContext -> \
    Code --> removeContext -> UDF -> code
    ID ----> removeContext -> /
    

    For ID

    Trans -> removeContext -> \
    Code --> removeContext -> UDF -> splitByValue:eachValue -> ID
    ID -----> removeContext -> /
    

    Hope this helps,

    Mark

    Edited by: Mark Dihiansan on Nov 9, 2011 3:47 AM

    Add comment
    10|10000 characters needed characters exceeded

    • Hello,

      Raj is right, you need to use mapWithDefault

      Trans -> removeContext ----------------------------------> \
      Code --> removeContext ----------------------------------> UDF -> splitByValue:eachValue -> ID
      ID ----->mapWithDefault:Suppressed------> removeContext -> / 
      

      You just need a little tweaking from the UDF to control the output

      Arguments: inTrans
      inCode
      inID
       
      for(int a=0;a<inCode.length;a++){
      	if(inCode[a].equals("CE")|inCode[a].equals("CB")|inCode[a].equals("CH")|inCode[a].equals("CJ")|inCode[a].equals("CI")|inCode[a].equals("CO")){
      		result.addSuppress();
      	}
      	else if(inCode[a].equals("AF")&inTrans[0].equals("01")){
      		result.addValue("axv0001");
      	}
      	else if(inCode[a].equals("AF")&inTrans[0].equals("02")){
      		result.addValue("axv0002");
      	}
      	else{
      		if(inID[a].equals("Suppressed")){
                      result.addSuppress();
                      }
                      else{
                      result.addValue(inID[a]);
                      }
      	}
      }
      

      Hope this helps,

      Mark

  • Nov 08, 2011 at 07:09 PM

    as i can see, you can solve you requirement ussing a UDF but also ussing standard functions.

    for example you know the rigths codes. so you can do this:

    change the context of <Code> to the nameof your message Type > rigth click > context-->MT_XXX

    once you did it use the Equals function (Text group) and compear with 'AF':

    <Code>---------------Equals---->And----->Trans-->Equals-------IF(true)---->axv0001
    AF(constant)---------                                 01------>                      (false)---> Trans-->Equals--->ifWithOutElse-->axv0002
                                                                                    02---->
    
    

    Add comment
    10|10000 characters needed characters exceeded