2007 Jan 10 7:39 AM
HI all,
i got an error when i run the program which has the following syntax
call transformation z_id
source output = git_nisl_file
result xml xml_out.
append xml_out to xmltable.
loop at xmltable into wa_xmltable.
transfer wa_xmltable-record to gv_file.
endloop.
here i am trying to transform the internal table data to XML format where it is giving error like "XML page can not be dispalyed".
"Cannot view XML input using XSL style sheet , please correct the error and then click the refresh button,or try again later."
can you give the solution for this error?
2007 Jan 10 8:31 AM
to transform itab to standard ABAP XML format, just use the XSLT ID
call transformation (`ID`)
source output = git_nisl_file
result xml xml_out.
from your code i see you used custom XSLT.
To analyze whats causing the error we should see the XSLT code and also the contents of variable xml_out.
Regards
Raja
2007 Jan 10 8:31 AM
to transform itab to standard ABAP XML format, just use the XSLT ID
call transformation (`ID`)
source output = git_nisl_file
result xml xml_out.
from your code i see you used custom XSLT.
To analyze whats causing the error we should see the XSLT code and also the contents of variable xml_out.
Regards
Raja
2007 Jan 10 9:05 AM
Hi Raaja ,
Thanx for reply,
here my problem is happening when i transfer huge data like 500 records;I even tried ur code using ('ID') in call transformation then it is giving same error.Its giving the output with truncated result it is only when i try to transfer the huge data, i think it is crossing the limit of the lenght.But i may require to transfer the huge data then what would be the solution ? plz tell me?
2007 Jan 10 9:16 AM
Hi Raaja ,
Thanx for reply,
here my problem is happening when i transfer huge data like 500 records;I even tried ur code using ('ID') in call transformation then it is giving same error.Its giving the output with truncated result it is only when i try to transfer the huge data, i think it is crossing the limit of the lenght.But i may require to transfer the huge data then what would be the solution ? plz tell me?
2007 Jan 10 9:57 AM
500 records is not huge at all.
what is the type of your variable xml_out . it should be of type string.
data: xml_out type string.
Regards
Raja
2007 Jan 10 10:20 AM
Hi,
i have defined like string only
TYPES: BEGIN OF ttab,
record(65535) TYPE c,
END OF ttab.
DATA: xmltable TYPE TABLE OF ttab.
DATA: xml_out TYPE string,
is the problem with length 65535?
see the last part of screen shot
<MAT_TYP>MA</MAT_TYP>
<SALES_ORG>2000</SALES_ORG>
<DIST_CH>80</DIST_CH>
<DIVISION>01</DIVISION>
<REP_NAME>REP NAME</REP_NAME>
</item>
- <item>
<MAT_TYP>MA</MAT_TYP>
<SALES_ORG>2000</SALES_ORG>
<DIST_CH>80</DIST_CH>
<DIVISION>01</DIVISION>
&nbsThe 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.
-
The following tags were not closed: asx:abap, asx:values, OUTPUT, item, MAT_TYP. Error processing resource 'file:///C:/temp...
p; <REP_NAME>REP NAME</REP_NAME>
</item>
- <item>
<MAT_TYP>MA</MAT_TYP>
<SALES_ORG>2000</SALES_ORG>
<DIST_CH>80</DIST_CH>
2007 Jan 10 10:35 AM
that certainly is the problem.
you are just appending xml_out to ttab and because your original xml_out is longer than 65535 you are getting this problem.
to over come this just call FM CONVERT_STRING_TO_TABLE
where set i_string = xml_out and
et_table = ttab
now use ttab with gui_download
Regards
Raja
2007 Jan 10 10:58 AM
Excellent..it is working,
thanx raja,
Now it is working for 500 records i have given
i_tabline_length = 65535
but for 5000 records it is giving the same error, could you plz look into it?
2007 Jan 10 11:05 AM
it should work for 5000 lines as well. however if you are still having problem try the following.
can xml_out from string to xstring.
then use FM SCMS_XSTRING_TO_BINARY
(the return table should be of type SOLIX_TAB)
and then use gui_download like below.
call function 'GUI_DOWNLOAD'
exporting
bin_filesize = size
filename = file
filetype = 'BIN'
tables
data_tab = xml_tab
exceptions
others = 1.
Regards
Raja
2007 Jan 10 11:19 AM
Hi raja,
am not down loading the file am writing the file into application server.And from there am getting it opened using the Tcode CG3Y.
thanx n regards.
2007 Jan 10 11:23 AM
how are you writing to application server - post the code here. may be something wrong there.
Regards
Raja
2007 Jan 10 11:34 AM
Hi am sending code plz check it out.
REPORT z_tab_file.
PARAMETERS : gv_file(100) DEFAULT '.ATABTEST.TXT',
p_csv AS CHECKBOX,
p_xml AS CHECKBOX.
---Types--
TYPES:
Structure for Header File
BEGIN OF gt_nisl_file,
urgent_flag(1) TYPE c,
mat_typ(2) TYPE c,
sales_org(4) TYPE c,
dist_ch(2) TYPE c,
division(2) TYPE c,
cont_no(1) TYPE c,
sold_to(4) TYPE c,
goods_rep(10) TYPE c,
delv_dt(1) TYPE c,
po_no(10) TYPE c,
rep_name(40) TYPE c,
contact(32) TYPE c,
street(100) TYPE c,
postcode(10) TYPE c,
city(40) TYPE c,
region(1) TYPE c,
country(3) TYPE c,
phone_no(30) TYPE c,
fst_ln_ind(1) TYPE c,
order_ln_no(3) TYPE c,
ni_part_no(35) TYPE c,
cust_part(18) TYPE c,
quantity(3) TYPE c,
die_no(18) TYPE c,
town_circle(50) TYPE c,
code(1) TYPE c,
slogan_no(1) TYPE c,
head_txt(1000) TYPE c,
itm_txt1(32) TYPE c,
itm_txt2(10) TYPE c,
END OF gt_nisl_file.
---Internal Tables--
DATA:
git_nisl_file TYPE TABLE OF gt_nisl_file.
---Structures/Workareas--
DATA:
gs_nisl_file TYPE gt_nisl_file.
gv_dom TYPE REF TO if_ixml_element,
gv_document TYPE REF TO if_ixml_document,
gv_string TYPE xstring,
gv_size TYPE i,
git_xml TYPE dcxmllines.
*FIELD-SYMBOLS: <f> TYPE ANY, <delim> TYPE ANY.
gv_file = '.ATABTEST.TXT'.
*gs_nisl_file-urgent_flag = 'X'.
DO 5000 TIMES.
gs_nisl_file-mat_typ = 'MA'.
gs_nisl_file-sales_org = '2000'.
gs_nisl_file-dist_ch = '80'.
gs_nisl_file-division = '01'.
*gs_nisl_file-cont_no = '12345'.
*gs_nisl_file-sold_to = '2002'.
*gs_nisl_file-goods_rep = 'CUST ADDR'.
*gs_nisl_file-po_no = 'PO12345'.
*gs_nisl_file-delv_dt =
gs_nisl_file-rep_name = 'REP NAME'.
*gs_nisl_file-contact = 'CONTACT'.
*gs_nisl_file-street = 'STREET'.
*gs_nisl_file-postcode = 'POCODE'.
*gs_nisl_file-city = 'CITY'.
*gs_nisl_file-region =
*gs_nisl_file-country = 'GB'.
*gs_nisl_file-phone_no = '12234 57819'.
*gs_nisl_file-fst_ln_ind = 'X'.
*gs_nisl_file-order_ln_no = '010'.
*gs_nisl_file-ni_part_no = '100110'.
*gs_nisl_file-cust_part = '100110'.
*gs_nisl_file-quantity = '1'.
*gs_nisl_file-die_no = '1000032'.
*gs_nisl_file-town_circle = '30000004'.
*gs_nisl_file-code =
*gs_nisl_file-slogan_no = '100110'.
*gs_nisl_file-head_txt = 'HEADER TEXT'.
*gs_nisl_file-itm_txt1 = 'ITEM TEXT1'.
*gs_nisl_file-itm_txt2 = 'ITEM TEXT2'.
APPEND gs_nisl_file TO git_nisl_file.
ENDDO.
DATA:
lv_file(1000) TYPE c,
lv_colt(5000) TYPE c,
lv_cnt(2) TYPE c,
lv_text(8) TYPE c.
CONSTANTS:
lc_hash TYPE x VALUE '09'.
DATA :
lc_hash_x TYPE xstring,
lc_hash_str type string.
lc_hash_str(2) TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
FIELD-SYMBOLS:
<lf_text> TYPE ANY.
*ASSIGN lc_hash TO <delim>.
clear : lc_hash_x, lc_hash_str.
lc_hash_x = lc_hash.
*
CALL FUNCTION 'NLS_STRING_CONVERT_TO_SYS'
EXPORTING
lang_used = sy-langu
SOURCE = lc_hash_x
IMPORTING
RESULT = lc_hash_str.
XML
TYPES: BEGIN OF ttab,
record(65535) TYPE c,
END OF ttab.
DATA: xmltable TYPE TABLE OF ttab.
DATA: xml_out TYPE string,
length LIKE sy-tabix,
result1 LIKE gs_nisl_file.
DATA wa_xmltable TYPE ttab.
CHECK NOT git_nisl_file IS INITIAL.
OPEN DATASET gv_file FOR OUTPUT IN TEXT MODE ENCODING UTF-8. "DEFAULT.
IF sy-subrc NE 0.
WRITE 😕 'Unable to open file'(021),
gv_file.
EXIT.
ENDIF. " sy-subrc
IF p_csv = 'X'.
PERFORM csv_download.
ENDIF.
IF p_xml = 'X'.
PERFORM xml_download.
ENDIF.
CLOSE DATASET gv_file.
END-OF-SELECTION.
&----
*& Form csv_download
&----
text
----
FORM csv_download.
Header line 1: Transfer empty line
TRANSFER lv_file TO gv_file.
lv_file = '1'.
lv_colt = text-h01.
lv_cnt = '1'.
DO.
lv_cnt = lv_cnt + 1.
Generate line with all column numbers
CONCATENATE lv_file lv_cnt INTO lv_file SEPARATED BY lc_hash_str.
IF lv_cnt LE 9.
CONCATENATE 'TEXT-H0' lv_cnt INTO lv_text.
ELSE.
CONCATENATE 'TEXT-H' lv_cnt INTO lv_text.
ENDIF.
ASSIGN (lv_text) TO <lf_text>.
Generate line with all column headers
CONCATENATE lv_colt <lf_text> INTO lv_colt SEPARATED BY lc_hash_str.
IF lv_cnt = 30.
EXIT.
ENDIF.
ENDDO.
Header line 2: Line with all column numbers
TRANSFER lv_file TO gv_file.
Header line 3: Line with all column headers
TRANSFER lv_colt TO gv_file.
LOOP AT git_nisl_file INTO gs_nisl_file.
CLEAR lv_file.
CONCATENATE gs_nisl_file-urgent_flag
gs_nisl_file-mat_typ
gs_nisl_file-sales_org
gs_nisl_file-dist_ch
gs_nisl_file-division
gs_nisl_file-cont_no
gs_nisl_file-sold_to
gs_nisl_file-goods_rep
gs_nisl_file-po_no
gs_nisl_file-delv_dt
gs_nisl_file-rep_name
gs_nisl_file-contact
gs_nisl_file-street
gs_nisl_file-postcode
gs_nisl_file-city
gs_nisl_file-region
gs_nisl_file-country
gs_nisl_file-phone_no
gs_nisl_file-fst_ln_ind
gs_nisl_file-order_ln_no
gs_nisl_file-ni_part_no
gs_nisl_file-cust_part
gs_nisl_file-quantity
gs_nisl_file-die_no
gs_nisl_file-town_circle
gs_nisl_file-code
gs_nisl_file-slogan_no
gs_nisl_file-head_txt
gs_nisl_file-itm_txt1
gs_nisl_file-itm_txt2
INTO lv_file SEPARATED BY lc_hash_str.
PO details
TRANSFER lv_file TO gv_file.
ENDLOOP. " LOOP AT git_nisl_file
ENDFORM. "csv_download
&----
*& Form xml_download
&----
text
----
FORM xml_download.
CALL TRANSFORMATION ('ID')
SOURCE output = git_nisl_file
RESULT XML xml_out.
CALL FUNCTION 'CONVERT_STRING_TO_TABLE'
EXPORTING
i_string = xml_out
i_tabline_length = '65535'
TABLES
et_table = xmltable.
LOOP AT xmltable INTO wa_xmltable.
TRANSFER wa_xmltable-record TO gv_file.
ENDLOOP.
ENDFORM. "xml_download
2007 Jan 10 11:38 AM
why not simply do this
TRANSFER <b>xml_out</b> TO gv_file.
Regards
Raja
2007 Jan 10 11:50 AM
Yes it is quite simple now it is working.
Thanx for the solution.