Internal Table Data to XML
Hi
I have a requirement of writing internal table data to XML. Any idea where i should start.
I have pretty good experience with ABAP and basic knowledge in XML.
There are good blogs which talk about transformations and other stuff but they are not able to give me clear path to my solution.
Could somebody give me a basic example or some reference material where i can move the data in internal table (assume Sales order details of a day) to XML.
Thanks
Refer the program -
In this implementation we will only focus on the creation of the XML file and the transfer to the user. You can not create a XML document directly. You have to use a so called ixml factory first.
TYPE-POOLS: ixml.
DATA: l_ixml TYPE REF TO if_ixml.
l_ixml = cl_ixml=>create( ).
This iXML factory can create an empty XML document object named l_document.
DATA: l_document TYPE REF TO if_ixml_document.
l_document = l_ixml->create_document( ).
At this point you can add the nodes (elements, attributes) into the document. First you have to declare the root element node.
DATA: l_element_root TYPE REF TO if_ixml_element.
This node we have to give a name and add it (create_simple_node) to the document object l_document, which will be the parent of this node.
l_element_root = l_document->create_simple_element(
name = 'flights'
parent = l_document ).
Next we can add child nodes to there parent node using the same method of the document object.
DATA: l_element_airline TYPE REF TO if_ixml_element,
l_element_airline = l_document->create_simple_element(
name = 'airline'
parent = l_element_root ).
An attribute can be add easily using the method set_attribute of the element node.
l_rc = l_element_airline->set_attribute( name = 'code' value = 'LH401' ).
Now we have finished the document object. Regretfully it can not be displayed in any form due to the fact that it is a binary object.
The next step is to convert the created document to a flat file. To achieve this we have to create a stream factory, which will help us to create an output stream.
DATA: l_streamfactory TYPE REF TO if_ixml_stream_factory.
l_streamfactory = l_ixml->create_stream_factory( ).
In this case, we will convert the document into an output stream which is based on an internal table of type x.
TYPES: BEGIN OF xml_line,
data(256) TYPE x,
END OF xml_line.
DATA: l_xml_table TYPE TABLE OF xml_line,
l_xml_size TYPE i,
l_rc TYPE i,
l_ostream TYPE REF TO if_ixml_ostream.
l_ostream = l_streamfactory->create_ostream_itable( table = l_xml_table ).
When we have created the output stream we can do the rendering from the document into the stream. The XML data will be stored in the internal table automatically.
DATA: l_renderer TYPE REF TO if_ixml_renderer.
l_renderer = l_ixml->create_renderer( ostream = l_ostream
& nbsp; document = l_document ).
l_rc = l_renderer->render( ).
In the last step we upload the file to the sapgui
l_xml_size = l_ostream->get_num_written_raw( ).
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = l_xml_size
filename = 'c:\temp\flights.xml'
filetype = 'BIN'
CHANGING
data_tab = l_xml_table
EXCEPTIONS
OTHERS = 24.
This finished the first step-of-three. As mentioned before the next log will focus on the conversion from xml files (back) to abap tables.
REPORT z_xit_xml_dom_create.
TYPE-POOLS: ixml.
TYPES: BEGIN OF xml_line,
data(256) TYPE x,
END OF xml_line.
DATA: l_ixml TYPE REF TO if_ixml,
l_streamfactory TYPE REF TO if_ixml_stream_factory,
l_ostream TYPE REF TO if_ixml_ostream,
l_renderer TYPE REF TO if_ixml_renderer,
l_document TYPE REF TO if_ixml_document.
DATA: l_element_flights TYPE REF TO if_ixml_element,
l_element_airline TYPE REF TO if_ixml_element,
l_element_flight TYPE REF TO if_ixml_element,
l_element_from TYPE REF TO if_ixml_element,
l_element_to TYPE REF TO if_ixml_element,
l_element_dummy TYPE REF TO if_ixml_element,
l_value TYPE string.
DATA: l_xml_table TYPE TABLE OF xml_line,
l_xml_size TYPE i,
l_rc TYPE i.
DATA: lt_spfli TYPE TABLE OF spfli.
DATA: l_spfli TYPE spfli.
START-OF-SELECTION.
Fill the internal table
SELECT * FROM spfli INTO TABLE lt_spfli.
Sort internal table
SORT lt_spfli BY carrid.
Start filling xml dom object from internal table
LOOP AT lt_spfli INTO l_spfli.
AT FIRST.
Creating a ixml factory
l_ixml = cl_ixml=>create( ).
Creating the dom object model
l_document = l_ixml->create_document( ).
Fill root node with value flights
l_element_flights = l_document->create_simple_element(
name = 'flights'
parent = l_document ).
ENDAT.
AT NEW carrid.
Create element 'airline' as child of 'flights'
l_element_airline = l_document->create_simple_element(
name = 'airline'
parent = l_element_flights ).
Create attribute 'code' of node 'airline'
l_value = l_spfli-carrid.
l_rc = l_element_airline->set_attribute( name = 'code' value = l_value ).
Create attribute 'name' of node 'airline'
SELECT SINGLE carrname FROM scarr INTO l_value WHERE carrid EQ l_spfli-carrid.
l_rc = l_element_airline->set_attribute( name = 'name' value = l_value ).
ENDAT.
AT NEW connid.
Create element 'flight' as child of 'airline'
l_element_flight = l_document->create_simple_element(
name = 'flight'
parent = l_element_airline ).
Create attribute 'number' of node 'flight'
l_value = l_spfli-connid.
l_rc = l_element_flight->set_attribute( name = 'number' value = l_value ).
ENDAT.
Create element 'from' as child of 'flight'
CONCATENATE l_spfli-cityfrom ',' l_spfli-countryfr INTO l_value.
l_element_from = l_document->create_simple_element(
name = 'from'
value = l_value
parent = l_element_flight ).
Create attribute 'airport' of node 'from'
l_value = l_spfli-airpfrom.
l_rc = l_element_from->set_attribute( name = 'airport' value = l_value ).
Create element 'to' as child of 'flight'
CONCATENATE l_spfli-cityto ',' l_spfli-countryto INTO l_value.
l_element_to = l_document->create_simple_element(
name = 'to'
value = l_value
parent = l_element_flight ).
Create attribute 'airport' of node 'from'
l_value = l_spfli-airpto.
l_rc = l_element_to->set_attribute( name = 'airport' value = l_value ).
Create element 'departure' as child of 'flight'
l_value = l_spfli-deptime.
l_element_dummy = l_document->create_simple_element(
name = 'departure'
value = l_value
parent = l_element_flight ).
Create element 'arrival' as child of 'flight'
l_value = l_spfli-arrtime.
l_element_dummy = l_document->create_simple_element(
name = 'arrival'
value = l_value
parent = l_element_flight ).
Create element 'type' as child of 'flight'
CASE l_spfli-fltype.
WHEN 'X'.
l_value = 'Charter'.
WHEN OTHERS.
l_value = 'Scheduled'.
ENDCASE.
l_element_dummy = l_document->create_simple_element(
name = 'type'
value = l_value
parent = l_element_flight ).
ENDLOOP.
IF sy-subrc NE 0.
MESSAGE 'No data into db table ''spfli'', please run program ''SAPBC_DATA_GENERATOR'' with transaction ''SA38''' TYPE 'E'.
ENDIF.
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
Connect internal XML table to stream factory
l_ostream = l_streamfactory->create_ostream_itable( table = l_xml_table ).
Rendering the document
l_renderer = l_ixml->create_renderer( ostream = l_ostream
document = l_document ).
l_rc = l_renderer->render( ).
Saving the XML document
l_xml_size = l_ostream->get_num_written_raw( ).
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = l_xml_size
filename = 'c:\temp\flights.xml'
filetype = 'BIN'
CHANGING
data_tab = l_xml_table
EXCEPTIONS
OTHERS = 24.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
<?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>
<airline code="AZ" name="Alitalia">
<flight number="0555">
<from airport="FCO">ROME,IT</from>
<to airport="FRA">FRANKFURT,DE</to>
<departure>190000</departure>
<arrival>210500</arrival>
<type>Scheduled</type>
</flight>
<flight number="0788">
<from airport="FCO">ROME,IT</from>
<to airport="TYO">TOKYO,JP</to>
<departure>120000</departure>
<arrival>085500</arrival>
<type>Scheduled</type>
</flight>
<flight number="0789">
<from airport="TYO">TOKYO,JP</from>
<to airport="FCO">ROME,IT</to>
<departure>114500</departure>
<arrival>192500</arrival>
<type>Scheduled</type>
</flight>
<flight number="0790">
<from airport="FCO">ROME,IT</from>
<to airport="KIX">OSAKA,JP</to>
<departure>103500</departure>
<arrival>081000</arrival>
<type>Charter</type>
</flight>
</airline>
<airline code="DL" name="Delta Airlines">
<flight number="1984">
<from airport="SFO">SAN FRANCISCO,US</from>
<to airport="JFK">NEW YORK,US</to>
<departure>100000</departure>
<arrival>182500</arrival>
<type>Scheduled</type>
</flight>
<flight number="1699">
<from airport="JFK">NEW YORK,US</from>
<to airport="SFO">SAN FRANCISCO,US</to>
<departure>171500</departure>
<arrival>203700</arrival>
<type>Scheduled</type>
</flight>
<flight number="0106">
<from airport="JFK">NEW YORK,US</from>
<to airport="FRA">FRANKFURT,DE</to>
<departure>193500</departure>
<arrival>093000</arrival>
<type>Scheduled</type>
</flight>
</airline>
<airline code="JL" name="Japan Airlines">
<flight number="0407">
<from airport="NRT">TOKYO,JP</from>
<to airport="FRA">FRANKFURT,DE</to>
<departure>133000</departure>
<arrival>173500</arrival>
<type>Scheduled</type>
</flight>
<flight number="0408">
<from airport="FRA">FRANKFURT,DE</from>
<to airport="NRT">TOKYO,JP</to>
<departure>202500</departure>
<arrival>154000</arrival>
<type>Charter</type>
</flight>
</airline>
<airline code="LH" name="Lufthansa">
<flight number="2407">
<from airport="TXL">BERLIN,DE</from>
<to airport="FRA">FRANKFURT,DE</to>
<departure>071000</departure>
<arrival>081500</arrival>
<type>Scheduled</type>
</flight>
<flight number="2402">
<from airport="FRA">FRANKFURT,DE</from>
<to airport="SXF">BERLIN,DE</to>
<departure>103000</departure>
<arrival>113500</arrival>
<type>Scheduled</type>
</flight>
<flight number="0402">
<from airport="FRA">FRANKFURT,DE</from>
<to airport="JFK">NEW YORK,US</to>
<departure>133000</departure>
<arrival>150500</arrival>
<type>Charter</type>
</flight>
<flight number="0401">
<from airport="JFK">NEW YORK,US</from>
<to airport="FRA">FRANKFURT,DE</to>
<departure>183000</departure>
<arrival>074500</arrival>
<type>Scheduled</type>
</flight>
<flight number="0400">
<from airport="FRA">FRANKFURT,DE</from>
<to airport="JFK">NEW YORK,US</to>
<departure>101000</departure>
<arrival>113400</arrival>
<type>Scheduled</type>
</flight>
</airline>
<airline code="QF" name="Qantas Airways">
<flight number="0005">
<from airport="SIN">SINGAPORE,SG</from>
<to airport="FRA">FRANKFURT,DE</to>
<departure>225000</departure>
<arrival>053500</arrival>
<type>Scheduled</type>
</flight>
<flight number="0006">
<from airport="FRA">FRANKFURT,DE</from>
<to airport="SIN">SINGAPORE,SG</to>
<departure>205500</departure>
<arrival>150500</arrival>
<type>Scheduled</type>
</flight>
</airline>
<airline code="SQ" name="Singapore Airlines">
<flight number="0988">
<from airport="SIN">SINGAPORE,SG</from>
<to airport="TYO">TOKYO,JP</to>
<departure>163500</departure>
<arrival>001500</arrival>
<type>Scheduled</type>
</flight>
<flight number="0158">
<from airport="SIN">SINGAPORE,SG</from>
<to airport="JKT">JAKARTA,ID</to>
<departure>152500</departure>
<arrival>160000</arrival>
<type>Scheduled</type>
</flight>
<flight number="0015">
<from airport="SFO">SAN FRANCISCO,US</from>
<to airport="SIN">SINGAPORE,SG</to>
<departure>160000</departure>
<arrival>024500</arrival>
<type>Scheduled</type>
</flight>
<flight number="0002">
<from airport="SIN">SINGAPORE,SG</from>
<to airport="SFO">SAN FRANCISCO,US</to>
<departure>170000</departure>
<arrival>192500</arrival>
<type>Scheduled</type>
</flight>
</airline>
<airline code="UA" name="United Airlines">
<flight number="0941">
<from airport="FRA">FRANKFURT,DE</from>
<to airport="SFO">SAN FRANCISCO,US</to>
<departure>143000</departure>
<arrival>170600</arrival>
<type>Scheduled</type>
</flight>
<flight number="3504">
<from airport="SFO">SAN FRANCISCO,US</from>
<to airport="FRA">FRANKFURT,DE</to>
<departure>150000</departure>
<arrival>103000</arrival>
<type>Scheduled</type>
</flight>
<flight number="3516">
<from airport="JFK">NEW YORK,US</from>
<to airport="FRA">FRANKFURT,DE</to>
<departure>162000</departure>
<arrival>054500</arrival>
<type>Scheduled</type>
</flight>
<flight number="3517">
<from airport="FRA">FRANKFURT,DE</from>
<to airport="JFK">NEW YORK,US</to>
<departure>104000</departure>
<arrival>125500</arrival>
<type>Scheduled</type>
</flight>
</airline>
</flights>
Regards,
Amit
Reward all helpful replies.
Similar Messages
-
Internal table data to XML file.
Hi All,
May I know how can we convert the internal table data to xml file?
Regards
Ramesh.Re: Convert XML to internal Table
Go through the link..u should be able to solve the problem.. -
How to Convert internal table data into xml and xml data into internal tab
Hi Guys,
I have a requirement that i have to convert the internal table data into xml format and viceversa . for my requirement i came to know that i have to use Transformations concept. i done the converting the data from internal table into xml data by using standard Tranformations. My Question is
1) Can i use same Transformation to convert the xml data into abap internal table. if it is possible then how ???
2) Is it possible using the standard Transformation or I have to go for XSLT approach
Please help me out from this guys,
Thanks and Regards
KotiHi Koti,
This is possible. There is a link. With the help of this link you can convert ABAP data to XML and vice versa.
Link: http://www.heidoc.net/joomla/index.php?option=com_content&view=article&id=15:sapxslt&catid=22:sap-xslt&Itemid=31 -
How to download internal table data into xml file?
Hi,
Experts,
I have downloaded internal table data into XLS format using GUI_DOWNLOAD Function module, But i didn't Know how to download internal table data into XML format please post some ideas/inputs on this issue.
Thank you,
Shabeer ahmed.check this
data : gd_repid type sy-repid.
GD_REPID = SY-REPID.
DATA : L_DOM TYPE REF TO IF_IXML_ELEMENT,
M_DOCUMENT TYPE REF TO IF_IXML_DOCUMENT,
G_IXML TYPE REF TO IF_IXML,
W_STRING TYPE XSTRING,
W_SIZE TYPE I,
W_RESULT TYPE I,
W_LINE TYPE STRING,
IT_XML TYPE DCXMLLINES,
S_XML LIKE LINE OF IT_XML,
W_RC LIKE SY-SUBRC.
DATA: XML TYPE DCXMLLINES.
DATA: RC TYPE SY-SUBRC,
BEGIN OF XML_TAB OCCURS 0,
D LIKE LINE OF XML,
END OF XML_TAB.
data : l_element type ref to if_ixml_element,
xml_ns_prefix_sf type string,
xml_ns_uri_sf type string.
CLASS CL_IXML DEFINITION LOAD.
G_IXML = CL_IXML=>CREATE( ).
CHECK NOT G_IXML IS INITIAL.
M_DOCUMENT = G_IXML->CREATE_DOCUMENT( ).
CHECK NOT M_DOCUMENT IS INITIAL.
CALL FUNCTION 'SDIXML_DATA_TO_DOM'
EXPORTING
NAME = 'REPAIRDATA'
DATAOBJECT = IT_FINAL_LAST1[]
IMPORTING
DATA_AS_DOM = L_DOM
CHANGING
DOCUMENT = M_DOCUMENT
EXCEPTIONS
ILLEGAL_NAME = 1
OTHERS = 2.
CHECK NOT L_DOM IS INITIAL.
W_RC = M_DOCUMENT->APPEND_CHILD( NEW_CHILD = L_DOM ).
*Start of code for Header
* namespace
t_mnr = sy-datum+4(2).
CALL FUNCTION 'IDWT_READ_MONTH_TEXT'
EXPORTING
LANGU = 'E'
MONTH = t_mnr
IMPORTING
T247 = wa_t247
concatenate sy-datum+6(2)
wa_t247-ktx
sy-datum(4) into t_var1.
concatenate sy-uzeit(2)
sy-uzeit+2(2)
sy-uzeit+4(2) into t_var2.
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
l_element = m_document->get_root_element( ).
xml_ns_prefix_sf = 'TIMESTAMP'.
concatenate t_var1 t_var2 into xml_ns_uri_sf separated by space.
clear : t_var1,
t_var2,
t_mnr,
wa_t247.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'FILECREATOR'.
xml_ns_uri_sf = 'SAP'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'CLAIMGROUP'.
xml_ns_uri_sf = '1'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'CLAIMTYPES'.
xml_ns_uri_sf = 'W'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
*End of Code for Header
CALL FUNCTION 'SDIXML_DOM_TO_XML'
EXPORTING
DOCUMENT = M_DOCUMENT
IMPORTING
XML_AS_STRING = W_STRING
SIZE = W_SIZE
TABLES
XML_AS_TABLE = IT_XML
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2.
LOOP AT IT_XML INTO XML_TAB-D.
APPEND XML_TAB.
ENDLOOP.
*Start of Code for File name
concatenate p_file
'\R'
'000_119481'
sy-datum+6(2) sy-datum+4(2) sy-datum+2(2)
sy-uzeit(2) sy-uzeit+2(2) sy-uzeit(2) '.xml' into p_file.
*End of Code for File name
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_SIZE
FILENAME = p_file
FILETYPE = 'BIN'
TABLES
DATA_TAB = XML_TAB
EXCEPTIONS
OTHERS = 10.
IF SY-SUBRC = 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
How to covvert internal table data to XML file?
Hi,
Do u have material on ABAP with XML?
and how to convert internal table to XML?
Thanks and Regards,
ArpitaCheck below links:
XML DOM Processing in ABAP part II - Convert an XML file into an ABAP table using SAP DOM Approach.
Re: include a structure in a TYPES declaration
Thanks and Regards, -
Problem converting data in XML file to internal table data
Hi all,
I have a requirement. I need to convert an XML file to internal table data and based on that data do Goods Receipt in SAP.
With the help of this blog /people/r.eijpe/blog/2005/11/10/xml-dom-processing-in-abap-part-i--convert-an-abap-table-into-xml-file-using-sap-dom-approach
I am able to convert the XML file to data in SAP. But this blog will display the output on screen as ELELEMNT = nodename VALUE= value of that node.
But I donu2019t want in that way, I want to store all the data in XML file in an internal table so that I can make use of those values and do Goods Recipt in SAP.
Can some one suggest how should I read the data in an internal table.
Here is my code..what changes should I make?
*& Report z_xit_xml_check
REPORT z_xit_xml_check.
TYPE-POOLS: ixml.
TYPES: BEGIN OF t_xml_line,
data(256) TYPE x,
END OF t_xml_line.
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:\temp\orders_dtd.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 METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = l_filename
filetype = 'BIN'
IMPORTING
filelength = l_xml_table_size
CHANGING
data_tab = l_xml_table
EXCEPTIONS
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.
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.
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.
CASE node->get_type( ).
WHEN if_ixml_node=>co_node_element.
element node
name = node->get_name( ).
nodemap = node->get_attributes( ).
WRITE: / 'ELEMENT :'.
WRITE: AT indent name COLOR COL_POSITIVE INVERSE.
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 :'.
WRITE: AT indent value COLOR COL_GROUP INVERSE.
ENDCASE.
advance to next node
node = iterator->get_next( ).
ENDWHILE.
ENDFORM. "process_dom
Any help would be highly apperciated.
regards,
Jessica SamPavel Vera,
With your example i tries doing the following .....
I tried to convert the data of XML file to internal table data. I am collecting the data in internal table to do goos recipt with that data.
Please find my XML file, ABAP pgm and XSLT pgm . I donu2019t know what I am missing I am not getting any output. I donu2019t know what is wrong please help me with this
Below is my XML file, My code and XSLT Program. In the below XML file I need to collect Vendor Number, Order Number, and Date tags which occur only once for one XML file.
I also need to collect the following tags from <Shipmentdetail>
<Shipmentdetail> has following child nodes and I need to collect them
TrackingNumber
Freight
Weight
ShipmentDate
ShipmentMethod
Need to collect to collect the following tags from <ProductInformation>
<ProductInformation> has following child nodes and I need to collect them
LineNumber
SKUNumber
OrderedQuantity
ShippedQuantity
UOM
The <Shipmentdetail> and <ProductInformation> are child nodes of <OrderShipment>
The <Shipmentdetail> occurs only ones but the <ProductInformation> can occur once or many times and will be dynamic and differs depening on the input file.
My XML file is as follows
<?xml version="1.0" encoding="iso-8859-1" ?>
- <ShipmentHeader>
<AccountID />
- <OrderShipment>
<VendorNumber>1000</VendorNumber>
<OrderNumber>P00009238</OrderNumber>
<OrderType>Stock</OrderType>
<Company />
<Division />
<Department />
<Date>20061120</Date>
<CartonCount>2</CartonCount>
<ShipAllProducts>No</ShipAllProducts>
- <ShipmentDetail>
<TrackingNumber>1ZR3W891PG47477811</TrackingNumber>
<Freight>000000010000</Freight>
<ShipmentDate>20061120</ShipmentDate>
<ShipmentMethod>UPS1PS</ShipmentMethod>
</ShipmentDetail>
- <ProductInformation>
<LineNumber>000000001</LineNumber>
<SKUNumber>110FR</SKUNumber>
<AdvSKUNumber>003 4518</AdvSKUNumber>
<SKUID />
<OrderedQuantity>00000001000000</OrderedQuantity>
<ShippedQuantity>00000001000000</ShippedQuantity>
<UOM>EA</UOM>
<Factor>1</Factor>
</ProductInformation>
- <ProductInformation>
<LineNumber>000000002</LineNumber>
<SKUNumber>938EN</SKUNumber>
<AdvSKUNumber>001 7294</AdvSKUNumber>
<SKUID />
<OrderedQuantity>00000000450000</OrderedQuantity>
<ShippedQuantity>00000000450000</ShippedQuantity>
<UOM>EA</UOM>
<Factor>1</Factor>
</ProductInformation>
- <CaseInformation>
<LineNumber>000000001</LineNumber>
<SKUNumber>110FR</SKUNumber>
<AdvSKUNumber>003 4518</AdvSKUNumber>
<SKUID />
<SSCCNumber>00000001668000002487</SSCCNumber>
<CaseQuantity>00000001000000</CaseQuantity>
<UOM>EA</UOM>
<Factor>1</Factor>
</CaseInformation>
<CaseInformation>
<LineNumber>000000001</LineNumber>
<SKUNumber>110FR</SKUNumber>
<AdvSKUNumber>003 4518</AdvSKUNumber>
<SKUID />
<SSCCNumber>00000001668000002487</SSCCNumber>
<CaseQuantity>00000001000000</CaseQuantity>
<UOM>EA</UOM>
<Factor>1</Factor>
</CaseInformation>
- </OrderShipment>
</ShipmentHeader>
My Program
TYPE-POOLS abap.
CONSTANTS gs_file TYPE string VALUE 'C:\temp\test.xml'.
* This is the structure for the data from the XML file
TYPES: BEGIN OF ts_shipment,
VendorNumber(10) TYPE n,
OrderNumber(20) TYPE n,
OrderType(8) TYPE c,
Date(8) TYPE c,
END OF ts_shipment.
TYPES: BEGIN OF ts_shipmentdetail,
TrackingNumber(30) TYPE n,
Freight(12) TYPE n,
Weight(14) TYPE n,
ShipmentDate(8) TYPE c,
ShipmentMethod(8) TYPE c,
END OF ts_shipmentdetail.
TYPES: BEGIN OF ts_productinformation,
LineNumber(9) TYPE n,
SKUNumber(20) TYPE c,
OrderedQuantity(14) TYPE n,
ShippedQuantity(14) TYPE n,
UOM(4) TYPE c,
END OF ts_productinformation.
* 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_shipment TYPE STANDARD TABLE OF ts_shipment,
gs_shipment TYPE ts_shipment.
DATA: gt_shipmentdetail TYPE STANDARD TABLE OF ts_shipmentdetail,
gs_shipmentdetail TYPE ts_shipmentdetail.
DATA: gt_productinformation TYPE STANDARD TABLE OF ts_productinformation,
gs_productinformation TYPE ts_productinformation.
* 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
* "ISHIPMENT".
GET REFERENCE OF gt_shipment INTO gs_result_xml-value.
gs_result_xml-name = 'ISHIPMENT'.
APPEND gs_result_xml TO gt_result_xml.
* Fill the result table with a reference to the data table.
* Within the XSLT stylesheet, the data table can be accessed with
* "ISHIPDET".
GET REFERENCE OF gt_shipmentdetail INTO gs_result_xml-value.
gs_result_xml-name = 'ISHIPDET'.
APPEND gs_result_xml TO gt_result_xml.
* Fill the result table with a reference to the data table.
* Within the XSLT stylesheet, the data table can be accessed with
* "IPRODDET".
GET REFERENCE OF gt_productinformation INTO gs_result_xml-value.
gs_result_xml-name = 'IPRODDET'.
APPEND gs_result_xml TO gt_result_xml.
* Perform the XSLT stylesheet
TRY.
CALL TRANSFORMATION z_xml_to_abap3
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 'E'.
ENDTRY.
* Writing the data from file for gt_shipment
*Collecting the Shipping Data from the XML file to internal table gt_shipment
*and writing the data to the screen
LOOP AT gt_shipment INTO gs_shipment.
WRITE: / 'VendorNumber:', gs_shipment-VendorNumber.
WRITE: / 'OrderNumber :', gs_shipment-OrderNumber.
WRITE: / 'OrderType :', gs_shipment-OrderType.
WRITE: / 'Date :', gs_shipment-Date.
WRITE : /.
ENDLOOP. "gt_shipment.
LOOP AT gt_shipmentdetail INTO gs_shipmentdetail.
WRITE: / 'TrackingNumber:', gs_shipmentdetail-TrackingNumber.
WRITE: / 'Freight :', gs_shipmentdetail-Freight.
WRITE: / 'Weight :', gs_shipmentdetail-Weight.
WRITE: / 'ShipmentDate :', gs_shipmentdetail-ShipmentDate.
* WRITE: / 'ShipmentMethod :' gs_shipmentdetail-ShipmentMethod
WRITE : /.
ENDLOOP. "gt_shipmentdetail.
LOOP AT gt_productinformation INTO gs_productinformation.
WRITE: / 'LineNumber:', gs_productinformation-LineNumber.
WRITE: / 'SKUNumber :', gs_productinformation-SKUNumber.
WRITE: / 'OrderedQuantity :', gs_productinformation-OrderedQuantity.
WRITE: / 'ShippedQuantity :', gs_productinformation-ShippedQuantity.
WRITE: / 'UOM :', gs_productinformation-UOM.
WRITE : /.
ENDLOOP. "gt_productinformation.
XSLT Program
<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>
<ISHIPMENT>
<xsl:apply-templates select="//OrderShipment"/>
</ISHIPMENT>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="OrderShipment">
<item>
<VENDORNUMBER>
<xsl:value-of select="VendorNumber"/>
</VENDORNUMBER>
<ORDERNUMBER>
<xsl:value-of select="OrderNumber"/>
</ORDERNUMBER>
<ORDERTYPE>
<xsl:value-of select="OrderType"/>
</ORDERTYPE>
<DATE>
<xsl:value-of select="Date"/>
</DATE>
</item>
</xsl:template>
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ISHIPDET>
<xsl:apply-templates select="//OrderShipment/ShipmentDetail"/>
</ISHIPDET>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="ShipmentDetail">
<item>
<TRACKINGNUMBER>
<xsl:value-of select="TrackingNumber"/>
</TRACKINGNUMBER>
<FREIGHT>
<xsl:value-of select="Freight"/>
</FREIGHT>
<SHIPMENTDATE>
<xsl:value-of select="ShipmentDate"/>
</SHIPMENTDATE>
<SHIPMENTMETHOD>
<xsl:value-of select="ShipmentMethod"/>
</SHIPMENTMETHOD>
</item>
</xsl:template>
</xsl:transform> .
Any help is highly appreciated. If anyone encountered this situation before please let me know where i am going wrong in my XSLT transformation.
Any Help will be highly apppreciated. Thanks in advance
Regards,
Jessica Sam -
Sending internal table data to application server as an XML file
Hi All,
I am trying to send the internal table data to application server which should be stored in XML format.
I am using the following code:
DATA:
result TYPE xstring.
CALL TRANSFORMATION id
SOURCE tab = p_output-xsfdata
RESULT XML result.
OPEN DATASET l_xml_full_path FOR OUTPUT IN BINARY MODE.
TRANSFER result TO l_xml_full_path.
CLOSE DATASET l_xml_full_path.
And the content in the internal table is :
3C3F786D6C2076657273696F6E3D22312E30223F3E3C736620786D6C6E733D2275726E3A736
73796D206E616D653D22534653592D44415445223E30362F31302F323030393C2F73796D3E2
50617961626C653C6E65772D6C696E652F3E50617274206F6620746865204E616D653C6E657
.......and so on
With this a file is getting created on the application server, but the data is not correct. I am getting the data something like:
<?xml version="1.0" encoding="utf-8"?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0"><asx:values><TAB><item>
PD94bWwgdmVyc2lvbj0iMS4wIj8+PHNmIHhtbG5zPSJ1cm46c2FwLWNv
MDA6eHNmIj48c21hcnR4c2Y+PGhlYWRlcj48Z2VuZXJhbD48dmVyc2lvbj4xLjE0LjI8L3ZlcnNp
b24PGZvcm0WkJMX1NESU5WX0xfMzwvZm9ybT48bGFuZ3VhZ2U+RU48L2xhbmd1YWdlPjxkZXZp
Y2UUFJJTlRFUjwvZGV2aWNlPjxvdXRwdXQtZGV2aWNlPlNYU0Y8L291dHB1dC1kZXZpY2UPC9n
ZW5lcmFsPjxwYWdlIG5hbWU9IkZJUlNUIiBpZD0iMDAxIi8PC9oZWFkZXIPGRhdGEgeG1sOnNw
YWNlPSJwcmVzZXJ2ZSIgc3R5bGU9Ii9TTUIxMS9CTF9TRiI+PGdyYXBoaWNzIG5hbWU9IkNPTUxP
R08iIG9iam5hbWU9Ii9TTUI0MC9MRUFGIiBvYmplY3Q9IkdSQVBISUNTIiBpZD0iQk1BUCIgdHlw
ZT0iQkNPTCIgcGFnZT0iRklSU1QiIHBhZ2UtaWQ9IjAwMSIgcmVzb2x1dGlvbj0iMDEwMCIvPjx3
aW5kb3cgbmFtZT0iU0VOREVSIiBwYWdlPSJGSVJTVCIgcGFnZS1pZD0iMDAxIj48dGV4dCBuYW1l
PSJDT01BRERSIiBzdHlsZT0iL1NNQjExL0JMX1NGIiBvYmpuYW1lPSIvU01CMTEvQkxfU0VOREVS
IiBsYW5nPSJFTiIPHAgbmFtZT0iWlMiPkJhc2VsaW5lIENvbXBhbnk8L3APHAgbmFtZT0iWlMi
PjM0NzUgRGVlciBDcmVlazx0YWIvPlBob25lOjx0YWIvPisxICg2NTApIDg0OS00MDAwPC9wPjxw
IG5hbWU9IlpTIj5QYWxvIEFsdG8sIENBIDk0MzA0PHRhYi8+RmF4Ojx0YWIvPisxICg2NTApIDg0
OS00MjAwPC9wPjxwIG5hbWU9IlpTIj5VU0E8dGFiLz5JbnRlcm5ldDo8dGFiLz5odHRwOi8vd3d3
LnNhcC5jb208L3A+PC90ZXh0Pjwvd2luZG93Pjx3aW5kb3cgbmFtZT0iUEFHRSIgcGFnZT0iRklS
U1QiIHBhZ2UtaWQ9IjAwMSI+PHRleHQgbmFtZT0iUEFHRU5VTUJFUiIgc3R5bGU9Ii9TTUIxMS9C
TF9TRiIgbGFuZz0iRU4iPjxwIG5hbWU9IlROIj5QYWdlIDxzeW0gbmFtZT0iU0ZTWS1QQUdFIj4x
PC9zeW0IG9mIDxzeW0gbmFtZT0iU0ZTWS1KT0JQQUdFUyIvPjwvcD48cCBuYW1lPSJUTiIPA==</item>
<item>c3ltIG5hbWU9IlNGU1ktREFURSI+MDYvMTAvMjAwOTwvc3ltPiA8c
RSIMTQ6MDg6MDM8L3N5bT48L3APC90ZXh0Pjwvd2luZG93Pjx3aW5kb3cgbmFtZT0iTkFNRSIg
cGFnZT0iRklSU1QiIHBhZ2UtaWQ9IjAwMSI+PHRleHQgbmFtZT0iRk9STVVMQVJUSVRFTCIgc3R5
bGU9Ii9TTUIxMS9CTF9TRiIgbGFuZz0iRU4iPjxwIG5hbWU9IlROIj48Y2hyIG5hbWU9Ik1MIj48
c3ltIG5hbWU9IlRJVExFIj5JbnZvaWNlPC9zeW0PC9jaHIPC9wPjwvdGV4dD48L3dpbmRvdz48
d2luZG93IG5hbWU9IkJJTExUT1BBUlRZIiBwYWdlPSJGSVJTVCIgcGFnZS1pZD0iMDAxIj48dGV4
dCBuYW1lPSJXSU5ET1dfVEVYVCIgc3R5bGU9Ii9TTUIxMS9CTF9TRiIgbGFuZz0iRU4iPjxwIG5h
bWU9IlRIIj5CaWxsLVRvLVBhcnR5PC9wPjwvdGV4dD48YWRkcmVzcyBuYW1lPSJCSUxMQUREUkVT
UyIgYWRkcm51bWJlcj0iMDAwMDAyMjQyNyI+PHRleHQgbmFtZT0iQklMTEFERFJFU1MiIHN0eWxl
PSIvU01CMTEvQkxfU0YiIGxhbmc9IkVOIj48cCBuYW1lPSJUMiI+VGVjaCBJbmM8bmV3LWxpbmUv
Could anyone tell me the reason why am I getting the data in this way?
Thanks in advance,
Swapna.
Edited by: NagaSwapna Thota on Jun 10, 2009 5:44 PMHI,
Use this FM SAP_CONVERT_TO_XML_FORMAT to convert the data to XML format and then upload the convert data from the internal table to Application server. -
How to transfer internal table data to Applicatiion Server in XML fromat.
how to transfer internal table data to Applicatiion Server in XML fromat.
Hi if u want to transfer from to application server using xml in
do like this,
v_xml_table is u r internal table,
and define li_xml_table as line of u r internal table
OPEN DATASET g_file FOR OUTPUT IN BINARY MODE .
LOOP AT v_xml_table INTO li_xml_table.
TRANSFER li_xml_table TO g_file .
ENDLOOP.
CLOSE DATASET g_file.
ENDIF.
<removed_by_moderator>
Regards,
Prasad.
Edited by: Julius Bussche on Jul 16, 2008 2:43 PM -
Internal table data 1E2 automatically convert to scientific format
Dear all,
I have been searched for solution moths from the forums and tried all possible methods, but still no way to solve my above problem. I found a way to solve it partially for us, but may be very helpful for others who meet similly case like mine, so I posted here.
my problem is when I export my internal table data to Excel, the Cell data with 1E2 auto becomes 1.00E02, and 1E8 becomes 1.00E08, we need it to be 1E2 and 1E8 in excel.
you can recreate my problem by
1, input 1E2 into your Microsoft Excel, then Enter, it will auto change into scientific format. which is we do not want.
2, use any of your SAP system open any table as long as there is a Char (>3) field in that table. add some
data entry in that field in the form "any amount (<15) of numeric 1 to 9"E"any one or two numeric 1 to 9". such as, 123E2, 1234E12 etc. then save this table's data to local file spread sheet, or use any FM to download it to a Excel file, when you open this
file by Excel, the cell with above form will display as scientific. but
if you put three or more numeric after the "E", such as 123E123 it will
display correctly.
what I have done:
I searched in SCN for similar thread:
Export to Excel 2007 - item number problem
Exceding the limit of numbers in Excel at target side
Excel download cell format problem
Formating as Text in excel through SAP
Converting of amount field into excel file through GUI DOWNLOAD
Data downloaded to excel gets converted to exponential format.
Problem with Excel download and scientific number
Re: Issue in displaying numbers in Excel?
CSV Flat File Data Problem (Number converting to Scientific Notation)
Tested accordingly, But none of these works in our case. because our
ultimate receiver of email attachment will be external third party, we cannot ask
them to change anything in their Excel.
Search Microsoft help about Excel, http://support.microsoft.com/kb/214233,
and it says this "Automatic Number Formatting" is a normal behaviour of excel.
no way to turn it off, the "work-around" way that Microsoft provides is not suitable for our
case.
We test CL_iXML recently arrording to weblog http://wiki.sdn.sap.com/wiki/display/Snippets/FormattedExcelasEmailAttachment
it successful controled the format. so this could be a solution for others whose internal table size is small. but our 2MB internal table bocome 6MB when converted to xml file attachment, which cannot be received by our end user's mail box. too big.
So please advise your ideas.
Many thanks in advance!
Peter Ding
Thank you very much for your time!Hi,
You can achieve this by describing the spreadsheet in XML with the help of the DOM classes.
The later releases of Excel can read and save spreadsheets as XML, providing your release supports this you can achieve it.
Check out the following Wiki
[Excel - XML|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/exporting%2bdata%2bto%2bexcel%2b-%2bxml%2bto%2bthe%2brescue]
Regards,
Darren -
PDF File from an internal table data
I have an internal table ready for grid display of a report. But according to the new requirement, it shouldn't create a Spool request as it is affecting the performance of the system (because its a huge file with 3000+ pages).
So, now we want to create a (non-editable) PDF File and store it in an application server.
From the forum, i see that i have only one option, which is to Convert internal table data to OTF Format and then to PDF.
Right now i am using PRINT_TEXT to convert to OTF file and FM CONVERT_OTF for PDF file.
The challenges i am facing right now is..
1. After getting the OTF file from PRINT_TEXT, i couldn't get the correct PDF File. It shows random characters instead..
2. My internal table has 103 columns. So how should i accommodate data from all these columns into a single row on a PDF?
3. I couldn't create a table kind of view/display in PDF
Please help/advice me on the above issue.
Thanks,
SaradaHi,
103 columns need to be seen in at least 7 pages or more. Cant display in just 1 page.
I guess that better to create a smartforms and pass all the information from the table to the smartforms.
There you can create multipages.
Probably, that huge table need to separete it in 7 tables, so each page will get the information from one table...
i will try to do sth like that.
Regards
Miguel -
How to send internal table data through mail from report in foreground
hi all,
iam trying to convert the internal table data into excel format and sending it through mail by runnning the report in foreground.
mail is going sucessfully with excel format,but iam facing the problem in the excel format of the material column as follows:
the matrno shows the wrong format -2.63E+11 instead of displaying correct format-263215000000.
Pls suggest the alternative process for the above mentioned problem.
Thanks,
Sivagopal R.Hi Siva,
Try to copy 263215000000 in one of the cells of excel sheet and press enter.It will automatically convert into -2.63E+11 .
This means the default formatting of the excel sheet makes this happen.If you convert the format of the cell to "NUMBER" then u will get the required result.
But I doubt whether or not it is possible through ABAP programming.
Regards,
Vimal. -
How to download internal table data to .xlsx file ?
Hello All,
I am using SAP ECC 6.0. I need to download internal table data to .xlsx file.
I tried GUI_DOWNLOAD, all the data are getting transferred to the .xlsx file, but while opening I am getting the below error.
Excel cannot open the file "download.xlsx" because file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.
Though Microsoft office 2007 is installed in my system.
Please help <removed by moderator>.
Edited by: Thomas Zloch on Oct 24, 2011 10:55 AMHi,
Please find the below code to download data into excel file.
DATA: ld_filename TYPE string,
ld_path TYPE string,
ld_fullpath TYPE string,
ld_result TYPE i.
Display save dialog window
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = ' '
DEFAULT_EXTENSION = 'XLS'
default_file_name = 'accountsdata'
INITIAL_DIRECTORY = 'c:\temp\'
CHANGING
filename = ld_filename
path = ld_path
fullpath = ld_fullpath
user_action = ld_result.
Check user did not cancel request
CHECK ld_result EQ '0'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = ld_fullpath
filetype = 'ASC'
APPEND = 'X'
write_field_separator = 'X'
CONFIRM_OVERWRITE = 'X'
TABLES
data_tab = it_datatab[] "need to declare and populate
EXCEPTIONS
file_open_error = 1
file_write_error = 2
OTHERS = 3.
Thanks and Regards
Chitra -
How to access internal table data from webdynpro to Flex application.
Hi Connoisseur
The data transfer from Abap WebDeypro to flex island works well. I followed , there is an example from Thomas Jung (by the way as always Great Work) and Karthikeyan Venkatesan (Infosys) but this example covers simple type only.
There is no example with complex types like arrayCollection which handle the transfer of data from flex to WebDynpro.
i tried to do pass internal table value to flex-datagrid.but its not work.
i would like to know
1.how to access internal table data from webdynpro to Flex application.
2.how to pass the internal table to flex-datagrid.
2.how to pass dynamically in ADOBE flex.
3. how to do Flex is receiving the wd context data?
4. how can we update WD context with FLEX data.
Ple give me sample example and step by step procedure.
Regards
laxmikanthHi Laxmikanth,
Please refer this...
Flash island: update complex type from flex
Cheers..
kris. -
How to Convert internal table data into text output and send mail in ABAP
Hi All,
Good Morning.
Taking a glance at a code that converts internal table data to an Excel file in ABAP. also checked how to send this excel to mailing list as attachment.
But thought of doing it without excel.
I mean, I have an internal table which contains fields of all types (character,integer,date,time). Since it is only around 4 to 5 rows in it (output),why to convert it to excel. not required!!. Instead I want to send this output to User's mails as Normal mail body with No attachments.
Could anybody please suggest me a way as to how to send internal table data as a mail ( not as an excel or PDF etc).
as of now my findings are, it is quite complex to convert internal table data to email (Text) format. but i believe if there is some way of doing it.
Best Regards
Dileep VThere's something I have used in the past where we send out information about failed precalculation settings (which are stored in internal table gt_fail)
notice we use gt_text as "mail body"
TRY.
* -------- create persistent send request ------------------------
gv_send_request = cl_bcs=>create_persistent( ).
* -------- create and set document -------------------------------
* create text to be sent
wa_line = text-001.
APPEND wa_line TO gt_text.
CLEAR wa_line.
APPEND wa_line TO gt_text.
LOOP AT gt_fail ASSIGNING <fs_fail>.
MOVE <fs_fail>-retry_count TO gv_count.
CONCATENATE text-002
<fs_fail>-setting_id
text-003
gv_count
INTO wa_line SEPARATED BY space.
APPEND wa_line TO gt_text.
CLEAR wa_line.
ENDLOOP.
APPEND wa_line TO gt_text.
wa_line = text-007.
APPEND wa_line TO gt_text.
* create actual document
gv_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = gt_text
i_length = '12'
i_subject = 'Failed Precalculation Settings!' ).
* add document to send request
CALL METHOD gv_send_request->set_document( gv_document ).
* --------- set sender -------------------------------------------
gv_sender = cl_sapuser_bcs=>create( sy-uname ).
CALL METHOD gv_send_request->set_sender
EXPORTING
i_sender = gv_sender.
* --------- add recipient (e-mail address) -----------------------
LOOP AT s_email INTO wa_email.
MOVE wa_email-low TO gv_email.
gv_recipient = cl_cam_address_bcs=>create_internet_address(
gv_email ).
CALL METHOD gv_send_request->add_recipient
EXPORTING
i_recipient = gv_recipient
i_express = 'X'.
ENDLOOP.
* ---------- set to send immediately -----------------------------
CALL METHOD gv_send_request->set_send_immediately( 'X' ).
* ---------- send document ---------------------------------------
CALL METHOD gv_send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = gv_sent_to_all ).
IF gv_sent_to_all = 'X'.
WRITE text-004.
ENDIF.
COMMIT WORK.
* exception handling
CATCH cx_bcs INTO gv_bcs_exception.
WRITE: text-005.
WRITE: text-006, gv_bcs_exception->error_type.
EXIT.
ENDTRY.
with the following declarations
* TABLES *
TABLES:
adr6,
rsr_prec_sett.
* INTERNAL TABLES & WORK AREAS *
DATA:
gt_fail TYPE SORTED TABLE OF rsr_prec_sett
WITH UNIQUE KEY setting_id run_date,
gt_text TYPE bcsy_text,
wa_fail LIKE LINE OF gt_fail,
wa_line(90) TYPE c.
FIELD-SYMBOLS:
<fs_fail> LIKE LINE OF gt_fail.
* VARIABLES *
DATA:
gv_count(4) TYPE n,
gv_send_request TYPE REF TO cl_bcs,
gv_document TYPE REF TO cl_document_bcs,
gv_sender TYPE REF TO cl_sapuser_bcs,
gv_recipient TYPE REF TO if_recipient_bcs,
gv_email TYPE adr6-smtp_addr,
gv_bcs_exception TYPE REF TO cx_bcs,
gv_sent_to_all TYPE os_boolean.
* SELECTION-SCREEN *
SELECT-OPTIONS:
s_email FOR adr6-smtp_addr NO INTERVALS MODIF ID sel.
DATA:
wa_email LIKE LINE OF s_email. -
How to Populate Internal table data to Table Control in a Report Program
Dear All,
How to Populate Internal table data to Table Control in a Report Program? It is a pure report program with out any Module pool coding involved, which is just used to display data. Till now it is being displayed in a report. Now the user wants the data to be displayed in a table control. Could someone tell me how to go about with this.
Thanks in Advance,
Joseph ReddyIf you want to use a table control, you will need to create a screen.
In your report....
start-of-selection.
perform get_data. " Get all your data here
call screen 100. " Now present to the user.
Double click on the "100" in your call screen statement. This will forward navigate you to the screen. If you have not created it yet, it will ask you if you want to create it, say yes. Go into screen painter or layout of the screen. Use the table control wizard to help you along the process. It will write the code for you. Since it is an output only table control, it will be really easy with not a lot of code.
A better way to present the data to the user would be to give it in a ALV grid. If you want to go that way, it is a lot easier. Here is a sample of the ALV function module. You don't even have to create a screen.
report zrich_0004
no standard page heading.
type-pools slis.
data: fieldcat type slis_t_fieldcat_alv.
data: begin of imara occurs 0,
matnr type mara-matnr,
maktx type makt-maktx,
end of imara.
* Selection Screen
selection-screen begin of block b1 with frame title text-001 .
select-options: s_matnr for imara-matnr .
selection-screen end of block b1.
start-of-selection.
perform get_data.
perform write_report.
* Get_Data
form get_data.
select mara~matnr makt~maktx
into corresponding fields of table imara
from mara
inner join makt
on mara~matnr = makt~matnr
where mara~matnr in s_matnr
and makt~spras = sy-langu.
endform.
* WRITE_REPORT
form write_report.
perform build_field_catalog.
* CALL ABAP LIST VIEWER (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = fieldcat
tables
t_outtab = imara.
endform.
* BUILD_FIELD_CATALOG
form build_field_catalog.
data: fc_tmp type slis_t_fieldcat_alv with header line.
clear: fieldcat. refresh: fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Material Number'.
fc_tmp-fieldname = 'MATNR'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '18'.
fc_tmp-col_pos = 2.
append fc_tmp to fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Material'.
fc_tmp-fieldname = 'MAKTX'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '40'.
fc_tmp-col_pos = 3.
append fc_tmp to fieldcat.
endform.
Regards,
Rich Heilman
Maybe you are looking for
-
Power Mac 10.5.8 Cannot Eject Drives or Send Files to Trash
Hello, I'm posting to the forum for a friend. He is using a Power Mac OSX 10.5.8 with Dual 2 GHz Power PC G5 processor. The past two months he has been having issues deleting files and ejecting drives (flash drives and external hard drives). He will
-
Airport Extreme and External Hard Drive. Backup over WAN?
Hi I'm new to Mac's and just got a macbook air and a airport extreme. I connected my external hard (toshiba) drive to the AE and my computer will recognize it, but when I try to connect to it using Time Machine my external hard drive is not recogniz
-
KE24 Functionality ?--URGENT
in KE24 Report showing Negative values and Positive values for any changes that we done in Sales Order for the respective line item. I want to know in which cases it will show the Negative values and which cases it wil shows Positive Values and it is
-
My iphone 5 send sms but not recive sms
IPhone 5 sends text messages but not recive text messages when the message sent from another mobile phone I notice that the message Send but to not recive to my mobile
-
Strange issue with dbms_scheduler
Hi All, Below is our DB details SQL> select * 2 from v$version; BANNER Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi PL/SQL Release 10.2.0.4.0 - Production CORE 10.2.0.4.0 Production TNS for Linux: Version 10.2.0.4.0 - P