XML to deep/complex ABAP table
Hello
I can successfully transform an XML file into an internal table with a flat structure.
But I would like to use an internal table with a deep/complex structure representing the relationship of some of data elements.
Has anyone been able to transform an XML into an internal table with deep/complex structure?
Regards, Steve
Hi all
I eventually found an old SDJ article entitled "Mastering the asXML format to Leverage ABAP-XML Serialization". Understanding the asXML format for my particular requirement was the key to building my XSLT.
Briefly here's the steps I took to determine how the asXML should look:
I changed my ABAP to populate the complex internal table with some dummy data and changed the direction of my transformation to produce asXML from the internal table. By complex I mean an internal table with a nested table as one of its fields.
My call to the transformation now looks like this:
CALL TRANSFORMATION ID
SOURCE thisone = lt_complextable
RESULT XML lt_xml. " asxml.
Using keyword "ID" tells the transformation to produce an asXML stream instead of performing a transformation via my XSLT. "thisone" is a dummy tag that is written into the stream and surrounds the data.
Looking at the resulting lt_xml I can now see what my XSLT needs to output. Now that I know what format the asXML needs to be I am able to modify my XSLT accordingly.
There is quite a bit of code involved in a demo so I won't post it all here but if anyone is interested I'll write up a document with all the sample code etc.
Cheers, Steve
Similar Messages
-
Hello,
as a novice to abap, i have the following question:
I want to save a string containing a large xml content into an abap table and also additional fields to the same table.
Could you provide some advice?
Thanks in advance,
Peter Hado you mean storing it in DB table. if so check out the sample code given in the following thread
Re: How to store big XML string in ABAB DB
Regards
Raja -
Read an XML file into an ABAP program and manipulate it.
I would like to know if it is possible to do the following in an ABAP program:
1) Read an XML file into an ABAP internal table
2) Call an XSLT transformation on the source file and store the results in an ABAP table.
Is this possible to do? I have used ABAP XSLT in PI, but never in an ABAP program. I see you can use the CALL TRANSFORMATION command, but I have never used it in an ABAP program.
Kind Regards,
Tony.Check out these blogs.
XML DOM Processing in ABAP part I - Convert an ABAP table into XML file using SAP DOM Approach.
XML DOM Processing in ABAP part II - Convert an XML file into an ABAP table using SAP DOM Approach. -
ABAP Table for DynamicConfiguration details of XML message in SXMB_MONI
Dear All
I have a requirement where I have to read the value from DCJMSCorreleationID property of message which is recorded in SXMB_MONI based on the SAP PI message ID.
I have 2 interfaces as below
Interface one (INT1) : JMS-PI-ECC --->Inbound interface to ECC when message is received on PI it will have DCJMSCorreleationID populated with some ID as shown below
Go to SXMB_MONI -->Inbound Message ---> SOAP Header --->DynamicConfiguration
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<SAP:DynamicConfiguration SOAP:mustUnderstand="1" xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SAP:Record namespace="http://sap.com/xi/XI/System/JMS" name="DCJMSCorreleationID">
a26c4276-9d5e-11e3-ba87-000004238292
</SAP:Record>
<SAP:Record namespace="http://sap.com/xi/XI/Message/30/general" name="senderAgreementGUID">dd3fb7c6b983314293e14ba59df1ad45</SAP:Record></SAP:DynamicConfiguration>
Interface Two (INT2):-ECC-PI-JMS----> Outbound from ECC where I am passing a SAP PI Message ID for INT1 in one of the field
Can I read this DCJMSCorreleationID for INT1 when INT2 is executed and have message ID for INT1 ?
Where are these SOAP hearder porperties like DCJMSCorreleationID are stored on ABAP table?Thanks Jörg for your reply
I have a back up plan for ZTable approach but the only concern there is RFC calls for read and write
we have implemented a FM which gives the original payload using a std SAP functional modules FM SXMB_GET_XI_MESSAGE_INT and ECATT_CONV_XSTRING_TO_STRING
But I am looking for the SOAP Header information for DCJMSCorreleationID
So if there is anything which will help to read this DCJMSCorreleationID property easily form existing message SOAP header is really helpful -
Collect data from a dynamic XML file into multiple internal tables
I need to convert the XML file into multiple internal tables. I tried many links and posts in SDN but still was facing difficulty in achieving this. Can some one tell me where I am going wrong.
My XML file is of the following type.It is very complex and the dynamice.
The following tags occur more than once in the XML file. The "I" and "L" tags and its child tags can occur ones or more than once for each XML file and it is not constant. i.e in one file they can occur 1 time and in another they can occur 100 times.
"I" and "L" are child tags of <C>
<I>
<J>10</J>
<K>EN</K>
</I>
<L>
<J>20</J>
<N>BB</N>
</L>
Tags <C> and <F> occur only ones for each XML file. <C> is the child tag of "A" and "F" is the child tag of <C>.
I need to collect <D>, <E> in one internal table ITAB.
I need to collect <G>, <H> in one internal table JTAB.
I need to collect <J>, <K> in one internal table KTAB.
I need to collect <J>, <N> in one internal table PTAB.
Below is the complete XML file.
?xml version="1.0" encoding="iso-8859-1" ?>
<A>
<B/>
<C>
<D>RED</D>
<E>999</E>
<F>
<G>TRACK</G>
<H>PACK</H>
</F>
<I>
<J>10</J>
<K>EN</K>
</I>
<I>
<J>20</J>
<K>TN</K>
</I>
<I>
<J>30</J>
<K>KN</K>
</I>
<L>
<J>10</J>
<N>AA</N>
</L>
<L>
<J>20</J>
<N>BB</N>
</L>
<L>
<J>30</J>
<N>CC</N>
</L>
</C>
</A>
With the help of SDN I am able to gather the values of <D> <E> in one internal table.
Now if I need to gather
<G>, <H> in one internal table JTAB.
<J>, <K> in one internal table KTAB.
<J>, <N> in one internal table PTAB.
I am unable to do. I am following XSLT transformation method. If some one has some suggestions. Please help.
Here is my ABAP program
TYPE-POOLS abap.
CONSTANTS gs_file TYPE string VALUE 'C:\TEMP\ABCD.xml'.
* This is the structure for the data from the XML file
TYPES: BEGIN OF ITAB,
D(10) TYPE C,
E(10) TYPE C,
END OF ITAB.
* Table for the XML content
DATA: gt_itab TYPE STANDARD TABLE OF char2048.
* Table and work ares for the data from the XML file
DATA: gt_ITAB TYPE STANDARD TABLE OF ts_ITAB,
gs_ITAB TYPE ts_ITAB.
* Result table that contains references
* of the internal tables to be filled
DATA: gt_result_xml TYPE abap_trans_resbind_tab,
gs_result_xml TYPE abap_trans_resbind.
* For error handling
DATA: gs_rif_ex TYPE REF TO cx_root,
gs_var_text TYPE string.
* Get the XML file from your client
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = gs_file
CHANGING
data_tab = gt_itab1
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Fill the result table with a reference to the data table.
* Within the XSLT stylesheet, the data table can be accessed with
* "IITAB".
GET REFERENCE OF gt_shipment INTO gs_result_xml-value.
gs_result_xml-name = 'IITAB'.
APPEND gs_result_xml TO gt_result_xml.
* Perform the XSLT stylesheet
TRY.
CALL TRANSFORMATION zxslt
SOURCE XML gt_itab1
RESULT (gt_result_xml).
CATCH cx_root INTO gs_rif_ex.
gs_var_text = gs_rif_ex->get_text( ).
MESSAGE gs_var_text TYPE 'E'.
ENDTRY.
* Now let's see what we got from the file
LOOP AT gt_ITAB INTO gs_ITAB.
WRITE: / 'D:', gs_ITAB-D.
WRITE: / 'E :', gs_ITAB-E.
ENDLOOP.
Transformation
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<IITAB>
<xsl:apply-templates select="//C"/>
</IITAB>
</asx:values>
</asx:abap>
</xsl:template>
<item>
<D>
<xsl:value-of select="D"/>
</D>
<E>
<xsl:value-of select="E"/>
</E>
</item>
</xsl:template>
</xsl:transform>
Now the above pgm and transformation work well and I am able to extract data into the ITAB. Now what changes should I make in transformation and in pgm to collect
<G>, <H> in one internal table JTAB.
<J>, <K> in one internal table KTAB.
<J>, <N> in one internal table PTAB.
Please help..i am really tring hard to figure this out. I am found lot of threads addressing this issue but not my problem.
Kindly help.
Regards,
VSHi Rammohan,
Thanks for the effort!
But I don't need to use GUI upload because my functionality does not require to fetch data from presentation server.
Moreover, the split command advised by you contains separate fields...f1, f2, f3... and I cannot use it because I have 164 fields. I will have to split into 164 fields and assign the values back to 164 fields in the work area/header line.
Moreover I have about 10 such work areas. so the effort would be ten times the above effort! I want to avoid this! Please help!
I would be very grateful if you could provide an alternative solution.
Thanks once again,
Best Regards,
Vinod.V -
How do I import one xml file into 3 separate tables in db?
I need to utilize xslt to import one xml file into 3 separate tables: account, accountAddress, streetAddress
*Notice the missing values in middleName, accountType
sample xml
<account>
<firstName>Joe</firstName>
<middleName></middleName>
<lastName>Torre</lastName>
<accountAddress>
<streetAddress>
<addressLine>myAddressLine1</addressLine>
<addressLine>myAddressLine2</addressLine>
</streetAddress>
<city>myCity</city>
<state>myState</state>
<postalCode>mypostalCode</postalCode>
</accountAddress>
<accountId>A001</accountId>
<accountType></accountType>
<account>
I need the following 3 results in 3 separate xml files in order for me to upload into my 3 tables.
Result #1
<rowset>
<row>
<firstName>Joe</firstName>
<lastName>Torre</lastName>
<accountId>A001</accountId>
<row>
<rowset>
Result #2
<rowset>
<row>
<addressId>1</address>
<city>myCity</city>
<state>myState</state>
<postalCode>myPostalCode</postalCode>
<row>
<rowset>
Result #3
<rowset>
<row>
<addressId>1</addressId>
<addressLineSeq>1</addressLineSeq>
<addressLine>myAddressLine1</addressLine>
<row>
<row>
<addressId>1</addressId>
<addressLineSeq>2</addressLineSeq>
<addressLine>myAddressLine2</addressLine>
<row>
<rowset>Use XSU to store in multiple tables.
"XSU can only store data in a single table. You can store XML across tables, however, by using the Oracle XSLT processor to transform a document into multiple documents and inserting them separately. You can also define views over multiple tables and perform insertions into the views. If a view is non-updatable (because of complex joins), then you can use INSTEAD OF triggers over the views to perform the inserts."
http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14252/adx_j_xsu.htm#i1007013 -
Load XML records in a normal table
Good afternoon all,
I have a very simple question:
I get a XML file and want to store that data in my Oracle database in a normal table.
I have seen so many answers everywhere, varying from LOBs and using XDB etc.
What i don't understand is why it is so difficult.
When i want to load a CSV file in a table I make a very small Control File CTL and from the command prompt / command line I run the SQL Loader.
Control file:
load data
infile 'import.csv'
into table emp
fields terminated by "," optionally enclosed by '"'
( empno, empname, sal, deptno )
command:
sqlldr user/password@SID control=loader_Control_File.ctl
Next I connect to the database and run SQL query:
select * from emp;
and i see my data as usual, I can make Crystal Reports on it, etc etc
I really don't understand why this can't be done with an XML file
Oracle know the fields in the table EMP
The xml file has around every field the <EMPNO> and </EMPNO>
Can't be easier than that I would say.
I can understand Oracle likes some kind of description of the XML table, so reference to a XSD file would be understandable.
But all examples are describing LOB things (whatever that is)
Who can help me to get XML data in a normal table?
Thanks
FrankHi Frank,
What i don't understand is why it is so difficult.Why do you think that?
An SQL*Loader control file might appear very small and simple to you, but you don't actually see what happens inside the loader itself, I guess a lot of complex operations (parsing, datatype mapping, memory allocation etc.).
XML, contrary to a CSV format, is a structured, well standardized language and could handle far more complex documents than row-organized CSV files.
I think it naturally requires a few extra work (for a developer) to describe what we want to do out of it.
However, using an XML schema is not mandatory to load XML data into a relational table.
It's useful if you're interested in high-performance loading and scalability, as it allows Oracle to fully understand the XML data model it has to deal with, and make the correct mapping with SQL types in the database.
Furthermore, now with 11g BINARY XMLType, performance has been improved with or without schema.
Here's a simple example, loading XML file "import.xml" into table MY_EMP.
Do you find it difficult? ;)
SQL> create or replace directory test_dir as 'D:\ORACLE\test';
Directory created
SQL> create table my_emp as
2 select empno, ename, sal, deptno
3 from scott.emp
4 where 1 = 0
5 ;
Table created
SQL> insert into my_emp (empno, ename, sal, deptno)
2 select *
3 from xmltable('/ROWSET/ROW'
4 passing xmltype(bfilename('TEST_DIR', 'import.xml'), nls_charset_id('CHAR_CS'))
5 columns empno number(4) path 'EMPNO',
6 ename varchar2(10) path 'ENAME',
7 sal number(7,2) path 'SAL',
8 deptno number(2) path 'DEPTNO'
9 )
10 ;
14 rows inserted
SQL> select * from my_emp;
EMPNO ENAME SAL DEPTNO
7369 SMITH 800.00 20
7499 ALLEN 1600.00 30
7521 WARD 1250.00 30
7566 JONES 2975.00 20
7654 MARTIN 1250.00 30
7698 BLAKE 2850.00 30
7782 CLARK 2450.00 10
7788 SCOTT 3000.00 20
7839 KING 5000.00 10
7844 TURNER 1500.00 30
7876 ADAMS 1100.00 20
7900 JAMES 950.00 30
7902 FORD 3000.00 20
7934 MILLER 1300.00 10
14 rows selected
import.xml :
<?xml version="1.0"?>
<ROWSET>
<ROW>
<EMPNO>7369</EMPNO>
<ENAME>SMITH</ENAME>
<SAL>800</SAL>
<DEPTNO>20</DEPTNO>
</ROW>
<ROW>
<EMPNO>7499</EMPNO>
<ENAME>ALLEN</ENAME>
<SAL>1600</SAL>
<DEPTNO>30</DEPTNO>
</ROW>
<!-- more rows here -->
<ROW>
<EMPNO>7934</EMPNO>
<ENAME>MILLER</ENAME>
<SAL>1300</SAL>
<DEPTNO>10</DEPTNO>
</ROW>
</ROWSET>
Who can help me to get XML data in a normal table?If you have a specific example, feel free to post it, including the following information :
- structure of the target table
- sample XML file
- database version (select * from v$version)
Hope that helps.
Edited by: odie_63 on 9 mars 2011 21:22 -
Redaing an XML file to an internal table
hi ,
I want to import an XML file in an interface program for ABAP. I was looking for an optimal method of parsing and reading the XML data to an intrenal table so that I can display errors corresponding to invidual records.
SangeetHai Sangeeta
go through the following Code
This program exports an internal table to an XML file.
Report ZPRUEBA_MML_13 *
Export an internal table to XML document *
NO BORRAR ESTE CODIGO *
REPORT ZPRUEBA_MML_13.
PANTALLA SELECCION *
PARAMETERS: GK_RUTA TYPE RLGRAP-FILENAME.
PANTALLA SELECCION *
TYPE TURNOS *
TYPES: BEGIN OF TURNOS,
LU LIKE T552A-TPR01,
MA LIKE T552A-TPR01,
MI LIKE T552A-TPR01,
JU LIKE T552A-TPR01,
VI LIKE T552A-TPR01,
SA LIKE T552A-TPR01,
DO LIKE T552A-TPR01,
END OF TURNOS.
TYPE TURNOS *
TYPE SOCIO *
TYPES: BEGIN OF SOCIO,
NUMERO LIKE PERNR-PERNR,
REPOSICION LIKE PA0050-ZAUVE,
NOMBRE LIKE PA0002-VORNA,
TURNOS TYPE TURNOS,
END OF SOCIO.
TYPE SOCIO *
ESTRUCTURA ACCESOS *
DATA: BEGIN OF ACCESOS OCCURS 0,
SOCIO TYPE SOCIO,
END OF ACCESOS.
ESTRUCTURA ACCESOS *
START OF SELECTION *
START-OF-SELECTION.
PERFORM LLENA_ACCESOS.
PERFORM DESCARGA_XML.
END-OF-SELECTION.
END OF SELECTION *
FORM LLENA_ACCESOS *
FORM LLENA_ACCESOS.
REFRESH ACCESOS.
CLEAR ACCESOS.
MOVE: '45050' TO ACCESOS-SOCIO-NUMERO,
'MOISES MORENO' TO ACCESOS-SOCIO-NOMBRE,
'0' TO ACCESOS-SOCIO-REPOSICION,
'T1' TO ACCESOS-SOCIO-TURNOS-LU,
'T2' TO ACCESOS-SOCIO-TURNOS-MA,
'T3' TO ACCESOS-SOCIO-TURNOS-MI,
'T4' TO ACCESOS-SOCIO-TURNOS-JU,
'T5' TO ACCESOS-SOCIO-TURNOS-VI,
'T6' TO ACCESOS-SOCIO-TURNOS-SA,
'T7' TO ACCESOS-SOCIO-TURNOS-DO.
APPEND ACCESOS.
CLEAR ACCESOS.
MOVE: '45051' TO ACCESOS-SOCIO-NUMERO,
'RUTH PEÑA' TO ACCESOS-SOCIO-NOMBRE,
'0' TO ACCESOS-SOCIO-REPOSICION,
'T1' TO ACCESOS-SOCIO-TURNOS-LU,
'T2' TO ACCESOS-SOCIO-TURNOS-MA,
'T3' TO ACCESOS-SOCIO-TURNOS-MI,
'T4' TO ACCESOS-SOCIO-TURNOS-JU,
'T5' TO ACCESOS-SOCIO-TURNOS-VI,
'T6' TO ACCESOS-SOCIO-TURNOS-SA,
'T7' TO ACCESOS-SOCIO-TURNOS-DO.
APPEND ACCESOS.
ENDFORM.
FORM LLENA_ACCESOS *
FORM DESCARGA_XML *
FORM DESCARGA_XML.
DATA: L_DOM TYPE REF TO IF_IXML_ELEMENT,
M_DOCUMENT TYPE REF TO IF_IXML_DOCUMENT,
G_IXML TYPE REF TO IF_IXML,
W_STRING TYPE XSTRING,
W_SIZE TYPE I,
W_RESULT TYPE I,
W_LINE TYPE STRING,
IT_XML TYPE DCXMLLINES,
S_XML LIKE LINE OF IT_XML,
W_RC LIKE SY-SUBRC.
DATA: XML TYPE DCXMLLINES.
DATA: RC TYPE SY-SUBRC,
BEGIN OF XML_TAB OCCURS 0,
D LIKE LINE OF XML,
END OF XML_TAB.
CLASS CL_IXML DEFINITION LOAD.
G_IXML = CL_IXML=>CREATE( ).
CHECK NOT G_IXML IS INITIAL.
M_DOCUMENT = G_IXML->CREATE_DOCUMENT( ).
CHECK NOT M_DOCUMENT IS INITIAL.
WRITE: / 'Converting DATA TO DOM 1:'.
CALL FUNCTION 'SDIXML_DATA_TO_DOM'
EXPORTING
NAME = 'ACCESOS'
DATAOBJECT = ACCESOS[]
IMPORTING
DATA_AS_DOM = L_DOM
CHANGING
DOCUMENT = M_DOCUMENT
EXCEPTIONS
ILLEGAL_NAME = 1
OTHERS = 2.
IF SY-SUBRC = 0.
WRITE 'Ok'.
ELSE.
WRITE: 'Err =',
SY-SUBRC.
ENDIF.
CHECK NOT L_DOM IS INITIAL.
W_RC = M_DOCUMENT->APPEND_CHILD( NEW_CHILD = L_DOM ).
IF W_RC IS INITIAL.
WRITE 'Ok'.
ELSE.
WRITE: 'Err =',
W_RC.
ENDIF.
CALL FUNCTION 'SDIXML_DOM_TO_XML'
EXPORTING
DOCUMENT = M_DOCUMENT
IMPORTING
XML_AS_STRING = W_STRING
SIZE = W_SIZE
TABLES
XML_AS_TABLE = IT_XML
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2.
IF SY-SUBRC = 0.
WRITE 'Ok'.
ELSE.
WRITE: 'Err =',
SY-SUBRC.
ENDIF.
LOOP AT IT_XML INTO XML_TAB-D.
APPEND XML_TAB.
ENDLOOP.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_SIZE
FILENAME = GK_RUTA
FILETYPE = 'BIN'
TABLES
DATA_TAB = XML_TAB
EXCEPTIONS
OTHERS = 10.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
FORM DESCARGA_XML *
Thanks & regards
Sreenivasulu P -
Upload an XML file into the Internal table
Hi Guys,
I want to know, how to upload an xml file into the Internal table through ABAP programmingyou just wanted to load the xml file into internal table (as a table of binary strings)or load the xml data mapped to itab row columns
for the first one you can simply use gui_upload
and for the second one you need to load the xml file using gui_upload and use XLST program to transform into an itab
Regards
Raja -
Dynamic configuration- Is file name stored in any abap table in PI
Hi.
Is there any ABAP table in XI containing the dynamic configuration's xml of a message.
For any file scenario Can I get the file name from any of the abap table in PI
Regards,
DeepakInteresting ABAP tables in XI
Interesting ABAP tables in XI Part I
Regards,
Phani -
Dynamic configuration in ABAP tables
Hi,
is there any ABAP table in XI containing the dynamic configuration's xml of a message (or an equivalent information in any format)?
Thanks,
Danielehi
Dynamic configurations will be a part of the xi message header
chk these tables
1.SXMSPMAST: (Integration Engine: Message Queue (Master)) The table is the master table for the monitoring information. You can get the timestamp, interface status, message id, and many more information.
2.SXMSPEMAS: (Integration Engine: Enhanced Message Queue (Master)) The table provides the namespaces, the business systems and message interfaces involved in the interface.
3.SXMSMSTATT: (Exchange Infrastructure: Message Status Description) This table provides a message status description.
4.SXMSMSTAT: (Exchange Infrastructure: Message Status) This table is helpful if you want to show the process status icon for the corresponding message state.
refer this for code sample
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/909760cb-0ec8-2a10-4a96-ee8417acfbc9
rgds
arun -
Call Abap FM from XI mapping to insert lines to abap table
Hi All,
I'm trying to insert data from an XML file into a Z table during mapping in XI. I have an ABAP function module that takes in parameters and inserts into the corresponding fileds of the Z-table.
How do I make use of this ABAP Function module in a user defined function in XI mapping.
Any tips would be really helpful.
Thanks
KarthikHi Karthik,
have a look in this document:
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/4fbe7b8e-0a01-0010-b69b-b7e717378f22
In the document look at: "Step 3 Coding User-Defined Java Function in Message Mapping".
This should solve your problem.
Regards Mario -
How Save XML Document in a Destination Table
Hi
How Save a XML Document Information in Data Table.
for Example
Create Table MDat (Id Number(6), Description Varchar2(50))
XML Document
<Data>
<ROW NUMROW="1" ID="1" Description="Dat 01" /ROW>
<ROW NUMROW="2" ID="5" Description="Dat 05" /ROW>
</DATA>
I Need insert into Tabla MDAT XML Document Information, This XML Document exist in Server Directory.
Thanks
PS: I Have a Steve Muench Book (Building Oracle XML Aplications.huh? Perhaps READING Steven's book might help you in this matter :) For smallish files you can probably use putXML (e.g., p 467) or if you have a more complex or larger then you need to work with XMLLoader (also in the book (p. 534) as well as online somewhere).
Mike
null -
Hi,
Project IDoc is triggered from SAP system, when project status is REL(Release). Project IDoc, does not have information about if it is a new project or an existing changed project.
Any idea how i can deal with this problem? Can i use ABAP table to maintain status info?
Thanks,
GowriHi,
In the example by Bhavesh Kantilal :
import com.sap.aii.mapping.lookup.*;
import java.io.*;
// Business Service -- give the name of the business service / system
String bussService="";
// RFC Comm Channle -- give the name of the RFC Comm Channel
String CommChannel="";
Channel channel = LookupService.getChannel(bussService,CommChannel);
RfcAccessor accessor = LookupService.getRfcAccessor(channel);
//Request RFC XML with values poppulated.
String rfcxml ="";
InputStream inputStream =new ByteArrayInputStream(rfcxml.getBytes());
XmlPayload payload = LookupService.getXmlPayload(inputStream);
Payload rfcOutPayload = null;
//The response will be a Payload. Parse this to get the response field out.
rfcOutPayload = accessor.call(payload);
If the ztable in called (table1) and has 3 fields (field1, field2 and field3). What would be an example of the rfcxml string if I would like to do this select:
Select field1 field2 field3 from table table1 where field1 = 1234.
In my EDI scenario, I need to do some r/3 table lookups in my mapping and using the RFC Lookup seems to be a good way.
Thanks
Yves -
Read data from xml files and populate internal table
Hi.
How to read data from xml files into internal tables?
Can u tell me the classes and methods to read xml data..
Can u explain it with a sample program...<pre>DATA itab_accontextdir TYPE TABLE OF ACCONTEXTDIR.
DATA struct_accontextdir LIKE LINE OF itab_accontextdir.
DATA l_o_error TYPE REF TO cx_root.
DATA: filename type string ,
xmldata type xstring .
DATA: mr TYPE REF TO if_mr_api.
mr = cl_mime_repository_api=>get_api( ).
mr->get( EXPORTING i_url = 'SAP/PUBLIC/BC/xml_files_accontext/xml_accontextdir.xml'
IMPORTING e_content = xmldata ).
WRITE xmldata.
TRY.
CALL TRANSFORMATION id
SOURCE XML xmldata
RESULT shiva = itab_accontextdir.
CATCH cx_root INTO l_o_error.
ENDTRY.
LOOP AT itab_accontextdir INTO struct_accontextdir.
WRITE: / struct_accontextdir-context_id,
struct_accontextdir-context_name,
struct_accontextdir-context_type.
NEW-LINE.
ENDLOOP.</pre>
<br/>
Description:
In the above code snippet I am storing the data in an xml file(you know xml is used to store and transport data ) called 'xml_accontextdir.xml' that is uploaded into the MIME repository at path 'SAP/PUBLIC/BC/xml_files_accontext/xml_accontextdir.xml'.
The below API is used to read a file in MIME repo and convert it into a string that is stored in ' xmldata'. (This is just a raw data that is got by appending the each line of xml file).
mr = cl_mime_repository_api=>get_api( ).
mr->get( EXPORTING i_url = 'SAP/PUBLIC/BC/xml_files_accontext/xml_accontextdir.xml'
IMPORTING e_content = xmldata ).
Once the 'xmldata' string is available we use the tranformation to parse the xml string that we have got from the above API and convert it into the internal table.
<pre>TRY.
CALL TRANSFORMATION id
SOURCE XML xmldata
RESULT shiva = itab_accontextdir.
CATCH cx_root INTO l_o_error.
ENDTRY.</pre>
Here the trasnsformation 'id ' is used to conververt the source xml 'xmldata' to resulting internal table itab_accontextdir, that have same structure as our xml file 'xml_accontextdir.xml'. In the RESULT root of the xml file has to be specified. (In my the root is 'shiva').
Things to be taken care:
One of the major problem that occurs when reading the xml file is 'format not compatible with the internal table' that you are reading into internal table. Iin order to get rid of this issue use one more tranformation to convert the data from the internal table into the xml file.
<pre>TRY.
CALL TRANSFORMATION id
SOURCE shiv = t_internal_tab
RESULT XML xml.
CATCH cx_root INTO l_o_error.
ENDTRY.
WRITE xml.
NEW-LINE.</pre>
<br/>
This is the same transformation that we used above but the differnce is that the SOURCE and RESULT parameters are changed the source is now the internal table and result is *xml *string. Use xml browser that is available with the ABAP workbench to read the xml string displayed with proper indentation. In this way we get the format of xml file to be used that is compatable with the given internal table.
Thank you, Hope this will help you!!!
Edited by: Shiva Prasad L on Jun 15, 2009 7:30 AM
Edited by: Shiva Prasad L on Jun 15, 2009 11:56 AM
Edited by: Shiva Prasad L on Jun 15, 2009 12:06 PM
Maybe you are looking for
-
T.code of resp. program to be displayed in ALV as heading or header
Hi ! I have a rather simple yet confusing question for me. My requirement is to display the respective transaction code of the Zreport in the report itself. I am able to display it in classical format but unable to figure out a way in ALV format. Can
-
Hi! I have 16 multiplexers (ADG 406) with a 5 bit adress for the gates. However the first bit is the enable bit, and I have it always "on", so my question is for the remaining 4 bit in the adress. Q: Is it possible to create a cycle or loop so that t
-
OSB 11g + DB adapter - best practices
Hello All, I am creating some data services using OSB 11g+Db adapter to perform operations (Sel,Ins,Upd) from two databases. Most of them are simple queries, however some include complex db operations 1. If I have two separate datasources for databas
-
PC Windows 7, Illustrator CC crashes when opening a file or creating a new file
I have followed these suggestions on how to delete/reset the preferences but this did not work. Any ideas why this is happening with Illustrator, all of the other CC programs seem to still open and work fine?
-
Configurator installation file not recognized
I have installed Adobe Air 2.7.1.19610 on my Windows Vista SP1 32 bit. Rebooted. Download the Adobe Configurator installation file configurator2_p1_052610.air When I double click on it my computer does not know what program should run it. The