Issue in handlng context change
Hi All,
I have the following requirement :
Consider for example there are 4 idocs sent from SAP ECC system . At the target end we have a segment called Records which repeats based on the number of times unique payment id exists.
So , in the 4 IDOCs which was posted to XI . First 2 IDOCs contain same payment run id and the next 2 different payment run id . So , finally we will be generated 3 Records (target segments).
While doing so , we have a segment called abc inside the 2nd IDOC . The data under this segment (for the 2nd IDOC) should occur in the 1st Record segment (which is repeating based on the 1st IDOC) aking with 1st IDOC abc segment details . In short , I want the following occurence :
Records (1st IDOC)
- abc (1st IDOC)
- abc (2nd IDOC).
Records(3rd IDOC)
- abc(3rd IDOC)
Recrords(4th IDOC)
- abc (4th IDOC).
I am facing an issue regarding 1st IDOC , 2nd abc segment which should come from the 1st IDOC . How can we solve this issue,
Regards
Vinay P.
Try the below logic:
abc(Idoc segment)-----\
PaymentId-->removeContext-->sort-->splitbyValue(value change)--> formatByExample-->abc node(Target)
Similar Messages
-
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
VijayHi 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 -
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 -
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 -
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. -
Context Changes got impact on what?
Context Changes got impact on what?.
Hi Ash,
Context changes have impact on:
�� User-Defined Functions
�� 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 -
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
rajashekarHi 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, -
This MacBook Pro (circa 2011) is the second Apple laptop I have owned with the exact same issue. When I change sites (or at least many of them), the Mac issues a single chime. I do not have any clue what this might be ... or if it even needs repairing if I can stand the chime.
If anyone has any ideas, I surely would love to hear! Many thanks!
MadelaineThis is the Mac Pro (desktop workstation) forum. You will probably get more meaningful results here:
MacBook Pro: Notebooks: Apple Support Communities
good luck -
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 -
Authorization issues MM/PP STATUS Changes
Hello,
I'm getting the following error even with SAP_ALL SAP_NEW
BDC Transaction Report for ZM02. Report: ZUCC0026
Run by: KHALIFAO page: 1
On: 11/11/2009 at : 09:06:12
In System: Q47
Authorization issues MM/PP STATUS Changes
M365SC1110020 ZFIN M680 MM/PP STATUS 00 Not authorized to change MM/PP status
One of my user is having the following error when she excuted the following steps :
Steps:
SE38/ ZUCC0026 - Material Mass update program for Costing View
Enter the following fields before executions
Material : M365SC1110020
Plant: M680
Check off update material
Field to update: select MM/PP status
New Value: 00
Execute transaction
Thanks
Osama
Expected results: output document should states that update of MM/PP status was changed from XX to 00.
This messageHello Julius,
SY-UNAME
ZUCC0026 550 WRITE: / 'BDC Transaction Report for ZM02. Report:'(b01),
/ 'Run by: '(b02) ,sy-uname COLOR 5,
1167 * IF sy-uname <> 'BATCH'.
1183 READ TABLE itab_zusrgroup WITH KEY group_id = group_id
user_name = sy-uname.
1212 SELECT SINGLE update_ind scop_ind
FROM zusrgroup INTO (itab-update_field,l_scop_ind)
WHERE user_name = sy-uname
AND group_id = itab_fields-group_id.
1219 * WHERE user_name = sy-uname
1223 READ TABLE i_zplant WITH KEY
user_name = sy-uname
werks = itab-werks.
1422 SELECT werks FROM zusrplant
INTO zusrplant-werks
WHERE user_name = sy-uname.
1453 MOVE: sy-uname TO i_zplant-user_name,
Parameter :
188 *PARAMETERS: p_mode TYPE c DEFAULT 'N' NO-DISPLAY. JHSIR35508-
189 PARAMETERS: p_field LIKE itab_fields-descriptio.
190 PARAMETERS: p_name LIKE itab_fields NO-DISPLAY.
191 PARAMETERS: p_newval(14) TYPE c.
193 PARAMETERS: p_file(100) TYPE c LOWER CASE.
194 PARAMETERS: p_filval AS CHECKBOX. "0001+
195 PARAMETERS: p_unix AS CHECKBOX. "0004+
33 PARAMETERS: P_UPD AS CHECKBOX.
Thanks
Osama
Maybe you are looking for
-
Trying to create XML file from 1 oracle table .
I'M NEW IN ODI Step1: Target XML format - <Customers> - <UserInfo> <UserID>0000000000202406</UserID> <LegalEntityCode>0USAL</LegalEntityCode> <BranchCode>001</BranchCode> <LegalEntity>>0USAL</LegalEntity> <BranchCode>001</BranchCode> <Type
-
Server process id (Server PID).
Hi friends, I wanted server process id (Server PID). i have executed the below query on SQL+ select p.spid from v$session s, v$process p where s.paddr = p.addr and s.audsid = to_number(sys_context('USERENV','SESSIONID'));i got an error > ORA-00942: t
-
I'm trying to simply create text and drag that clip onto the timeline. once i drop it in the timeline, fcp 3 "unexpectedly quits" and i have to re-start. I'm on quicktime 6.5.2, os 10.3.8, powerbook g4 1.67 ghz 768 mb ram. any suggestions?
-
Iphone Battery Issues...worse?
Hi all..love my Iphone like many of us. But now it's getting to be a pain here. There's an increasing amount of instances where I pick my Iphone up from it's cradle before going to work, let it sit on the desk next to me for my 8 hour shift of dispat
-
Hello,How can i change my IP address for a WLPI licence ?