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,
VS
Hi 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
Similar Messages
-
Need to Load data in XML file into multiple Oracle tables
Experts
I want to load data that is stored at XML file into multiple Oracle table using plsql.
I am novice in this area.Kindly explain in depth or step by step so that i can achive this.
Thanks in advnace.Hi,
extract your xml and then you can use insert all clause.
here's very small example on 10.2.0.1.0
SQL> create table table1(id number,val varchar2(10));
Table created.
SQL> create table table2(id number,val varchar2(10));
Table created.
SQL> insert all
2 into table1 values(id,val)
3 into table2 values(id2,val2)
4 select extractValue(x.col,'/a/id1') id
5 ,extractValue(x.col,'/a/value') val
6 ,extractValue(x.col,'/a/value2') val2
7 ,extractValue(x.col,'/a/id2') id2
8 from (select xmltype('<a><id1>1</id1><value>a</value><id2>2</id2><value2>b</value2></a>') col from dual) x;
2 rows created.
SQL> select * from table1;
ID VAL
1 a
SQL> select * from table2;
ID VAL
2 b Ants -
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 -
How to upload XML file into the internal table in Webdynpro ABAP ?
Hi Friends,
I am not able to upload the XML file into ABAP,can you please help me in solving this issue with the help of source code.
Regards
DineshHi Dinesh,
Try go through this program which I had developed earlier. It takes as input an XML file and then breaks it down into name-value pairs of an intrnal table. You need to pass an XML file as input to this program. (I had hard coded the path for my XML file in it. You need to replace it with 1 of your own or you can just delete it and use the browse button to selet the file on your PC)
Regards,
Uday
REPORT ZUDAY_XML no standard page heading.
" Internal table to store the XML file in binary mode
data: begin of it_xml occurs 1,
c(255) type x,
end of it_xml,
" Name-value pairs table rturned by FM SMUM_XML_PARSE
it_SMUM_XMLTB type SMUM_XMLTB occurs 0 with header line,
" Table returned by FM SMUM_XML_PARSE for error handling
it_bapiret2 type bapiret2 occurs 0 with header line.
" XSTRING variable to be used by FM SCMS_BINARY_TO_XSTRING to hold the XML file in XSTRING format
data: I_xstring type xstring,
" String variable to hold XML file path to pass to GUI_UPLOAD
I_file_path type string,
" Variable to store the size of the uploaded binary XML file
I_LENGTH TYPE I VALUE 0.
parameters: P_path type IBIPPARMS-PATH default 'C:\Documents and Settings\c5104398\Desktop\flights.xml'.
" Get the XML file path from the user
at selection-screen on value-request for P_path.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_PATH. -
I want to convert XML file into SAP Internal table
Hi Frndz,
My xml file is:
<?xml version="1.0" ?>
- <!-- Comments: START DATE :1/11/2002 11:26:14 PM
-->
- <!-- Comments: RFID Tags read by Mercury4 Copyright Praff@Anantara Solutions
-->
<RFIDs><ID>0x303030303030303035050000B5EC</ID><ID>0x300833B2DDD901403505000042E7</ID></RFIDs>
i want to take those 2 ID's in a internal table that id field is of 28 character type....
very urgent.
Thanks,
Arunprasad.Pclass cl_ixml definition load.
type-pools: ixml.
types: begin of t_xml_line,
data(256) type x,
end of t_xml_line,
begin of tsfixml,
data(1024) type c,
end of tsfixml.
data: l_ixml type ref to if_ixml,
l_streamfactory type ref to if_ixml_stream_factory,
l_parser type ref to if_ixml_parser,
l_istream type ref to if_ixml_istream,
l_document type ref to if_ixml_document,
l_node type ref to if_ixml_node,
l_xmldata type string.
data: l_elem type ref to if_ixml_element,
l_root_node type ref to if_ixml_node,
l_next_node type ref to if_ixml_node,
l_name type string,
l_iterator type ref to if_ixml_node_iterator.
data: l_xml_table type table of t_xml_line,
l_xml_line type t_xml_line,
l_xml_table_size type i.
data: l_filename type string.
parameters: pa_file type char1024 default
'C:\WINDOWS\Desktop\RFIDTags.xml'.
*Validation of XML file: Only DTD included in xml document is supported
parameters: pa_val type char1 as checkbox.
start-of-selection.
*Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
*Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
perform get_xml_table changing l_xml_table_size l_xml_table.
*wrap the table containing the file into a stream
l_istream = l_streamfactory->create_istream_itable( table = l_xml_table
size = l_xml_table_size ).
*Creating a document
l_document = l_ixml->create_document( ).
*Create a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).
*Validate a document
if pa_val eq 'X'.
l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
endif.
*Parse the stream
if l_parser->parse( ) ne 0.
if l_parser->num_errors( ) ne 0.
data: parseerror type ref to if_ixml_parse_error,
str type string,
i type i,
count type i,
index type i.
count = l_parser->num_errors( ).
write: count, ' parse errors have occured:'.
index = 0.
while index < count.
parseerror = l_parser->get_error( index = index ).
i = parseerror->get_line( ).
write: 'line: ', i.
i = parseerror->get_column( ).
write: 'column: ', i.
str = parseerror->get_reason( ).
write: str.
index = index + 1.
endwhile.
endif.
endif.
*Process the document
if l_parser->is_dom_generating( ) eq 'X'.
perform process_dom using l_document.
endif.
*& Form get_xml_table
form get_xml_table changing l_xml_table_size type i
l_xml_table type standard table.
*Local variable declaration
data: l_len type i,
l_len2 type i,
l_tab type tsfixml,
l_content type string,
l_str1 type string,
c_conv TYPE REF TO cl_abap_conv_in_ce,
l_itab type table of string.
l_filename = pa_file.
*upload a file from the client's workstation
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = l_filename
FILETYPE = 'BIN'
IMPORTING
FILELENGTH = l_xml_table_size
HEADER =
TABLES
DATA_TAB = l_xml_table
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*Writing the XML document to the screen
CLEAR l_str1.
LOOP AT l_xml_table INTO l_xml_line.
c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data
replacement = space ).
c_conv->read( IMPORTING data = l_content len = l_len ).
CONCATENATE l_str1 l_content INTO l_str1.
ENDLOOP.
l_str1 = l_str1+0(l_xml_table_size).
SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
WRITE: /.
WRITE: /' XML File'.
WRITE: /.
LOOP AT l_itab INTO l_str1.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab
IN
l_str1 WITH space.
WRITE: / l_str1.
ENDLOOP.
WRITE: /.
endform. "get_xml_table
*& Form process_dom
form process_dom using document type ref to if_ixml_document.
data: node type ref to if_ixml_node,
iterator type ref to if_ixml_node_iterator,
nodemap type ref to if_ixml_named_node_map,
attr type ref to if_ixml_node,
name type string,
prefix type string,
value type string,
indent type i,
count type i,
index type i.
data: name2 type string,
name_root type string,
node_parent type ref to if_ixml_node,
node_root type ref to if_ixml_node,
num_children type i.
node ?= document.
check not node is initial.
uline.
write: /.
write: /' DOM-TREE'.
write: /.
if node is initial. exit. endif.
create a node iterator
iterator = node->create_iterator( ).
get current node
node = iterator->get_next( ).
loop over all nodes
while not node is initial.
indent = node->get_height( ) * 2.
indent = indent + 20.
num_children = node->num_children( ).
case node->get_type( ).
when if_ixml_node=>co_node_element.
element node
name = node->get_name( ).
nodemap = node->get_attributes( ).
node_root = node->get_root( ).
name_root = node_root->get_name( ).
write: / 'ELEMENT :'.
write: at indent name color col_positive inverse.
write: 'NUM_CHILDREN:', num_children.
write: 'ROOT:', name_root.
node_parent = node->get_parent( ).
name2 = node_parent->get_name( ).
write: 'NAME2: ' , name2.
if not nodemap is initial.
*attributes
count = nodemap->get_length( ).
do count times.
index = sy-index - 1.
attr = nodemap->get_item( index ).
name = attr->get_name( ).
prefix = attr->get_namespace_prefix( ).
value = attr->get_value( ).
write: / 'ATTRIBUTE:'.
write: at indent name color col_heading inverse, '=',
value color col_total inverse.
enddo.
endif.
when if_ixml_node=>co_node_text or
if_ixml_node=>co_node_cdata_section.
*text node
value = node->get_value( ).
write: / 'VALUE :'.
node_parent = node->get_parent( ).
write: at indent value color col_group inverse.
name2 = node_parent->get_name( ).
write: 'NAME2: ' , name2.
endcase.
*advance to next node
node = iterator->get_next( ).
endwhile.
endform. "process_dom
Thanks,
Arunprasad.P -
Insert Insert XML file into multiple records in Oracle Database
I would like to find out if it is possible to insert a single XML file into multiple records or tuples in a Oracle database table. I have a single XML file which is at multiple levels. The meta data for the levels are common and each level can have meta data of their own in addition. I do not have any meta data field which will uniquely determine whether the data belongs to Root level, Intermediate level or at the document level. Is there any way I can determine which level the meta data belongs to and thereby make a corresponding entry into the database table tuple? For example I could have an attribute called level which is going to be present only in the database table and not in the XML file. If level=1 then it corresponds to "Root" meta data, if level=2 then it corresponds to "Intermediate" level and if level=3 then it corresponds to meta data at document level. I need a way to calculate the value for level from the XML file and thereby insert the meta data element into a tuple in a single table in Oracle.
Hi,
extract your xml and then you can use insert all clause.
here's very small example on 10.2.0.1.0
SQL> create table table1(id number,val varchar2(10));
Table created.
SQL> create table table2(id number,val varchar2(10));
Table created.
SQL> insert all
2 into table1 values(id,val)
3 into table2 values(id2,val2)
4 select extractValue(x.col,'/a/id1') id
5 ,extractValue(x.col,'/a/value') val
6 ,extractValue(x.col,'/a/value2') val2
7 ,extractValue(x.col,'/a/id2') id2
8 from (select xmltype('<a><id1>1</id1><value>a</value><id2>2</id2><value2>b</value2></a>') col from dual) x;
2 rows created.
SQL> select * from table1;
ID VAL
1 a
SQL> select * from table2;
ID VAL
2 b Ants -
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 -
C# Split xml file into multiple files
Below i have an xml file, in this file, i need to split this xml file into multiple xml files based on date column value,
suppose i have 10 records with 3 different dates then all unique date records should go into each file . for ex here i have a file with three dates my output should get 3 files while each file containing all records of unique date data. I didn't get any idea
to proceed on this, thats the reason am not posting any code.Needed urgently please
<XML>
<rootNode>
<childnode>
<date>2012-12-01</date>
<name>SSS</name>
</childnode>
<childnode>
<date>2012-12-01</date>
<name>SSS</name>
</childnode>
<childnode>
<date>2012-12-02</date>
<name>SSS</name>
</childnode>
<childnode>
<date>2012-12-03</date>
<name>SSS</name>
</childnode>
</rootNode>
</XML>Here is full code:
using System.Xml.Linq;
class curEntity
public DateTime Date;
public string Name;
public curEntity(DateTime _Date, string _Name)
Date = _Date;
Name = _Name;
static void Main(string[] args)
XElement xmlTree = new XElement("XML",
new XElement("rootNode",
new XElement("childnode",
new XElement("date"),
new XElement("name")
string InfilePath = @"C:\temp\1.xml";
string OutFilePath = @"C:\temp\1_";
XDocument xmlDoc = XDocument.Load(InfilePath);
List<curEntity> lst = xmlDoc.Element("XML").Element("rootNode").Elements("childnode")
.Select(element => new curEntity(Convert.ToDateTime(element.Element("date").Value), element.Element("name").Value))
.ToList();
var unique = lst.GroupBy(i => i.Date).Select(i => i.Key);
foreach (DateTime dt in unique)
List<curEntity> CurEntities = lst.FindAll(x => x.Date == dt);
XElement outXML = new XElement("XML",
new XElement("rootNode")
foreach(curEntity ce in CurEntities)
outXML.Element("rootNode").Add(new XElement("childnode",
new XElement("date", ce.Date.ToString("yyyy-MM-dd")),
new XElement("name", ce.Name)
outXML.Save(OutFilePath + dt.ToString("yyyy-MM-dd") + ".xml");
Console.WriteLine("Done");
Console.ReadKey(); -
A query while importing an XML file into a Database Table
Hi,
I am Creating an ODI Project to import an XML file into a Database Table.With the help of the following link
http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/odi/odi_11g/odi_project_xml-to-table/odi_project_xml-to-table.htm
I am facing a problem while creating Physical Schema for the XML Source Model.
For the
Schema(Schema)
and
Schema(Work Schema) field they have selected GEO_D.
What is GEO_D here??
or
What I have to select here?
1) schema of the xml file (NB:-I havn't created any .xsd or .dtd file for my .xml file)
or
2)my target servers schema
Please tell me what I'll do??
Thanksand
Schema(Work Schema) field they have selected GEO_D.
What is GEO_D here??This is the schema name which is specified in the XML file .
What I have to select here?
1) schema of the xml file (NB:-I havn't created any .xsd or .dtd file for my .xml file)Yes
2)my target servers schema
Please tell me what I'll do??
Thanks -
Reading XML file to ABAP internal table
Hi all,
Iam trying to convert a XLM file into abap internal table , am using XSLT transformation to parse the XML file and i am using "CALL METHOD cl_gui_frontend_services=>gui_upload" for reading the XML file.
below is the XML file.
===========================================================================
- <PIXBridge version="2.2" timestamp="2003-04-09T15:27:00">
- <PIX>
<TransactionType>605</TransactionType>
<TransactionCode>98</TransactionCode>
<TransactionNumber>6888965</TransactionNumber>
<SequenceNumber>40001</SequenceNumber>
- <SKUDefinition>
<Company>GZL</Company>
<Division>BMD</Division>
<Season />
<SeasonYear />
<Style>ORT002A</Style>
<StyleSuffix />
<Color>K13</Color>
<ColorSuffix />
<SecDimension />
<Quality />
<SizeRangeCode />
<SizeDesc>M</SizeDesc>
<SkuID>200140577</SkuID>
</SKUDefinition>
</PIX>
</PIXBridge>
=================================================================
and my Transformation code is as below
<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>
<IPIX>
<xsl:apply-templates select="//PIX"/>
</IPIX>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="PIX">
<item>
<TRANSACTIONTYPE>
<xsl:value-of select="TransactionType"/>
</TRANSACTIONTYPE>
<TRANSACTIONCODE>
<xsl:value-of select="TransactionCode"/>
</TRANSACTIONCODE>
<TRANSACTIONNUMBER>
<xsl:value-of select="TransactionNumber"/>
</TRANSACTIONNUMBER>
<SEQUENCENUMBER>
<xsl:value-of select="SequenceNumber"/>
</SEQUENCENUMBER>
<SKUDEFINITION>
<COMPANY>
<xsl:value-of select="Company"/>
</COMPANY>
<DIVISION>
<xsl:value-of select="Division"/>
</DIVISION>
<SEASON/>
<SEASONYEAR/>
<STYLE>
<xsl:value-of select="Style"/>
</STYLE>
<STYLESUFFIX/>
<COLOR>
<xsl:value-of select="Color"/>
</COLOR>
<COLORSUFFIX/>
<SECDIMENSION/>
<QUANTITY/>
<SIZERANGECODE/>
<SIZEDESC>
<xsl:value-of select="SizeDesc"/>
</SIZEDESC>
<SKUID>
<xsl:value-of select="SkuID"/>
</SKUID>
</SKUDEFINITION>
</item>
</xsl:template>
When i run my program i am getting the values only till the sequence number part and im not getting any values that is read in between <SKUDEFINITION> ..... </SKUDEFINITION>
I need help to sort this , kindly help me in this.
regs,
rajaI am not able to get a clue out of that, can Get Durairaj Athavan Raja in to loop for sorting this out.
I made changes to my transformation program , but still not getting the output of the components inside the
<SKUDefinition> , but when i debug the transformation i can able to see the output values for those components but when i get the values in the result table im not getting values of those components.
<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>
<IPIX>
<xsl:apply-templates select="//PIX"/>
</IPIX>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="PIX">
<item>
<TRANSACTIONTYPE>
<xsl:value-of select="TransactionType"/>
</TRANSACTIONTYPE>
<TRANSACTIONCODE>
<xsl:value-of select="TransactionCode"/>
</TRANSACTIONCODE>
<TRANSACTIONNUMBER>
<xsl:value-of select="TransactionNumber"/>
</TRANSACTIONNUMBER>
<SEQUENCENUMBER>
<xsl:value-of select="SequenceNumber"/>
</SEQUENCENUMBER>
<xsl:for-each select="SKUDefinition">
<SKUDEFINITION>
<COMPANY>
<xsl:value-of select="Company"/>
</COMPANY>
<DIVISION>
<xsl:value-of select="Division"/>
</DIVISION>
<SEASON/>
<SEASONYEAR/>
<STYLE>
<xsl:value-of select="Style"/>
</STYLE>
<STYLESUFFIX/>
<COLOR>
<xsl:value-of select="Color"/>
</COLOR>
<COLORSUFFIX/>
<SECDIMENSION/>
<QUANTITY/>
<SIZERANGECODE/>
<SIZEDESC>
<xsl:value-of select="SizeDesc"/>
</SIZEDESC>
<SKUID>
<xsl:value-of select="SkuID"/>
</SKUID>
</SKUDEFINITION>
</xsl:for-each>
</item>
</xsl:template>
</xsl:transform>
==================
Below is my main program
===================
TYPE-POOLS abap.
CONSTANTS gs_file TYPE string VALUE 'C:\XMLABAP1.xml'.
This is the structure for the data from the XML file
TYPES: BEGIN OF ty_text,
TransactionType(3) type n,
TransactionCode(2) type n,
TransactionNumber(7) type n,
SequenceNumber(5) type n,
Company(3) type c,
Division(3) type c,
Season(3) type c,
SeasonYear(4) type c,
Style(8) type c,
Color(3) type c,
SecDimension(3) type c,
Quality(3) type n,
SizeRangeCode(2) type c,
SizeDesc(1) type c,
SkuID(10) type c,
END OF ty_text.
Table for the XML content
DATA: gt_itab TYPE STANDARD TABLE OF char2048.
data: xmlstr TYPE XSTRING.
Table and work ares for the data from the XML file
DATA: gt_person TYPE STANDARD TABLE OF ty_text,
gs_person TYPE ty_text.
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_itab
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
"IPERSON".
GET REFERENCE OF gt_person INTO gs_result_xml-value.
gs_result_xml-name = 'IPIX'.
APPEND gs_result_xml TO gt_result_xml.
Perform the XSLT stylesheet
TRY.
CALL TRANSFORMATION ZAUM_MANH_SYNC_RPT
SOURCE XML XMLSTR
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_person INTO gs_person.
WRITE: / 'Transaction Type:', gs_person-TransactionType.
WRITE: / 'Transaction Code :', gs_person-TransactionCode.
WRITE: / 'Transaction Number :', gs_person-TransactionNumber.
WRITE: / 'SequenceNumber :', gs_person-SequenceNumber.
WRITE: / 'Company : ', gs_person-Company.
WRITE : /.
ENDLOOP. "gt_person. -
Upload a .CSV File into an Internal table
Hi,
What are the parameters to be filled into the Function Modules "GUI_UPLOAD" and "ALSM_EXCEL_TO_INTERNAL_TABLE" to Upload a .CSV File into an internal table.
Please send a sample code to support this....
Regards,
Aadhi.Hi,
Check the below code.
TYPE-POOLS: truxs.
TYPES:
BEGIN OF ty_line,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
END OF ty_line.
*data: ty_Lines TYPE STANDARD TABLE of ty_Line WITH DEFAULT KEY.
DATA: itab TYPE STANDARD TABLE OF ty_line WITH DEFAULT KEY.
DATA: itab1 TYPE truxs_t_text_data.
SELECT
vbeln
posnr
UP TO 10 ROWS
FROM vbap
INTO TABLE itab.
CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
EXPORTING
i_field_seperator = ';'
TABLES
i_tab_sap_data = itab
CHANGING
i_tab_converted_data = itab1
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'd:\TEMP\test1.txt'
TABLES
data_tab = itab1
EXCEPTIONS
OTHERS = 1.
IF sy-subrc eq 0.
WRITE: 'Data downloaded successfully'.
ENDIF.
DATA: BEGIN OF IEXCEL OCCURS 0.
INCLUDE STRUCTURE ALSMEX_TABLINE.
DATA: END OF IEXCEL.
PARAMETERS: FILENM LIKE rlgrap-filename MEMORY ID M01,
NOHEADER AS CHECKBOX.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = FILENM
i_begin_col = 1
i_begin_row = 1
i_end_col = 100
i_end_row = 30000
tables
intern = IEXCEL
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
if sy-subrc <> 0.
WRITE: / 'EXCEL UPLOAD FAILED ', FILENM, SY-SUBRC.
endif. -
Upload an Excel file into an Internal Table
Hi,
I want to upload an Excel file into an internal table but it doesn't work. I'd appreciate if someone could tell me what is wrong.
My excel file has the following format:
Col1 Col2
Row1 1 2
Row2 2 3
Row3 3 4
And the report code is the following one:
REPORT ZFI_PROKON_PROCESOS.
DATA: BEGIN OF itab OCCURS 0,
num1(1),
num2(1).
DATA: END OF itab.
PARAMETERS: p_file LIKE rlgrap-filename obligatory.
AT SELECTION-SCREEN.
AT SELECTION-SCREEN on value-request for p_file.
call function 'KD_GET_FILENAME_ON_F4'
EXPORTING
static = 'X'
CHANGING
file_name = p_file.
START-OF-SELECTION.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = p_file
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 2
I_END_ROW = 5
TABLES
INTERN = itab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT itab.
WRITE: / itab-num1, 10 itab-num2.
ENDLOOP.
Thanks in advance,
GerardTry function module
ALSM_EXCEL_TO_INTERNAL_TABLE
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = p_path
i_begin_col = 1
i_begin_row = 2
i_end_col = 70
i_end_row = 10000
tables
intern = i_excel
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
P_PATH is file name with path.
I_EXCEL is internal table to store data.
declaration is "i_excel like structure alsmex_tabline"
then loop at i_Excel and populate your table
for eg
loop at i_excel.
case i_excel-col.
when '0001'.
i_data-compcode = i_excel-value.
when '0002'.
i_data-rcpttyp = i_excel-value.
when '0003'.
i_data-pocimpro = i_excel-value.
when '0004'.
i_data-tranno = i_excel-value.
when '0005'.
i_data-msrpo = i_excel-value.
when '0006'.
i_data-mporel = i_excel-value.
endcase.
at end of row.
append i_data.
clear i_data.
endat.
endloop. -
Split a string into multiple internal tables
Hi all,
I need to split a string based internal table into multiple internal tables based on some sub strings in that string based internal table...
High priority help me out...
eg...
a | jhkhjk | kljdskj |lkjdlj |
b | kjhdkjh | kldjkj |
c | jndojkok |
d |
this data which is in the application server file is brought into a internal table as a text. Now i need to send 'a' to one internal table, 'b' to one internal table, so on... help me
<Priority downgraded>
Edited by: Suhas Saha on Oct 12, 2011 12:24 PMHi pradeep,
eg...
a | jhkhjk | kljdskj |lkjdlj |
b | kjhdkjh | kldjkj |
c | jndojkok |
d |
As per your statement "Now i need to send 'a' to one internal table, 'b' to one internal table"
Do you want only a to one internal table and b to one internal table
OR
Do you want the whole row of the internal table i mean
a | jhkhjk | kljdskj |lkjdlj | to 1 internal table
Having the case of an internal table which is of type string,
1) Loop through the internal table. LOOP AT lt_tab INTO lwa_tab.
2) Ge the work area contents and get the first char wa_tab-string+0(1)
3) FIELD-SYMBOLS: <t_itab> TYPE ANY TABLE.
w_tabname = p_table.
CREATE DATA w_dref TYPE TABLE OF (w_tabname).
ASSIGN w_dref->* TO <t_itab>.
Follow the link
http://www.sap-img.com/ab030.htm
http://www.sapdev.co.uk/tips/dynamic-structure.htm
and then based on the sy-tabix values you will get that many number of internal table
<FS> = wa_tab-string+0(1)
append <FS>
OR
USE SPLIT statement at the relevant seperator
revert for further clarification
Thanks
Sri
Edited by: SRIKANTH P on Oct 12, 2011 12:36 PM -
How to create a data connection with dynamic XML file?
Thanks for all reply first!
I have formatted the submitted data into an XML file on the server side,this file can be import to PDF form correctly.
I try to send this XML file to the user to let him can review what he has submitted.
I guess that I should create a data connection to the XML file so that it can be reviewed by the user.
But the question is that the XML file is dynamic generated.
How can i do?
give me some clus or examples,please.
thanks,
Jasper.Hi Jasper,
To show user back the result, you can use PDF instead of XML. You can store the PDF template in server and you can merge XML data with PDF template by Livecycle Form Data Integration service.
We, as KGC, can generate huge number of Adobe Livecycle forms in small periods. Also we give consultancy on Adobe Livecycle ES products and Adobe Livecyle Designer. In case of any need, do not hesitate to contact us.
Asiye Günaydın
Project Consultant
KGC Consulting Co.
www.kgc.com.tr -
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
-
Accessor is not a parameter accessor
Hello! I am using Oracle Provider for OLE DB 10.2.0.2.20 with my vb6 code. I am getting this " accessor is not a parameter accessor" error with the long decimal values? Is there any fix for this problem? Round function helps, but it is not "right" fi
-
Lion Server Mobile accounts for Macbook users
Hi All, I'm looking for a 'Best Practice' when setting up mobile accounts for Macbook users who just want to be able to use their machine away from the office. We DON'T want to sync anything, just create a mobile account on the Mac (a bit like a doma
-
Automatically add new SQL data sources on secondary server
Hi there.. I have found an issue that I cannot resolve. We have two DPM servers set up to be secondary servers for each other.. it has worked well for months and I was very happy with the setup. What I had not realized was if a new SQL database was c
-
I need to run an iMac as a server, without a keyboard
I have an iMac that I am using to connect to a weather station via an USB port. It runs 24 hours a day, with a self-reboot every night (because the USB port connection is not always stable over long periods.) Scripts get weather data and upload it to
-
Is it a must to create font folders separately for 32bit Ai & 64bit PS ?
is there any way to create ONE common font folder for both 32bit Ai and 63bit PS?