Need FM to read XML document from appliacation server.
Hi all .
I need a FM which can read the XML data from Apllication server into internal table.Example code will be very helpful.
Kind Regards,
sami.
Check This code :
===============
Local data delaration.
DATA: v_string TYPE string.
Opening the file from the given location.
OPEN DATASET p_pathup FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc <> 0.
MESSAGE i000 WITH text-018.
LEAVE LIST-PROCESSING.
ENDIF.
File opened, Reading the contents and transfering to internal table.
DO.
READ DATASET p_pathup INTO v_string.
IF sy-subrc = 0.
SPLIT v_string AT c_sep
INTO w_upload-lifnr
w_upload-loevm_ven
w_upload-banksrec
w_upload-bankkrec
w_upload-banknrec
w_upload-loevm_rec
w_upload-waers
w_upload-bankssnd
w_upload-bankksnd
w_upload-loevm_snd
w_upload-chainno
w_upload-chainbankt
w_upload-chainbanks
w_upload-chainbankk
w_upload-chainbankn
w_upload-loevm_cor.
ELSE.
EXIT.
ENDIF.
APPEND w_upload TO i_upload.
CLEAR: w_upload,
v_string.
ENDDO.
Closing the file.
CLOSE DATASET p_pathup.
Let me know if you need any help on understanding the logic.
Regards
Similar Messages
-
FM to read XML files from Application server in ECC5.0
Hi All,
We need to pick up an XML file from Application server/FTP server. The requirement is to parse the XML file and process it to create material master. SAP provides standard function modules to read XML files.
Now we need to read the XML file contents of MM01 and upload into SAP Data Base through BAPI
I need to know about the Function modules to read XML files from Application Server and also about the FM's that will update the Date base tables with the data obtained form XML files.
Regards
PrathimaParsing XML data:
http://help.sap.com/saphelp_nw04/helpdata/en/86/8280ba12d511d5991b00508b6b8b11/frameset.htm
or alternatively check out ABAP online help for "CALL TRANSFORMATION".
For creating the material master look at BAPI_STANDARDMATERIAL_CREATE.
Thomas -
Read XML file from presentation server
Hi All,
I want read XML file from presentation server currently i am using GUI_UPLOAD fm . but it is reading some junk data.
DATA : BEGIN OF upl OCCURS 0,
f(255) TYPE c,
END OF upl.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = D:\XX.XML'
filetype = 'BIN'
TABLES
data_tab = upl.
is there any other alternative.
Thanks
Swarup,Hi Swarup,
Use method IMPORT_FROM_FILE of class CL_XML_DOCUMENT.
A sample code snippet :-
PARAMETERS: p_filnam TYPE localfile OBLIGATORY
DEFAULT 'C:\Documents and Settings\ssaha\Desktop\test.xml'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_filnam.
DATA: l_v_fieldname TYPE dynfnam.
l_v_fieldname = p_filnam.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = l_v_fieldname
IMPORTING
file_name = p_filnam.
START-OF-SELECTION.
TYPES:
BEGIN OF ty_tab,
name TYPE string,
value TYPE string,
END OF ty_tab.
DATA:
lcl_xml_doc TYPE REF TO cl_xml_document,
v_subrc TYPE sysubrc,
v_node TYPE REF TO if_ixml_node,
v_child_node TYPE REF TO if_ixml_node,
v_root TYPE REF TO if_ixml_node,
v_iterator TYPE REF TO if_ixml_node_iterator,
v_nodemap TYPE REF TO if_ixml_named_node_map,
v_count TYPE i,
v_index TYPE i,
v_attr TYPE REF TO if_ixml_node,
v_name TYPE string,
v_prefix TYPE string,
v_value TYPE string,
v_char TYPE char2.
DATA:
itab TYPE STANDARD TABLE OF ty_tab,
wa TYPE ty_tab.
CREATE OBJECT lcl_xml_doc.
CALL METHOD lcl_xml_doc->import_from_file
EXPORTING
filename = p_filnam
RECEIVING
retcode = v_subrc.
CHECK v_subrc = 0.
v_node = lcl_xml_doc->m_document.
CHECK NOT v_node IS INITIAL.
v_iterator = v_node->create_iterator( ).
v_node = v_iterator->get_next( ).
WHILE NOT v_node IS INITIAL.
CASE v_node->get_type( ).
WHEN if_ixml_node=>co_node_element.
v_name = v_node->get_name( ).
v_nodemap = v_node->get_attributes( ).
IF NOT v_nodemap IS INITIAL
* attributes
v_count = v_nodemap->get_length( ).
DO v_count TIMES.
v_index = sy-index - 1.
v_attr = v_nodemap->get_item( v_index ).
v_name = v_attr->get_name( ).
v_prefix = v_attr->get_namespace_prefix( ).
v_value = v_attr->get_value( ).
ENDDO.
ENDIF.
WHEN if_ixml_node=>co_node_text OR
if_ixml_node=>co_node_cdata_section.
* text node
v_value = v_node->get_value( ).
MOVE v_value TO v_char.
IF v_char <> cl_abap_char_utilities=>cr_lf.
wa-name = v_name.
wa-value = v_value.
APPEND wa TO itab.
CLEAR wa.
ENDIF.
ENDCASE.
* advance to next node
v_node = v_iterator->get_next( ).
ENDWHILE.
LOOP AT itab INTO wa.
ENDLOOP.
Regards
Abhii -
Problem while reading XML file from Aplication server(Al11)
Hi Experts
I am facing a problem while reading XML file from Aplication server using open data set.
OPEN DATASET v_dsn IN BINARY MODE FOR INPUT.
IF sy-subrc <> 0.
EXIT.
ENDIF.
READ DATASET v_dsn INTO v_rec.
WHILE sy-subrc <> 0.
ENDWHILE.
CLOSE DATASET v_dsn.
The XML file contains the details from an IDOC number , the expected output is XML file giving all the segments details in a single page and send the user in lotus note as an attachment, But in the present output after opening the attachment i am getting a single XML file which contains most of the segments ,but in the bottom part it is giving the below error .
- <E1EDT13 SEGMENT="1">
<QUALF>001</QUALF>
<NTANF>20110803</NTANF>
<NTANZ>080000</NTANZ>
<NTEND>20110803<The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
Invalid at the top level of the document. Error processing resource 'file:///C:/TEMP/notesD52F4D/SHPORD_0080005842.xml'.
/SPAN></NTEND>
<NTENZ>000000</NTENZ>
for all the xml its giving the error in bottom part , but once we open the source code and if we saved in system without changing anything the file giving the xml file without any error in that .
could any one can help to solve this issue .Hi Oliver
Thanx for your reply.
see the latest output
- <E1EDT13 SEGMENT="1">
<QUALF>003</QUALF>
<NTANF>20110803</NTANF>
<NTANZ>080000</NTANZ>
<NTEND>20110803</NTEND>
<NTENZ>000000</NTENZ>
<ISDD>00000000</ISDD>
<ISDZ>000000</ISDZ>
<IEDD>00000000</IEDD>
<IEDZ>000000</IEDZ>
</E1EDT13>
- <E1EDT13 SEGMENT="1">
<QUALF>001</QUALF>
<NTANF>20110803</NTANF>
<NTANZ>080000</NTANZ>
<NTEND>20110803<The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
Invalid at the top level of the document. Error processing resource 'file:///C:/TEMP/notesD52F4D/~1922011.xml'.
/SPAN></NTEND>
<NTENZ>000000</NTENZ>
E1EDT13 with QUALF>003 and <E1EDT13 SEGMENT="1">
with <QUALF>001 having almost same segment data . but E1EDT13 with QUALF>003 is populating all segment data
properly ,but E1EDT13 with QUALF>001 is giving in between. -
Function module to read xml files from application server
Hi experts,
I need to read xml files from application server to sap. Is the any siutable function moldule for that?Hi Cenosure,
Donno about FM which will upload data directly to SAP, I think you have to do some mapping for it so that it will suit the SAP format. Again it depends on your requirement..
Please elaborate more about your requirement.
Please have a look on below FM
TEXT_CONVERT_XML_TO_SAP
Also search on SCN there are many threads on the same topic available.
http://abapreports.blogspot.com/2008/09/upload-xml-file-from-application-server.html
This is the link which will give you the Code
http://www.geocities.com/rmtiwari/Resources/MySolutions/Dev/Codes/Report/Z_RMTIWARI_XML_TO_ABAP_46C.html
Use this XML file to Upload the same, this Program will work for your XML file also,
http://www.geocities.com/rmtiwari/Resources/MySolutions/Dev/Codes/Report/input_xml.xml
See the below thread also
Upload XML to internal table and vice versa in SAP 4.6C
Hope it will solve your problem..
Thanks & Regards
ilesh 24x7
ilesh Nandaniya -
Reading XML file from application server and put into internal table-4.6C
Dear All,
Is there any way of reading XML file from application server to SAP? I am using 4.6C. Function module SCMS_STRING_TO_XSTRING function module is not available. Please suggest.
Thanks and regards,
AtanuHi Atanu!
Simply use the XSLT transformation 'ID'.
FIELD-SYMBOLS <ls_result> TYPE ANY.
CREATE DATA lref_data TYPE (your_structure).
ASSIGN lref_data->* TO <ls_result>.
CALL TRANSFORMATION id
SOURCE XML xmlstr
RESULT result = <ls_result>.
"xmlstr" contains your XML file. Just read it into it via standard I/O operations. "<ls_result>" will contain your DDIC formatted content.
Best regards
Torsten -
Read XML file from different server on JSP
Dear All,
I am a newbie to JSP with XML, now i want to read the "test.xml" from JSP.
I read successfully this "test.xml" file from my system and I got output, but I need to read the xml file from
different server like "http://www.domain.com/test.xml". I couldn't read such a type of file from different server.
Is it possible to read a xml file from different server?
If anybody have idea please let me know.
Thanks in Advance,
Prasath.
<%@ page import="java.sql.*,java.io.*,java.util.*,javax.xml.parsers.*,org.w3c.dom.*,org.xml.sax.*" %>
<%
try {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse (new File("http://www.domain.com/test.xml"));
// normalize text representation
doc.getDocumentElement ().normalize ();
out.println ("Root element of the doc is " +
doc.getDocumentElement().getNodeName()+"<br>");
NodeList listOfPersons = doc.getElementsByTagName("person");
int totalPersons = listOfPersons.getLength();
out.println("Total no of people : " + totalPersons+"<br>");
for(int s=0; s<listOfPersons.getLength() ; s++){
Node firstPersonNode = listOfPersons.item(s);
if(firstPersonNode.getNodeType() == Node.ELEMENT_NODE){
Element firstPersonElement = (Element)firstPersonNode;
NodeList firstNameList = firstPersonElement.getElementsByTagName("first");
Element firstNameElement = (Element)firstNameList.item(0);
NodeList textFNList = firstNameElement.getChildNodes();
out.println("First Name : " +
((Node)textFNList.item(0)).getNodeValue().trim()+"<br>");
NodeList lastNameList = firstPersonElement.getElementsByTagName("last");
Element lastNameElement = (Element)lastNameList.item(0);
NodeList textLNList = lastNameElement.getChildNodes();
out.println("Last Name : " +
((Node)textLNList.item(0)).getNodeValue().trim()+"<br>");
NodeList ageList = firstPersonElement.getElementsByTagName("age");
Element ageElement = (Element)ageList.item(0);
NodeList textAgeList = ageElement.getChildNodes();
out.println("Age : " +
((Node)textAgeList.item(0)).getNodeValue().trim()+"<br>");
}//end of if clause
}//end of for loop with s var
}catch (SAXParseException err) {
out.println ("** Parsing error" + ", line "
+ err.getLineNumber () + ", uri " + err.getSystemId ());
out.println(" " + err.getMessage ());
}catch (SAXException e) {
Exception x = e.getException ();
((x == null) ? e : x).printStackTrace ();
}catch (Throwable t) {
t.printStackTrace ();
%>You might try:
Document doc = docBuilder.parse ("http://www.domain.com/test.xml");Alternatively use the java.net package to obtain an Input Stream to the xml document
InputStream in = methodThatYouWriteYourselfCalledgetInputStreamForURI("http://www.domain.com/test.xml");
Document doc = docBuilder.parse (in);cheers,
evnafets -
Read xml filr from application server
Hi I want to read an XML file from application server. can anyone please give me the sample code?
Please its very urgent,
ThanksHello
The following sample report <b>ZUS_SDN_BCCIIXMLT2</b> (modified from BCCIIXMLT2) shows how to upload an XML file from the application server.
If the structure of the XML is according to the structure of a DDIC structure then you can directly convert the XML into the DDIC record using the transformation ID (= identical) which is used to convert ABAP to XML and vice versa.
* BCCIIXMLT2 - sample program
* This sample program shows how to read an XML document from a file
* in the appserver's file system, parse the document into a DOM
* representation and display the content as a list.
* Additionally the DOM representation is rendered back into an XML
* stream and stored as an output XML file on the appserver machine.
* This sample program uses ABAP strings to represent the XML input
* and output streams. See BCCIIXMLT1 for using internal tables.
REPORT zus_sdn_bcciixmlt2 MESSAGE-ID bcciixmlt3_msg LINE-SIZE 1000.
DATA:
gd_rc TYPE sysubrc,
go_doc TYPE REF TO cl_xml_document.
START-OF-SELECTION.
PARAMETERS: filename(80) TYPE c
DEFAULT 'tempIDoc_430040.xml'. "#EC NOTEXT
*-- read the XML document from a dataset into a string
DATA: inputstring TYPE xstring.
OPEN DATASET filename FOR INPUT IN BINARY MODE.
IF sy-subrc NE 0.
MESSAGE e000.
ENDIF.
READ DATASET filename INTO inputstring.
CLOSE DATASET filename.
CREATE OBJECT go_doc.
CALL METHOD go_doc->parse_xstring
EXPORTING
stream = inputstring
RECEIVING
retcode = gd_rc.
CALL METHOD go_doc->display
* EXPORTING
* WITH_BDN = SPACE
*-- create the main factory
DATA: pixml TYPE REF TO if_ixml.
pixml = cl_ixml=>create( ).
*-- create the initial document
DATA: pdocument TYPE REF TO if_ixml_document.
pdocument = pixml->create_document( ).
*-- create the stream factory
DATA: pstreamfactory TYPE REF TO if_ixml_stream_factory.
pstreamfactory = pixml->create_stream_factory( ).
*-- create a stream for the input (string)
DATA: pistream TYPE REF TO if_ixml_istream.
pistream = pstreamfactory->create_istream_xstring( inputstring ).
*-- create the parser
DATA: pparser TYPE REF TO if_ixml_parser.
pparser = pixml->create_parser( stream_factory = pstreamfactory
istream = pistream
document = pdocument ).
*-- parse the stream
IF pparser->parse( ) NE 0.
IF pparser->num_errors( ) NE 0.
DATA: count TYPE i.
count = pparser->num_errors( ).
WRITE: count, ' parse errors have occured:'. "#EC NOTEXT
DATA: pparseerror TYPE REF TO if_ixml_parse_error,
i TYPE i.
DATA: index TYPE i VALUE 0.
WHILE index < count.
pparseerror = pparser->get_error( index = index ).
i = pparseerror->get_line( ).
WRITE: 'line: ', i. "#EC NOTEXT
i = pparseerror->get_column( ).
WRITE: 'column: ', i. "#EC NOTEXT
DATA: string TYPE string.
string = pparseerror->get_reason( ).
WRITE: string.
index = index + 1.
ENDWHILE.
ENDIF.
ENDIF.
*-- we don't need the stream any more, so let's close it...
CLEAR pistream.
*-- just for fun: render the DOM back into an output stream/xstring
DATA: postream TYPE REF TO if_ixml_ostream,
outputstring TYPE xstring.
postream = pstreamfactory->create_ostream_xstring( outputstring ).
CALL METHOD pdocument->render( ostream = postream ).
*-- write the XML document as a dataset
DATA: dsn(80) TYPE c.
CONCATENATE filename '.out' INTO dsn. "#EC NOTEXT
OPEN DATASET dsn FOR OUTPUT IN BINARY MODE.
TRANSFER outputstring TO dsn.
CLOSE DATASET dsn.
*-- print the whole DOM tree as a list...
DATA: pnode TYPE REF TO if_ixml_node.
pnode = pdocument.
PERFORM print_node USING pnode.
* FORM print_node *
FORM print_node USING value(pnode) TYPE REF TO if_ixml_node.
DATA: indent TYPE i.
DATA: ptext TYPE REF TO if_ixml_text.
DATA: string TYPE string.
indent = pnode->get_height( ) * 2.
CASE pnode->get_type( ).
WHEN if_ixml_node=>co_node_element.
string = pnode->get_name( ).
WRITE: AT /indent '<', string, '> '. "#EC NOTEXT
WHEN if_ixml_node=>co_node_text.
ptext ?= pnode.
IF ptext->ws_only( ) IS INITIAL.
string = pnode->get_value( ).
WRITE: AT /indent string.
ENDIF.
ENDCASE.
pnode = pnode->get_first_child( ).
WHILE NOT pnode IS INITIAL.
PERFORM print_node USING pnode.
pnode = pnode->get_next( ).
ENDWHILE.
ENDFORM. "print_node
Regards
Uwe -
Reading XML File from application server
Hi experts,
My aim is to read a XML file from application server and extract the relevant data from it and process further.
When I am trying to read a XML file from application server it is reading success fully but the problem is that its not reading the last root structure of XML file why is so happening can any body help me?
I am using the following code:
TYPES: BEGIN OF xml_line,
text(256) type x,
END OF xml_line.
DATA: e_file LIKE rlgrap-filename VALUE 'applcatin server path'
OPEN DATASET e_file FOR INPUT IN BINARY MODE.
IF sy-subrc EQ 0.
DO.
READ DATASET e_file INTO wa_item1-text.
IF sy-subrc EQ 0.
APPEND wa_item1 TO gt_item1 .
CLEAR wa_item1.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET e_file.
after this i am passing this internal table to "cl_ixml" class to extract the data
but it returning the itab with required value except the last record.
The stream reading the file it self is i thought in complete thats why it is not converting the all values.
Please help me...
Thanks a ton in advance.Hi,
1 Copy Report BCCIIXMLT1
2 (you can change the way of filling internal table xml_table if necessary)
3 you don't need the part between
*-- render the DOM back into an output stream/internal table
and
*-- print the whole DOM tree as a list...
Comment it out or simply delete it
4 Rename form print_node to your liking e.g. process_node
5 In your new form you need three extra variables:
data: attribs type ref to IF_IXML_NAMED_NODE_MAP,
attrib_node type ref to IF_IXML_NODE,
attrib_value type string.
6 After the lines:
when if_ixml_node=>co_node_element.
string = pNode->get_name( ).
Insert:
attribs = pNode->get_attributes( ).
clear attrib_value.
case string.
when ''. "put your XML tag name here
attrib_node = attribs->get_named_item(name = '' ). "put your XML attribute name here
attrib_value = attrib_node->get_value( ).
You can also refer link,
/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach
thanks & regards
shreemohan -
Read XML files from remote server
Post Author: TomDegetel
CA Forum: Data Integration
This question may look simple to you but I don't see directly how to do this.The idea is to read data from an XML file which is sent to a UNIX directory on a server.When the JobServer is running on my local PC I can configure a flow that reads the file from the local harddisk but if the JobServer is running on another server I don't know how to reach this file.How can I connect from the jobserver to a remote server in order to read an xml file and read its contents into a query ? Thanks, TomPost Author: bhofmans
CA Forum: Data Integration
you have several options :
1) Make sure the directory is accessible to your jobserver via shares. This can even be done between Windows and UNIX using SAMBA or related software.
2) Use ftp to get the file from the remote location and ftp it to a local drive (DI had built-in options to do ftp)
3) In 11.7 we added the possibility to specify an URL for the XML file in stead of a file name. So if you can make the XML file available via a web server on the UNIX machine, this would be another way to access the file. -
Reading a document from application server / opening in SAP session
Hi guys,
we have a requirment has follows , please help me with your inputs.
We have list of documents available in the DMS server....(XLS,DOC,PDF)
1. How to get the list of file names ( available in the DMS server ) into the internal table.
2. i need to open these documents by clicking - into the same sap session itself. (it should not open in windows)
Please Note : Many of our forum friends earlier to open the file in windows.
regards
GiriHi,
You can show any doc that is uploaded in DMS using the URL of the doc . the doc will be shown in a container. You can refer the std prog . SAPRDEMOPIVOTINTERFACE.. or some thg like that ( i dont remember the exact name ) .
You need to pass the Class name . object type and object name to find the URL. Check transaction OAER and enter class as SSOFFICEINTEGRATION , type as OT and name as SSOFFICEINTEGRATION.
Hope this helps. -
Uploading xml file from application server
HI everybody guys having promblem reading xml file from application server.Here is the solution. the sample program is below.
TYPE-POOLS: ixml. "iXML Library Types
*TABLES : rbkp.
TYPE DECLERATIION
TYPES: BEGIN OF type_tabpo,
ebeln TYPE ekko-ebeln, "PO document number
ebelp TYPE ekpo-ebelp, "PO line item
END OF type_tabpo.
TYPES: BEGIN OF type_ekbe,
belnr TYPE rbkp-belnr, "Invoice document
gjahr TYPE rbkp-gjahr, "fiscal year
END OF type_ekbe.
TYPES: BEGIN OF type_invoice,
belnr TYPE rbkp-belnr, "PO document number
gjahr TYPE rbkp-gjahr, "Fiscal Year
rbstat TYPE rbkp-rbstat, "invoice status
END OF type_invoice.
TYPES: BEGIN OF t_xml_line, "Structure for holding XML data
data(256) TYPE x,
END OF t_xml_line.
INTERNAL TABLE DECLERATIION
DATA: gi_tabpo TYPE STANDARD TABLE OF type_tabpo,
gi_ekbe TYPE STANDARD TABLE OF type_ekbe,
gi_invoice TYPE STANDARD TABLE OF type_invoice,
gi_bapiret2 TYPE STANDARD TABLE OF bapiret2.
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 swif_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, " XML Table of the structure
l_xml_line TYPE t_xml_line, " Record of structure t_xml_line
l_xml_table_size TYPE i. " XML table size
DATA: l_filename TYPE string.
WORK AREA DECLARATION
DATA: gw_tabpo TYPE type_tabpo,
gw_ekbe TYPE type_ekbe,
gw_invoice TYPE type_invoice,
gw_bapiret2 TYPE bapiret2.
BEGIN OF SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
PARAMETERS: p_file TYPE pathintern LOWER CASE DEFAULT '/usr/sap/tmp/'.
Validation of XML file: Only DTD included in XML document is supported
SELECTION-SCREEN END OF BLOCK blk1.
INTIALISATION.
INITIALIZATION.
SELECTION SCREEN VALIDATION
AT SELECTION-SCREEN.
To validate p_file is not initial
PERFORM sub_validate_file.
PERFORM sub_validate_path.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
Request for filename for xml file from the application server
PERFORM sub_get_filename_appl USING p_file.
START OF SELECTION SCREEN
START-OF-SELECTION.
PERFORM sub_fetch_po_details.
PERFORM sub_get_invoice.
PERFORM sub_rel_invoice.
END OF SELECTION SCREEN
END-OF-SELECTION.
*& Form sub_validate_file
To Validate the file
FORM sub_validate_file .
IF p_file IS INITIAL.
MESSAGE e000. "specify the file path
ENDIF.
ENDFORM. " sub_validate_file
*& Form sub_get_filename_appl
form sub_get_filename_appl USING l_fname TYPE any.
DATA: l_fname TYPE filename-fileintern. " File name
*GET THE FILENAME FROM THE APPLICATION SERVER
CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
EXPORTING
directory = l_fname
filemask = '*'
IMPORTING
serverfile = l_fname
EXCEPTIONS
canceled_by_user = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " sub_get_filename_appl
*& Form sub_fetch_po_details
To fetch the PO details from the application server
Format of file is XML
FORM sub_fetch_po_details .
TYPE DECLERATIION
l_ixml = cl_ixml=>create( ).
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
PERFORM get_xml_table.
LOOP AT gi_tabpo INTO gw_tabpo.
WRITE:/ gw_tabpo.
ENDLOOP.
ENDFORM. " sub_fetch_po_details
*& Form get_xml_table
Read from the xml file
FORM get_xml_table .
Local variable declarations
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 = p_file.
code to upload data from application server
OPEN DATASET l_filename FOR INPUT IN BINARY MODE.
IF sy-subrc <> 0.
WRITE:/ 'invalid file path'.
ENDIF.
DO.
READ DATASET l_filename INTO l_xml_line.
IF sy-subrc EQ 0.
APPEND l_xml_line TO l_xml_table.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET l_filename.
code to find the table size
DESCRIBE TABLE l_xml_table.
l_xml_table_size = ( sy-tleng ) * ( sy-tfill ).
*code to convert hexadecimal to XML
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.
LOOP AT l_itab INTO l_str1.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN
l_str1 WITH space.
ENDLOOP.
CALL TRANSFORMATION ('ID') " code to put in internal table
SOURCE XML l_str1
RESULT tab = gi_tabpo[].
ENDFORM. " get_xml_tableHi Raja,
I tried the same. But it not populating the table and giving an error message in the return table "line 1 col 1-unexpected symbol; expected '<', '</', entity reference, charac".
I can't find any ' ; ' in the XML file. What could be the possible reason of error? -
Upload XML file from Application Server to Internal Table
Hi Experts,
i have xml file in application server and i want to convert to internal table .
i have tried this link http://wiki.sdn.sap.com/wiki/display/ABAP/UploadXMLfiletointernal+table.
Here the file is loaded from local(presentation Server) ..
i want to know how to select file from application layer ..and schedule in background..
i also tried FM '/SAPDMC/LSM_F4_SERVER_FILE' but this need front end selection of file from application server..
i need to select a xml file from application server and convert into internal table in background.. help me on this..Have a look on
Re: How to convert XML data to different ABAP internal table
Thanks
Ravin -
How can I access xml document from javascript whithin a JSP page
how can I access xml document from javascript whithin a JSP page?
I have a JSP that receives an XML document from a JavaBean, so I can access it within the entire JSP, but I need to access it from the javascript inside the JSP... and I have no idea how i can do this.
Thanks in advance!The solution would only work on MS IE browsers, as other browsers do not support an XML DOM.
It can be done, but you would be stuck with using the Microsoft broswer. If that is acceptable, I have some example code, and a book recommendation. -
How to create an XML document from a String.
Can anyone help,
In the Microsoft XML Document DOM there is a load function load(string) which will create an XML document, but now we are switching to Java and I do not know how to create and XML document from a string, this string �xml document� is passed to my program from a webservice and I need to read several xml elements form it in a web server.
This string is a well formatted XML document:
<?xml version="1.0" encoding="UTF-8"?>
<Countries NumberOfRecords="1" LanguageID="en-us">
<Country>
<CountryCode>AU</CountryCode>
<CountryName>AUSTRALIA</CountryName>
</Country>
</Countries>Thanks PC!
I made it work using:
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
factory.setIgnoringComments(true); // We want to ignore comments
// Now use the factory to create a DOM parser
DocumentBuilder parser = factory.newDocumentBuilder();
//TransformThisStringBuffer is a string buffer wich contain the 'XML document (String)'
InputStream in = new ByteArrayInputStream(TransformThisStringBuffer.toString().getBytes());
// Parse the InputStream and build the document
Document document = parser.parse(in);
But which one is faster InputSource or InputStream, were would you put the "new InputSource(new StringReader(yourString))" in the above code?
Maybe you are looking for
-
Why does Flash keep asking me to store stuff on my computer it doesn't do this on my computer at home
-
i just bought a MacBook wiht 10.4.8, for a couple of days, i had the accounts log in on because my brother wanted to use the laptop, now that i've deleted his account, my login shows up when i restart the computer and the default settings gets restor
-
SAP E-recruiting EHP4 external candidate registration web dynpro ABAP
Hi all, I am trying to activate the url of the web dynpro external candidate registration. we have setup the hrrcf_a_ext_cand(may be i misspelt the name) and it is fine. Now when a user tries to register using the "REGISTER" button the application as
-
If I have 2 sender adapters and define the same queue name for each of them, will it be EOIO for messages between the 2 adapters? Therefore will sender adapter 1 and sender adapter 2 put messages onto the same queue on the integration server? Thanks
-
Notify/Wait or Observable/Observer?
Hi, I have one thread process the data and store the result in a data object. Several threads access the data object to display. Which one to use: 1) Have the processing thread notify the display threads when it's done? Using thread wait()/notify()?