Create an XML File in Application server
Hello,
I have a requirement to create an XML File as Local File and as server File. For the local File it works fine and i got a Local XML File.
My problem is for the Server File.I found a solution in internet to convert in binary.But i don't get in the server File created the XML structure.
Here is My code for the unix server File
DATA ex_tab TYPE TABLE OF x255.
data: wa_tab type x255.
data: lv_line(255) type c.
**-- carica tabella gt_file
PERFORM CARICA_TAB_FILE.
LOOP AT GT_FILE.
MOVE-CORRESPONDING GT_FILE TO WA_SOURCE.
APPEND WA_SOURCE TO GT_SOURCE.
CLEAR WA_SOURCE.
ENDLOOP.
* Perform the XSLT stylesheet
TRY.
CALL TRANSFORMATION ZMESMO052_XML
SOURCE MATERIAL_DATA = GT_SOURCE[]
RESULT XML XML_RESULT .
CATCH CX_ROOT INTO GS_RIF_EX.
GS_VAR_TEXT = GS_RIF_EX->GET_TEXT( ).
MESSAGE GS_VAR_TEXT TYPE 'E'.
ENDTRY.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = XML_RESULT
TABLES
binary_tab = ex_tab.
CONCATENATE P_FILE '.xml' INTO P_FILE.
CONDENSE P_FILE.
TRANSLATE P_FILE TO LOWER CASE.
OPEN DATASET P_FILE FOR OUTPUT IN BINARY MODE.
IF SY-SUBRC NE 0.
MESSAGE E000(ZF) WITH ' Error opening File' P_FILE.
ENDIF.
loop at ex_tab into wa_tab.
move wa_tab to lv_line.
transfer lv_line to p_file.
endloop.
close dataset p_file.
And i Got a file like this
Any solution please
I Found the solution,
DATA EX_TAB TYPE TABLE OF X255.
DATA: WA_TAB TYPE X255.
DATA: LV_LINE(255) TYPE C.
DATA: L_CONVIN TYPE REF TO CL_ABAP_CONV_IN_CE.
DATA: L_HTML TYPE STRING.
DATA: L_VALUE TYPE STRING.
DATA: L_MSGSTR TYPE STRING.
DATA: FILENAME TYPE STRING.
**-- carica tabella gt_file
PERFORM CARICA_TAB_FILE.
LOOP AT GT_FILE.
MOVE-CORRESPONDING GT_FILE TO WA_SOURCE.
APPEND WA_SOURCE TO GT_SOURCE.
CLEAR WA_SOURCE.
ENDLOOP.
* Perform the XSLT stylesheet
TRY.
CALL TRANSFORMATION ZMESMO052_XML
SOURCE MATERIAL_DATA = GT_SOURCE[]
RESULT XML XML_RESULT .
CATCH CX_ROOT INTO GS_RIF_EX.
GS_VAR_TEXT = GS_RIF_EX->GET_TEXT( ).
MESSAGE GS_VAR_TEXT TYPE 'E'.
ENDTRY.
TRY.
CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
EXPORTING
ENCODING = 'UTF-8'
INPUT = XML_RESULT
RECEIVING
CONV = L_CONVIN.
CALL METHOD L_CONVIN->READ
IMPORTING
DATA = L_HTML.
CATCH CX_ROOT.
L_MSGSTR = 'Conversion error'.
ENDTRY.
SEARCH L_HTML FOR '><'.
CLEAR L_VALUE.
L_VALUE = CL_ABAP_CHAR_UTILITIES=>NEWLINE.
CONCATENATE '>' L_VALUE '<' INTO L_VALUE.
IF SY-SUBRC = 0.
REPLACE ALL OCCURRENCES OF '><' IN L_HTML WITH L_VALUE IN
CHARACTER MODE.
ENDIF.
CONCATENATE P_FILE '.xml' INTO P_FILE.
CONDENSE P_FILE.
TRANSLATE P_FILE TO LOWER CASE.
FILENAME = P_FILE.
OPEN DATASET FILENAME FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE
WITH UNIX LINEFEED.
TRANSFER L_HTML TO FILENAME.
CLOSE DATASET FILENAME.
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 -
XML data into Oracle Tables. XML file on Application Server.Oracle Apps R12
Hi All,
My Database version : 11.2.0.2.0
I have an XML file which needs to be loaded into the Database Tables. How ever i do not want to use the XMLTYPE as given below
insert into test1 (
SELECT PrcDate, PmtType, PmtStatus, PmtTypeCount, PmtTypeAmt
FROM XMLTABLE(
'/WFPaymentAck/RejectedDom1ACH'
PASSING XMLTYPE( BFILENAME('ECX_UTL_LOG_DIR_OBJ','wf_test_xml.XML'), NLS_CHARSET_ID('UTF8') )
COLUMNS
PrcDate VARCHAR2(2000) PATH '@PrcDate' ,
PmtType VARCHAR2(2000) PATH '@PmtType' ,
PmtStatus VARCHAR2(100) PATH '@PmtStatus' ,
PmtTypeCount VARCHAR2(100) PATH 'PmtTypeCount' ,
PmtTypeAmt VARCHAR2(100) PATH 'PmtTypeAmt'
Because this way the XML file needs to reside on the DB server.
I am looking into other option of loading the XML file into a CLOB column of a table and reading it from that column.
I did a couple of tests and feel that this way also the XML file has to reside on the Database Server itself. I am not sure if this is correct or if there is any problem with our TEST instance.
++Can anyone let me know if i need to have the XML file on the DB server instead of the Application server to load into a CLOB column of table ??++
++Or++
++Is there any other workaround for me to load XML into Oracle Tables, while having the XML file on Application Server.++
Your immediate help is appreciated. I need to get past this ASAP.
Thanks in Advance.
VJ1) Are you asking me to create a folder on Database directory which points to a folder on the Apps server ?I suggest creating an Oracle directory object (a database object) pointing to a real location (folder) on Application server.
we DONOT want a hand shake between the DB Server and the APPS server.I don't see where the problem is.
I'm not familiar with Apps R12 but there's no doubt the two servers are already communicating, at least App server should be able to access the DB for the whole thing to run.
As I said :
One way or another, the data has to make its way to the database, there's no workaround to that.How do you imagine the data will end up in a database table if it doesn't come to the DB server?
There's no magical method out there, both servers have to communicate at some point.
About client-server approaches (client being here the App server), you can read about accessing the XML DB repository in the XML DB Developer's Guide : http://download.oracle.com/docs/cd/E11882_01/appdev.112/e23094/toc.htm
Other option : SQL*Loader can load a CLOB, or an XMLType column too
Edited by: odie_63 on 19 déc. 2011 20:22 -
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 -
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? -
To create a new file in application server and transfer data to ti
i am doing the following where i have to create a new file in application server and transfer data to tht file from an internal table.but its saying file cant be opened.the path i am giving to parameter p_prefil is /tmp/prachi.txt.
wats the prob..can anyone help.
DATA:L_WA_FINAL TYPE TY_FINAL,
l_wa_string type string.
OPEN DATASET P_PREFIL FOR OUTPUT IN text mode encoding default.
if sy-subrc <> 0.
write: ' file cannot be opened'.
stop.
endif.
LOOP AT P_I_FINAL INTO L_WA_FINAL.
move l_wa_final to l_wa_string.
TRANSFER l_wa_string TO P_PREFIL.
if sy-subrc <> 0.
write: 'file can not be written'.
stop.
endif.
clear l_wa_final.
ENDLOOP.
CLOSE DATASET P_PREFIL.
if sy-subrc <> 0.
write: ' file cannot be closed'.
stop.
endif.DATA:L_WA_FINAL TYPE TY_FINAL,
l_wa_string type string.
OPEN DATASET P_PREFIL FOR OUTPUT IN text mode encoding default.
if sy-subrc ne 0.
write: ' file cannot be opened'.
stop.
endif.
LOOP AT P_I_FINAL INTO L_WA_FINAL.
move l_wa_final to l_wa_string.
TRANSFER l_wa_string TO P_PREFIL.
write: 'file can not be written'.
clear l_wa_final.
ENDLOOP.
CLOSE DATASET P_PREFIL.
if sy-subrc ne 0.
write: ' file cannot be closed'.
stop.
endif. -
Xml file in application server
Experts,
I'm using a a simple tranformation and "open dataset" statement in order to write a xml file in application server: This is working fine.
i notice that when i preview the file in transaction "AL11" , it shows like " <tag> <tag> <tag> <tag> ......
The encoding of this file is 'utf-8'.
I did another test that was writing, trouht transaction CG3Z, a xml file in encoding 'ISO-8859-15'. When a preview the file in AL11 is shows like :
<tag>
<tag>
<tag>
<tag>
The change in the preview is due to the codification ? Or is regarding that way we write the file to the server ?
Best regards,
MR.Hello,
Change is because of the encoding style changed from utf-8 to 'ISO-8859-15'.
May be you can try changing this manualy in XML file and see the output result.
Thanks,
Augustin. -
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 -
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 -
How to upload XML file from Application server.
Hi,
How to upload XML file from Application server.Please tell me as early as possible.
Regards,
Sagar.Hi,
parameters : p_file type ibipparms-path obligatory.
***DOWNLOAD---->SAP INTO EXCEL
filename1 = p_file.
call function 'GUI_DOWNLOAD'
exporting
BIN_FILESIZE =
filename = filename1
filetype = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = 'X'
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
tables
data_tab = it_stock
FIELDNAMES =
exceptions
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
others = 22
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
Regards,
Deepthi. -
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 -
Hi All,
Is there any way to upload Tariff Code (with multiple XML files) from application server?. Its urgent.
Regards,
JatinHi Jatin,
Yes, of course you can upload multiple files for tariff codes.
This can be done by the below path:-
SAP GTS Cockpit(tcode-/sapsll/menu_legal)-->Customs Management-->Classification-->Classification Master Data-->Upload Tariff Code Numbers from XML file(tocde- /SAPSLL/LLNS_UPL101).
In the above area after browsing and choosing the first file, please select multiple check box to choose more files as well. Then you can further select your application server and upload all those files in one go.
PS:- Although, we have an option to upload multiple such files but actually we should avoid multiple file uploads due to various reasons. Hence, please take utmost care during such procedure.
Regards,
Aman -
Creating a new file in application server
hai,
please rectify this, how to create a file in application server ?
can any one forward a sample code for creating a file in application server.
hazamHi Hazam,
Please check the below code.
Data : P_UFILE(60) " Unix File name
TYPE C
value '/emn_R3/hr/ben_age25_dep'.
CLEAR GD_SUBRC.
<b>OPEN DATASET</b> GD_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC <> 0.
GD_SUBRC = SY-SUBRC.
gs_error-pernr = gs_0021-pernr.
gs_error-ename = gd_ename.
gs_error-mess
= 'Can not open File:'(017) + gd_file.
append gs_error to gt_error.
clear gs_error.
* CLEAR GD_MSG1.
* CONCATENATE 'Can not open File:'(017)
* GD_FILE
* INTO GD_MSG1.
* WRITE : / GD_MSG1.
ELSE.
LOOP AT GT_BODY INTO GS_BODY.
<b>TRANSFER</b> GS_BODY TO GD_FILE.
ENDLOOP.
<b>CLOSE DATASET</b> GD_FILE.
ENDIF.
Hope this will help you.
Thanks&Regards,
Siri.
Message was edited by: Srilatha T -
Create XML file on application server (unix directory) from internal table
Hallo everybody,
I have got the following problem:
I am working with <u><b>release 4.6C</b></u> and have got to create XML files from HR master data and organizational data respectively.
This takes place in 3 steps:
1. Collect the data in an internal table
2. Convert the data to XML format using the function module 'SAP_CONVERT_TO_XML_FORMAT'
3. Download the data
If I download the converted data, which are in an internal table, to the presentation server via the function module WS_DOWNLOAD and open it with the Internet Explorer, everything is ok.
If I download the converted data to the application server, i.e. into a unix directory via
open dataset, loop at internal table, transfer working area to file, close dataset
and then try to open it, this is not possible, because after the last tag some unreadable characters, e.g. a square, appear that arent supposed to be there. Thats what my colleagues told me, for I havent got access to the server.
I have no idea where these characters come from and how I can get rid of them. I guess that either I have to modify (how?) the table with the converted data before the download or I have to use another way to convert the data. For the second way I would probably have to work with an XML class or an XML interface. Unfortunately II am not an expert in working with classes so sample coding would have to be rather detailed.
Heres some more information about how I work with the conversion function module:
call function 'SAP_CONVERT_TO_XML_FORMAT'
exporting
i_field_seperator = lv_field_seperator
i_line_header = lv_line_header
i_filename = lv_xml_file
i_appl_keep = ' '
i_xml_doc_name = lv_xml_doc_name
importing
pe_bin_filesize = lv_result
tables
i_tab_sap_data = gt_data
changing
i_tab_converted_data = lt_tab_converted_data
exceptions
conversion_failed = 1
others = 2.
lv_field_seperator = X.
lv_xml_doc_name = Personalstammdaten Publikation
lv_result: type i
gt_data: fields: PERNR, PERSG, PERSK etc.
types:
begin of truxs_xml_line,
data(256) type x,
end of truxs_xml_line.
types:
truxs_xml_table type table of truxs_xml_line.
data:
lv_tab_converted_data type truxs_xml_line,
lt_tab_converted_data type truxs_xml_table
open dataset lv_xml_file for output in binary mode.
loop at lt_tab_converted_data into lv_tab_converted_data.
transfer lv_tab_converted_data to lv_xml_file.
endloop.
close dataset lv_xml_file
lv_xml_file: /usr/users/.../.../Personendaten_2004-11-02.xml
Hope the information is detailed enough! Otherwise let me know. Thank you in advance.
Message was edited by: Johannes SchwehmHi Raja,
tried the "TEXT" mode, but that didn't help.
There are still characters after the last tag, that are not supposed to be there including a date that is not
the creation date of the file.
Thank you for your help.
Regards
Johannes -
Parsing XML files from application server
I need to read an XML file from the application server. This can be done using OPEN DATASET in BINARY MODE and reading into internal table of type binary data.
But inorder to parse the document using the iXML library, i need to pass the filesize of the XML file that is read into internal table.
Please let me know how to calculate this filesize ?Hi ,
Check the FM : /SAPDMC/LSM_F4_SERVER_FILE.
Inside this FM , subroutine below exists.The main program for routine is /SAPDMC/LLSMW_AUX_020F02.
Call this routine from your program. You will get the length in bytes from the field len of table pt_file.
data:
begin of gs_file,
directory(75) type c, " name of directory.
" (possibly truncated.)
name(75) type c, " name of entry.
" (possibly truncated.)
type(10) type c, " type of entry: directory, file
*len(8) type p, " length in bytes*
owner(8) type c, " owner of the entry
mtime(6) type p, " last modification date,
" seconds since 1970
mode(9) type c, " like "rwx-r-x--x":
" protection mode
errno(3) type c,
errmsg(40) type c,
mod_date type d,
mod_time(8) type c, " hh:mm:ss
subrc like sy-subrc,
end of gs_file.
DATA : pt_file LIKE TABLE OF gs_file.
DATa : p_ok.
PERFORM /sapdmc/llsmw_aux_020f02(directory_contents_get)
TABLES pt_file
USING '/TMP' ""!!! Here is your filepath
CHANGING p_ok
Maybe you are looking for
-
Image Print problem in PDF Reports
Hi, I have imported a JPG image on the layout using Reports builder 6i using File -> Import -> Image. Once imported, this image is displayed correctly in the report layout editor. But, when I run this report (Pdf format) from Oracle Apps, this image
-
Can I connect the Blue Snowball Mic to my iphone 4 and If I can How do I do it?
Im thinking of buying the Blue snowball mic, it sounds like a really good quality except im not sure if it would work well with the iphone 4. I seen a youtube video of a guy using it on his ipad.. Im using this to record a group session with the ever
-
ComboBox with Lovs on Jdev 11g r2
I'm facing this Error on JSF on Jdeveloper 11g r2, Windows7. I'm Using a ComboBox with Lovs on af:table. I'm getting this Error below when I invoke the (Search) option... to see the popup list. it works fine in every other case, if I select from the
-
Hello, Is there a possibility to get CREF simulator source codes somewhere? Regards, Kobi
-
Third Party PC Outlook Sync app, and accompanying BB10Sync PC software
http://rapidberry.net/two-way-outlook-sync-with-blackberry-10-devices/ For above link takes you to an article that details a paid for two way sync Outlook software solution for BB10 users. I do not regard the paid for solution to be acceptable and wo