6 Replies Latest reply: Mar 18, 2012 7:31 AM by S Bhavani Sankar RSS

mapping logic?

S Bhavani Sankar
Currently Being Moderated

hi Guys,

can you give the approaches to map the fields in mapping?

Main Rule: The value from received from SAP is in below format Name1=Value1&Name2=Value2&Name3=Value3……… Tokenise the string of A_ DATA to get individual pairs of Name and Value and A_DATA length is 1000.

->>>>>>>>>>>>>>>>

so pass the A_data field value to target filed obj_name (rule:string token(ref above) if the Name="PROCESS)

  • Re: mapping logic?
    Baskar Gopalakrishnan
    Currently Being Moderated

    If you are looking for how to handle the name value pair from the source, this is one possible way.

    Use Java class Hashtable which has key value pair. Use StringTokenizer to pull name and store it in key of hashtable and pull value and store it in the respective value pair of hashtable.  This way you retrieve all the information about value string. Then use hashtable method to pass entire keys or values to the target object. Refer Hashtable java class and Stringtokenizer class for your need

  • Re: mapping logic?
    Mark Dihiansan
    Currently Being Moderated

    Hello,

    Main Rule: The value from received from SAP is in below format Name1=Value1&Name2=Value2&Name3=Value3……… Tokenise the string of A_ DATA to get individual pairs of Name and Value and A_DATA length is 1000.

    ->>>>>>>>>>>>>>>>

    so pass the A_data field value to target filed obj_name (rule:string token(ref above) if the Name="PROCESS)

    You can achieve it using the UDF below: execution type is Context Type, arguments: inp

     String temp[] = inp[0].split("&");
     for(int a=0;a<temp.length;a++){
          int ind = temp[a].indexOf("PROCESS");
          if(ind>-1){
               result.addValue(temp[a].substring(ind+8));     
          }
     }

    Hope this helps,

    Mark

    • Re: mapping logic?
      Mark Dihiansan
      Currently Being Moderated

      Hello,

      I have posted a modified code in an earlier post:

       

      String temp[] = inp[0].split("&");
      StringBuffer sb = new StringBuffer();
      for(int a=0;a<temp.length;a++){
      int ind = temp[a].indexOf("PROCESS");
        if(ind>-1){
              sb = sb.append(temp[a].substring(ind+8)+":"); 
        }
      }  
      result.addValue(sb.substring(0, sb.length()-1)+"");
       

      Hope this helps,

      Mark

  • Re: mapping logic?
    Amit Srivastava
    Currently Being Moderated

    u can chk this code also:

    execution type: all values of a context

     

    Input: a

    {code}

    //write your code here

    String [] temp1 = a[0].split("&");

    String Output ="";

    boolean flag=false;

    for(int i=0;i<temp1.length;i++)

    {

    String [] temp2 = temp1[i].split("=");

    if(temp2[0].equals("PROCESS"))

    {

    Output = Output + temp2[1] +":";

    flag=true;

    }

    }

    if(flag)

    {

    int len = Output.length()-1;

    result.addValue (Output.substring(0,len));

    }

    else

    {

    result.addValue("No Process exist");

    }

    {code}

    Sorry i am using ur thread...but can anyone please tell me how to paste the code in the way which we used to do in earlier version??

     

    Message was edited by: Amit Srivastava

     

     

    • Re: mapping logic?
      Mark Dihiansan
      Currently Being Moderated

      Hello Amit,

      Once you click reply, click the Use Advanced Editor. Once you are into the new window, click the >> icon and then under syntax highlighting, select Java.

      Hello Bhavanisankar,

      for ex: data is A=06470&B=101969D0&PROCESS=DPAR

      Set it to "ACTIVE2"  if Name(from string token(ref above)) equals "A"
      Set it to "Order2" if Name(from string token(ref above)) equals "B"

      What is your desired output for this? e.g for PROCESS it is DPAR:....

      Regards,

      Mark

Actions