XSLT transformation for deep structure .....
Hello,
I am trying to do an XSLT transformation for a deep structure HAP_S_PDF_DOCUMENT (see it in SE11), I have managed to achieve this. but not with perfection. i still get some redundant data and data have been experiencing Data duplication. I was hoping if you people point out the what is wrong in the transfromation. The data repeats for every once under node DATA and then under node of the refered structure name. Besides it also create a blank row even if the record is 0. I am mostly facing problem with nodes T_ELEMENTS. T_COL_CELL and T_FIELD. These are the nested structures, Can anybody help / guide me to achieve these transforamtion?
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="HAP_DOCUMENT">
<xsl:element name="HAP_DOCUMENT" namespace="">
<xsl:apply-templates select="MAIN_HEADER"/>
<xsl:apply-templates select="T_ELEMENTS"/>
<xsl:apply-templates select="T_STAT_CHG_BUTTONS"/>
<xsl:apply-templates select="S_APPRAISAL_ID"/>
<xsl:apply-templates select="S_HEADER"/>
<xsl:apply-templates select="POSITIONS"/>
<xsl:element name="STAT_CHG_BUTTON">
<xsl:value-of select="../STAT_CHG_BUTTON"/>
</xsl:element>
<xsl:element name="OFFLINE_ID">
<xsl:value-of select="OFFLINE_ID"/>
</xsl:element>
<xsl:element name="BSP_FLAG">
<xsl:value-of select="BSP_FLAG"/>
</xsl:element>
<xsl:element name="ROLE">
<xsl:value-of select="ROLE"/>
</xsl:element>
<xsl:element name="APPRAISAL_YEAR">
<xsl:value-of select="APPRAISAL_YEAR"/>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="MAIN_HEADER">
<xsl:element name="MAIN_HEADER">
<xsl:for-each select="ZBGAPR_FORM_HEADER">
<xsl:element name="DATA">
<xsl:copy-of select="child::node()"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template match="T_ELEMENTS">
<xsl:element name="T_ELEMENTS">
<xsl:for-each select="ZHAP_S_PDF_ELEMENTS">
<xsl:element name="DATA">
<xsl:apply-templates select="T_COL_CELL"/>
<xsl:copy-of select="child::node()"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template match="T_COL_CELL">
<xsl:element name="T_COL_CELL">
<xsl:for-each select="ZHAP_S_PDF_COL_CELL">
<xsl:element name="DATA">
<xsl:apply-templates select="T_FIELD"/>
<xsl:copy-of select="child::node()"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template match="T_FIELD">
<xsl:element name="T_FIELD">
<xsl:for-each select="ZHAP_S_PDF_FIELD">
<xsl:element name="DATA">
<xsl:apply-templates select="T_VAL_VALUES"/>
<xsl:apply-templates select="T_VAL_RANGES"/>
<xsl:copy-of select="child::node()"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template match="T_VAL_VALUES">
<xsl:element name="T_VAL_VALUES">
<xsl:for-each select="HAP_S_BODY_CELL_VAL_VALUES">
<xsl:element name="DATA">
<xsl:copy-of select="child::node()"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template match="T_VAL_RANGES">
<xsl:element name="T_VAL_RANGES">
<xsl:for-each select="HAP_S_BODY_CELL_VAL_RANGES">
<xsl:element name="DATA">
<xsl:copy-of select="child::node()"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template match="T_STAT_CHG_BUTTONS">
<xsl:element name="T_STAT_CHG_BUTTONS">
<xsl:for-each select="HAP_S_BODY_CELL_VAL_RANGES">
<xsl:element name="DATA">
<xsl:copy-of select="child::node()"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template match="S_APPRAISAL_ID">
<xsl:element name="S_APPRAISAL_ID">
<xsl:copy-of select="node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="S_HEADER">
<xsl:element name="S_HEADER">
<xsl:apply-templates select="S_TEXTS"/>
<xsl:apply-templates select="T_APPRAISER"/>
<xsl:apply-templates select="T_APPRAISEE"/>
<xsl:apply-templates select="T_PART_APPRAISER"/>
<xsl:apply-templates select="T_OTHERS"/>
<xsl:apply-templates select="S_STATUS"/>
<xsl:apply-templates select="S_DATES"/>
<xsl:apply-templates select="S_DISPLAY"/>
</xsl:element>
</xsl:template>
<xsl:template match="POSITIONS">
<xsl:element name="POSITION">
<xsl:for-each select="ZBGHR_APR_POSITION_DET">
<xsl:element name="DATA">
<xsl:copy-of select="child::node()"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template match="S_TEXTS">
<xsl:element name="S_TEXTS">
<xsl:copy-of select="node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="T_APPRAISER">
<xsl:element name="T_APPRAISER">
<xsl:for-each select="HAP_S_PDF_APPRAISER">
<xsl:element name="DATA">
<xsl:copy-of select="child::node()"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template match="T_APPRAISEE">
<xsl:element name="T_APPRAISEE">
<xsl:for-each select="HAP_S_PDF_APPRAISEE">
<xsl:element name="DATA">
<xsl:copy-of select="child::node()"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template match="T_OTHERS">
<xsl:element name="T_OTHERS">
<xsl:for-each select="HAP_S_PDF_OTHERS">
<xsl:element name="DATA">
<xsl:copy-of select="child::node()"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template match="T_PART_APPRAISER">
<xsl:element name="T_PART_APPRAISER">
<xsl:for-each select="HAP_S_PDF_PART_APPRAISERS">
<xsl:element name="DATA">
<xsl:copy-of select="child::node()"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template match="T_PART_APPRAISER">
<xsl:element name="T_PART_APPRAISER">
<xsl:for-each select="HAP_S_PDF_PART_APPRAISERS">
<xsl:element name="DATA">
<xsl:copy-of select="child::node()"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template match="S_STATUS">
<xsl:element name="S_STATUS">
<xsl:copy-of select="node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="S_DATES">
<xsl:element name="S_DATES">
<xsl:copy-of select="node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="S_DISPLAY">
<xsl:element name="S_DISPLAY">
<xsl:copy-of select="node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="STAT_CHG_BUTTON">
</xsl:template>
<xsl:template match="OFFLINE_ID">
</xsl:template>
<xsl:template match="BSP_FLAG">
</xsl:template>
<xsl:template match="ROLE">
</xsl:template>
<xsl:template match="APPRAISAL_YEAR">
</xsl:template>
</xsl:transform>
Regards,
Shishir.P
"XSLT transformation for a deep structure"
which way abap to xml or xml to abap?
you may want to check this thread
Re: Problem converting XML back to structure using XSLT
Similar Messages
-
Reciever file adapter configuration for Deep structure
Hi Experts,
I have a idoc to file scenario in which i used a data type for file in below format:
DT_Test
-->Recordset(0.unbounded)
>E21DPU1(0.unbounded)
>field1
>field2
>E21DPU5(0.unbounded)
>filed 3
>filed 4
>E21DP03(0.unbounded)
>filed 5
>filed 6
Here DT_test is datatype name,Recordset is a structure name which contain E21DPU1, E21DPU5,E21DPO3 stucture inside it.Now,E21DPU5 and E21DPO3 structures are under E21DPU1.
I am confused in creating content conversion parameters i.e what we have to mention in Recordset Stucture .
I used E21DPU1,,E21DPU5,,E21DP03,* .should it work for deep structure.
Thanks
DeepakHi,
file adapter does not handle 2 level deep structures
the easiest way to do it now is to go for abap or java mapping
and create a line for each of the output lines and handle this in the file adapter
so like <line> </line>
<line>E21DPU1(0.unbounded) with fields </line>
<line>E21DPU5(0.unbounded) with fields </line>
<line> etc. </line>
Regards,
Michal Krawczyk -
BI Admin Tool and XSLT transformation for XML data source - How it works ?
Hello,
There is a possibility to import data from XML data source using BI Admin Tool.
In the import window we can point XSLT file. What is the purpose of that XSLT field?
Why I am asking ?
I thought it is smth like XSLT processor, but simply it doesnt work.
What I did:
- I pointed XML data source file
- I pointed XSLT transformation file
- Click OK, and still get the message that the XML file structure is not supported
After that I transformed that XML file with some desktop XSLT processor using the same XSLT file, and I tried to connect that file directly using BI Admin tool.Then it works. So it means that the transformation is ok.
So basically one question comes to my mind in that situation:
What is the purpose of XSLT field in BI Admin Tool when it comes to XML data source ?
(it doesnt look like XSLT processor)
Greetings
/MichalHi Mariano
Why you need to use XSLT for transforming XML file into ABAP table
Code is a part of some ABAP report. Looks like it is reading a file from file system and updating table after transformation
If you have requirement like you need to read XML file and then insert the data into a SAP table
You can use
File to RFC
File to Proxy scenario using SAP PI.
Please provide more inputs on requirement to help
Thanks
Gaurav -
XSLT transformation for Single XML Output
I want to save a book to a single XML document. Is it correct that I can do this by adding an xslt to merge the standard framemaker entity type output ? Can I easily reconfigure the standard Save As XML to acheive this? or do I need to add a new menu item and call the XSLT dialogue...
any advice appreciated.
Thanks!Tracey,
A related discussion appeared in the FrameSGML Yahoo group recently. Much of what follows is what I wrote there.
Your XML application (defined in structapps.fm or another application definition file) can specify an XSLT post-process. No need to change Save as XML or define a new menu item. Depending on what you want, the XSLT transform can be as simple as the following:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="/ | node() | @*">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:transform>
This is an identity transform that simply copies the interpreted input to the output. I've used the word "interpreted" here because XSLT does not distinguish among some variations of how content is entered. In particular, it does not distinguish between content in referenced general entities (which is what you want) or between attribute values that happen to be the same as the attribute default value and attributes that are not explicitly specified and hence use the default value.
There are a few things to watch out for involving use of general entities.
First, if you are using entity attributes for graphics, you'll need to modify the above slightly. It's probably easier to replace the entity attributes with file attributes, but if you want to keep the entities, the above needs to be extended to declare the entities.
Second, if you are using and want to preserve entity references for special characters or variables, you'll need to account for them as well. See $FMHOME\Structure\xml\PreserveEntity\readme.pdf.
--Lynne -
XSLT transformation for XML to ABAP internal table
Hi, can anyone please tell me how it should be the xslt tranformation to conver this xml
<Embargos_ARBA_DOC>
<ns:Embargos_ARBA_MT
xmlns:ns="un:swissmedical:sap:proxy:embargos_arba:file">
<Embargos_ARBA_MT>
<FECHA>20081101</FECHA>
<CUIT>50000002124</CUIT>
<MONTO>0000013794090</MONTO>
<RAZON_SOCIAL>RAUL ARMANDO CUNQUEIRO S.A.C.I.</RAZON_SOCIAL>
</Embargos_ARBA_MT>
<Embargos_ARBA_MT>
<FECHA>20081101</FECHA>
<CUIT>55000001456</CUIT>
<MONTO>0000001144410</MONTO>
<RAZON_SOCIAL>PARODI ESTEBAN ARMANDO</RAZON_SOCIAL>
</Embargos_ARBA_MT>
</ns:Embargos_ARBA_MT>
</Embargos_ARBA_DOC>
to this abap Table....
DATA: BEGIN OF i_embargos_arba_doc occurs 0,
fecha TYPE d,
cuit TYPE char11,
monto TYPE char13,
razon_social(120),
END OF i_embargos_arba_mt.
so i can transform it with this sentence
CALL TRANSFORMATION ('embargos_transformation')
SOURCE XML source
RESULT Embargos_ARBA_DOC = embargos.
pls i need help because i am unable to create this xslt transformation...
I will give the highest rewards points to the one who can help me.
thanks!
marianoHi Mariano
Why you need to use XSLT for transforming XML file into ABAP table
Code is a part of some ABAP report. Looks like it is reading a file from file system and updating table after transformation
If you have requirement like you need to read XML file and then insert the data into a SAP table
You can use
File to RFC
File to Proxy scenario using SAP PI.
Please provide more inputs on requirement to help
Thanks
Gaurav -
Dynamic XSLT Transformation for ABAP
Hi Team,
I have a simple requirement, but could not get it to work. Tried different posts but need some help.
I have an input XML file as follows:
<ITEM>
<ITEMQUALF>
<MATERIAL>
<UPC>
<VENDORMATERIAL>
<ITEM>
I created my internal table with the exact fields as above and created a transformation which works fine. The problem is, there are scenario's where only one tag "MATERIAL", "UPC", OR "VENDORMATERIAL" is passed in the input XML. Empty tags are not passed. For E.G.
<ITEM>
<ITEMQUALF>
<UPC>
<ITEM>
My transformation fails in this scenario because it does not finds the MATERIAL and VENDORMATERIAL tags. I tried using the <tt:cond/> tag, but no luck. I have some specific questions:
1) How to take care of this scenario where empty tags are not passed? (I have the Superset of all the Tags available in an XSD). A quick Sample would help me a lot because I have spent weeks breaking my head with this.
2) Is there any other method or Option to parse a very larger input file (~40 MB) as above? I have seen the iXML ABAP methods but don't know if we should use XSLT or iXML or is there any other method. We don't have XI in our landscape. Our system is ECC 6.0, ABAP 7.0 - SP 17, Enhancement Pack 3.
Any pointers would help a lot. Thanks for your time.
Regards
SanjayHello Sanjay
In such a scenario I usually make pre-transformation filling the missing elements before the main mapping.
Input:
<?xml version="1.0" encoding="utf-8"?>
<List>
<ITEM>
<ITEMQUALF/>
<MATERIAL/>
<UPC/>
<VENDORMATERIAL/>
</ITEM>
<ITEM>
<ITEMQUALF/>
<UPC/>
</ITEM>
<ITEM>
<MATERIAL/>
</ITEM>
</List>
XSLT Mapping (XML to XML):
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="*">
<List>
<xsl:for-each select="ITEM">
<xsl:element name="ITEM">
<xsl:element name="ITEMQUALF">
<xsl:value-of select="ITEMQUALF"/>
</xsl:element>
<xsl:element name="MATERIAL">
<xsl:value-of select="MATERIAL"/>
</xsl:element>
<xsl:element name="UPC">
<xsl:value-of select="UPC"/>
</xsl:element>
<xsl:element name="VENDORMATERIAL">
<xsl:value-of select="VENDORMATERIAL"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</List>
</xsl:template>
</xsl:stylesheet>
Resulting XML:
<?xml version="1.0" encoding="UTF-8"?>
<List>
<ITEM>
<ITEMQUALF/>
<MATERIAL/>
<UPC/>
<VENDORMATERIAL/>
</ITEM>
<ITEM>
<ITEMQUALF/>
<MATERIAL/>
<UPC/>
<VENDORMATERIAL/>
</ITEM>
<ITEM>
<ITEMQUALF/>
<MATERIAL/>
<UPC/>
<VENDORMATERIAL/>
</ITEM>
</List>
Regards
Uwe -
Exception in creating XSLT transform for ESB Routing Service
Hi,
I am trying to create a Routing service in an ESB project. When I try to create the XSLT in a routing rule I get this error "Error while reading wsdl file esb:///ESB_projects/...../ship.wsdl ... Failed to read WSDL file at location esb:///ESB_projects/...../ship.wsdl . java.net.Socket Exception.
I am able to create and register other adapter/soap services on the ESB server but not able to create this transform.Could anybody guide me as to how to resolve this?
Regards,
SriThe file doesn't physically exist on the server. If you explore the subfolders of the %OH%\integration\esb\oraesb folder, you'll see how ESB projects are deployed.
-
Hi
I have a flat file like this.
I am not able to create sender and receiver data types. can anyone tell me how to do.
Here For one plant there are many materials.
=====================================================================
Werks MATNR ERSDA ERNAM MTART MATKL MAKTX
====================================================================
0001 CP-12 20020719 PREMKE KMAT CP-12
0001 CP12 20020717 PREMKE HAWA 015 CP12
0001 CPH_3001 20050802 D035495 ROH Aqua
005 T-EC0201 20060327 WILHELMH HAWA 009 Cycle shorts
0005 T-FC0101 20060327 WILHELMH FERT Lady`s 24'' Street Bike
0006 NGL-OS-FILE 20060316 LCHAMDONDOG NLAG 006 File
0007 NGL-OS-FILE 20060316 LCHAMDONDOG NLAG 006 File
0008 NGL-OS-FILE 20060316 LCHAMDONDOG NLAG 006 File
I want XML file should be like this
<MT_Sender>
<record>
<plant>
<werks>0001</werks>
</plant>
<matinfo>
<matnr>cp-12></matnr>
<ersda>20020719</ersda>
</matinfo>
<matinfo>
<matnr>cp-12</matnr>
<ersda>20020717</ersda>
</matinfo>
</record>
<record>
like this..I want to connvert tht into flat file-xml file.
I looked some deep struture blogs..but I couldnot understand.
Reagrds
Vijay
Edited by: vijay reddy on Apr 10, 2009 4:10 PMHi Vijay,
Using FCC it is not posible.You can acheive it using two message mapping.
Steps:
STEP1:
Do the normal content conversion and get each Line as separate Record. say the message type you created is MT_FCC_Outbound
STEP 2:
First Mapping:
Outbound Mesage type : MT_FCC_Outbound
Inbound Mesage type : MT_FCC_Outbound
Here in this mapping you group the records on the basis of werks.
STEP3:
Second mapping:
Outbound Mesage type : MT_FCC_Outbound
Inbound Mesage type : MT_FCC_Inbound
Do the actual maaping
STEP 4:
Interface mapping: Outbound Mesage :
MI_FCC_Outbound (message interface)
Inbound Mesage : MI_FCC_Inbound
first give mapping1 then in second row mapping 2.
Ritu -
How to read xml with deep structure into intarnal table.
Hi,
Could you pls any body provide xslt code for deep structure convert into internal table.
sample xml file:
- <ns0:CREATIONOFCONTRACT xmlns:ns0="http://BPCreationXSD.CreationOfContract">
- <CREATIONOFCONTRACTDATA>
<RequestType>L0011</RequestType>
<ApplicationId>AN-12</ApplicationId>
<LoanId>QO-22</LoanId>
- <Borrowerguarantorinfo>
<Borrowerbpno>101020</Borrowerbpno>
<Co-borrower1BPNo>101021</Co-borrower1BPNo>
<Co-borrower2BPNo>101022</Co-borrower2BPNo>
<Guarantor1BPNo>101023</Guarantor1BPNo>
<Guarantor2BPNo>101024</Guarantor2BPNo>
<Branch>New Delhi</Branch>
</Borrowerguarantorinfo>
- <Loaninfo>
<Applicationtype>Fresh</Applicationtype>
<Purposeofloan>Home Purchase</Purposeofloan>
<Securedunsecuredflag>Secured</Securedunsecuredflag>
<Loantype>HL with MRTA</Loantype>
<Loancurrency>INR</Loancurrency>
<Loanproduct>MaxiHome Loan Package</Loanproduct>
<Loanscheme>MaxiHome ZEC</Loanscheme>
<Loanamount>1500000.00</Loanamount>
<Loantenure>60</Loantenure>
<Tiered>No</Tiered>
</Loaninfo>
<Periodfrom>01/07/2009</Periodfrom>
<Periodto>16/09/2019</Periodto>
<RateType>Fixed</RateType>
<Ratecode>10.25</Ratecode>
</CREATIONOFCONTRACTDATA>
</ns0:CREATIONOFCONTRACT>Hi Ramesh,
Thanks for the info,but I found lot of tables unfortunately I am not getting the value for radio buttons. Also I found a FM FIELD_SELECTION_CUSTOMIZE , IMPORT_DYNPRO etc which will call that screen based on profile but it will not store data any where. I found several tables like TCATS, TFAWC, TFAWF, TFAWT etc.But I am not getting the value for raduio buttons.
Thanks & Regards,
Nagaraj Kalbavi -
UTF-8 encoding in XSLT transformation
Hello,
I have a problem with a transformation of an ABAP structure into XML. I use the XSLT transformation for this.
My XSLT starts like this:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:strip-space elements="*"/>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
I tried many settings I could find posted on the internet, but I did not find one that would allow encoding to UTF-8.
It always encodes to iso-8859-1 which my interface partner cannot read.
Does anyone know a way to force encoding to UTF-8?
Adding a command like <xsl:output encoding="utf-8"/> did not help.
Thanks a lot!
J. EulerHello!
I think I just solved the problem taking a different approach.
In a note here on SDN, a guy from SAP wrote, that the SAP XSLT processor is not able to code anything but the system's default to a string, BUT that it is able to code it to an xstring.
All I did now is add the tag
<xsl:output encoding="utf-8" indent="yes" method="xml"/>
to my xslt program and change the coding in the program accordingly.
The program code is now:
DATA: tempxstring TYPE xstring,
temp_length TYPE i,
conv TYPE REF TO cl_abap_conv_in_ce.
CLEAR tempxstring.
TRY.
CALL TRANSFORMATION
zxxje_tst_xslt
SOURCE omsregdatawebservice = wa_data
RESULT XML tempxstring.
CATCH cx_sy_conversion_base64.
CATCH cx_sy_conv_illegal_date_time.
ENDTRY.
IF tempxstring IS NOT INITIAL.
CLEAR: conv, temp_length, string_xml_result.
conv = cl_abap_conv_in_ce=>create( input = tempxstring ).
conv->read( IMPORTING data = string_xml_result len = temp_length ).
ENDIF.
Thanks anyways for all your help!
regards,
Johannes Euler -
XSLT and ABAP Transformation Deep Structure
Hello Everyone,
While I've read the forums and the links of a number of folks doing the same thing. I am stuck in that I cannot figure out how to populate a deep structure via XSLT. Not sure what is going wrong, but I suspect it is obvious. The simple problem is that my structure is not getting populated. It is blank. The transformation works in testing STRANS (and in Stylus Studio).
I cannot figure out what is wrong that makes the t_pexr2002 table blank. Thanks for any insight.
Greg
The simple program is:
TYPES: BEGIN OF ty_head,
sndprn TYPE string,
bgmref TYPE string,
moabetrh TYPE string,
create_date TYPE string,
settlement_date TYPE string,
no_lines TYPE string,
END OF ty_head.
TYPES: BEGIN OF ty_pricing,
moabetr TYPE string,
END OF ty_pricing.
TYPES: BEGIN OF ty_item,
docname TYPE string,
docnummr TYPE string,
pricing TYPE ty_pricing,
END OF ty_item.
TYPES: BEGIN OF ty_summary,
status_message TYPE string,
END OF ty_summary.
TYPES: BEGIN OF ty_mn,
header_data TYPE ty_head,
item_data TYPE ty_item,
summary_data TYPE ty_summary,
END OF ty_mn.
DATA: t_pexr2002 TYPE STANDARD TABLE OF ty_mn.
DATA: xml_doc TYPE REF TO cl_xml_document, xml TYPE string.
CREATE OBJECT xml_doc.
CALL METHOD xml_doc->import_from_file
EXPORTING
filename = 'C:\temp\2640273.xml'.
CALL METHOD xml_doc->render_2_string
EXPORTING
pretty_print = 'X'
IMPORTING
stream = xml.
CALL TRANSFORMATION zusl_pexr2002_v1
SOURCE XML xml
RESULT output = t_pexr2002.
Edited by: Thomas Zloch on Jun 9, 2010 6:05 PMHere is my XSLT:
Here is the transformation: Also pretty simple...
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ... >
<xsl:strip-space elements="*"/>
<xsl:template match="/PEXR2002/IDOC">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<OUTPUT>
<HEADER_DATA>
<SNDPRN>
<xsl:value-of select="EDI_DC40/SNDPRN"/>
</SNDPRN>
<BGMREF>
<xsl:value-of select="E1IDKU1/BGMREF"/>
</BGMREF>
<MOABETRH>
<xsl:value-of select="E1IDKU5/MOABETR"/>
</MOABETRH>
<CREATE_DATE>
<xsl:value-of select="EDI_DC40/CREDAT"/>
</CREATE_DATE>
<SETTLEMENT_DATE>
<xsl:value-of select="E1EDK03/DATUM"/>
</SETTLEMENT_DATE>
<NO_LINES>
<xsl:value-of select="count(E1IDPU1)"/>
</NO_LINES>
</HEADER_DATA>
<ITEM_DATA>
<xsl:for-each select="E1IDPU1">
<DOCNAME>
<xsl:value-of select="DOCNAME"/>
</DOCNAME>
<DOCNUMMR>
<xsl:value-of select="DOCNUMMR"/>
</DOCNUMMR>
<PRICING_DATA>
<xsl:for-each select="E1IDPU5[MOAQUAL = '006']">
<MOABETR>
<xsl:value-of select="MOABETR"/>
</MOABETR>
</xsl:for-each>
</PRICING_DATA>
</xsl:for-each>
</ITEM_DATA>
<SUMMARY_DATA>
<xsl:for-each select="EDI_DS40">
<STATUS_MESSAGE>
<xsl:value-of select="STAPA1"/>
</STATUS_MESSAGE>
</xsl:for-each>
</SUMMARY_DATA>
</OUTPUT>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform>
Edited by: Thomas Zloch on Jun 9, 2010 6:05 PM -
ABAP XSLT transformation - XML to deep structure/nested standard table
Hi all,
I was struggling with this topic recently and couldn't find a single working example or description of a possible solution. So now that I've sorted it out, I did a quick example to elustrate how it works. Here is the code with XML embeded in it and the XSLT follows:
<HR>
<PRE>
*& Report Z_XML2ABAP
*& Author: Jayanta Roy
*& Date: 03/02/2010
REPORT z_xml2abap.
DATA input_xml TYPE string.
TYPES: BEGIN OF t_address,
house_no TYPE string,
street_name TYPE string,
city_name TYPE string,
phone_no TYPE string,
END OF t_address.
TYPES: t_addresses TYPE STANDARD TABLE OF t_address with NON-UNIQUE KEY house_no.
TYPES: BEGIN OF t_person,
firstname TYPE string,
surname TYPE string,
addresses TYPE t_addresses,
END OF t_person.
input_xml = '<Friends>' &&
'<People>' &&
'<FirstName>Homer</FirstName>' &&
'<Surname>Simpson</Surname>' &&
'<Address>' &&
'<HouseNo>123</HouseNo>' &&
'<Street>Evergreen Terrace</Street>' &&
'<City>Springfield</City>' &&
'<PhoneNo>011212321</PhoneNo>' &&
'</Address>' &&
'<Address>' &&
'<HouseNo>7G</HouseNo>' &&
'<Street>Neuclear Power Plant</Street>' &&
'<City>Spring Field</City>' &&
'<PhoneNo>911</PhoneNo>' &&
'</Address>' &&
'</People>' &&
'<People>' &&
'<FirstName>Bart</FirstName>' &&
'<Surname>Simpson</Surname>' &&
'<Address>' &&
'<HouseNo>123x</HouseNo>' &&
'<Street>Evergreen Terracex</Street>' &&
'<City>Springfieldx</City>' &&
'<PhoneNo>011212321x</PhoneNo>' &&
'</Address>' &&
'</People>' &&
'</Friends>' .
DATA lt_person TYPE STANDARD TABLE OF t_person.
TRY.
CALL TRANSFORMATION xslt_person
SOURCE XML input_xml
RESULT all_people = lt_person.
CATCH cx_root.
WRITE 'Problemo!'.
ENDTRY.
WRITE 'Now, debug the program to see the values read from the XML'.
</PRE>
<HR>
and here is the XSLT Transformation program (xslt_person):
<HR>
<PRE>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ALL_PEOPLE>
<xsl:apply-templates select="//People"/>
</ALL_PEOPLE>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="People">
<ALLMYFRIENDS> <!This element name is not relevent... needed to just group the loop>
<FIRSTNAME>
<xsl:value-of select="FirstName"/>
</FIRSTNAME>
<SURNAME>
<xsl:value-of select="Surname"/>
</SURNAME>
<ADDRESSES>
<xsl:for-each select="Address">
<ADDRESS> <!This element name is not relevent... needed to just group the loop>
<HOUSE_NO>
<xsl:value-of select="HouseNo"/>
</HOUSE_NO>
<STREET_NAME>
<xsl:value-of select="Street"/>
</STREET_NAME>
<CITY_NAME>
<xsl:value-of select="City"/>
</CITY_NAME>
<PHONE_NO>
<xsl:value-of select="PhoneNo"/>
</PHONE_NO>
</ADDRESS>
</xsl:for-each>
</ADDRESSES>
</ALLMYFRIENDS>
</xsl:template>
</xsl:transform>
</PRE>
<HR>
HTH,
Jayanta.thanks a LOT Jayanta..
I was looking for an XSLT example for some time.. this one atleast got me started in the right direction..
THANKS -
Creating an XML From a Deep Structure using XSL Transformation
Hi ABAPers,
I have a requirement to use XSL Transformations on an ABAP deep type structure.
Currently i have an API that fills in this deep structure and by using CALL TRANSFORMATION ID.... i will get the BIG XML having having 100s of nodes . But actualy form the deep structure i need only some NODES (say 50)... So i tried writing an XSLT
in the transaction STRANS.. but on using this TRANSFORMATION which i wrote i am getting an error messgae like INVALID XML...
Am i going in right track or is there a good solution...
My sample transformation is as below...
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:value-of select="DATA/NODE_ELEMENTS/UUID_KEY/UUID"/>
<xsl:value-of select="DATA/NODE_ELEMENTS/SEMANTICAL_NAME"/>
<xsl:value-of select="DATA/NODE_ELEMENTS/STRUCT_CAT"/>
<xsl:value-of select="DATA/NODE_ELEMENTS/USAGE_CAT"/>
<xsl:value-of select="DATA/NODE_ELEMENTS/RESTRICTED_IND"/>
<xsl:value-of select="VALUES/DATA/NODE_ID"/>.
</xsl:template>
</xsl:transform>
Please help me in solving this issue....
Thanks,
Linda.Hi Linda,
I am replying based on your sample code.
Try the below following suggestions.
here 'GRPHDR' is the node where I am selecting the data.
IGRPHDR is the name of the reference.
First calling the transformation in you program.
TYPES: BEGIN OF tl_hdr,
msgid(20) TYPE c,
END OF tl_hdr.
DATA : t_hdr TYPE STANDARD TABLE OF tl_hdr.
GET REFERENCE OF t_hdr INTO l_result_xml-value.
l_result_xml-name = 'IGRPHDR'.
APPEND l_result_xml TO t_result_xml.
TRY.
CALL TRANSFORMATION yfi_xml_read
SOURCE XML it_xml_data
RESULT (t_result_xml).
CATCH cx_root INTO l_rif_ex.
l_var_text = l_rif_ex->get_text( ).
l_bapiret-type = 'E'.
l_bapiret-message = l_var_text.
APPEND l_bapiret TO errormsgs.
EXIT.
ENDTRY.
in XSL transformation
First write a block of statement to specify from which node you are taking the data.
No matter it is a node or sub-node.
<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>
<IGRPHDR> " reference name of internal table
<xsl:apply-templates select="//GrpHdr"/>
</IGRPHDR>
</asx:values>
</asx:abap>
</xsl:template>
Next select the data from the nodes under the nodes specified in the transformation.
here msgid is the field i am selecting for value.
<xsl:template match="GrpHdr">
<item>
<MSGID> " field in the internal table t_hdr where data has to go
<xsl:value-of select="MsgId"/>
</MSGID>
</item>
</xsl:template>
reply back if further clarification is needed.
Thanks and regards,
Kannan N -
Xslt transformation rules for BPEL
Hi there,
Can anyone advise where I can find the xslt transformation rules for BPEL. I am unable to find the mentioned file "114.XSLTTransformations".
Best regards!
LindaI installed the BPEL process manager and find the 114.XSLTTransformations tutorial project, but the sample xslt file is for a specific xml file but not for a general bpel file, which doesn't help with my problem.
For instance, if I want to transform a bpel file to other formats using xslt, how to handle "partner link" structure of bpel?
Best regards,
Linda -
Create a deep structure for dynamic internal table
Hi All,
I am creating a dynamic table using method cl_alv_table_create=>create_dynamic_table.
The normal structure gets created. but now I want to creat a Deep structure for having information of colors also for each column. So I want to add a COLTAB type LVC_T_SCOL for colors information .
How should I create this using above method?
Rgds,
MadhuriI created a zcelltab structure as below. But while creating dynamic internal table, I received the error with
'Type "ZCELLTAB" is unknown 68 ZCELLTAB-CELLTAB
Here is the code.
DATA: BEGIN OF ZCELLTAB,
CELLTAB LIKE LVC_S_STYL,
END OF ZCELLTAB.
FIELD-SYMBOLS <T_CELLTAB> TYPE LVC_T_STYL.
DATA : LT_CELLTAB TYPE LVC_T_STYL.
DATA: WA_CELLTAB TYPE LINE OF LVC_T_STYL.
DATA: GT_FCAT1 TYPE LVC_T_FCAT,
GW_FCAT1 TYPE LVC_S_FCAT,
GT_FCAT2 TYPE LVC_T_FCAT,
GW_FCAT2 TYPE LVC_S_FCAT.
After filling the FCAT1, I added the field in FCAT2 like below
GT_FCAT2[ ] = GT_FCAT1[ ].
G_TABIX = G_TABIX + 1.
GW_FCAT2-INTTYPE = 'C'.
MOVE G_TABIX TO GW_FCAT2-COL_POS.
GW_FCAT2-OUTPUTLEN = '10'.
GW_FCAT2-FIELDNAME = 'T_CELLTAB'.
GW_FCAT2-TABNAME = 'ZCELLTAB'.
GW_FCAT2-REF_FIELD = 'CELLTAB'.
GW_FCAT2-REF_TABLE = 'ZCELLTAB'.
APPEND GW_FCAT2 TO GT_FCAT2
CLEAR GW_FCAT2.
While calling the below method, the error with
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = GT_FCAT2
IMPORTING
EP_TABLE = GT_REQ.
ASSIGN GT_REQ->* TO <F_TAB>.
CREATE DATA GWA_REQ LIKE LINE OF <F_TAB>.
ASSIGN GWA_REQ->* TO <F_WA>.
LOOP AT ITAB.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <F_WA> TO <F_VAL>
<F_VAL> = ITAB-MATNR.
IF ITAB-MATNR IS INITIAL.
ASSIGN COMPONENT 'T_CELLTAB' OF STRUCTURE <F_WA> TO <T_CELLTAB>
CLEAR WA_CELLTAB.
WA_CELLTAB-FIELDNAME = 'MATNR'.
WA_CELLTAB-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
INSERT WA_CELLTAB INTO TABLE <T_CELLTAB>.
ENDIF.
APPEND <F_WA> TO <F_TAB>
ENDLOOP.
CALL METHOD GR_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_CONSISTENCY_CHECK = G_CONSISTENCY_CHECK
IT_TOOLBAR_EXCLUDING = G_EXCLUDE
I_SAVE = G_SAVE
I_DEFAULT = 'X'
IS_LAYOUT = G_LAYOUT
CHANGING
IT_OUTTAB = <F_TAB>
IT_FIELDCATALOG = F_CAT1.
Please let me know where I was wrong.
Should I remove the T_CELLTAB as the field name is not mentioned in the structure 'ZCELLTAB'.
Thanks,
Kumar.
Edited by: venn e on May 7, 2010 4:10 PM
Maybe you are looking for
-
User exit for LT03 - Creation of transfer order.
Hi All, In LT03 while creating a transfer order for delivery the system picks the storage unit in ascending order(FIFO - First in first out). Is there any badi available to change this picking order into descending order(LIFO- Last in first out). I h
-
Imac 27" superdrive never works and scratches the discs
Is it just me? I have rarely used my superdrive to burn CDs or DVDs since 2009, and whenever i have it is always going wrong. The disc/drive makes a horrible noise, and ends up scratching the DVD or CD. Now when i need it the most to burn a dual laye
-
Webform Page dropdown box search functionality
All, We are on Planning 11.1.2.2.303. Since we have a page dimension with over 1000 members (and the member names are a name followed by 19 numbers in length), the business owner really likes the "Like" search of the page dropdown in the webform
-
Hi I bought one program (Sketch club) and they withdraw from my account 3.99 $ that's okey in this issue. But, next day they withdraw 12 $ from itunes store... why is that? could you please help me with that
-
Java Script Assistant in xMII 12.0
Hi All, Kindly help me to find out the "Java Script Assistance in xMII 12.0" version. Thanks Rajesh Sivaprakasam. Edited by: Rajesh Sivaprakasam on Nov 27, 2008 12:05 PM