cancel
Showing results for 
Search instead for 
Did you mean: 

How to extract XML data to Web Dynpro context

Former Member
0 Kudos

Hi Experts,

I have know that web dynpro context can export to XML string easily. And can we do it in the opposite direction?

I have a XML string which contains some nodes of the context in a web dynpro View. How can I extract the XML string to data like tables or structures and then mapping it into the context?

Thanks so much.

Best Regrads,

Guo Guo Qing

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

You can refer the below blog.

It will give you a very clear picture of uploading PDF data to view context.

[Upload XML Data to view context|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/9121%3Fpage%3Dlast%26x-order%3Ddate] [original link is broken] [original link is broken] [original link is broken];

[Upload PDF form Data to the view context|/people/shruti.rathour/blog/2008/02/07/uploading-sap-interactive-form-on-the-abap-webdynpro-view]

Hope it will help.

Thanks.

rainer_liebisch
Contributor
0 Kudos

Hello Guo,

you have to write a XSLT transformation and call it like:

try.

call transformation MY_TRANSF

source XML xcontent

result TRANSPORT = it_table.

catch cx_xslt_exception into except.

wd_this->message_manager->report_error_message( message_text = 'error_txt' ).

return.

endtry.

xcontent is the XSTRING containing your XML string and it_table is the table you want to fill. This table can be bound to the context.

The XSLT transformation must reflect the structure of your XML code. Here an example I have written some time ago:

<xsl:transform version="1.0"

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

xmlns:sap="http://www.sap.com/sapxsl" >

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

<xsl:template match="transport">

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

<asx:values>

<TRANSPORT>

<xsl:apply-templates/>

</TRANSPORT>

</asx:values>

</asx:abap>

</xsl:template>

<xsl:template match="message">

<xsl:variable name="msg" select="."/>

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

<xsl:variable name="prod" select="."/>

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

<xsl:variable name="devgr" select="."/>

<xsl:for-each select="./responsibles/name">

<xsl:variable name="resp" select="."/>

<xsl:for-each select="../../sp">

<xsl:variable name="SP" select="."/>

<xsl:variable name="p4" select="./p4"/>

<xsl:variable name="track" select="./track"/>

<T_TRANSPORTS_TAB>

<MESSAGE><xsl:value-of select="$msg/@validFor"/></MESSAGE>

<PRODUCT><xsl:value-of select="$prod/@name"/></PRODUCT>

<DEVGRP><xsl:value-of select="$devgr/@name"/></DEVGRP>

<RESPONSIBLE><xsl:value-of select="$resp"/></RESPONSIBLE>

<MAILADDR><xsl:value-of select="$resp/@mailaddr"/></MAILADDR>

<SUPPACK><xsl:value-of select="$SP/@name"/></SUPPACK>

<PERF><xsl:value-of select="$p4"/></PERF>

<TRACK><xsl:value-of select="$track"/></TRACK>

</T_TRANSPORTS_TAB>

</xsl:for-each>

</xsl:for-each>

</xsl:for-each>

</xsl:for-each>

</xsl:template>

</xsl:transform>

Regards,

Rainer

Former Member
0 Kudos

hi Rainer Liebisch ,

is it possible to do the transfermation using DOM? not ST?

I prefer DOM ,because it could be used generically(as long as the field names are identical ), using ST,we have to define a schem first.

br.

netz

Former Member
0 Kudos

Hi,

For DOM approach,

These blog links are useful to read XML data into Internal

Tables and the other way.

[1. XML DOM Processing in ABAP part I - |https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2657] [original link is broken] [original link is broken] [original link is broken] [original link is broken];

[2. XML DOM Processing in ABAP part II - |https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2657] [original link is broken] [original link is broken] [original link is broken] [original link is broken];

Also, check if this link could help you,

[Uploading SAP Interactive Form on the ABAP WebDynpro View-|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/8554] [original link is broken] [original link is broken] [original link is broken];

revert back for more details,

-

Achyut

Edited by: Achyut Dake on Apr 23, 2008 11:10 AM