cancel
Showing results for 
Search instead for 
Did you mean: 

XML to DDIC Tables

Former Member
0 Kudos

I need to import an xml file lookgin like this:

<TABLE>

<TABNAME>COMM_PRODUCT</TABNAME>

<FIELDNAMES>

<FIELDNAME>CLIENT</FIELDNAME>

<FIELDNAME>PRODUCT_ID</FIELDNAME>

</FIELDNAMES>

</TABLE>

The above XML has been created using the following XSLT:

<?xml version="1.0" encoding="iso-8859-1"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:xa="urn:schemas-microsoft-com:xml-analysis:mddataset"

xmlns:asx="http://www.sap.com/abapxml" version="1.0">

<xsl:strip-space elements="*"/>

<xsl:output method="xml" />

<xsl:variable name="fieldnames" select="//asx:abap/asx:values/FIELDCAT" />

<xsl:template match="/">

<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">

<asx:values>

<xsl:apply-templates select="//ZTESTSWB"/>

</asx:values>

</asx:abap>

</xsl:template>

<xsl:template match="//ZTESTSWB">

<ZTESTSWB>

<xsl:for-each select="*">

<!column &amp;gt;&amp;lt;xsl:apply-templates&amp;gt;&amp;lt;/column>

<xsl:copy>

<xsl:apply-templates select="text()"/>

<xsl:for-each select="@FIELDNAMES|*">

<FIELDNAME><xsl:value-of select="FIELDNAME"/></FIELDNAME>

</xsl:for-each>

</xsl:copy>

</xsl:for-each>

</ZTESTSWB>

</xsl:template>

</xsl:stylesheet>

I have also declared an internal table looking like this:

Table: META

Structure:

ZTESTSWB

TABNAME

FIELDNAMES (Reference table type)

FIELDNAME

When using the command

Call transformation with the parameters:

SOURCE XML (xml string)

RESULT ZTESTSWB = META.

the result is :

Format error at the XML Element of type text, name: "{}"

Thank you for your help.

Soeren Baek

Accepted Solutions (0)

Answers (1)

Answers (1)

athavanraja
Active Contributor
0 Kudos

Hi Soeren,

Welcome to SDN.

which XSLT program you are using to convert XML to ITAB?

is it the one you posted here?

and also give us the XML so that we can see whats going wrong?

Regards

Raja

Former Member
0 Kudos

Hi Raja,

Thank you for the welcome.

I use the SAP internal XSLT program, the stylesheet declaration is just a copy of another program.

here is the XML:

<?xml version="1.0" encoding="utf-8" ?>

<asx:abap xmlns:asx="http://www.sap.com/abapxml" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:xa="urn:schemas-microsoft-com:xml-analysis:mddataset" version="1.0">

<asx:values>

<ZTESTSWB>

<TABNAME>COMM_PRODUCT</TABNAME>

<REFTAB />

<FIELDNAMES>

<FIELDNAME>CLIENT</FIELDNAME>

<FIELDNAME>PRODUCT_GUID</FIELDNAME>

<FIELDNAME>PRODUCT_ID</FIELDNAME>

<FIELDNAME>PRODUCT_TYPE</FIELDNAME>

<FIELDNAME>CONFIG</FIELDNAME>

<FIELDNAME>XNOSEARCH</FIELDNAME>

<FIELDNAME>OBJECT_FAMILY</FIELDNAME>

<FIELDNAME>BATCH_DEDICATED</FIELDNAME>

<FIELDNAME>COMPETITOR_PROD</FIELDNAME>

<FIELDNAME>VALID_FROM</FIELDNAME>

<FIELDNAME>VALID_TO</FIELDNAME>

<FIELDNAME>UPNAME</FIELDNAME>

<FIELDNAME>HISTEX</FIELDNAME>

<FIELDNAME>LOGSYS</FIELDNAME>

</FIELDNAMES>

</ZTESTSWB>

<ZTESTSWB>

<TABNAME>COMM_CATEGORY</TABNAME>

<REFTAB />

<FIELDNAMES>

<FIELDNAME>CLIENT</FIELDNAME>

<FIELDNAME>CATEGORY_GUID</FIELDNAME>

<FIELDNAME>CATEGORY_ID</FIELDNAME>

<FIELDNAME>HIERARCHY_GUID</FIELDNAME>

<FIELDNAME>PARENT_GUID</FIELDNAME>

<FIELDNAME>NON_ASSIGNABLE</FIELDNAME>

<FIELDNAME>VALID_FROM</FIELDNAME>

<FIELDNAME>VALID_TO</FIELDNAME>

<FIELDNAME>UPNAME</FIELDNAME>

<FIELDNAME>HISTEX</FIELDNAME>

<FIELDNAME>LOGSYS</FIELDNAME>

</FIELDNAMES>

</ZTESTSWB>

</asx:values>

</asx:abap>

The internal table(s) has been declared exactly like the XML structure.

Regards

Soeren

athavanraja
Active Contributor
0 Kudos

your internal table declaration should be something like below.

types : begin of fn_type ,

fieldname(100),

end of fn_type .

data: begin of ztestswb occurs 0 ,

tabname(100),

reftab(100),

fieldnames type standard table of fn_type ,

end of ztestswb .

as for the XSLT program to use with your call transformation, can you give me the XSLT program name i can check it up in the system (looks like BW system).

My guess is that you may have to write the XLST.

Regards

Raja

Former Member
0 Kudos

My internal tables has been declared exactly like you wrote it.

The XSLT program i have already created and i included it in the earlier email. Do I need to create a second one for the import?

The system is CRM 4.

If i use the test function the result looks fine, but the call transform fails.

regards

Soeren

athavanraja
Active Contributor
0 Kudos

you wrote in your first post that the XLST file was used to create the XML - thus the confusion.

CALL TRANSFORMATION (`<Z_myxslt_program>`)

SOURCE XML xml_string

RESULT outtab = itab[].

the XSLT program for ABAP to XML and for XML to ABAP will be different they wont be the same.

<i><b>If i use the test function the result looks fine, but the call transform fails</b></i>.

which test function are you talking about?

if the delivered test tool (in package SXSLT_TOOL) is working fine then you should not be having a problem with CALL TRANSFORMATION.

Regards

Raja

Former Member
0 Kudos

I use the one through transaction SE80 (XSLT-Program)

Then simply the Test button and I supply the XML file.

If I need to create an XSLT for the XML to DDIC, do you have any examples for that?

Thank you again.

Soeren

athavanraja
Active Contributor
0 Kudos

check out the following code sample this should give you an idea. for itab to XML and XML to itab

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/f50dcd4e-0501-0010-3596-b68...

Regards

Raja

Since you are new to SDN may i introduce to the SDN way of thanks - check out the following weblog for the same.

/people/mark.finnern/blog/2004/08/10/spread-the-love

Former Member
0 Kudos

I already tried the solution in that document, but the issue is the complex structure of the internal table which in this case does not work.

but thank you for your time.

Regards

Soeren

athavanraja
Active Contributor
0 Kudos

i havent tried with nested itabs. i will try to do a sample and i will post my findings here.

Regards

Raja

(you have to wait till saturday as thrusday and friday are my weekly off)