on 07-14-2004 6:22 AM
hi folks,
when calling a webfrom from an bsp , e.g. des sample forms, than some characters like ä ö etc. are not shown correctly - when switching manually (on the explorer) to encoding UNICODE than they are shown correctly -> we have this problem only with webFroms , are there any suggestions what we made wrong? or how can we avoid that.
kind regards
oliver
Hi Oliver,
I should add that as Brian has already mentioned the Smartforms give you the right output. So just use something like:
file = entity->get_data( ).
Do not use get_cdata( ) because this will do the conversion.
At the end (after you got the data) call the
response_complete( ).
This should help.
Rainer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Oliver,
call it at the end of onInputProcessing. Please also
have a look at the example.
Regards,
Rainer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
since kernel patch (I believe)1253 all data written with
append_cdata into the response object will be converted
into the codepage set be char-set in the header field.
The point is that you can display the whole data with or
without conversion. If you call the layout of the BSP
append_cdata will be always executed and the data will be
converted. That's what you don't want. So you must leave the page before the onLayout will be called. This can be
done by navigation->response_complete( ) if you're
working with a page. If you use MVC, just don't call the
view. You can find an example in application IT00 called
transition_parameter.htm
Hoping this helps.
Rainer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hallo Oliver,
This is going to be slightly complex. I can give you some ideas what to look for. You will have to debug yourself, or will have go via OSS if you need more help.
The problem has to do with two things that must match. One is the call to the response object to set the Content-Type header. The other is the actual content that is set.
For example, is you are running in DE, then set the Content-Type (which also includes the charset) with iso-something. Then write in the content into the response.
It is ultra important that the Content-Type (with charset) must be set before the first byte is written onto the response. Otherwise the kernel will set it for you.
So as first step, BSP will try to set this Content-Type depending on logon language. You can configure this on the properties tab of pages and controllers to set you own. I am not sure if smart forms do anything with the request. And then you might also be setting this header.
Whatever the final value, it must match the data you are going to write. And now comes the next aspect. I suspect SmartForms give you UTF-8 output. If this is true, then you must yourself the Content-Type correctly.
The last aspect is that there was a kernel change to work around some problems here. I can not remember the exact rules, but from what I remember, on Unicode systems, the data is always forced into UTF-8 format.
Maybe this is enough to track down the problem. As a first step use a proxy tool and see what the actual header values are. If you require more help, please open OSS message.
++bcm
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hello brian,
as i found out smartforms makes utf-8 output.
your sentence If this is true, then you must yourself the Content-Type correctly -
was not fulfilled? any hints how to set the content type, i set it as explained in the demo in event "OnInitialization" with
response->set_header_field( name = 'content-type'
value = ls_xmloutput-trfresult-type ).
where value is the value that comes from smartforms???? but this does not work, in the value is at runtime the string "text/html" .... any hints behind that?
kind regards
oliver
The 'text/html' in the content-type isn't enought. You also need to set the character set. The full value for content-type should be `text/html; charset=utf-8` if you want to force unicode.
response->set_header_field( name = 'content-type'
value = `text/html; charset=utf-8` ).
You can also set this for a page or view via the properties tab in the field Mime Type. Just make the value <i>text/html; charset=utf-8</i>. If you have a MVC, this can be set from the controller with the following method call:
me->set_mime_type( `text/html; charset=utf-8` ).
That's interesting. I just tried the BSP application in our system SMART_FORMS_DEMO_02. The default display has some characters that show corrupted (which don't display properly in this forum either):
NeurottstraĂźe 16
However when I go into the debugger and force the content type to be text/html; charset=utf-8 it then displays the following:
Neurottstraße 16
This would seem to confirm that SmartForms (in my system at least) does return Unicode data and that using content field that is returned from the SmartForms function module is not enough. Perhaps as Brian suggest there is a missing support package or kernel fix in your system. My system is 620 SP35 with kernel 620 Patch 1248.
hi thomas,
i found a solution but i cannot understand this.
i give as charset iso-1151 (smartforms returns unicode i'm sure) and then it works -> in the source of the html-page there is still charset = 'utf-8' as always before but now shown correctliy
my system is 620 SP35 patch level 1350, abap load 1462 ????
so maybe someone can explain why this works now????
This code from Thomas is correct:
response->set_header_field(
name = 'content-type'
value = `text/html; charset=utf-8` ).
Important is to set it before the response is written, that is before the very first byte! So move this code into the onInitialization!
If you can reduce your problem to about 25 lines of code (only smartform call plus response handling), please email it to me, and I will test it quickly. Email is name.surname@sap.com
hallo brian,
my portion of the smartforms code is, as an explaination -> is use charset =iso-1151 as not it works, with utf-8 it does not work????
-
coding----
response->set_header_field( name = 'content-type'
value = 'text/html; charset=iso-1151' ).
LOOP AT lt_html_raw INTO lv_xstring.
CONCATENATE lv_html_xstring lv_xstring INTO lv_html_xstring
IN BYTE MODE.
ENDLOOP.
lv_xlength = XSTRLEN( lv_html_xstring ).
response->set_data( data = lv_html_xstring
length = lv_xlength ).
Oliver,
Can you also append the five lines of smartform code you use. I would like to test this myself to understand what you are doing.
Also what logon language (sy-langu) are you using? And why did you pick 'iso-1151'? My search engine keeps giving me specs about flying. Or am I overlooking something?
hi brian,
my logon language is German -> i used iso-1151, i just tried an ibm codepage 850 compatible one, thats the first i found
my code goes here:
lv_formname = 'ZCP_0001'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = lv_formname
IMPORTING
fm_name = lv_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
ls_output_options-xsf = 'X'. " XSF Output active
ls_output_options-xsfcmode = 'X'. " Get XSF params from program
ls_output_options-xsfoutmode = 'A'. " A:Application
ls_output_options-xsfformat = 'X'. " Formatting ON
ls_output_options-xsfaction = space. " Action URL for submit btn.
ls_control_parameters-langu = sy-langu.
CALL FUNCTION lv_fm_name
EXPORTING
is_print = ls_print
control_parameters = ls_control_parameters
output_options = ls_output_options
user_settings = ''
IMPORTING
job_output_info = ls_output_data
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
ls_xmloutput = ls_output_data-xmloutput.
lt_html_raw = ls_xmloutput-trfresult-content[].
lt_style = ls_xmloutput-stsheet.
*----
Fill HTTP request
*----
manipulieren????
response->set_header_field( name = 'content-type'
value = 'text/html; charset=iso-1151' ).
*----
SAP Smart Forms returns XML data island in raw data format.
method 'set_data' of the response object needs the output
in XSTRING. The next loop convertes the raw table into xstring.
*----
LOOP AT lt_html_raw INTO lv_xstring.
CONCATENATE lv_html_xstring lv_xstring INTO lv_html_xstring
IN BYTE MODE.
ENDLOOP.
lv_xlength = XSTRLEN( lv_html_xstring ).
response->set_data( data = lv_html_xstring
length = lv_xlength ).
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.