Adapter module to insert into DB
Hello,
is it possible to write an adapter module which will insert whole payload into predefined table in DB?
Can you please provide me hints, how to do it?
Is it possible to use Java JDBC API in it, or do you have any best practices/cookbooks?
The reason why I need this:
I have to save all incoming and all outgoing payloads into audit DB table for archiving purposes - So my plan is to write adapter module and put it in Sender and Receiver channel in SOAP Adapter.
I have found this useful link Database Handling in SAP PI Map Using JDBC API
But this is jdbc inside mapping. Anybody tried to do database INSERT in custom adapter module inside SOAP Adapter?
Similar Messages
-
JDBC Receiver adapter Error for insert into DB2 table
Hi all,
I want to insert data into a DB2 table on AS400 via a Receiver JDBC adapter.
The communication channel seems to be ok but when I try to send the message, I obtain the following message on the adapter monitoring :
Error: TransformException error in xml processor class, rollback:
Error processing request in sax parser: Error when executing statement for table/stored proc. 'GIK.GDT01' (structure 'Statement'): java.sql.SQLException: La table GDT01 de la bibliothèque GIK est incorrecte pour cette opération.
Could someone help me?
In the communication channel I have seen we can choose "native SQL String" as message protocol.
Do you think it could be a workaround for me? if yes, could someone send me an example about it?
thanks a lot,
PhilippeHi,
Try to remove GIK.GDT01 in table tag of your XML structure and put GDT01 alone and see.
The solution to your problem is found on this particular link.
http://www.websina.com/bugzero/faq/exception-as400.html
Tell me if it works
Best regards,
Felix -
Adapter Module Error-Sending excel file as an attachment of the mail
Hi ,
My scenario is as follows
1)I am sending an excel file as an attachment of the mail.I need to read that excel attachment as a payload.
So mail adapter is used in sender side.
To configure this, have used standard PayloadSwapBean module with proper module key.
Next to convert excel to XML another custom adapter module is being used.
Both this adapter module , I configured into the CC of sender mail adapter.
The order in which adapter modules are being used in the sender CC are as follows
1)localejbs/AF_Modules/PayloadSwapBean
2)localejbs/MDPExcelToXMLConversion
3)sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean
MDPExcelToXMLConversion-Custom adapter module written to convert excel to xml.
I am getting the following error
exception caught during processing mail message [4899]com.sap.aii.af.lib.mp.module.ModuleException
And also,
no messages in coming MONI of PI.
Pls suggest what to do.
Thanks
AyanShabarish,
Will the ordering in which the adapter modules(In this case there are two-PayloadSwapBean & MDPExcelToXML) are appearing into Module tab of sender adapter matter?
Firstly, what is happenning
1)If I take out the custom adapter module MDPExcelToXML and put only PayloadSwapBean then it is successfully converting mail attachment into the main Payload i.e PayloadSwapBean module is working.
2)Nextly, my local code( i.e java code without including standard Module specific method like ejbActivate(),ejbPassivate(),process() etc etc.)) for MDPExcelToXML is successfuly converting the excel file into the XML file.Then I am making the local code into adapter module specific code and deploying that.
A few question arises here,
Do I need to do any specific configurations here in PI for this particular things.Maybe both the adapter module is clashing with each other.
And also using tracing and logging into my custom adapter module code.Getting the following error,
java.io.IOException: Unable to read entire header; 116 bytes read; expected 512 bytes#
Thanks
Ayan -
Issue in calling Adapter Module
Hi experts,
We have a File -
> IDoc scenario where the file has got fixed length data. The data is in the following format:
Header xdfsdfefefeswefr
Detail dfdkfereorierwer
Detail fdfkjwoeiefiwere
Detail
Trailer erererewoirwoiwe
We do not have any identifier to identify the header, detail and trailer record.
We have gone for custom java adapter module which inserts H, D, T as the first character of each line in the file to identify the Header, Detail and Trailer nodes.
We added a entry for calling the adapter module under the module tab in file sender communciation channel. The EAR for adapter module has been deployed successfully.
But we are unable to call the adapter module at runtime.
The channle log has no indication wrt to the module being called.
We are on SAP XI 3.0 SP17
If any one has faced a similar issue. Please respond and your help would be highly appreciated.
regards,
YounusHi,
Check this document.Nice document on adding an adpater module at runtime.
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00838345-708c-2a10-1199-9514c0b0a91c
this forum replies too..
Reg Integration Scenario
Thanks,
Vijaya. -
Hi Friends
Iam trying to insert a record in MSAccess table from a legacy file. I could establish the connection to MSAccess and could able to retrive the data from it. But while inserting it gives me an error:
<b>Receiver Adapter v1109 for Party '', Service 'ORACLE_SERVER_BS':
Configured at 11:41:23 2005-10-24
Last message processing started 12:18:28 2005-10-24, Error: TransformException error in xml processor class, rollback:
Error processing request in sax parser: Error when executing statement for table/stored proc. 'VendorMaster': java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
at com.sap.aii.adapter.jdbc.xml2sql.service(xml2sql.java:179)
at com.sap.aii.adapter.jdbc.XI2JDBC.onInternalMessage(XI2JDBC.java:347)
at com.sap.aii.adapter.jdbc.SapAdapterServiceFrameImpl.callSapAdapter_i(SapAdapterServiceFrameImpl.java:170)
at com.sap.aii.adapter.jdbc.SapAdapterServiceFrameImpl.callSapAdapter(SapAdapterServiceFrameImpl.java:146)
at com.sap.aii.af.modules.CallAdapterWithMessageBean.process_receiver(CallAdapterWithMessageBean.java:204)
at com.sap.aii.af.modules.CallAdapterWithMessageBean.process(CallAdapterWithMessageBean.java:159)
at com.sap.aii.af.mp.module.ModuleLocalLocalObjectImpl1.process(ModuleLocalLocalObjectImpl1.java:103)
at com.sap.aii.af.mp.ejb.ModuleProcessorBean.process(ModuleProcessorBean.java:221)
at com.sap.aii.af.mp.processor.ModuleProcessorLocalLocalObjectImpl0.process(ModuleProcessorLocalLocalObjectImpl0.java:103)
at com.sap.aii.af.listener.AFWListenerBean.onMessage(AFWListenerBean.java:220)
at com.sap.aii.af.listener.AFWListenerLocalObjectImpl0.onMessage(AFWListenerLocalObjectImpl0.java:103)
at com.sap.aii.af.ra.ms.impl.ServicesImpl.deliver(ServicesImpl.java:274)
at com.sap.aii.adapter.xi.ms.XIEventHandler.onDeliver(XIEventHandler.java:653)
at com.sap.aii.af.ra.ms.impl.core.queue.ReceiveConsumer.invokeHandler(ReceiveConsumer.java:374)
at com.sap.aii.af.ra.ms.impl.core.queue.ReceiveConsumer.onMessage(ReceiveConsumer.java:98)
at com.sap.aii.af.ra.ms.impl.core.queue.Queue.run(Queue.java:448)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)</b>
The structure for the target field is
VendorMaster_DT
>Insert
>>VendorMaster
action
table
>>>access
VendorNumber
LastNameHi,
<i>java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] <b>Syntax error in INSERT INTO statement.</b>at com.sap.aii.adapter.jdbc.xml2sql.service(xml2sql.java:179)</i>
looks like your insert statement in the inbound message is wrong, check your inbound message...
naveen -
hi,guruvulu
this is the program...............to insert the data into sap r/3 table
but record is not inserting....any commit i have to write in my program?
Created on Feb 20, 2007
TODO To change the template for this generated file go to
Window - Preferences - Java - Code Style - Code Templates
package comm;
@author sapusr006
TODO To change the template for this generated type comment go to
Window - Preferences - Java - Code Style - Code Templates
Example2.java
Property of SAP AG, Walldorf
(c) Copyright SAP AG, Walldorf, 2000-2005.
All rights reserved.
//import java.sql.Connection;
//import java.sql.PreparedStatement;
import com.sap.mw.jco.IFunctionTemplate;
import com.sap.mw.jco.IRepository;
import com.sap.mw.jco.JCO;
@version 1.0
@author SAP AG, Walldorf
public class Fm {
// The MySAP.com system we gonna be using
static final String SID = "R3";
// static String query="insert into BAPI_COMPANYCODE_GETLIST values(?,?)";
// The repository we will be using
IRepository repository;
//ESTABLISHING A CONNECTION TO SAP
public Fm()
try {
JCO.addClientPool( SID, // Alias for this pool
10, // Max. number of connections
"800", // SAP client
"RFCTEST", // userid
"welcome", // password
"EN", // language
"10.10.88.170", // host name
"01" );
// Create a new repository
// The repository caches the function and structure definitions
// to be used for all calls to the system SID. The creation of
// redundant instances cause performance and memory waste.
repository = JCO.createRepository("MYRepository", SID);
catch (JCO.Exception ex) {
System.out.println("Caught an exception: \n" + ex);
// RETRIEVES AND DISPLAY A ZHR INFOTYPE OPERATION
public void salesOrders()
JCO.Client client = null;
try {
// Get a function template from the repository
//System.out.println("goes to sales order");
IFunctionTemplate ftemplate = repository.getFunctionTemplate("ZHR_INFOTYPE_OPERATION");
System.out.println("hai");
if(ftemplate != null) {
// Create a function from the template
JCO.Function function = ftemplate.getFunction();
JCO.ParameterList paralist=function.getImportParameterList();
paralist.setValue("0000000011","PERNR");
paralist.setValue("UPD","ACTIO");
paralist.setValue("A","TCLAS");
System.out.println("hello");
paralist.setValue("20061215","BEGDA");
System.out.println("hello");
paralist.setValue("20061215","ENDDA");
paralist.setValue("1","OBJPS");
paralist.setValue("LTA","SUBTY");
System.out.println("SETTING VALUES");
// Get a client from the pool
client = JCO.getClient(SID);
System.out.println("goes to sales order");
//function.getImportParameterList().setValue("QUERY_TABLE","ZHRJ2EETEST");
//EXECUTING THE FUNCTION
client.execute(function);
System.out.println("after exeucting the function");
// NO OF IMPORT PARAMS IT DISPLAY
//STRUCTURE
JCO.Structure returnStructure =
function.getExportParameterList().getStructure("RETURN");
String structure=returnStructure.toString();
System.out.println(structure);
JCO.Table sales_orders = function.getTableParameterList().getTable("PROPOSED_VALUES");
System.out.println("after function");
System.out.println("proposed111"+sales_orders.getNumRows());
sales_orders.firstRow();
sales_orders.appendRows(3);
sales_orders.setValue("0582","INFTY");
sales_orders.setValue("P0582-AMTEX","FNAME");
sales_orders.setValue("200.00","FVAL");
sales_orders.nextRow();
sales_orders.setValue("0582","INFTY");
sales_orders.setValue("P0582-JBGDT","FNAME");
sales_orders.setValue("20061215","FVAL");
sales_orders.nextRow();
sales_orders.setValue("0582","INFTY");
sales_orders.setValue("P0582-JENDT","FNAME");
sales_orders.setValue("20061215","FVAL");
System.out.println("proposed222"+sales_orders.getNumRows());
/*for (int i = 0; i <sales_orders.getNumRows(); i++) {
sales_orders.setRow(i);
System.out.println(sales_orders.getString("INFTY"));
JCO.Table sales_orders1 = function.getTableParameterList().getTable("MODIFIED_KEYS");
System.out.println("modified"+sales_orders1.getNumRows());
sales_orders1.setRow(1);
sales_orders1.appendRows(1);
sales_orders1.setValue("0000000011","PERNR");
sales_orders1.setValue("0582","INFTY");
sales_orders1.setValue("LTA","SUBTY");
sales_orders1.setValue("1","OBJPS");
sales_orders1.setValue("20061215","BEGDA");
sales_orders1.setValue("20061215","ENDDA");
System.out.println("modified222"+sales_orders1.getNumRows());
System.out.println("execute222"+sales_orders1.getNumRows());
for (int i = 0; i <sales_orders1.getNumRows(); i++) {
sales_orders.setRow(i);
System.out.println("hia"+sales_orders1.getString("SUBTY"));
System.out.println("NO OF ROWS ARE:---"+ sales_orders.getNumRows());
String fieldName[]=new String[sales_orders.getFieldCount()];
System.out.println("THE COLUMNS IN THE TABLE ARE:--"+sales_orders.getFieldCount());
// sales_orders.firstRow();
//COLUMNS NAMES
System.out.println(fieldName.length);
for (int iCtrst = 0;iCtrst < sales_orders1.getFieldCount();iCtrst++) {
fieldName[iCtrst] = sales_orders1.getName(iCtrst);
System.out.println(fieldName[iCtrst]);
if (sales_orders.getNumRows() > 0) {
// Loop over all rows
do {
System.out.println("----
//int r=1;
// Loop over all columns in the current row
for (JCO.FieldIterator e = sales_orders.fields(); e.hasMoreElements();)
JCO.Field field = e.nextField();
String compcode=field.getString();
//pst.setString(r,compcode);
System.out.println(field.getName() + ":\t" + field.getString());
// r++;
}//for
// i=pst.executeUpdate();
} while(sales_orders.nextRow());
else {
System.out.println("No results found");
if (sales_orders1.getNumRows() > 0) {
// Loop over all rows
do {
System.out.println("----
//int r=1;
// Loop over all columns in the current row
for (JCO.FieldIterator e = sales_orders1.fields(); e.hasMoreElements();)
JCO.Field field1 = e.nextField();
//String compcode=field1.getString();
//pst.setString(r,compcode);
System.out.println(field1.getName() + ":\t" + field1.getString());
// r++;
}//for
// i=pst.executeUpdate();
} while(sales_orders1.nextRow());
else {
System.out.println("No results found");
System.out.println("modified"+sales_orders1.getNumRows());
System.out.println("modified"+sales_orders.getNumRows());
//if
/* if(i>=1)
System.out.println("\t\t\tUpdated ORACLE successfully");
else {
System.out.println("FUNCTION MODULE not found in backend system.");
}//if
catch (JCO.AbapException ex) {
System.out.println("Caught an exception: \n" + ex);
}catch(Exception en){en.printStackTrace();}
finally {
JCO.releaseClient(client);
protected void cleanUp() {
JCO.removeClientPool(SID);
public static void main(String[] argv)
Fm e=new Fm();
// e.systemInfo();
e.salesOrders();
e.cleanUp();
output:
TABLE: MODIFIED_KEYS
TABLE: PROPOSED_VALUES
IMPORT ACTIO
IMPORT BEGDA
IMPORT DIALOG_MODE
IMPORT ENDDA
IMPORT LUW_MODE
IMPORT MASSN
IMPORT NO_ENQUEUE
IMPORT NO_EXISTENCE_CHECK
IMPORT OBJPS
IMPORT PERNR
IMPORT PERSG
IMPORT PERSK
IMPORT PLANS
IMPORT SEQNR
IMPORT SPRPS
IMPORT SUBTY
IMPORT TCLAS
IMPORT WERKS
EXPORT HR_RETURN
EXPORT RETURN
EXPORT RETURN1
appending
NO OF ROWS ARE:---3
THE COLUMNS IN THE TABLE ARE:--4
INFTY: 0582
FNAME: P0582-AMTEX
FVAL: 200.00
SEQNR: 00
INFTY: 0582
FNAME: P0582-JBGDT
FVAL: 20061215
SEQNR: 00
INFTY: 0582
FNAME: P0582-JENDT
FVAL: 20061215
SEQNR: 00
PERNR: 00000011
INFTY: 0582
SUBTY: LTA
OBJPS: 1
SPRPS:
ENDDA: 2006-12-15
BEGDA: 2006-12-15
SEQNR: 000hi jagadesh,
ur code is very length to see.
see the following code ,
JCO.Function objFunction =
this
.objIRepository
.getFunctionTemplate("BAPI_MATERIAL_AVAILABILITY")
.getFunction();
objFunction.getImportParameterList().setValue(strPlant, "PLANT");
objFunction.getImportParameterList().setValue(strMaterial, "MATERIAL");
objFunction.getImportParameterList().setValue(strQuantity, "UNIT");
this.objClient.execute(objFunction);
JCO.Structure ret =
objFunction.getExportParameterList().getStructure("RETURN");
String strRetMsg = ret.getString("MESSAGE");
System.out.println(strRetMsg); // it will tell whether record is inserted or not
/*JCO.Function objFunction1 =
this
.objIRepository
.getFunctionTemplate("BAPI_TRANSACTION_COMMIT")
.getFunction();
objFunction1.setValue("",WAIT);
objClient.execute(objFunction1);*/
CHECK THE RETURN MSG .IT WILL TELL THE PROBLEM
give me points if it is useful
regards
Guru
Message was edited by:
Guruvulu Bojja
Message was edited by:
Guruvulu Bojja
Message was edited by:
Guruvulu Bojja -
ModuleData.getPrincipalData returns null in the adapter module development
Hi gurus,
i am doing a test on the adapter module development following an article written by William Li:
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0ac06cf-6ee2-2c10-df98-e17430ca5949?QuickLink=index&overridelayout=true
my problem is after the EJB has been deployed, it seems that the return of inputModuleData.getPrincipalData() is always null which makes the program can not get the xml payload from the framework.
the main process of the example has been simplified like this:
public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData) throws ModuleException {
Object obj = null;
try {
obj = inputModuleData.getPrincipalData();
Message msg1 = (Message) obj;
XMLPayload xmlpayload = msg1.getDocument();}
catch (Exception e) {
ModuleException me = new ModuleException(e);
throw me;
return inputModuleData;
after deployed, i get the following error in the adapter monitor of RWB: (my JNDI is testtest)
17.02.2012 17:13:44.643 Information Send binary file "test8.xml" from FTP server "10.18.48.150:/encrypt_test/", size 206 bytes with QoS EO
17.02.2012 17:13:44.644 Information MP: processing local module localejbs/CallSapAdapter
17.02.2012 17:13:44.644 Information Application attempting to send an XI message asynchronously using connection File_http://sap.com/xi/XI/System
17.02.2012 17:13:44.645 Information Trying to put the message into the send queue
17.02.2012 17:13:44.648 Information MP: processing local module localejbs/testtest
17.02.2012 17:13:44.648 Error MP: exception caught with cause java.lang.NullPointerException: while trying to invoke the method com.sap.engine.interfaces.messaging.api.Message.getDocument() of an object loaded from local variable 'msg1'
whereas if the code has been changed like this:
public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData) throws ModuleException {
Object obj = null;
try {
obj = inputModuleData.getPrincipalData();
Message msg1 = (Message) obj;
if (obj != null )
XMLPayload xmlpayload = msg1.getDocument();
catch (Exception e) {
ModuleException me = new ModuleException(e);
throw me;
return inputModuleData;
the file can be read by the file adapter.
i just quite confused that why the return of the getPrincipalData() is null? where is the problem? thanks
Edited by: Stephen Xue on Feb 17, 2012 5:22 AMI'm gonna reply to myself here. I changed the processing sequence of the adapter modules in the in the FileSender channel so that my module comes first then CallSapAdapter. Then getPrincipalData() contains the message.
Hope this helps someone else. -
Is the Mini-Dvi adapter suppose to click into the back on the Mac mini?
Is the Mini-Dvi adapter suppose to click into the back on the Mac mini? It does on my mac book but not on the Mac mini. I sort of have to just jam it in there, no nice clicking sound, and it does not feel very secure.
If after 'jamming it in there' it actually works, then at least you know it's the correct type of adapter. However, if it doesn't work, you are definitely not inserting it correctly or into the correct location. In either case, you may have a damaged port - all the connections on the rear when applied correctly with anything like a decent quality standard type connector should work smoothly. You should never have to 'jam' anything into the back of your mini.
-
Error while insert into database using DB adpater for Field BLOB
Hello All
I am trying to tranfer data from Database A to Database B using Oracle DB adapter.
Table of databse A contains field BLOB, which cotains the resume /doc file.After transformation in Database B format ,while invoking the DB adapter to insert, I am getting follwing error
<bindingFault xmlns="http://schemas.oracle.com/bpel/extension"><part name="code"><code>null</code>
</part><part name="summary"><summary>file:/u01/bpelvinc/product/10.1.3.1/OracleAS_1/bpel/domains/viapps/tmp/.bpel_ERecuit_Application_New_1.0_d1c2b2149a9e0c7c745279667ad1fc84.tmp/DB_APPL_111.wsdl [ DB_APPL_111_ptt::insert(RtmApplicantCollection) ] - WSIF JCA Execute of operation 'insert' failed due to: DBWriteInteractionSpec Execute Failed Exception.
insert failed. Descriptor name: [DBAPPL111.RtmApplicant]. [Caused by: Error in encoded stream, got 2]
; nested exception is:
ORABPEL-11616
DBWriteInteractionSpec Execute Failed Exception.
insert failed. Descriptor name: [DBAPPL111.RtmApplicant]. [Caused by: Error in encoded stream, got 2]
Caused by Exception [TOPLINK-3001] (Oracle TopLink - 10g Release 3 (10.1.3.3.0) (Build 070608)): oracle.toplink.exceptions.ConversionException
Exception Description: The object [xs:base64Binary 43524541544520544193B0D0A], of class [class java.lang.String], could not be converted to [class java.sql.Timestamp].
Internal Exception: java.io.IOException: Error in encoded stream, got 2.
</summary>
</part><part name="detail"><detail>
Exception Description: The object [xs:base64Binary 4352E616D65293B0D0A], of class [class java.lang.String], could not be converted to [class java.sql.Timestamp].
Internal Exception: java.io.IOException: Error in encoded stream, got 2</detail>
</part></bindingFault>
Please let me know ,what are the possibilities.
Thanks
SatendraHi...
well... My flow goes like Pl/SQl ---> BPEL,
Now PL/SQL code reads data from the Database A and Send it to BPEL which inserts into the Database B.
with respest to above design, I found the problem in pl/sql block.
Actually I am sending a BLOB field in the soap message. but some how pl/sql now ablt tot handle that or sending some wrong data.
my question is how to send a blob filed data to bpel using pl/sql block. this the reasion I am getting above error.
Thanks -
Adapter module to enhance File adapter
Hey guys
i need a small clarification regarding adapter modules.
is it possible via adapter modules to enhance the File adapter to such an extent that it can deliver files to two separate systems in separate landscapes.
i know i can design one more receiver determination and can also use Run OS command options,but modules in general give better performance compared to others so just wan't to explore a little bit more about them.
Thanx
AamirHey Aamir,
yeah, they do take a lot of resources, but that's how XI was built to work.
What you're trying to do is a workaround and may not get support from SAP.
If I have understood right, you still wanna maintain the endpoint connection data in the communication channels but want to acces them directly without going through the technical routing pipeline, is that so?
If that's it, I'm sorry but I cannot help you any further.
The only way I know of accessing adapters without going throught technical routing is by using lookup API (RFC, JDBC, Soap) but it is not intended for endpoint scenarios (insert, update etc), mainly for simple read (lookups).
If maintaining the connection data outside adapters is not a concern, you could try to create the connections directly in Java code, inside java proxies.
Regards,
Henrique. -
Help required in File Adapter Module Development
Hi All,
I am working out a File to File scenario where my source file is in some different format. Please find the below sample:
<Root>
<ID>100</ID>
<NAME>SAP</NAME>
<END-Root>
Before taking this into IS, I need to change the file to a proper XML format. I need to replace "END-" with "/".
<?xml version="1.0" encoding="UTF-8" >
<Root>
<ID>100</ID>
<NAME>SAP</NAME>
</Root>
I think I can achive this by developing Adapter Modules. I am new to Adapter Module development.
Can you please tell me if there are any inbuilt Adapter Modules for this. If not please suggest me some relevant blogs to solve this issue. Thanks in Advance.Hi Phani Kumar
There are more than one ways to do this. As per your timelines and skill set you can decide
1. You can use the XMLAnonymizerBean this is an inbuilt module
Check Stefen's blog
Remove namespace prefix or change XML encoding with the XMLAnonymizerBean
2. You can read this complete file in a single field and then you can create XSLT or Java mapping to parse it in a target XML you desire.
Check these
https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/3823 [original link is broken] [original link is broken] [original link is broken](XSLT mapping)
Java Mapping (Part I) (Java Mapping)
The specified item was not found. (Java Mapping helper DOM)
The specified item was not found. (XML Node into string)
3. You can develop Adapter modules for this
Refer
Check Guides
XI 3.0
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3bdc14e1-0901-0010-b5a9-a01e29d75a6a
PI 7.0
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f013e82c-e56e-2910-c3ae-c602a67b918e
PI 7.1
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00838345-708c-2a10-1199-9514c0b0a91c -
RFC enabled function module for insert update and delete in a Ztable..
friends..
Is there any standatd RFC enabled function module to insert , update and delete data in a custom database-table (Ztable)? if not how can we create it? plz give me the details steps..
what are the import, export parameters and how to develop and process it.. (for example: suppose fields in the table is Emp_Id, Name, Address)
Thanks and RegardsHi,
Try this code.
REPORT ZMMC071Z_RMV.
TYPE-POOLS : ABAP.
FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
<DYN_WA>,
<DYN_FIELD>,
<LV_CONDI>.
DATA: DY_TABLE TYPE REF TO DATA,
DY_LINE TYPE REF TO DATA,
XFC TYPE LVC_S_FCAT,
IFC TYPE LVC_T_FCAT.
SELECTION-SCREEN BEGIN OF BLOCK F1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_TABLE LIKE DD02L-TABNAME OBLIGATORY.
SELECTION-SCREEN END OF BLOCK F1.
Evento: At Selection Screen *
START-OF-SELECTION.
PERFORM GET_STRUCTURE.
PERFORM CREATE_DYNAMIC_ITAB.
PERFORM GET_DATA.
END-OF-SELECTION.
*& Form get_structure
text
FORM GET_STRUCTURE.
DATA : IDETAILS TYPE ABAP_COMPDESCR_TAB,
XDETAILS TYPE ABAP_COMPDESCR.
DATA : REF_TABLE_DES TYPE REF TO CL_ABAP_STRUCTDESCR.
DATA VL_LENGHT(30).
Get the structure of the table.
REF_TABLE_DES ?=
CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME( P_TABLE ).
IDETAILS[] = REF_TABLE_DES->COMPONENTS[].
LOOP AT IDETAILS INTO XDETAILS.
CLEAR XFC.
XFC-FIELDNAME = XDETAILS-NAME .
XFC-DATATYPE = XDETAILS-TYPE_KIND.
XFC-INTTYPE = XDETAILS-TYPE_KIND.
XFC-INTLEN = XDETAILS-LENGTH.
XFC-DECIMALS = XDETAILS-DECIMALS.
APPEND XFC TO IFC.
ENDLOOP.
ENDFORM. "get_structure
*& Form create_dynamic_itab
text
FORM CREATE_DYNAMIC_ITAB.
Create dynamic internal table and assign to FS
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = IFC
IMPORTING
EP_TABLE = DY_TABLE.
ASSIGN DY_TABLE->* TO <DYN_TABLE>.
Create dynamic work area and assign to FS
CREATE DATA DY_LINE LIKE LINE OF <DYN_TABLE>.
ASSIGN DY_LINE->* TO <DYN_WA>.
ENDFORM. "create_dynamic_itab
*& Form get_data
text
--> p1 text
<-- p2 text
FORM GET_DATA .
*Get data from p_table into internal table <DYN_TABLE>
SELECT * INTO TABLE <DYN_TABLE>
FROM (P_TABLE)
Here you can implemente function DELETE, INSERT.
ENDFORM. " De_para -
Import parametes and insert into database table suggestions
experts need suggestions
created a table with 3 fields.
zstable.
field dataelement type length
kunnr kunnr char 10 key field
name dname char 30 key field
aedat aedat dats 8
aenam aenam char 12
now i am creating a function modlue with two input parameters
1)kunnr
2)name
i want to update this two fields into table zstable.
1. so suggest me the best way to do this.
Delcarations in import options which one of the below is best and why?
name type char30
kunnr type kunnr
or
name like zstable-name
kunnr like zstable-kunnr
or
kunnr type zstable-kunnr
name type zstable-name.
2. inserting into table
the data that we recieve from the import parameters need to be inserted into the zstable.
please suggest me the appropriate statement waht i need to code for this.
insert kunnr name into zstable.
can i ignore the third field as it is not the key field?
3. before inserting do i need to check whether kunnr and uname is initial ie import parametrs?
4. suppose if i delcared two input parameters in function module zfuntion say vbeln and posnr.
and source code
insert vbeln and posnr into zstable.
now i am calling from the program
zreport.
call function 'ZFUNCTION'.
EXPORT
NAME =
KUNNR =
Will the above statement updates the blank records into the table zstable?.Hi,
1) I think the best is either refer directly to data element or to table field. This is beacuse once any change is made to this data element it will automatically reflect in your parameters. For table fields it is a bit less safier but still correct. Golden rule - always try to refer to DDIC components like data elements.
name type dname
kunnr type kunnr
2) You need to provide all key fields. I recommend to use MODIFY as it would hanlde both INSERT (if yet no such record exists ) and UPDATE (if already exists).
data: wa_zstable type zstable. "declare work area
wa_zstable-kunnr = kunnr. "pass parameters here
wa_zstable-name = name.
modify zstable from wa_zstable.
3) good practise, for this use
if kunnr is initial and
name is initial.
"modify ...
endif.
"or if parameters are set as OPTIONAL, then use
if kunnr is supplied and
name is supplied.
endif.
4) No, the statment you want to use
insert vbeln and posnr into zstable.
is only used for FIELD GROUPS, not DB table. Please refer [INSERT|http://help.sap.com/abapdocu/en/ABAPINSERT_DBTAB_SHORTREF.htm] for correct syntax.
You can alternatively use somthing like
UPDATE zstable SET vbeln = ...
posnr = ...
WHERE ...
This will update fields VBELN and PONR for all records fullfilling WHERE condition. These however musn't be key fields, only non-key fields can be udpated.
Regards
Marcin -
PI 7.1 Adapter Modules not longer available/moved?
Hi everybody,
in our file sender cc on XI 3.0 we got the following adapter modules to transform special (german) characters:
localejbs/AFModules/MessageTransformBean_
localejbs/AFModules/TextCodepageConversionBean_
When I try to use this modules in PI 7.1 I got an error in cc-monitoring:
Error: javax.naming.NamingException: Unable to obtain EJB home interface (Root exception is java.lang.NoSuchMethodException: com.sap.engine.services.jndi.implclient.ClientContext.create())
I searched SDN to adjust the modules but can't find any useful information.
Thanks regards
Mario
Edited by: Mario Müller on Feb 5, 2009 1:38 AMHi Mario,
Have a look into these wikis for your solution.
Example of Adapter Module Development
https://www.sdn.sap.com/irj/scn/wiki?path=/display/xi/adaptermoduleexampleforPI+7.1
Adapter Module Development Libraries for PI 7.1
https://wiki.sdn.sap.com/wiki/display/XI/XIlibrariesfor+development
Regards
Aashish Sinha -
Error in Adapter Module to unzip files
Hello ,
I wish to unzip many files with use of an adapter module
To du this I use following code
package de.lsv.moduledevelopement;
import java.io.*;
import java.util.Hashtable;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.ejb.CreateException;
import com.sap.aii.af.mp.module.Module;
import com.sap.aii.af.mp.module.ModuleContext;
import com.sap.aii.af.mp.module.ModuleData;
import com.sap.aii.af.mp.module.ModuleException;
import com.sap.aii.af.ra.ms.api.Message;
import com.sap.aii.af.ra.ms.api.MessageDirection;
import com.sap.aii.af.ra.ms.api.Payload;
import com.sap.aii.af.ra.ms.spi.Trace;
import com.sap.aii.af.service.auditlog.Audit;
import com.sap.aii.af.service.auditlog.AuditDirection;
import com.sap.aii.af.service.auditlog.AuditLogStatus;
import com.sap.aii.af.service.auditlog.AuditMessageKey;
* @ejbLocal <{de.lsv.moduledevelopement.UnZipFilesLocal}>
* @ejbLocalHome <{de.lsv.moduledevelopement.UnZipFilesLocalHome}>
* @stateless
public class UnZipFilesBean implements SessionBean, Module {
static AuditMessageKey amk = null;
static String auditStr = "UnzipFilesBean - ";
static ModuleException mEx = null;
public static final String VERSION_ID =
"$Id://de.lsv.moduledevelopement.UnZipFilesBean.java#1 $";
private static final Trace TRACE = new Trace(VERSION_ID);
public void ejbRemove() {
public void ejbActivate() {
public void ejbPassivate() {
public void setSessionContext(SessionContext context) {
myContext = context;
private SessionContext myContext;
* Create Method.
public void ejbCreate() throws CreateException {
// TODO : Implement
/* (non-Javadoc)
* @see com.sap.aii.af.mp.module.Module#process(com.sap.aii.af.mp.module.ModuleContext, com.sap.aii.af.mp.module.ModuleData)
public ModuleData process(
ModuleContext moduleContext,
ModuleData inputModuleData)
throws ModuleException {
Object obj = null;
Message msg = null;
Payload attachment = null;
//initializing variables for module parameters
String modkey = "";
String fileMask = "";
String directory = "";
String saveDirectory = "";
// String newMimeType = "";
// String newAttachmentName = "";
// String newAttachmentExtension = "";
// String newAttachmentNameReplace = "";
//this block is to manage the adapter when is not file/FTP
try {
//get the XI Message
obj = inputModuleData.getPrincipalData();
msg = (Message) obj;
// create AuditMessageKey object to write audit log.
if (msg.getMessageDirection() == MessageDirection.INBOUND)
amk =
new AuditMessageKey(
msg.getMessageId(),
AuditDirection.INBOUND);
else
amk =
new AuditMessageKey(
msg.getMessageId(),
AuditDirection.OUTBOUND);
// ******start get the module parameters from the configuration******
modkey = moduleContext.getContextData("module.key");
Audit.addAuditLogEntry(
amk,
AuditLogStatus.SUCCESS,
auditStr + "Module Configuration Key: " + modkey);
//***** einlesen der Moduke Parameter******************
//***** DateiMaske
fileMask = moduleContext.getContextData("FileMask");
Audit.addAuditLogEntry(
amk,
AuditLogStatus.SUCCESS,
auditStr + "FileMask: " + fileMask);
// check ob fileMask definiert ist
if (fileMask == null || fileMask.equalsIgnoreCase("")) {
//if no attachment name is specified in the module configuration the module will end the execution
throw mEx =
new ModuleException(
auditStr
+ "!FileMask in Modulconfiguration nicht definiert!");
//***** DateiMaske2
String fileMask2 = moduleContext.getContextData("FileMask2");
Audit.addAuditLogEntry(
amk,
AuditLogStatus.SUCCESS,
auditStr + "FileMask2: " + fileMask2);
//***** Directory
directory = moduleContext.getContextData("Directory");
Audit.addAuditLogEntry(
amk,
AuditLogStatus.SUCCESS,
auditStr + "Directory: " + directory);
// Fehler wenn Directory nicht definiert
if (directory == null || directory.equalsIgnoreCase("")) {
//the module will end the execution
throw mEx =
new ModuleException(
auditStr
+ "Directory in Modulconfiguration nicht definiert");
//***** Sicherungs Verzeichnis
saveDirectory = moduleContext.getContextData("SaveDirectory");
Audit.addAuditLogEntry(
amk,
AuditLogStatus.SUCCESS,
auditStr + "SaveDirectory: " + saveDirectory);
// entpacken aufrufen
entpacke(directory, saveDirectory, fileMask);
if (fileMask2.length() > 0) {
entpacke(directory, saveDirectory, fileMask2);
//update the XI Message
inputModuleData.setPrincipalData(msg);
} catch (Exception e) {
String errorMessage =
auditStr + "Error bei der . Exception:" + e.getMessage();
Audit.addAuditLogEntry(amk, AuditLogStatus.ERROR, errorMessage);
throw mEx = new ModuleException(auditStr + errorMessage);
Audit.addAuditLogEntry(
amk,
AuditLogStatus.SUCCESS,
auditStr + "Verarbeitung beendet ");
return inputModuleData;
//+++++++++++++++++++++++++
private static void entpacke(
String directory,
String saveDirectory,
String mask)
// TODO Auto-generated method stub
Audit.addAuditLogEntry(
amk,
AuditLogStatus.SUCCESS,
auditStr + "Funktion entpacke");
if (!directory.endsWith("\")) {
directory = directory + "\";
} // if
File f;
f = new File(directory);
Audit.addAuditLogEntry(
amk,
AuditLogStatus.SUCCESS,
auditStr + "f = new File(directory)");
// // Achtung Klasse in einer Klasse :-)
// String[] strFiles = f.list(new FilenameFilter() {
// public boolean accept(File file, String filename) {
// Wildcard wildcard1 = new Wildcard(mask);
// Audit.addAuditLogEntry(
// amk,
// AuditLogStatus.SUCCESS,
// auditStr + "wc1");
// return wildcard1.match(filename, false);
String [] strFiles = f.list(new MyFilter(mask));
// Liste der Gefundenen dateien
Audit.addAuditLogEntry(
amk,
AuditLogStatus.SUCCESS,
auditStr + "Anzahl gepackter Dateien: " + strFiles.length);
//System.out.println( strFiles.length + " Dateien zum entpacken");
for (int i = 0; i < strFiles.length; i++) {
Audit.addAuditLogEntry(
amk,
AuditLogStatus.SUCCESS,
auditStr + "verarbeite Datei: : " + strFiles<i>);
// System.out.println("f[" + i + "]=" + strFiles<i>);
} // for
// *****entpacken**********************
for (int i = 0; i < strFiles.length; i++) {
try {
byte[] buf = new byte[4096];
ZipInputStream in =
new ZipInputStream(
new FileInputStream(directory + strFiles<i>));
Audit.addAuditLogEntry(
amk,
AuditLogStatus.SUCCESS,
auditStr + "Entpacke " + directory + strFiles<i>);
//System.out.println("Entpacke " + directory + strFiles<i>);
int count = 0;
while (true) {
count++;
// Nächsten Eintrag lesen
ZipEntry entry = in.getNextEntry();
if (entry == null) {
break;
// Beschreibung ausgeben
Audit.addAuditLogEntry(
amk,
AuditLogStatus.SUCCESS,
auditStr + entry.getName());
//System.out.println(entry.getName());
// Ausgabedatei erzeugen
FileOutputStream out =
new FileOutputStream(directory + entry.getName());
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
out.close();
// Eintrag schließen
in.closeEntry();
} // while
in.close();
Audit.addAuditLogEntry(
amk,
AuditLogStatus.SUCCESS,
auditStr + count + "Dateien entpackt");
//System.out.println(count + "Dateien entpackt");
// verschieben
if (saveDirectory.length() > 0) {
File quelle = new File(directory + strFiles<i>);
File ziel = new File(saveDirectory + strFiles<i>);
boolean bla = quelle.renameTo(ziel);
if (!bla) {
Audit.addAuditLogEntry(
amk,
AuditLogStatus.SUCCESS,
auditStr
+ strFiles<i>
+ " konnte nicht verschoben werden");
} else {
Audit.addAuditLogEntry(
amk,
AuditLogStatus.SUCCESS,
auditStr
+ strFiles<i>
+ "verschoben nach "
+ saveDirectory);
// System.out.println(
// strFiles<i> + "verscgoben nach " + directory + "sik//");
} // if
} catch (Exception e) {
String errorMessage =
auditStr
+ "Error in entpacken. Exception:"
+ e.getMessage();
Audit.addAuditLogEntry(amk, AuditLogStatus.ERROR, errorMessage);
} // catch
// *****entpacken*************
} // for
} //entpacke
} // UnzipFilesBean
class Wildcard {
static AuditMessageKey amk = null;
static String auditStr = "WildCard - ";
static ModuleException mEx = null;
private final String wildcardString;
* Der Konstruktor für die WildcardSuche.
* @param wildcardString
* Der WildcardString
public Wildcard(String wildcardString) {
this.wildcardString = wildcardString;
Audit.addAuditLogEntry(
amk,
AuditLogStatus.SUCCESS,
auditStr + "Constructor");
* Die Methode, welche den Vergleich durchführt.
* @param str
* Der String, welcher darauf überprüft werden soll, ob er dem
* WildcardString entspricht.
* @return true Wenn der String dem wildcardString entspricht.
public boolean match(String str, boolean fCasesensitive) {
if (str == null || wildcardString == null) {
return false;
return recursiveMatch(wildcardString, str, fCasesensitive);
* Hier wird der eigentliche Vergleich durchgeführt
* @param strWildcard
* Der Wildcardstring, z.B.: "Test*"
* @param str
* Der zu überprüfende String, z.B. "Testlauf"
* @return true, wenn eine Übereinstimmung vorhanden ist, sonst false
private boolean recursiveMatch(
String strWildcard,
String str,
boolean fCasesensitive) {
while (true) {
if (strWildcard.length() == 0)
return str.length() == 0;
char ch = strWildcard.charAt(0);
switch (ch) {
case '?' :
if (str.length() == 0)
return false;
break;
case '*' :
strWildcard = strWildcard.substring(1);
while (true) {
if (recursiveMatch(strWildcard, str, fCasesensitive))
return true;
if (str.length() == 0)
return false;
str = str.substring(1);
default :
if (str.length() == 0)
return false;
if (fCasesensitive) {
if (ch != str.charAt(0))
return false;
} else if (
Character.toLowerCase(ch)
!= Character.toLowerCase(str.charAt(0)))
return false;
break;
strWildcard = strWildcard.substring(1);
str = str.substring(1);
//++++++++++++++++++++++++++
} // class
/** Nun der eigentliche Filter */
class MyFilter implements FilenameFilter {
static AuditMessageKey amk = null;
static String auditStr = "MyFilter - ";
static ModuleException mEx = null;
String fileMask;
public MyFilter(String fileMask) {
this.fileMask = fileMask;
Audit.addAuditLogEntry(
amk,
AuditLogStatus.SUCCESS,
auditStr + "Constructor");
} //constructor
public boolean accept(File file, String filename) {
// TODO Auto-generated method stub
//fileMask = "?5LBL*";
Wildcard wildcard1 = new Wildcard(fileMask);
return wildcard1.match(filename, false);
} //class
But in Audit Protocol it failed after:
17.09.2008 17:33:19 Erfolgreich UnzipFilesBean - Module Configuration Key: 2
17.09.2008 17:33:19 Erfolgreich UnzipFilesBean - FileMask: ?5LBL???
17.09.2008 17:33:19 Erfolgreich UnzipFilesBean - FileMask2:
17.09.2008 17:33:19 Erfolgreich UnzipFilesBean - Directory: //transfer//X1E//100//99//lb//ein
17.09.2008 17:33:19 Erfolgreich UnzipFilesBean - SaveDirectory: //transfer//X1E//100//99//lb//ein_s
17.09.2008 17:33:19 Erfolgreich UnzipFilesBean - Funktion entpacke
17.09.2008 17:33:19 Erfolgreich UnzipFilesBean - f = new File(directory)
17.09.2008 17:33:19 Fehler UnzipFilesBean - Error bei der . Exception:null
I could not find the error??
Were there any log files to look into?
regarts
ZimmerningkatHi Ralf,
I am late..........
I am bit confused with your explanation.
1. Does all zip files will be picked by file adapter in one shot or is it conditional, since you have a XML descriptor file in firts zip file and the XML files describes the list of JPEG files which might be stored in the other zipped JPEG files?
2. Can you tell the exact flow of your scenario
3. Receiver in your scenario?
Thanks,
Gujjeti.
Maybe you are looking for
-
Classpath issues when executing from a jar
I have a jar that I built for an RMI server that has a need to access another jar. (log4j). I run the jar from the command line using: java -jar -Djava.rmi.server.codebase=my.jar my.jar and the code runs fine but when I try to add in the log4j.jar I
-
QTVR and Javascript interaction
I am developing a piece of training courseware which shows a 'start-up' procedure involving several panels / displays, and is being produced using HTML, Javascript and Quicktime VR. This is to be run 'client-side', i.e. on a local machine, no server
-
Loading an input text..
Hi, Here is my problem: I'm trying to load and input text with a 'x' value. This 'x' value is result of a method operation. I need to do this after the partial page rendering of a select one choice, and the method operation bases its calculation upon
-
Query varibale - display InfoObject attribute in selection screen
Hi, At my Query I have a variable for ZSurvey (InfoObject), when I run the report I got the first screen to select a Survey (ZSurvey). in This Selection Screen I have 2 columns ( Survey number & Description) How Do I add third Column (Start Time) Whi
-
i just started using flash... well, yesterday, though after i read most of a manual (flash cs3 pro bible) and for the most part things were going well so far except for a few snags. one in particular has been giving me grief. when i first started thi