Context changes

wat is context and how it changes?

Hi,
  Assume u have message type as follows.
i.e MTO_Sample-
       -Data1
          - filed1
          - filed2
          - filed3
      -Data2
          - filed1
          - filed2
          -filed3
    -Data N
          - filed1
          - filed2
         - filed3
where Data1, Data2 and Date3 are context..
assume u have Data1 with 2 records, then start of second record nothing but context change.
please chk the following link.
http://help.sap.com/saphelp_nw04s/helpdata/en/48/444941db42f423e10000000a155106/frameset.htm
/people/yukai.shi/blog/2006/06/02/b2b-mapping-techniques-using-the-graphical-mapping-tool
/people/harrison.holland5/blog/2006/12/08/mapping-context-changes-in-xi
regards
mahesh.

Similar Messages

  • Context change by DOM parsing Java Mapping in XI

    Hi Team,
    I would like to know that how can I handle Context Change by DOM Parser Java Mapping in XI.?
    Suppose  the source XML structure I have like below:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:Header xmlns:ns0="urn:bp:xi:hr:edm:test:100">
       <FileName>
          <filesub>
             <subname>a</subname>
             <subname>b</subname>
             <subname>c</subname>
          </filesub>
       </FileName>
       <FileName>
          <filesub>
             <subname>d</subname>
             <subname>e</subname>
             <subname>f</subname>
          </filesub>
       </FileName>
    </ns0:Header>
    Where the field FileName can occur maximum thrice(0...3) but the subname field is (0....unbounded) but in the target source I would like to have as given below:
    <?xml version="1.0" encoding="UTF-8" ?>
    - <MT_Test4 xmlns="urn:bp:xi:hr:edm:test:100">
    - <Header>
      <FileName>a</FileName>
      <FileName1>d</FileName1>
        </Header>
    - <Header>
      <FileName>b</FileName>
      <FileName1>e</FileName1>
       </Header>
    Header>
      <FileName>c</FileName>
      <FileName1>f</FileName1>
       </Header>
    </MT_Test4>
    That means the first value from every context of the source field is forming my first and second value in my target first context.Thensecond value from every context is forming my 1st and 2nd value of my target 2nd context and finally 3rd value of every context is forming my 1st and 2nd value of my target 3rd context.Is this possible to done through DOM parsing or we have to do it by UDF only?

    Hi Atanu,
        In my last post I gave an alogorithm to solve the mapping problem. Here is the complete program for the mapping.
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.Map;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import com.sap.aii.mapping.api.StreamTransformation;
    import com.sap.aii.mapping.api.StreamTransformationException;
    public class DOMParser1  implements StreamTransformation{
         public void execute(InputStream in, OutputStream out)
                   throws StreamTransformationException {
              try
                   DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
                   DocumentBuilder builderel=factory.newDocumentBuilder();
                   /input document in form of XML/
                   Document docIn=builderel.parse(in);
                   /document after parsing/
                   Document docOut=builderel.newDocument();
                   TransformerFactory tf=TransformerFactory.newInstance();
                   Transformer transform=tf.newTransformer();
                   Element root,child,child1=null;
                   Node textChild;
                   NodeList l;
                   int i,n1,j,div,k;
                   String s[];
                   root=docOut.createElement("MT_Test4");
                   root.setAttribute("xmlns","urn:bp:xi:hr:edm:test:100");
                   l=docIn.getElementsByTagName("subname");
                   n1=l.getLength();
                   s=new String[n1];
                   for(i=0;i<n1;++i)
                             s<i>=l.item(i).getFirstChild().getNodeValue();
                   l=docIn.getElementsByTagName("filesub");
                   div=l.getLength();
                   j=n1/div;
                   for(i=0,k=0;i<j;++i)
                        child1=docOut.createElement("Header");
                        root.appendChild(child1);
                        child=docOut.createElement("FileName");
                        textChild=docOut.createTextNode(s[k]);
                        child.appendChild(textChild);
                        child1.appendChild(child);
                        child=docOut.createElement("FileName1");
                        textChild=docOut.createTextNode(s [ k + j ]);
                        child.appendChild(textChild);
                        child1.appendChild(child);
                        ++k;
                   docOut.appendChild(root);
                   transform.transform(new DOMSource(docOut), new StreamResult(out));     
              catch(Exception e)
                   e.printStackTrace();
         public void setParameter(Map arg0) {
         public static void main(String[] args) {
              try{
                   DOMParser1 genFormat=new DOMParser1();
                   FileInputStream in=new FileInputStream("C:/Apps/my dw/sdnq/apps.xml");
                   FileOutputStream out=new FileOutputStream("C:/Apps/my dw/sdnq/tgt1.xml");
                   genFormat.execute(in,out);
              catch(Exception e)
                   e.printStackTrace();
    source ->  apps.xml
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:Header xmlns:ns0="urn:bp:xi:hr:edm:test:100">
    - <FileName>
    - <filesub>
      <subname>a</subname>
      <subname>b</subname>
      <subname>c</subname>
      </filesub>
      </FileName>
    - <FileName>
    - <filesub>
      <subname>d</subname>
      <subname>e</subname>
      <subname>f</subname>
      </filesub>
      </FileName>
      </ns0:Header>
    target structure ->  tgt1.xml
    <?xml version="1.0" encoding="UTF-8" ?>
    - <MT_Test4 xmlns="urn:bp:xi:hr:edm:test:100">
    - <Header>
      <FileName>a</FileName>
      <FileName1>d</FileName1>
      </Header>
    - <Header>
      <FileName>b</FileName>
      <FileName1>e</FileName1>
      </Header>
    - <Header>
      <FileName>c</FileName>
      <FileName1>f</FileName1>
      </Header>
      </MT_Test4>
    Hope this helps
    one more thing  in this line "textChild=docOut.createTextNode(s k + j );"   somehow the the third braces one opening  before k and one closing after j is missing for unknown reasons. Please correct it when you actually run this code.
    regards
    Anupam
    Edited by: anupamsap on Mar 7, 2011 12:47 PM

  • Context change explicitly

    How to apply context change explicitly?

    Hi,
    Refer the section context handling page No 19: Explicit Context selection.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f59730fa-0901-0010-df97-c12f071f7d3b
    /people/riyaz.sayyad/blog/2006/04/23/introduction-to-context-handling-in-message-mapping
    Also u can achieve it by writing the code in UDF.Already provided by experts
    Thnx
    Chirag

  • Context Changes got impact on what?

    Context Changes got impact on what?.

    Hi Ash,
    Context changes have impact on:
    &#56256;&#56452; User-Defined Functions
    &#56256;&#56452; Breaking and inserting of hierarchy levels
    For more see below PPT of SAP:
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/be05e290-0201-0010-e997-b6e55f9548dd">https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/be05e290-0201-0010-e997-b6e55f9548dd</a>
    Regards,
    Subhasha Ranjan

  • Context change

    Hi,
    what is context change?? where it is implemented?
    thanks in advance.

    Hi!
    Context changes take place in Message Mapping when the source structure is processed. for more details about mapping and context change see sap online help - e.g. here http://help.sap.com/saphelp_nwpi71/helpdata/en/49/1ebc6111ea2f45a9946c702b685299/content.htm
    Regards,
    Volker
    Additionally:
    More detailed information about contexts and context changes see here: http://help.sap.com/saphelp_nwpi71/helpdata/en/3d/24e15bf9d79243b45d49b13b03de8f/content.htm
    Edited by: Volker Kolberg on May 25, 2009 10:10 AM

  • User changes in tab strip ui element are not recorded in context change log

    Hi All,
    We are using a tab strip ui element in webdynpro component. But user changes inside tab strip ui element are not getting recorded to the context change log. I have an input field on the same view besides  tab strip ui element. User changes to this input field are getting recorded to the context change log.
    Is there any restriction on context change log usage with tab strip ui element?
    Could you please suggest If there is any way to record changes inside tab strip ui element.
    Thanks,
    Sudheer.

    I think there are some limitations exists, context change logs are not complete when you do value help , i am not sure about tab strip.
    [http://help.sap.com/saphelp_nw70ehp1/helpdata/en/47/a8e5d273b12fe2e10000000a42189d/content.htm|http://help.sap.com/saphelp_nw70ehp1/helpdata/en/47/a8e5d273b12fe2e10000000a42189d/content.htm]

  • Add a context change after a set of values in a context

    Dear experts,
    My requirement is as follows:
    Scenario: Idoc to Idoc. I need to check if there are line items > 5- I need to do a split. The split is happening properly via my mapping but I have a problem at the header record level on the target- I do not get the values populated correctly. I need to add a context change after 5 values in the queue.
    eg:
    Say there are 2 Idocs at the source with following unique IDs: called Journal ID:
    My source:
    Idoc 1: Journal ID 123
    Line Itme 1
    Line Item 2
    Idoc 2: Journal ID 124
    Line item 1
    Line item 2
    Line item 3
    Line item 4
    Line item 5
    Line item 6
    Line item 7
    So I need to get total of three Idocs in my target:
    Idoc 1: Journal Entry 123
    Line Item 1
    Line Item 2
    Idoc2: Journal Entry 124
    Line item 1
    Line item 2
    Line item 3
    Line item 4
    Line item 5
    Idoc3: Journal entry 124
    Line item 6(new 1)
    Line item 7(new 2)
    The split in the target Idoc is working perfectly. But inside the header record the journal ID field(taken from Item record level) is not populating correctly. I am getting this output:
    Idoc 1: Journal Entry 123
    Header Record-->JournalID Field value= '123'
    Line Item 1
    Line Item 2
    Idoc2: Journal Entry 124
    Header Record-->JournalID Field value= '124'
    Line item 1
    Line item 2
    Line item 3
    Line item 4
    Line item 5
    Idoc3: Journal entry 124
    Header Record-->JournalID Field value= Null
    Line item 6(new 1)
    Line item 7(new 2)
    So please suggest a UDF/standard function to populate the right values inside header record--->Journal ID field.Something like the below...
    public void calculate(String[] var1, ResultList result, Container container) throws StreamTransformationException{
      for ( int i = 0; i < var1.length; i++ )
         if( var1[i].length() > 5) //here var1 I am passing the Journal ID
           result.addContextChange();
    Apparently this doesnt work.

    The first Idoc has two line items and the second idoc has 7 line items. As the split is per 5 line item- the target has 3 Idocs.
    Now the problem is that the header value in the target: REF_DOC_NO has to be created as per the number of line items and doesnt come from header record directly.

  • Message Mapping - Initialize counter every context change

    Hi all,
    is there any way to develop a counter customer function in a graphical message mapping so every context change of a field the counter initializes?
    Imagine i have the following structure:
    1 DATA
    1.1 DETAIL
    1.2 DETAIL
    2 DATA
    2.1 DETAIL
    2.2 DETAIL
    and i wanna count DETAIL fields but initialize the counter every DATA field. Is there any way to do it?
    Thanks a lot.

    Hi,
    If your Source structure is
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_DATA xmlns:ns0="http://yash.com.YH1309">
       <DATA>
          <DETAIL/>
          <DETAIL/>
       </DATA>
       <DATA>
          <DETAIL/>
          <DETAIL/>
          <DETAIL/>
       </DATA>
    </ns0:MT_DATA>
    and You want the Target as
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_DATA xmlns:ns0="http://yash.com.YH1309">
       <DATA>
          <DETAIL>COUNTER=1</DETAIL>
          <DETAIL>COUNTER=2</DETAIL>
       </DATA>
       <DATA>
          <DETAIL>COUNTER=1</DETAIL>
          <DETAIL>COUNTER=2</DETAIL>
          <DETAIL>COUNTER=3</DETAIL>
       </DATA>
    </ns0:MT_DATA>
    Create the below UDF with one argument (DETAIL)  and select Execution type all values of a Context
    for (int i =1;i<=DETAIL.length;i++)
    result.addValue("COUNTER=" + i);
    but if you want Your Target as
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_DATA xmlns:ns0="http://yash.com.YH1309">
       <DATA>
          <DETAIL>1</DETAIL>
          <DETAIL>2</DETAIL>
       </DATA>
       <DATA>
          <DETAIL>1</DETAIL>
          <DETAIL>2</DETAIL>
          <DETAIL>3</DETAIL>
       </DATA>
    </ns0:MT_DATA>
    So please Follow abhishek salvi's reply

  • Context Change & Explicit Context Change

    Hi
           i need some info about Context Change and Context Handling, explisit context change how can we r defineing
    Thanks&Regards
    rajashekar

    Hi Raja,
    Please refer these:
    http://help.sap.com/bp_bpmv130/Documentation/Operation/MappingXI30.pdf
    Pages 62-74
    http://www.riyaz.net/blog/index.php/2007/12/08/xipi-introduction-to-context-handling-in-message-mapping/
    http://help.sap.com/saphelp_nw70/helpdata/en/bd/ca1105c81c6742a0f8c8d49f8834bf/frameset.htm
    Refer section: Structure Mapping by Setting the Context
    Thanks ,
    Shweta

  • Mapping query for context change without UDF

    Hi,
    My requirement is as below:
    Input queues are
    4319, 4319,4320,4321,4321
    M1,M1,M1,M2,M2,M2
    Required output is
    4319,4320,CC,4321
    COntext change is to be inserted when there is a change in value in second queue.
    regards, Anirudh.

    Hi,
    Have you tried using the formatByExample as specified?
    input1-->removeContext--> concat --> splitByValue:ValueChanged --> collapseContext --> substring (2..6) --> formatByExample (1) --> Target
    input2-->removeContext--> /
    input1-->removeContext--> concat --> splitByValue:ValueChanged --> collapseContext --> substring (0..2) --> splitByValue:ValueChanged -->formatByExample (2)
    input2-->removeContext--> /
    code explanation
    input1 and input 2 when concatted outputs M12319,M12319,M12320,M22321,M22321,M22321
    The upper part of the code does this: M12319,M12320,M22321, when you use the substring it outputs now 2319,2320,2321
    The lower part of the code does this: M12319,M12320,M22321, when you use the substring it outputs
    M1,M1,M2, then you use splitByValue. The output is now M1,M1,CC,M2.
    When you input the code from the upper part and lower part into a formatByExample node, the output becomes
    2319,2320,CC,2321
    Hope this helps,

  • Query on context change

    Hi,
    i am getting small problem in the context change..
    i have input as
    1
    2
    3
    [3]context change
    4
    5
    [5]conext change
    6
    7
    8
    [8]context change
    i want out put as
    2
    3
    [3]conext change
    5
    [5]context change
    7
    8
    [8]context change
    my requirement is the element after context change in the input sholud be deleted.
    Thank you,
    Madhav.

    Hi Madhav,
    Try This
    for(int i=0;i<a.length;i++)
    if(a<i>.equals(ResultList.CC))
    result.addValue(ResultList.CC);
    i++ ;
    else
    result.addValue(a<i>);
    "if(a.equals(ResultList.CC))" it should be a(i) but in rect bracket ,Dont know why it is not showing the same in above code
    Thanks
    Sunil Singh
    Edited by: SUNIL SINGH on Nov 19, 2008 5:57 AM
    Edited by: SUNIL SINGH on Nov 19, 2008 5:59 AM

  • Reg: Logic for context change

    Dear friends,
    I have a scnario where i need to  uploade the sumary of financial entries.
    For every one line item i need to create a target side as 2 line item for debit and credit entry.
    I achived this by using  duplicatesubtree.
    Now the issue is  for all the entries there should only one debit entry by summing all the line item amout and all the credit item entries.
    Even this is achived by using the context change at the sum function.
    In fico we can uploade only 900 line item not more that. for this i have make use of counter and udf to resolve this.
    But now for context change i need to genarate one debit entry for every 899 credit entrries(input line items).
    It mean for 899 input item sum to be taken in to one debit line item at target in the duplicatesubtree
    For this i have a udf it gives a counter change after 899 line items.
    Now on this change how should i change the context..for sum and create the debit item after every 899.
    I have refered this thread .
    [context change  in message mapping]
    Regards
    Vijay

    Hi Vijay,
    To get Sum
    Source item (0 .. outbound)
               line1 (0..1)
               line2 (0..1)
               line3 (0..1)
               line4 (0..1)
               line5 (0..1)
               line6 (0..1)
    Now map Line6 --> (RemoveContext) u will get all values ===> Write UDF1 ===> Map to first element under Item1
    ===> Write UDF2 ===> Map to first element under Item1
    UDF1
    public void CreditSum(String[] a,ResultList result,Container container){
    float count = a.length;
    float c = count/2;
    int d = (int)c;
    int sum=0;
    String Sum_str = " ";
    for(int i=0;i<=d-1;i++)
    sum = sum+Integer.parseInt(a<i>);
    Sum_str =Integer.toString(sum);
    result.addValue(Sum_str);
    UDF2
    public void Credit2Sum(String[] a,ResultList result,Container container){
       //write your code here
        //write your code here
    float count = a.length;
    float c = count/2;
    int d = (int)c;
    int sum=0;
    String Sum_str = " ";
    for(int i=d;i<=count-1;i++)
    sum = sum+Integer.parseInt(a<i>);
    Sum_str =Integer.toString(sum);
    result.addValue(Sum_str);
    Thx
    Srini

  • What is Context Change

    Hi
    experts plz tell me what is context change

    Hi
    Context : Context of an element is nothing but just the level, where
    the XML tag appears in the given XML
    document. Level of any element is set to the immediate parent node by
    default.
    Context Change : Context change is just changing the level of XML
    tag(element level in XSD) in the XML document.
    This means when we map one source field to one target field then that
    both field segments should be at same
    level.
    Example
    The reason that context changes can occur in mapping is because sometimes you want to manipulate the structure of the message that's being transferred between systems. For example, lets say you have a message being sent from one system as an XML file, and the structure looks similar to the following:
    code
    <header>
    <field1></field1>
    <field2></field2>
    </header>
    [/code]
    However, the system that the message is being sent to has a requirement that each field be split into individual <header> format (I know, this is not a real world example), then you want to use context changes to make the format look something like this instead:
    code
    <header>
    <field1></field1>
    </header>
    <header>
    <field2><field2>
    </header>
    [/code]
    Essentially, you use context mapping when your requirements ask you to change the structure of the XML message, not just strictly apply transformations to each field. You can also check this blog that incorporates user-defined functions for advanced context changes: Mapping Context Changes in XI
    Message Mapping Simplified - Part I
    /people/sravya.talanki2/blog/2005/12/08/message-mapping-simplified-150-part-ii
    Hope this info is useful to you..
    Thanks
    Saiyog
    Edited by: Saiyog Gonsalves on Aug 1, 2008 10:00 AM

  • Context change not working during test

    Hi all,
    I've made a mapping. With several context changes. They all work fine when testing them in the message mapping and the operation mapping. But when I'm testing the actual scenrio all the target fields where a context change is used the target value is missing.
    What is going wrong?

    HI, thanks for the quick post. But the missing parts are already in the sxmb_moni. A download will not help in my situation. I thnk

  • Context change problem

    Team,
    I have a problem with context change in a peculiar mapping requirement.
    Scenario is IDOC --> XML
    There's an idoc field MRKN1 which carries all shipment unit numbers seperated by spaces.
    MRKN1 : 50325 50326 50329 50321 50215
    This field should be mapped to target XML as below:
    <Package>                                                                                <identifier>50325</identifier>
    </Package>
    <Package>                                                                                <identifier>50326</identifier>                                                           
    </Package>
    <Package>                                                                                <identifier>50329</identifier>                                                           
    </Package>
    <Package>                                                                                <identifier>50321</identifier>                                                           
    </Package>
    <Package>                                                                                <identifier>50215</identifier>                                                           
    </Package>
    I created a USD StringTokenizer to extract the values from MRKN1 & to populate it in the identier field:
    import java.lang.*;
    public void StringTokenizer(String[] input,ResultList result,Container container){
    String x[] = new String[input.length];
    for(int j=0; j<input.length;j++) {
    x = input[j].split(" ");
    for(int i=1;i<x.length;i++) {
         result.addValue(x<i>);
    and mapped liked below:
    MRKN1 --> StringTokeniser --> identifier
    But the output xml looks like this:
    <Package>                                                                                <identifier>50325</identifier>                                                                              <identifier>50326</identifier>                                                                                <identifier>50329</identifier>                                                                                <identifier>50321</identifier>                                                           
    <identifier>50215</identifier>                                                           
    </Package>
    Please help me how to create new Package tag for every new identifier tag.
    I already tried adding result.addContextChange() just by returning empty value to the above code & mapped it to Package node. But it throws error.
    Any immediate help is appreciated.
    Thanks in advance,
    Shanthi

    The above logic works quite different. The complete XML looks like this
    Given 3 items & 2 values in MRKN1
    <GoodsItem..1>
    <Packaging>
        <marksNumber>503124</marksNumber>
            <PackagesCollection>
                <Package>
                    <identifier>50216</identifier>
                </Package>
            </PackagesCollection>
           <packageType>PK</packageType>
    </Packaging>
    </GoodsItem..1>
    <GoodsItem..2>
    <Packaging>
        <marksNumber>503124</marksNumber>
            <PackagesCollection>
                <Package>
                    <identifier>50215</identifier>
                </Package>
            </PackagesCollection>
           <packageType>PK</packageType>
    </Packaging>
    </GoodsItem..2>
    <GoodsItem..3>
    <Packaging>
        <marksNumber>503124</marksNumber>
        <PackagesCollection/>
        <packageType>PK</packageType>
    </Packaging>
    </GoodsItem..3>
    But the customer requirement is quite different

Maybe you are looking for

  • 5700 - Email - Send - Set the code table

    I installed the Psiloc Crystal Japanese But when i send message to a my friend she cannot see my messages because her phone (or her Mobile Operator: Japana AU) Wants emails only with JIS but my nokia send only as unicode. Can I do something? Is it a

  • Best practice - transitions without state?

    I'm noticing that, sometimes, its easier to just do a Transition on a component without having the changes in a State. For example, I can't seem to get a sequence of Resize effects when the properties are set in State, but I succeed when I empty out

  • I am having problems installing CS4. It stalls during the "checking system profile" part.

    How can I fix this? I am using OS Windows 7.

  • Do not process empty messages

    Hello XI Gurus, I have a " File -> XI -> Server Proxy" scenario, some times after mapping the target message is empty, and we do not want to receive such messages in the target System. How can we filter them? some one have had  the same situation? Th

  • Having to re-enable sharing on 2008R2 server after each reboot.

    I have a 2008R2 EE server that has some foder shares located on a drive. We have an application that uses those shares but evertime the server reboots I have to go in and manually re-enable the sharing for the shares to reappear. Has anyone seen this