Java mapping or UDF required for a requirement!!!
I am doing idoc to file scenario and stuck with the mapping in the following case. I think an UDF or JAVA mapping will do the bill. can some one help me in this regard please.
IDoc message type, IDoc basic type, IDoc extension
PAYEXT.PEXR2002.ZEXR2002.
<u><b>conditions:</b></u>
IF E1IDB02 BA-FIIKWAER = CNY
then MID(E1EDKA1 BE-NAME1,12,11)
IF E1IDB02 BA-FIIKWAER <> CNY and LEN(E1EDKA1 BE-NAME1)<=35
then MID(E1EDKA1 BE-STRAS,1,35)
IF E1IDB02 BA-FIIKWAER <> CNY and LEN(E1EDKA1 BE-NAME1)>35
then MID(E1EDKA1 BE-NAME1,36,35)
This will be mapped to "Info Line 1" field in file.
Thanks,
Kiran
Hi Mr.Kiran,
here is the code
pass the following fields to Context UDF
1.E1IDB02-FIIKWAER
2.E1EDKA1-NAME1
3.E1EDKA1-STRAS
for(int k = 0;k<FIIKWAER.length;k++)
if(FIIKWEAR[k].equalsIgnoreCase("CNY"))
result.addValue(NAME1[k].substring(11,12));
else if(!(FIIKWEAR[k].equalsIgnoreCase("CNY"))&&(NAME1[k].length() <= 35))
result.addValue(STRAS[k].substring(1,35));
else if(!(FIIKWEAR[k].equalsIgnoreCase("CNY"))&&(NAME1[k].length() > 35))
result.addValue(NAME1[k].substring(35,36));
Similar Messages
-
Get dynamic filename in a Java Mapping (NOT UDF)
Hi,
we are using a Java Mapping step in XI (not UDF). We need to have access to the filename. In the File Adapter we set the message attributes and can see the filename value in the SXMB_MONI.
We use the following code fragment to have access to the filename:
Container container = new Context(new FunctionWrapper(0));
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
String sourceFileName = conf.get(key);
This doesn't work. We think the declaration of the container class is wrong. Does anybody have some information about using the dynamic attributes in Java Mappings?
Thanks in advance
Michaelimport com.sap.aii.mapping.api.*;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
public class JavaProgram
implements StreamTransformation
public JavaProgram()
public void setParameter(Map map)
param = map;
if(param == null)
param = new HashMap();
public void execute(InputStream inputstream, OutputStream outputstream)
try
DynamicConfiguration dynamicconfiguration = (DynamicConfiguration)param.get("DynamicConfiguration");
DynamicConfigurationKey dynamicconfigurationkey = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
String s = dynamicconfiguration.get(dynamicconfigurationkey);
//Your logic
catch(Throwable throwable)
throwable.printStackTrace();
private Map param; -
How to find out the idoc type required for our requirement
Hi,
How to find out the list of available idoc type in SAP. It will be good if i get to know the table name where all the idoc type definitions are gets stored.
Say i have some requirement and for that requirement how i can find the proper idoc type to be used. (assume functional consultant is not providing that information)
Points will be given for the useful answers
Thanks,
PrasannaHi prasanna,
we can get SAP idoc types in tcode we31.For every requirment there will be different message type.
For example we want idoc type for account invoice receipt.
First find out message type for that purpose which can be found in we81-ACC_INVOICE_RECEIPT.
Get this message type and search in we82 where we can find message type and idoc type linkage.
try this way.
Reward if it is usful.
Thanks,
Srikanth.A -
Java Mapping Or Adapter Module for MultiLevel File Content Conversion ??
Hi Experts,
Hi All,
As we all know file content conversion cannot parse more than three level even if we use FCC paramenters or MessageTransform Bean /StrictXmlToPlain Bean.
Currently i am facing an scenario where i can expect an content coversion with four or five levels.
for ex.
Target Message Looks like
Header(0..1)
|_____X
|_____Y
|_____Detail(0.n)
|____A
|____B
|____SubDetail(0.n)
|_____Trailer(0.n)
|______rec1
|______rec2
|______rec3(0..n)
|______Subrec1
|______Subrec2
So my question how can i do the FixedLength/CSV in the target system ???
Shall i do java mapping ? if yes then any code example relevant to this type of scenario
Shall i do adapter module development ?if yes then any code example relevant to this type of scenario
Thanks In Advance
Ronit MishraTarget Message Looks like
Header(0..1)----
Level 1
|_____X
|_____Y
|_____Detail(0.n)----
Level 2
|____A
|____B
|____SubDetail(0.n)----
Level 3
|_____Trailer(0.n)----
Level 4
|______rec1
|______rec2
|______rec3(0..n)----
Level 5
|______Subrec1
|______Subrec2 -
Functional specification required for Me57 requirement
In SAP MM, Transaction ME57, I want to pull in the Common Inventory Quantity (Not Project or Sales Order Stock) of the Material which is maintained on the Purchase Requisition.
And also in the T code MB52 screen, the Inventory Quantity i want to bring it. It will be ALL Common Inventory in the Plant (minus Storage Loc a001 for Plant a000). Again, this should NOT pull in Project or Sales Order stock. Only Common Inventory.
I would like a rough functional specification draft ASAP. Pleas help.Hi prasanna,
we can get SAP idoc types in tcode we31.For every requirment there will be different message type.
For example we want idoc type for account invoice receipt.
First find out message type for that purpose which can be found in we81-ACC_INVOICE_RECEIPT.
Get this message type and search in we82 where we can find message type and idoc type linkage.
try this way.
Reward if it is usful.
Thanks,
Srikanth.A -
Java Mapping - add external jar for runtime use
Hi,
I have implemented a java mapping which executes an XSLT transformation on the input XML. This way I can control (I hope) what XSLT processor is used, as I want to use the SAXON XSLT processor. The java mapping executes fine locally in NWDS.
But when executed runtime I get the following error in default_trace and the message stops in Integration Engine:
javax.xml.transform.TransformerFactoryConfigurationError: Provider net.sf.saxon.TransformerFactoryImpl not found
In my java mapping I have set the following:
System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");
The TransformerFactoryImpl class is implemented in saxon9.jar.
Where do I store the saxon9.jar on the server so that it will find it during execution?
Any hints are most welcome!
Br,
KennethHi Kenneth,
First of all java mapping procedure has the capacity to transform XML using SAX or DOM parser directly. I am not sure as to why you need "SAXON XSLT processor" for the purpose.
Now coming to your question "Where do I store the saxon9.jar on the server so that it will find it during execution?"
In NWDS import the jar file saxon9.jar within your package, where you have written the source code. This you can do using File->import ->(ZIP or jar file). Before you import slect the package or folder where you want to import the jar file. Once jar file import is complete execute the code once, see if its running properly. Then choose file->export and select all *.java and *.class files in your package. Save this under one filename say package.jar.
Finally import this jar file in PI server by usual methods.
Hope this solves your problem
regards
Anupam -
Table details required for pegged requirements
Dear All,
I have the following scenario.
One child components is required for three different header materials. After MRP run, In MD04, three diffenerent planned orders will be there for child component for three reservations of three Header materials. I want to see the immediate header level of the child component through tables for report purpose. If you see through the function module MD_PEGGING or MD_PEGGING_NODIALOG, it is showing the top most header material. But it is not showing the immediate header material for the child component planned order. Please guide me to get the immediate header material through table or function module or any.
Thanks in advance.
Vijay.Check these tables.
MDTB,PLAF. -
Java Mapping (not UDF) and Adapter-Specific Message Attributes
Hello everybody,
is it possible to create an Adapter-Specific Message Attributes in a java Mapping?
I found in the SAP Help that the API com.sap.aii.mapping.api.DynamicConfiguration allows only to read, change or delete the attributes.
best regards.
Adnane ElgouteHi,
try the follwoing code
import com.sap.aii.mapping.api.*;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
public class JavaProgram
implements StreamTransformation
public JavaProgram()
public void setParameter(Map map)
param = map;
if(param == null)
param = new HashMap();
public void execute(InputStream inputstream, OutputStream outputstream)
try
DynamicConfiguration dynamicconfiguration = (DynamicConfiguration)param.get("DynamicConfiguration");
DynamicConfigurationKey dynamicconfigurationkey = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
String s = dynamicconfiguration.get(dynamicconfigurationkey);
//Your logic
catch(Throwable throwable)
throwable.printStackTrace();
private Map param; -
Select statement or a procedure or a function required for this requirement
i have 2 tables t1 and t2.
t1 contains 1 column,named as c_id
t2 contains 2 columns, named as tc_id and preceeding_c_id.
select * from t1;
c_id
100
200
300
400
select * from t2;
tc_id preceeding_c_id
150 100
180 150
100
190 180
210 200
250 210
260 250
Now my requirement is:
I need to send a parameter as :c_id = 100
the ouput should be as follows
100
150
180
190
:c_id = 200
the output should be as follows:
200
210
250
260
Thanks & RegardsSQL> variable c_id number
SQL> exec :c_id := 100
PL/SQL procedure successfully completed.
SQL> with t as (
2 select 150 tc_id, 100 preceeding_c_id from dual union all
3 select 180, 150 from dual union all
4 select 100, null from dual union all
5 select 190, 180 from dual union all
6 select 210, 200 from dual union all
7 select 250, 210 from dual union all
8 select 260, 250 from dual
9 )
10 select tc_id
11 from t
12 start with preceeding_c_id = :c_id
13 connect by preceeding_c_id = prior tc_id
14 union all
15 select :c_id
16 from dual
17 order by 1
18 /
TC_ID
100
150
180
190
SQL> exec :c_id := 200
PL/SQL procedure successfully completed.
SQL> /
TC_ID
200
210
250
260
SQL> SY. -
Logic required for the requirement (urgent)
HI experts,
can anyone help me out regarding the following logic.
The logic will check for both complete and partial goods receipts and invoice receipts. Based on the PO line item history it will calculate the totals into following categories:
(1) Total PO Line Item value with both GR & IR
(2) Total PO Line Item value with GR but no IR
(3) Total PO Line Item value with IR but no GR
For a single PO line, it is possible to have the Total Line Item Value divided into one or more of the above three categories at the same time. For example, if for a PO line item with 100 unit at $10.00 per unit, there is a GR for 50 Units and IR for only 30 units, the three columns above will be populated as:
(1) Total PO Line Item value with both GR & IR 30 x 10 = 300
(2) Total PO Line Item value with GR but no IR 20 x 10 = 200
(3) Total PO Line Item value with IR but no GR 0 x 10 = 0
Similarly, if for a PO line item with 100 units and $10.00 per unit, there is a GR for 50 units and IR for 70 units, the three columns will be populated as:
(1) Total PO Line Item value with both GR & IR 50 x 10 = 500
(2) Total PO Line Item value with GR but no IR 0 x 10 = 0
(3) Total PO Line Item value with IR but no GR 20 x 10 = 200
Regards,
NagarajMaybe this example will help....
report zrich_0002 .
data: iekbe type table of ekbe with header line.
data: xmbew type mbew.
data: xekpo type ekpo.
data: begin of ibuckets occurs 0,
ebeln type ekpo-ebeln,
ebelp type ekpo-ebelp,
pgrir type p decimals 2, " Total GR & IR
pgr type p decimals 2, " Total GR
pir type p decimals 2, " Total IR
pgrni type p decimals 2, "GR no IR
pirng type p decimals 2, "IR no GR
end of ibuckets.
parameters: p_ebeln type ekko-ebeln,
p_ebelp type ekpo-ebelp.
start-of-selection.
clear iekbe. refresh iekbe.
select * into table iekbe from ekbe
where ebeln = p_ebeln
and ebelp = p_ebelp
and vgabe in ('1','2').
loop at iekbe.
clear ibuckets.
ibuckets-ebeln = iekbe-ebeln.
ibuckets-ebelp = iekbe-ebelp.
select single * from ekpo into xekpo
where ebeln = iekbe-ebeln
and ebelp = iekbe-ebelp.
select single * from mbew into xmbew
where matnr = xekpo-matnr.
case iekbe-vgabe.
when '1'.
ibuckets-pgrir = iekbe-menge * xmbew-stprs.
ibuckets-pgr = iekbe-menge * xmbew-stprs.
when '2'.
ibuckets-pgrir = iekbe-menge * xmbew-stprs.
ibuckets-pir = iekbe-menge * xmbew-stprs.
endcase.
collect ibuckets.
endloop.
loop at ibuckets.
ibuckets-pgrni = ibuckets-pgr - ibuckets-pir.
ibuckets-pirng = ibuckets-pir - ibuckets-pgr.
if ibuckets-pgrni < 0.
clear ibuckets-pgrni.
endif.
if ibuckets-pirng < 0.
clear ibuckets-pirng.
endif.
modify ibuckets.
endloop.
loop at ibuckets.
write:/ ibuckets-ebeln,
ibuckets-ebelp ,
ibuckets-pgrir,
ibuckets-pgr ,
ibuckets-pir ,
ibuckets-pgrni ,
ibuckets-pirng .
endloop.
Regards,
Rich Heilman -
UDF in message mapping instead of Java Mapping. Pls advice urgent
Hi All,
My scenario
CRM --- XI -- CRM
In XI I have to open socket connection.
Pls refer link:
/people/saravanakumar.kuppusamy2/blog/2005/12/15/socket-integration-with-xi
Can Java Mapping code given in above link for socket connection can be used in Message Mapping (CRM -- CRM)UDF?
Pls advice urgent
RegardsHi Henry,
I understood your requirement.
But as per the architecture of XI/PI some message has to trigger your scenario.
In this case there is no adapter where you can directly communicate with CRM system.
Do one thing configure a dummy scenario on the sender side.
Use File adapter for simplicity. once it pools the file with some dummy data in the file it comes to Interface mapping(message mapping) of the PIPELINE steps. Now use the code as you mentioned above(within UDF) for opening socket to CRM system and implement you business logic within that program and write the response to target interface which will infact talk with CRM system.
Dont forget to do the coding in an infinite loop with some delay (if required). Other wise every time you have to put a message for File Adapter for triggering purposes.
You can also acheive the same if you use Java Mapping instead of Graphical mapping with UDF(code for Opening socket and business logic). I suggest you to use Java Mapping.
I dont know how you will comunicate with CRM system on receiver side.?
Thanks,
Gujjeti -
Need a Pegging module for dependent requirements.
Hi
Need a Pegging functional module for dependent requirements.
There is MD_PEGGING_NODIALOG ,where we need to pass the planned order number.
Please advise how to get the pegged requirements for dependent requirements or other MRP elements other than planned order.
Thanks
PrasadHello,
Function module MD_PEGGING_NODIALOG works with data structures of MRP list or current requirements/stock list. For a given material, you first need to fetch the relevant structures by the help of following FMs; BAPI_MATERIAL_MRP_LIST and BAPI_MATERIAL_STOCK_REQ_LIST. You can loop at the structures exported by these FMs and run MD_PEGGING_NODIALOG with the corresponding parameters of the MRP element you require. You can run MD_PEGGING_NODIALOG with any MRP element you like as in MD04 and MD05 transactions.
Regards. -
Problem in Uploading Java mapping Code
Hi Guys,
I never work on Java mapping before, i got the code required for my progrmme in these forums.So i saved it as a text file. now i want to import that fileintomy programme as Java class. i think i have to use Netweaver Studio. what exactly i have o do it.
Thanks in advance.
KartikHello Kartik,
If your code is handling the Required Mapping.Then what is you need to do is :
Create the Jar file using any Java IDE (or) use Netweaver developer studio.
Before creating the u201Cjaru201D file just make sure that the "path" of the class file in the imported archive. It should be the
same as your "package" path.
Once the class file is created, we have to create the jar file with all the necessary files. After creating the jar file, it
has to be deployed to XI.
Import the Jar file using Imported Archive in IR under Mapping Objects.
See this blog it explains how to load :
Java Mapping (Part III)
After doing the necessary setps you can test the Mapping.
regards
Gangaprasad -
How to set adapter specific message attributes on Pi 7.1 inside a Java map.
Hello,
how can I set adapter specific message attributes in a Java mapping on PI 7.1.? The TransformationInput grants access to the DynamicConfiguration but the TransformationOutput doesn't. I have found threads refering to the old way of implementing Java mappings (e.g. Get dynamic filename in a Java Mapping (NOT UDF)). But there doesn't seem to be one refering to the actual PI.
Kind regards,
HeikoUsing DynamicConfiguration from the TransformationInput works.
-
Issue with java mapping in a multi-mapping scenario
Hi
We have a 1:n multiple mapping scenario in XI and the source is R3 proxy and target side is files. So, creating multiple file from a single message from R3 .
R3 --> XI --> Multiple files
Structure of the output of the multi-mapping is
- <ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
- <ns0:Message1>
<Transaction>
</Transaction>
<Transaction>
</Transaction></ns0:Message1>
</ns0:Messages>
wherein each Transaction node represents a file.
Now, we need to introduce a constant /string like
<!DOCTYPE Transaction PUBLIC \"-//XXXXXX//DTD BatchReceiptAuthorization//EN\" \"http://dtd.XXXXXXX.com/dtds/ReceiptAuthorization.dtd\">
on each of the files at the very beginning - i.e within each transaction node , in the above structure, we need the above DTD string to be written. To do this, we added a java mapping as the second mapping after the message mapping that creates this string. Is this the right approach and would it produce what we are expecting ?
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.Map;
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.StreamTransformationConstants;
import com.sap.aii.mapping.api.DynamicConfiguration;
import com.sap.aii.mapping.api.AbstractTrace;
public class ModifyRootAndDelay implements StreamTransformation {
AbstractTrace myTrace;
public void execute(InputStream input, OutputStream output) throws StreamTransformationException {
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(input));
String NameSpacePrefix = "<!DOCTYPE Transaction PUBLIC \"-//innotrac//DTD BatchReceiptAuthorization//EN\" \"http://dtd.innotrac.com/dtds/ReceiptAuthorization.dtd\">";
String sLine = null;
StringBuffer XmlMsg= new StringBuffer();
String Result,PayloadBody;
int indexOfFirst;
while ((sLine = reader.readLine()) != null) {
XmlMsg.append(sLine);
String StartingTag = XmlMsg.toString();
indexOfFirst = StartingTag.indexOf("<MerchantID>") ;
PayloadBody=new String(XmlMsg.substring(indexOfFirst));
Result=NameSpacePrefix.concat(PayloadBody);
output.write(Result.getBytes());
/* Thread.sleep(200000); */
}catch(Exception e){
myTrace.addWarning("Exception raised in the JavaMapping:modifyNamespace.java""\n The Exception Message: " e.getMessage());
throw new RuntimeException(e.getMessage()) ;
} public void setParameter(Map param) {
myTrace = (AbstractTrace) param
.get(StreamTransformationConstants.MAPPING_TRACE);Hi XI Gurus
In my scenario, I sent the inputstream that is being passed to the Java execute method - to trace and I see that the whole of the xml file - as shown below - which is the output of message mapping ( from the first mapping step ) in sent to the execute method of the java mapping a single call
<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
<ns0:Message1>
<Transaction> </Transaction>
<Transaction> </Transaction>
</ns0:Message1>
<ns0:Messages>
So, I modified Java mapping program to look for multiple occurences of <Transaction> tag and prefix them with my constant DTD Literal - which is the primary reason , why I had to use Java mappings after the message mapping.
Now, I get an error is XI- SXMB_MONI
- <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
<SAP:Category>XIServer</SAP:Category>
<SAP:Code area="MAPPING" />
<SAP:P1>unexpected symbol; expected '<', '</', entity refe</SAP:P1>
<SAP:P2>rence, character data, CDATA section, processing i</SAP:P2>
<SAP:P3>0</SAP:P3>
<SAP:P4>113</SAP:P4>
<SAP:AdditionalText />
<SAP:ApplicationFaultMessage namespace="" />
<SAP:Stack>The exception occurred (program: CL_XMS_MAIN===================CP, include CL_XMS_MAIN===================CM00A, line: 609)</SAP:Stack>
<SAP:Retry>M</SAP:Retry>
</SAP:Error>
Should I create multiple outputs - as many as the numberof target split files ( of type outputstream ) from the execute method in the java program ?
Maybe you are looking for
-
My sound does not work on my computer
Hey I don't know if anyone can help me but my sound is not working on my computer. I went to my system preferences and when I click on output it says that the device has no output controls. I don't know why it is doing this. Can anyone help me to sol
-
I am unable to stream video and I lose connection frequently. Ive tried it using wireless connection and with ethernet. Ive tried using the O2 router (%series) as a modem for the extreme, Ive tried using the O2 without the extreme - not poss to exten
-
BAPI_SALESORDER_CREATEFROMDAT2 Multiple Line Items
Hi How do I implement BAPI_SALESORDER_CREATEFROMDAT2 for multiple line items. I am currently doing this to create a new SO: loop at it_item into wa_item where group = wa_head-group. add 10 to lv_item. lw_item-itm_number = lv_item.
-
I WANT TO KNOW IF THE XA 20 CAMCORDER HAS ENOUGH IR ILLUMINATION POWER TO RECORD STARS,SATTELITES ,POSSIBLE UFOS . WILL IT BE A GRAINY MESS OR WILL THERE BE SOMETHING OF IDENTIFIABLE RESOLUTION? Solved! Go to Solution.
-
Hi All, I am learning J2EE technology. Please suggest me any book which gives complete procedures like packaging an application in war, ear format, deploying applications, web applications directory structure and other details on various application