BSP Element Expressions XML Parameters : ABAP Question
Hi, can anyone please give me a tip or a small example of a use of parameters in XML BEE? They are defined in a BSP and then set there in the bee SET method of CL_BSP_BEE_XML. Brian McKellar gives an example in his Weblog /people/brian.mckellar/blog/2003/10/30/bsp-programming-bsp-element-expressions-bees but I have a different situation and dont understand what they might mean for me. Thanks for any information. Best regards David Lawn
This post has now been answered in the BSP forum.
Best regards
David Lawn
Similar Messages
-
BSP Element Expressions XML Parameters
Hi, can anyone please give me a tip or a small example of a use of parameters in XML BEE? They are defined in a BSP and then set there in the bee SET method of CL_BSP_BEE_XML. Brian McKellar gives an example in his Weblog /people/brian.mckellar/blog/2003/10/30/bsp-programming-bsp-element-expressions-bees but I have a different situation and dont understand what they might mean for me. Thanks for any information. Best regards David Lawn
Hi Brian, thank you very much.
In fact I have success with the tutorials you have given. I still have some difficulties but believe they can be overcome:
1. I am in a method of the bsp application class. I have dumped the code into this method from a bsp page include fragment.
2. Thus, in this method, I now have business logic abap determining which <htmlb elements are created and what values the variables of these elements have. Thus at runtime I pass to the bee a concatenated string like '<htmlb:textView id ="' l_id_element_name ' text = "' l_text 'design = "' l_design '"' ... '/>'. I had figured I had, at runtime, no variables and so needed no parameters. In fact, I have had to find that if I do not code parameters then adding in a second piece of <htmlb code crashes the bee and I loose the browser display of the first one. If I parameterise the first and the second, then I have both. So thats clear. I have also found that bee string syntax is totally strict. I also looked at bee->m_dom dom_table in the debugger, together with the parameters, which helped me understand.
I am adding in bits of the huge amount of business logic at a time to keep the bee string consistent.
3. After setting the bee I pass it back to the view include that called my method (I have a nice ddic structure for that) and display the result as you do in your tutorial.
4. The total result thus is that I no longer need business logic in my view includes and can create html from htmlb in the application class method, which is what I need. Thanks!
4. My need: I firstly just need to get a form onto the browser as quickly as possible so that other project members can see it and plan. Performance is secondary at the moment. I am happy to use the xml bee.
5. The bsp I work with has a strange structure, with a page with flow logic <bsp:goto-ing a controller which calls a view with many includes, one of which is mine (which also has includes). So your other suggestion, using views, will also be followed up as soon as I get my page up and visible.
Kind regards David -
BSP Programming: BSP Element Expressions (BEEs)
Hi,
Alex reported a difficulty with
BSP Programming: BSP Element Expressions (BEEs)
/people/brian.mckellar/blog/2003/10/30/bsp-programming-bsp-element-expressions-bees
back in March.
Since I also set up the example contained in that paper recently, and since I permitted myself to add in some lines of code with which it works well, I give those lines here:
1) the bee call:
<%
if bee is bound.
%>
<bsp:bee bee="<%= bee %>" />
<%
endif.
%>
2) in the xml part of onInputProcessing:
2.1)
data: xml_errors type TIXMLTERR.
2.2)
append <xml_parm> to xml_parms.
also seemed a good idea.
I hope this is useful.
Best regards
David LawnOops ... I dont need the append statement of course (because I have insert .. assigning). Sorry about that.
-
BEE(BSP Element Expression)
Hi Forums,
What is the use of BEE and where do we use it ? can any body explain with the help of example.
Documents with example will really helpful.
Thanks in advance.
Regards,
Ravi.Hi,
Did you check /people/brian.mckellar/blog/2003/10/30/bsp-programming-bsp-element-expressions-bees
Eddy -
Hi,
I am practicing on BSP Element Expressions and i have gone through the weblog by Brain McKellar. I am trying the same example given in the weblog but i am getting an exception at the statement
<bsp:bee bee = "<%= bee%>" /> in the layout.
I have not instantiated but i have declared it as an page attribute as given in the weblog.
Why am i getting an error? any help is highly appriciated.
Regards,
Azaz.You have to instantiate the bee before you use it. otherwise the bee is not bound or is null so u'll get exception. The right way is to check the bee before you use it i.e.
change the html layout code this way.
<% if bee is bound. %>
<bsp:bee bee = "<%= bee%>" />
<% endif. %>
This is the first step. This way even if you don't instantiate the bee, u'll not get any exception or crash.
Second point is using the bee if instantiated properly.
Instantiation of bee is compulsory if you want to use it.
Do the instantiation anywhere where u think its correct. you can do it in OnInitialization handler or in inputProcessing etc. In the blog it is done in the OnInputProcessing.
As I said earlier, the fixes to make that code work properly are mentioned at the bottom of the blog.
Regards,
Kumar -
Xml to abap internal table by using a dynamic internal table at runtime
Hi ,
I have a requirement to convert xml to abap internal table . But the requirement is that i need to create internal table according to the XML .
Ex : If my XML is :
<?xml version="1.0" ?>
- <flights>
- <airline code="AA" name="American Airlines">
- <flight number="0017">
<from airport="JFK">NEW YORK,US</from>
<to airport="SFO">SAN FRANCISCO,US</to>
<departure>110000</departure>
<arrival>140100</arrival>
<type>Scheduled</type>
</flight>
- <flight number="0064">
<from airport="SFO">SAN FRANCISCO,US</from>
<to airport="JFK">NEW YORK,US</to>
<departure>090000</departure>
<arrival>172100</arrival>
<type>Scheduled</type>
</flight>
</airline>
So after conversion my abap internal table shoul have fields as :
airline_code Name flight_number from_airport to_airport departure arrival type
and the field values should be corresponding field values .
Thanks in advance .
Regards .Hi Ujjwal,
use
CALL TRANSFORMATION
Study the online documentation and if required do some search for CALL TRANSFORMATION and/or XML PARSER
And, when coming back here with next question, tell us what searches you did with what results - please always follow the 'search before post' rule, thank you.
Regards,
Clemens -
To convert XML to ABAP internal table can we do it with DOM or we need XSLT
I have a requirement where I need to collect the data from XML file into an internal table.
I need to collect this data into an internal table as I should make use of this data and do Goods Receipt in SAP.
My XML file is very very complex and the child nodes in my XML file may occur ones or 10 times and change dynamically.
I want to know if XML to ABAP internal table is possible with DOM or does it need XSLT too.
I used the blog of Robert which uses DOM, but it I am unable to collect the data in internal table. The blog explains only how to wtite the out put to screen as element and value.
I want to know if XML to ABAP internal table is possible with DOM or do I need XSLT too? I am confused please help.
Any help will be highly appreciated.
Regards,
Jessica SamHello Jessica
Why not using the DOM itself for processing?
Below you see the post-processing coding which I use to add the interchange control number (ICN) into an EDI message (which at this stage is still an XML-EDI stream). This is done on SAP-XI yet on the ABAP stack so you could use this approach on your R/3 system as well.
method POSTPROCESSING.
* Post-Processing of outbound EDI invoices & dispatch advices
me->map_icn( ).
endmethod.
method MAP_ICN.
* define local data
DATA: lo_node TYPE REF TO if_ixml_node,
ld_name TYPE string,
ld_value TYPE string,
ld_error_code type MPG_ERRCODE,
** ld_control_number TYPE char13,
ld_rc TYPE i,
ld_msg TYPE string. " bapi_msg.
DATA: ld_interface TYPE string.
DATA: incode TYPE REF TO if_ixml_node_collection.
LOG-POINT ID zedi
SUBKEY mc_subkey_method_trace.
ld_error_code = md_clsname.
* Get next interchange control number (ICN)
me->md_next_number = me->get_next_number(
id_nrobj = me->md_nrobj " Object (SNRO)
id_nrnr = me->md_nrnr ). " Number Range
CALL METHOD zcl_edi_uk_counter=>calculate_modulo_n09
EXPORTING
id_input = me->md_next_number
receiving
rd_output = me->md_next_number.
* Build ICN according to naming conventions agreed with EDI customer
me->md_icn = me->generate_icn( me->md_next_number ).
ld_value = me->md_icn. " type conversion to string
CLEAR: incode,
lo_node.
incode = me->mo_document->get_elements_by_tag_name( mc_d_0020 ).
lo_node = incode->get_item( index = 0 ).
CALL METHOD lo_node->set_value
EXPORTING
value = ld_value
RECEIVING
rval = ld_rc.
IF ( ld_rc NE 0 ).
CONCATENATE 'Error [' mc_d_0020
']: Method SET_VALUE (IF_IXML_NODE)'
INTO ld_msg.
CONDENSE ld_msg.
me->mif_trace->trace2( message = ld_msg ).
RAISE EXCEPTION TYPE cx_mapping_fault
EXPORTING
* textid =
* previous =
error_code = ld_error_code
error_text = ld_msg.
** MESSAGE ld_msg TYPE 'A'.
ENDIF.
CLEAR: incode,
lo_node.
incode = me->mo_document->get_elements_by_tag_name( mc_d_0020_2 ). " element for ICN
lo_node = incode->get_item( index = 0 ).
CALL METHOD lo_node->set_value
EXPORTING
value = ld_value
RECEIVING
rval = ld_rc.
IF ( ld_rc NE 0 ).
CONCATENATE 'Error [' mc_d_0020_2
']: Method SET_VALUE (IF_IXML_NODE)'
INTO ld_msg.
CONDENSE ld_msg.
me->mif_trace->trace2( message = ld_msg ).
RAISE EXCEPTION TYPE cx_mapping_fault
EXPORTING
* textid =
* previous =
error_code = ld_error_code
error_text = ld_msg.
** MESSAGE ld_msg TYPE 'A'.
ENDIF.
* define local data
DATA: ls_record TYPE mpp_dynamic.
CLEAR: ls_record.
ls_record-namespace = mc_dynamic_namespace.
ls_record-name = mc_icn.
ls_record-value = ld_value.
mif_dynamic->add_record( ls_record ).
endmethod.
In your case you would need to do a DO...ENDDO loop until you parsed all required nodes.
NOTE: ME->MO_DOCUMENT is of TYPE REF TO IF_IXML_DOCUMENT.
Regards
Uwe -
Hello friends,
I am trying a ABAP program (posted on SDN) to convert XML into ABAP (internal table) and not having any luck. Either it is my table/structure declaration or XSLT. Could any of you experts give me a hand with it please?
Thanks in advance..but points on help!
Here is my XML:
And my ABAP program:
REPORT ZTESTXMLREAD.
TYPE-POOLS: abap, ixml.
class cl_ixml definition load.
TYPES: BEGIN OF t_dc40,
docnum(17) TYPE C,
status(2) TYPE C,
END OF t_dc40.
TYPES: BEGIN OF t_emkt,
spras(2) TYPE C,
maktx(35) TYPE C,
END OF t_emkt.
TYPES: BEGIN OF t_emrm,
matnr(12) TYPE C,
ersda(8) TYPE C,
ernam(25) TYPE C,
emktx TYPE t_emkt,
END OF t_emrm.
TYPES: BEGIN OF t_mm,
dc40 TYPE t_dc40,
emrm TYPE t_emrm,
END OF t_mm.
DATA: l_ixml TYPE REF TO if_ixml,
l_streamfactory TYPE REF TO if_ixml_stream_factory,
l_istream TYPE REF TO if_ixml_istream.
DATA: l_filename TYPE string.
DATA: it_airplus TYPE STANDARD TABLE OF t_mm,
wa_airplus TYPE t_mm.
*Errorvariables
DATA: xslt_err TYPE REF TO cx_xslt_exception,
err_string TYPE string.
PARAMETERS: pa_file TYPE char1024 DEFAULT 'c:Test.XML'.
START-OF-SELECTION.
Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
Creating input stream
l_istream = l_streamfactory->create_istream_uri( 'file://c:Test.xml' ).
here we use the CALL TRANSFORMATION method which calls
TRY.
CALL TRANSFORMATION ZTestXSLT
SOURCE xml l_istream
RESULT xml_output = it_airplus
catch any error, very helpful if the XSLT isn't correct
CATCH cx_xslt_exception INTO xslt_err.
err_string = xslt_err->get_text( ).
WRITE: / 'Transformation error: ', err_string.
EXIT.
ENDTRY.
setting a breakpoint to watch the workarea
by the internal table "it_airplus"
break-point.
LOOP AT it_airplus INTO wa_airplus.
ENDLOOP.Thank you Durairaj, as a matter of fact my program is based on your post (one that you pointed me to). For whatever reason I'm not having luck figuring it out (may be just a bit of work pressure) could you please hlep me a bit more by pointing me to where in my program code/xslt I'm going wrong? I somehow feel that it could be my table structure or xslt.
I would really appreciate it!
Thanks again,
erfan. -
How to use STRANS to translate XML to ABAP with deep structure
every experts, I want to use Tcode: STRANS to translate XML to ABAP, But it does not work well,
here is XML code,I want to translate this XML into an an Inter table gt_orders with deep structure of oeb, and colum oeb is also and intertable,how can I do this.
<?xml version="1.0" encoding="gb2312" ?><axmt410><ObjectID>setSalesOrder</ObjectID><azp01>000000</azp01><oea00>1</oea00><ta_oeaecn>SO-140227-3041</ta_oeaecn><oea03>25325017</oea03><oea02>2014-02-27 17:44:44.0</oea02><ta_oea002>2763.0</ta_oea002><ta_oea001>0.0</ta_oea001><oea14></oea14><oea15>25325017</oea15><oea23>RMB</oea23><oeaconf>S3</oeaconf><oea10></oea10><oeaud01>null</oeaud01><ta_oea007></ta_oea007><oea25>101</oea25><ta_oea008>0</ta_oea008><ta_oea009>null</ta_oea009><oeauser>Hanjingya</oeauser><ta_oeanday>2014-02-27 17:44:44.991</ta_oeanday><ta_oeamday>2014-02-28 08:30:14.866</ta_oeamday><ta_oeacday>2014-02-28 08:30:14.866</ta_oeacday><oeaud02>0</oeaud02><ta_oea030>null</ta_oea030><oeb><oeb03>1</oeb03><oeb04>7400208249</oeb04><oeb05>PCS</oeb05><oeb17>921.0</oeb17><oeb13>921.0</oeb13><oeb15></oeb15><oeb12>5</oeb12><oeb09>990001</oeb09><ta_oeb001></ta_oeb001><ta_oeb002>Yunnan</ta_oeb002><ta_oeb003>address1</ta_oeb003><ta_oeb004>zhangdagui、zhanglan</ta_oeb004><ta_oeb005>15974749998、15987782008</ta_oeb005><ta_oeb006>address and street</ta_oeb006><oebud01></oebud01></oeb><oeb><oeb03>2</oeb03><oeb04>7400208250</oeb04><oeb05>PCS</oeb05><oeb17>921.0</oeb17><oeb13>921.0</oeb13><oeb15></oeb15><oeb12>5</oeb12><oeb09>990001</oeb09><ta_oeb001></ta_oeb001><ta_oeb002>Yunnan</ta_oeb002><ta_oeb003>address2</ta_oeb003><ta_oeb004>zhangdagui、chenlan</ta_oeb004><ta_oeb005>15974749998、15987782008</ta_oeb005><ta_oeb006>address and street</ta_oeb006><oebud01></oebud01></oeb></axmt410>
I write these codes in SAP XSLT editor
<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:strip-space elements="*"/>
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ORDERS>
<xsl:apply-templates select="//axmt410"/>
</ORDERS>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="axmt410">
<OBJECTID>
<xsl:value-of select="ObjectID"/>
</OBJECTID>
<AZP01>
<xsl:value-of select="azp01"/>
</AZP01>
<OEA00>
<xsl:value-of select="oea00"/>
</OEA00>
<TA_OEAECN>
<xsl:value-of select="ta_oeaecn"/>
</TA_OEAECN>
<OEA03>
<xsl:value-of select="oea03"/>
</OEA03>
<OEA05>
<xsl:value-of select="oea05"/>
</OEA05>
<OEA02>
<xsl:value-of select="oea02"/>
</OEA02>
<TA_OEA002>
<xsl:value-of select="ta_oea002"/>
</TA_OEA002>
<TA_OEA001>
<xsl:value-of select="ta_oea001"/>
</TA_OEA001>
<OEA14>
<xsl:value-of select="ora14"/>
</OEA14>
<OEA15>
<xsl:value-of select="ora15"/>
</OEA15>
<OEA23>
<xsl:value-of select="ora23"/>
</OEA23>
<OEACONF>
<xsl:value-of select="oeaconf"/>
</OEACONF>
<OEA10>
<xsl:value-of select="ora10"/>
</OEA10>
<OEAUD01>
<xsl:value-of select="oeaud01"/>
</OEAUD01>
<TA_OEA007>
<xsl:value-of select="ta_oea007"/>
</TA_OEA007>
<OEA25>
<xsl:value-of select="ora25"/>
</OEA25>
<TA_OEA008>
<xsl:value-of select="ta_oea008"/>
</TA_OEA008>
<TA_OEA009>
<xsl:value-of select="ta_oea009"/>
</TA_OEA009>
<TA_OEA013>
<xsl:value-of select="ta_oea013"/>
</TA_OEA013>
<TA_OEA014>
<xsl:value-of select="ta_oea014"/>
</TA_OEA014>
<TA_OEA015>
<xsl:value-of select="ta_oea015"/>
</TA_OEA015>
<TA_OEA016>
<xsl:value-of select="ta_oea016"/>
</TA_OEA016>
<TA_OEA017>
<xsl:value-of select="ta_oea017"/>
</TA_OEA017>
<TA_OEA018>
<xsl:value-of select="ta_oea018"/>
</TA_OEA018>
<TA_OEA019>
<xsl:value-of select="ta_oea019"/>
</TA_OEA019>
<TA_OEA020>
<xsl:value-of select="ta_oea020"/>
</TA_OEA020>
<TA_OEA021>
<xsl:value-of select="ta_oea021"/>
</TA_OEA021>
<TA_OEA022>
<xsl:value-of select="ta_oea022"/>
</TA_OEA022>
<TA_OEA028>
<xsl:value-of select="ta_oea028"/>
</TA_OEA028>
<OEAUSER>
<xsl:value-of select="oeauser"/>
</OEAUSER>
<TA_OEANDAY>
<xsl:value-of select="ta_oeanday"/>
</TA_OEANDAY>
<TA_OEAMDAY>
<xsl:value-of select="ta_oeamday"/>
</TA_OEAMDAY>
<TA_OEACDAY>
<xsl:value-of select="ta_oeacday"/>
</TA_OEACDAY>
<OEAUD02>
<xsl:value-of select="oeaud02"/>
</OEAUD02>
<TA_OEA030>
<xsl:value-of select="ta_oea030"/>
</TA_OEA030>
<OEB>
<xsl:for-each select="oeb">
<OEB03>
<xsl:value-of select="oeb03"/>
</OEB03>
<OEB04>
<xsl:value-of select="oeb04"/>
</OEB04>
<OEB05>
<xsl:value-of select="oeb05"/>
</OEB05>
<OEB17>
<xsl:value-of select="oeb17"/>
</OEB17>
<OEB13>
<xsl:value-of select="oeb13"/>
</OEB13>
<OEB15>
<xsl:value-of select="oeb15"/>
</OEB15>
<OEB12>
<xsl:value-of select="oeb12"/>
</OEB12>
<OEB09>
<xsl:value-of select="oeb09"/>
</OEB09>
<TA_OEB001>
<xsl:value-of select="ta_oeb001"/>
</TA_OEB001>
<TA_OEB002>
<xsl:value-of select="ta_oeb002"/>
</TA_OEB002>
<TA_OEB003>
<xsl:value-of select="ta_oeb003"/>
</TA_OEB003>
<TA_OEB004>
<xsl:value-of select="ta_oeb004"/>
</TA_OEB004>
<TA_OEB005>
<xsl:value-of select="ta_oeb005"/>
</TA_OEB005>
<TA_OEB006>
<xsl:value-of select="ta_oeb006"/>
</TA_OEB006>
<OEBUD01>
<xsl:value-of select="oebud01"/>
</OEBUD01>
</xsl:for-each>
</OEB>
</xsl:template>
</xsl:transform>
and I use below ABAP program for a test, but the items from XML can not translate into Interner table gt_orders-oeb[]
TYPE-POOLS abap.
CONSTANTS gs_file TYPE string VALUE 'C:\temp\order02.xml'.
* This is the structure for the data from the XML file
TYPES:
BEGIN OF typ_s_oeb,
oeb03 TYPE string, "
oeb04 TYPE string, "
oeb05 TYPE string, "
oeb17 TYPE string, "
oeb13 TYPE string,
oeb15 TYPE string,
oeb12 TYPE string, "
oeb09 TYPE string, "
ta_oeb001 TYPE string, "
ta_oeb002 TYPE string, "
ta_oeb003 TYPE string, "
ta_oeb004 TYPE string, "
ta_oeb005 TYPE string, "
ta_oeb006 TYPE string, "
ta_oeb013 TYPE string, "
ta_oeb014 TYPE string, "
ta_oeb015 TYPE string, "
ta_oeb016 TYPE string, "
ta_oeb017 TYPE string, "
ta_oeb018 TYPE string, "
ta_oeb019 TYPE string, "
ta_oeb020 TYPE string, "
ta_oeb021 TYPE string, "
ta_oeb022 TYPE string, "
oebud01 TYPE string, "
END OF typ_s_oeb.
TYPES: typ_t_oeb TYPE TABLE OF typ_s_oeb WITH KEY oeb03.
TYPES:
BEGIN OF typ_s_order,
objectid TYPE string, "
azp01 TYPE string, "
oea00 TYPE string, "
ta_oeaecn TYPE string, "
oea03 TYPE string, "
oea02 TYPE string, "
ta_oea002 TYPE string, "
ta_oea001 TYPE string, "
oea14 TYPE string, "
oea15 TYPE string,
oea23 TYPE string, "
oeaconf TYPE string, "
oea10 TYPE string, "
oeaud01 TYPE string, "
ta_oea007 TYPE string, "
oea25 TYPE string, "
ta_oea008 TYPE string, "
ta_oea009 TYPE string, "
oeauser TYPE string, "
ta_oeanday TYPE string, "
ta_oeamday TYPE string, "
ta_oeacday TYPE string, "
oeaud02 TYPE string, "
ta_oea030 TYPE string, "
ta_oea013 TYPE string,
ta_oea014 TYPE string,
ta_oea015 TYPE string,
ta_oea016 TYPE string,
ta_oea017 TYPE string,
ta_oea018 TYPE string,
ta_oea019 TYPE string,
ta_oea020 TYPE string,
ta_oea021 TYPE string,
ta_oea022 TYPE string,
ta_oea025 TYPE string,
oeb TYPE typ_t_oeb,
END OF typ_s_order.
* Table for the XML content
DATA: gt_itab TYPE STANDARD TABLE OF char2048,
gs_itab LIKE LINE OF gt_itab.
* Table and work ares for the data from the XML file
DATA: gt_orders TYPE STANDARD TABLE OF typ_s_order,
gs_orders TYPE typ_s_order.
* 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_orders INTO gs_result_xml-value.
gs_result_xml-name = 'ORDERS'.
APPEND gs_result_xml TO gt_result_xml.
* Perform the XSLT styleshee
TRY.
CALL TRANSFORMATION zfx_so_xml_to_abap
SOURCE XML gt_itab
RESULT (gt_result_xml).
CATCH cx_root INTO gs_rif_ex.
gs_var_text = gs_rif_ex->get_text( ).
MESSAGE gs_var_text TYPE 'S'.
ENDTRY.
LOOP AT gt_orders INTO gs_orders.
ENDLOOP.The simplest way seems to me is to use a XSL file for that. The <xsl:output> attributes doctype-system and doctype-public generate the DTD declaration <!DOCTYPE YOUR_ROOT SYSTEM "yourDTDfile.dtd"> and <!DOCTYPE YOUR_ROOT PUBLIC "yourDTDfile.dtd">, respectively.
When calling transformerInstance.transform() the XSLT processor performs the identity transformation - it just copies elements, attributes, content, processing instructions and comments to the result stream.
If you're using an xsl file for your transformation already, simply add <xsl:output doctype-system="yourDTDfile.dtd"/> to your existing XSL file.
If you're only using the identity transformation you'd need to change the line of code where you obtain the transformer instance from the TransformerFactory to:
t_factory.newTransformer(new StreamSource("test.xsl"));
and use this as test.xsl:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output doctype-system="yourDTDfile.dtd"/>
<!-- this is the identity transformation -->
<xsl:template match="*|@*|comment()|processing-instruction()|text()">
<xsl:copy>
<xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>Good luck. -
Hi Experts, I need help with this XSLT for call transformation. I have defined an internal table and intend to use it as a source for Call Tranformation. But I have Problems to defining my internal table to get the resut of the function transformation.(SAP 4.7)
In my case i have a xml with attibutes and i can't store these attibutes in internal table.
Hope to hear from any of u soon!
CMA
<--XSLT--
>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/abapxml" version="1.0">
<xsl:template match="//Catalog">
<asx:abap xmlns:asx="http://www.sap.com/abapxml">
<asx:values>
<CATALOG>
<!-- Boucle catalogue -->
<xsl:for-each select="EnTete">
<ENTETE>
<EMETTEUR>
<xsl:value-of select="Emetteur"/>
</EMETTEUR>
<DATEPUBLICATION>
<xsl:value-of select="DatePublication"/>
</DATEPUBLICATION>
<!-- Suite -->
<xsl:for-each select="Univers">
<UNIVERS>
<LIBELLE>
<xsl:value-of select="@libelle"/>
</LIBELLE>
<OBJREF>
<xsl:value-of select="@objref"/>
</OBJREF>
<OBJID>
<xsl:value-of select="@objid"/>
</OBJID>
<EMETTEUR>
<xsl:value-of select="Emetteur"/>
</EMETTEUR>
</UNIVERS>
</xsl:for-each>
</ENTETE>
</xsl:for-each>
<!-- ENTETE-->
</CATALOG>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform>
<--XML--
>
<?xml version="1.0" encoding="UTF-8"?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml">
<asx:values>
<Catalog>
<EnTete>
<Emetteur>UGAP</Emetteur>
<DatePublication>27/06/2007 09:20:02</DatePublication>
<Univers libelle="Nettoyage, hygine et entretien" objref="08" objid="374417o.bemp" >
<Emetteur>UGAP</Emetteur>
</Univers>
<Univers libelle="Nettoyage, hygine et entretien" objref="09" objid="374417o.bemp" >
<Emetteur>UGAP</Emetteur>
</Univers>
</EnTete>
</Catalog>
</asx:values>
</asx:abap>
<--abap--
>
TYPES: BEGIN OF t_universs,
libelle(35),
objref(35),
objid(35),
boutique TYPE t_boutique,
END OF t_universs.
TYPES: t_univers TYPE t_universs OCCURS 0.
UNIVERS *
TYPES: BEGIN OF t_entetes,
Emetteur(20),
DatePublication(30),
UNIVERS TYPE t_univers,
END OF t_entetes.
*TYPES: t_entete TYPE t_entetes OCCURS 0.
DATA: it_data TYPE STANDARD TABLE OF t_entetes,
wa_data TYPE t_entetes.
PARAMETER p_file(200) DEFAULT '/tmp/catalogue4.xml' LOWER CASE .
start-of-selection.
DATA: dsn(20) VALUE '/usr/catalogue2.xml',
msg(100).
data : l_sysubrc like sy-subrc.
*OPEN DATASET p_file FOR INPUT MESSAGE msg
IN TEXT MODE ENCODING DEFAULT.
OPEN DATASET p_file FOR INPUT IN BINARY MODE.
IF sy-subrc = 0.
CLEAR : gv_read_xml.
clear l_sysubrc.
READ DATASET p_file INTO gv_read_xml.
Transformation XML en ABAP-DATA
PERFORM check_xml USING gv_read_xml.
CLOSE DATASET p_file.
ENDIF.
*& Form check_xml
FORM check_xml USING p_xml TYPE string.
DATA: cx_runtime_error TYPE REF TO cx_xslt_runtime_error.
DATA: cx_format_error TYPE REF TO cx_xslt_format_error.
DATA: err_text TYPE string.
DATA: lt_xml TYPE STANDARD TABLE OF typ_xml,
ls_xml TYPE typ_xml,
source_xml TYPE string,
lt_result_xml TYPE abap_trans_resbind_tab,
ls_result_xml TYPE abap_trans_resbind.
TRY.
CALL TRANSFORMATION ZUGAP
SOURCE XML p_xml
RESULT CATALOG = it_data.
ENDTRY.
LOOP AT it_data INTO wa_data.
ENDLOOP.
i'm wonder if is it possible to get attribute from xml with abap function transformation...
Hope to hear from any of u soon!Hi Marcelo,
Thanks a lot for your reply, your code is very usefull but my problem is located around the XSLT file.
With my progam (abap), I can't read the attibutes from a XML file correctly because the XSLT have not the suitable tags.
In my XML i have 2 rows of "Univers" and after use the function transformation from abap i can store only 1 rows in internal table :
<Catalog>
<EnTete>
<Emetteur>UBB</Emetteur>
<b><Univers libelle="Nettoyage, hygine et entretien" objref="08">
</Univers>
<Univers libelle="Nettoyage, hygine et entretien" objref="09">
</Univers></b>
</EnTete>
</Catalog>
XSLT :
<xsl:for-each select="EnTete">
<ENTETE>
<EMETTEUR>
<xsl:value-of select="Emetteur"/>
</EMETTEUR>
<xsl:for-each select="Univers">
<UNIVERS>
<UNIVERS1>
<LIBELLE> <xsl:value-of select="@libelle"/></LIBELLE>
<OBJREF> <xsl:value-of select="@objref"/> </OBJREF>
</UNIVERS1>
</UNIVERS>
</xsl:for-each>
</ENTETE>
</xsl:for-each>
My question is : How can i do to define attributes in XSLT to allow read them by a program abap ?
In my example, the program abap get only 1 attribute in my iternal table, what is the suitable syntax in the xslt to read all the attributes ?
Hope to hear from any of u soon!
Christophe. -
Optional attributes in XML to ABAP transformation
Hi,
I have to deserialize (transformation xml to abap) an xml input file.
I want to use SAP ST (Simple Transformations).
This xml format is using attributes
Such attributes can be transformed in ST with
<tt:attribute name="item_id" value-ref="MATNR"/>
I realized 2 problems:
1. If the xml file does not contain every attribute which is in the transformation.
This can be solved by tt:cond
Sample
<tt:cond>
<tt:attribute name="uom" value-ref="BASE_UOM"/>
</tt:cond>
Now attribute uom is optional. Without the tt:cond the ST prragrom would throw exception if it is not in the file.
2. If the xml file contains an attribute which is not used in the transformation.
I tried to use tt:skip but it is not working for "<tt:attribute name= ... value-ref=... name" but only for "<tt:value-ref=...".
I only want to get the values I need out of the parameter list.
How can I achieve this without defining a transformation for every parameter in the xml file?
Thanks and regards
MichaelHi,
thanks for reply. It took me into the right direction. You have to distinguish between elements (ordered structured nodes) and attributes (unordered structured nodes). In my case they are using attributes for the values of a material master.
Here is a snippet (sample of the XML):
<?xml version="1.0" encoding="utf-8"?>
<TcPLMXML>
<TCifEngPart item_id="1-3000-3630-00"
seMaterialType="HALB"
uom="ST"
seWeight="2000.0" seWeightUnit="KG">
</TCifEngPart>
<TCifEngPart item_id="1-30000-41002-00"
seMaterialType="HALB"
uom="ST"
</TCifEngPart>
</TcPLMXML>
and my transformation:
<tt:loop ref="MATERIAL_LIST">
<TCifEngPart>
<tt:attribute name="item_id" value-ref="MATNR"/>
<tt:attribute name="object_name" value-ref="MATL_DESC"/>
<tt:attribute name="seMaterialType" value-ref="MATL_TYPE"/>
<tt:attribute name="uom" value-ref="BASE_UOM"/>
<tt:cond>
<tt:attribute name="seLength" value-ref="LENGTH"/>
<tt:attribute name="seWidth" value-ref="WIDTH"/>
<tt:attribute name="seHeight" value-ref="HEIGHT"/>
</tt:cond>
<tt:skip>
<tt:attribute name="seWeight" />
<tt:attribute name="seVolume" />
</tt:skip>
</TCifEngPart>
</tt:loop>
Length, width and hight are optional in the XML and will be transferred to the corresponding SAP fields if they are in the input file Weight and volume will be ignored.
This means all attributes I don't need I have to put within the tt:skip.
Without this skip the transformation throws an error.
In consequence if the partner system add new attributes I have to enhance the transformation in SAP.
Is there any other way? -
How to check the element in xml file by xpath
hi all,
* How to check the element in xml file by xpath
for the following XML file,
* I want to check whether
the element (sage) is present or not in the following xml file XPATH expression...
* I have tried by the following expression ,
NodeList result = (NodeList) xpath.evaluate("//*:student/*:sage/text()",xml_dom,XPathConstants.STRING);
System.out.println(result.item(0).getLocalName()); * I want to get the Element sage as String value....
but i am not able to get the element,why that ??? and How to do that ???
MyXML File :
<x:student>
<x:sname>aaa</x:sname>
<x:sage>26</x:sage>
</x:student>
Thanks,
JavaImran<code>* Thanks for reply....
* </code><code>In </code>
<code>x:student element x represents the namespace...thats why i put *:student in my expression....
"//*[local-name() = 'student']/*[local-name() = 'sage']/text()"* By the above code , i am not able to get the sage as string from
</code> resul.item(0).getLocalName() method.......?
* How to get that as string format ? -
Hello,
From a provider we get the following XSD from a response message:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://xxx" targetNamespace="http://yyy">
<xsd:element name="loginResponse" type="loginResponse" />
<xsd:complexType name="loginResponse">
<xsd:sequence>
<xsd:element name="result" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
His actual response looks like this:
<SOAP-ENV:loginResponse
xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:SOAPENC='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-Instance'>
<Result xsi:type='xsd:string'>artv8uv38gvqu05gjohv26g8l5</Result>
</SOAP-ENV:loginResponse>
PI accepts this well, but during the conversion from XML to ABAP we get the following error:
PARSE_APPLICATION_DATA Error during XML => ABAP conversion (Response Message; error ID: CX_ST_MATCH_ELEMENT; (/1SAI/TXS3656E9BD8
Error during XML => ABAP conversion (Response Message; error ID: CX_ST_MATCH_ELEMENT; (/1SAI/TXS3656E9BD8A34AE8B7F16 XML Bytepos
Element 'loginResponse' verwacht
I have the impression that there is a problem with the namespace and wonder how I can solve this. I do not know enough about XML to judge if the returned XML is valid according to the definition. Maybe the problem lies there.
Thanks for any help.
KrisYou are right. The error is the root node:
SOAP-ENV:loginResponse
This prefix is not allowed.
It should be something like this:
<loginResponse xmlns="http://xxx"
Edited by: Stefan Grube on Aug 23, 2010 4:35 PM -
Friends,
I am intrigued with the following date comparison logic. This is a small snippet that I cut&paste from SAP code and modified to check whether the logic is correct.
the logic below writes STATUS 68. From SAP point of view and I agree, that it should not write 68.
Can you please elaborate the problem here.
Thanks in advance.
William
DATA: i_aedat type sy-datum, " Equipment Change date in the decentral
l_aedat type sy-datum. " Equipment Change date in the central.
I_aedat = '20120119'. "From deployed
L_aedat = '20120118'. "In central
* posting in Central
if l_aedat is not initial.
*...change mode
if I_aedat < L_aedat.
*.....existing entry is the actual one,
*.....we don't won't overtake old data
write: / 'status 68'.
endif.
endif.
Moderator message: please choose more descriptive titles for your posts, everybody here has ABAP questions...
Edited by: Thomas Zloch on Feb 20, 2012Ok, here is the function module
Please note i_aedat is the change date in the decentral and l_aedat is the changed date in the central
The function module determine whether the existing central date is before the Decentrla date.
If so it would update the central data with decentral data.
Code below produce 68 at our installation and it does not with Vijaj and Patrick. I concur with their reply.
The code that I have provided is how the function module behaves.
So is it a kernel issue?
Any help is much appreciated.
Thanks
William
function /isdfps/etups_maintain_chk.
""Lokale Schnittstelle:
*" IMPORTING
*" REFERENCE(I_EQUNR) TYPE EQUNR
*" REFERENCE(I_AEDAT) TYPE AEDAT
*" EXCEPTIONS
*" NOT_ALLOWED
data: l_aedat like equi-aedat.
select single aedat into l_aedat
from equi
where equnr = i_equnr.
if sy-subrc is initial and
l_aedat is not initial.
*...change mode
if i_aedat < l_aedat.
*.....existing entry is the actual one,
*.....we don't won't overtake old data
raise not_allowed.
endif.
endif.
endfunction. -
Hi !
I wanted to ask few Abap questions :
1. How do i show a calendar on select options date field ?
2. what is the name of the function for changes currencies of field ? for example i need to change from type Usd to Euro ?
3. What is the function for abstract , adding dates fields ? ( not to take in account a Saturday and not working days ).
thanks
mosheHi Moshe,
For Calender if you any field to which the domain DATUM is assigned it shows calender.
for eg,
select-options date for P0000_AF-hiredate.
You can try the function module to add the days WDKAL_DATE_ADD_FKDAYS.
One of the function modules to convert currency is HR_ECM_CONVERT_CURRENCY
Thanks
Lakshman
Maybe you are looking for
-
I updated my computer to the new software and now the iPhoto has a circle with a line through it. When I first try to open it the pop us says: "You can't use this version of the application "iPhoto" with this version of OS X. Version: 9.2.1" When I
-
SPS upgrade from 18 to 21 due to Windows 7 and IE 8 Release
Hi Guys, Our client has decided to upgrade their user's OS from Windows XP to Windows 7. Also the IE will be upgraded to IE8. We did an impact analysis with a single system for the BW front end. Except a few minor errors, nothing serious troubled the
-
Same certificates for two servers using Sun Java WS 6.1sp5 with Crypto card
Hi, I have 2 Sun java webserver 6.1 sp5 installed on two machines as : Single webserver1 instance on hostmachine1 Single webserver1 instance on hostmachine2. (both instance names are same) I have created server certificate and installed it using Exte
-
BDC-How to get the value of the screen field
Hi All, I am facing a problem while writing the BDC code for the XK02 transaction. Recording: We have recorded like this :after giving the values in the initial screen(vendor no and purchase group and selecting the purchasing data check box) and ente
-
Hi experts, When doing abap client proxy.. in receiver channel i speficied XI adapter.. its asking the Http destination... so i went sm59 tcode and trying to create Http connection.. what are the parameter i should give... Connection type is "H" in t