2005 Sep 17 7:38 AM
Can anybody give me an idea as to how to read xml from an ABAP Program?
Thanks and Regards,
Thiru
2005 Sep 19 9:08 AM
The type was BIN and p_file is of type c, still i get the same error.
2005 Sep 17 7:51 AM
do you want to read the XML file stored in the frontend to ABAP program,
use GUI_UPLOAD
what do you want to do with the loaded XML? if you could explain this then we can come up with suggestions.
Regards
Raja
2005 Sep 17 8:11 AM
Hello Durai,
I would like to know how to store the xml into an internal table.
I have created a dot net application where we download data from SAP and then send mails. We display the data within a HTML table. We found type out all the code(to create the table and display data) in ABAP store it in a string and then use SO_OBJECT_SEND to send email. Instead if we can store the file and read it into an internal table, then populate the SAP data and send the email, we thought it could be useful.
Kindly advise.
Thanks and Regards,
Thiru
2005 Sep 17 8:20 AM
<i>I would like to know how to store the xml into an internal table.</i>
you want to store the XML as just a string then just use GUI_UPLOAD
if you want to transform the loaded XML into a internal table of rows and columns the you need to use
CALL TRANSFORMATION key word. (search the forum there were solutions).
the second part of your explantaion is not clear to me.
Regards
Raja
2005 Sep 17 8:22 AM
hi , you can parse the XML using DOM, DOM is also supported in ABAP, there is a class CL_IXML, and other associated class. you can achieve your target by using them.
reference link:
http://help.sap.com/saphelp_nw04/helpdata/en/86/8280d212d511d5991b00508b6b8b11/frameset.htm
The other way is through XLST. it is supported in ABAP from 4.7. you can create a XSLT, and read you XML, then CALL TRANSFORMATION to convert a XML into ABAP data structure.
reference link:
http://help.sap.com/saphelp_nw04/helpdata/en/fd/9d7348389211d596a200a0c94260a5/frameset.htm
Hope it will be helpful
thanks
2005 Sep 17 8:29 AM
2005 Sep 17 9:22 AM
Hello Durai, Zhenglin,
Your inputs have been useful. I will explore this and get back.
Regards,
Thiru
2005 Sep 19 7:45 AM
Whil I use GUI_UPLOAD, I get the following error 'Type conflict when calling a function module.
'
I have tried the following-
1. FILETYPE = 'ASC'
2. FILETYPE = 'BIN'
3. FILETYPE = 'XML'
None seem to work. I used WS_FILENAME_GET to select the file, at selection-screen(using f4 help, I select the file and the path is stored in p_file).
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = p_file
FILETYPE = 'BIN'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = 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
OTHERS = 17
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Kindly advice.
2005 Sep 19 7:56 AM
for xml files better use BIN
and your variable p_file has to be of type string,
Regards
Raja
if you find the answers helpful, reward them by clicking the radio button and if you feel the question is answered mark it answered.
2005 Sep 19 9:08 AM
The type was BIN and p_file is of type c, still i get the same error.
2005 Sep 19 9:54 AM
p_file has to be type string.
data: p_file type string.
Regards
Raja
2005 Sep 19 10:24 AM
Hi Durai,
That problem got sorted out, and i have assigned the points. thanks, but i am getting an error in the standard program saying 'Error in ASSIGN statement in program "SAPLSFES ".
'
2005 Sep 19 11:18 AM
there is something wrong with your itab declaration.
how did you declare the itab?
Regards
Raja
2005 Sep 19 11:42 AM
DATA: BEGIN OF ITAB OCCURS 0,
CODE TYPE STRING,
END OF ITAB.
2005 Sep 19 12:07 PM
DATA: BEGIN OF ITAB OCCURS 0,
CODE TYPE <b>xSTRING</b>,
END OF ITAB.
Regards
Raja
2005 Sep 19 12:35 PM
I tried it Durai, still I get the same thing.
&----
*& Report ZVTN_XML_READ *
*& *
&----
*& *
*& *
&----
REPORT ZVTN_XML_READ.
DATA: BEGIN OF ITAB OCCURS 0,
CODE TYPE xSTRING,
END OF ITAB,
itabtemp like itab occurs 0 with header line.
DATA param type string.
selection-screen begin of block b1 with frame title text-001.
*parameter p_file like param obligatory.
parameter p_file like RLGRAP-FILENAME.
selection-screen end of block b1.
at selection-screen on value-request for p_file.
perform read_file using p_file.
start-of-selection.
perform Uploadfile.
perform Displaydata.
form read_file using p_p_file.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_FILENAME = SPACE
DEF_PATH = p_file
MASK = ',.,..'
MODE = '0'
TITLE = 'Choose File '
IMPORTING
FILENAME = p_p_file
RC =
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5
.
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.
form uploadfile.
param = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = param
FILETYPE = 'BIN'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = 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
OTHERS = 17
.
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.
form Displaydata.
write itab-code.
endform.
2005 Sep 19 12:52 PM
couldnt figureout the issue. but i guess you dont have any problem if the uploaded content is in binary format or ASC format.
make the following changes. (sorry for the inconvenience)
change the itab to string
and file type to 'ASC'
if you still want to have it in BIN format,
check out the program SXSLTDEMO_FLIGHTS
search for the code "<i>perform load_file using i_path changing srctab</i>"
you can see how the itab is built.
Regards
Raja
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |