cancel
Showing results for 
Search instead for 
Did you mean: 

how to encode the data

Former Member
0 Kudos

Hi Experts,

My requirement is i want to print the BI report data which is in unicode system in to the webdynpro but in arabic language.

Please help me in the same.

Is there any Function module to encode the data?

what is the UI element i have to use to display the report data to support the HTML.?

Thanking you in advacne.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Ramkumar,

You can use method Load_data from class cl_gui_html_viewer. Method has lot of logic to convert data using code pages. You can also check other methods of this class, hopefully it will help you to acheive the convertion and display of data as desired

method load_data .
  data: full_url(2048),
        extension(8),
        as_string type char01 value '',
        mime_type type w3param-cont_type,
        r3data    type char01,
        new_size  type i,
        is_charbased type char01.

* Flush called moved up to prevent indirect event triggering
* in one of the wrapper classes. Relevant notes 888720,884926.
  if m_url_prefix is initial.
    call method cl_gui_cfw=>flush.
    if sy-subrc ne 0.
      raise cntl_error.
    endif.
  endif.

  clear m_url.

  if url is initial.
    add 1 to m_unique_url_id.

    call method get_document_extension
      exporting
        type      = type
        subtype   = subtype
      importing
        extension = extension.

    concatenate 'HTML' m_unique_url_id extension into m_url.
  else.
    move url to m_url.
  endif.
  assigned_url = m_url.


  call method is_charbased_table
    exporting
      data_table = data_table
    importing
      ischar = is_charbased.

  call method update_table_dp_object
    exporting
      doc_url = m_url
      type    = type
      subtype = subtype
      is_charbased = is_charbased.

  concatenate m_url_prefix m_url into full_url.

  new_size = size.
  move type to mime_type.
  translate mime_type to lower case.                      "#EC SYNTCHAR
  if mime_type = 'text'.
    if cl_abap_char_utilities=>charsize gt 1.
      as_string = 'X'.
    endif.
    move subtype to mime_type.
    translate mime_type to lower case.                    "#EC SYNTCHAR
    if mime_type = 'html'.
      call method get_url_attributes
        exporting
          url         = full_url
        importing
          r3data      = r3data
        exceptions
          others      = 1.
      if sy-subrc = 0 and
         not r3data is initial and
         not is_charbased is initial.
        call method adjust_html_data
          exporting
            language        = language
          changing
            data_table      = data_table
            size            = new_size.
      endif.
    endif.
  endif.

  call function 'DP_CREATE_URL'
    exporting
      type                 = type
      subtype              = subtype
      size                 = new_size
      lifetime             = m_dp_lifetime
      send_data_as_string  = as_string
    tables
      data                 = data_table
    changing
      url                  = full_url
    exceptions
      dp_invalid_parameter = 1
      others               = 2.
  case sy-subrc.
    when 0.
    when 1.
      raise dp_invalid_parameter.
    when 2.
      raise dp_error_general.
  endcase.
endmethod.

Greetings

Prashant

Former Member
0 Kudos

Hi,

How to use this calss?

I am displaying the BI report and r/3 data in BSP application using ababp_unicode in arabic in browser,but i tried it in webdynpro abap it's not displaying arabic it's displaying in hexadecimal language.

can you tell me how to display that in webdynpro.

data : ls_candidate_data type zcand_arab_info_s.

types: begin of ty_summb,

/bic/objid type /bic/ahsummbse00-/bic/hobjid,

/bic/happlnam1 type /bic/ahsummbse00-/bic/happlnam1,

/bic/habbrevon type /bic/ahsummbse00-/bic/habbrevon,

act_type type /bic/ahsummbse00-act_type,

/bic/hacttyp_t type /bic/ahsummbse00-/bic/hacttyp_t,

end of ty_summb.

data: int_summb type table of ty_summb,

wa_summb type ty_summb.

*ls_candidate_data = '60007926'.

*append ls_candidate_data to lt_candidate.

*

select * from zbi_arab_can_smp into table lt_candidate.

call function 'Z_BI_GET_ARABIC_NAMES' destination 'DVRCLNT095'

tables

candidate = lt_candidate

encoded_data = lt_encoded_data.

select /bic/hobjid

/bic/happlnam1

/bic/habbrevon

act_type

/bic/hacttyp_t

into table int_summb

from /bic/ahsummbse00

for all entries in lt_candidate

where /bic/hobjid = lt_candidate-candidate.

loop at lt_encoded_data into ls_encoded_data.

read table int_summb with key /bic/objid = ls_encoded_data-candidate

into wa_summb.

if sy-subrc = 0.

ls_encoded_data-/bic/happlnam1 = wa_summb-/bic/happlnam1.

ls_encoded_data-/bic/habbrevon = wa_summb-/bic/habbrevon.

ls_encoded_data-act_type = wa_summb-act_type.

ls_encoded_data-/bic/hacttyp_t = wa_summb-/bic/hacttyp_t.

modify lt_encoded_data from ls_encoded_data.

clear: ls_encoded_data.

endif.

endloop.

............................................................in bsp part end here...................................................

Z_BI_GET_ARABIC_NAMES':

FUNCTION Z_BI_GET_ARABIC_NAMES_TEST.

*"----


""Local Interface:

*" TABLES

*" CANDIDATE STRUCTURE ZCAND_ARAB_INFO OPTIONAL

*" ENCODED_DATA STRUCTURE ZCAND_ARAB_DATA

*"----


data wa_HRP9550 type HRP9550.

data: input_val type char0128.

data: output_val type CHAR512.

data wa_ENCODED_DATA type ZCAND_ARAB_DATA.

TYPES: BEGIN OF ty_cand,

CANDIDATE type hrp9550-objid,

FNAME_AR type hrp9550-fname_ar,

MNAME_AR type hrp9550-MNAME_AR,

LNAME_AR type hrp9550-LNAME_AR,

GFNAME_AR type hrp9550-GFNAME_AR ,

end of ty_cand.

data: int_cand type table of ty_cand,

wa_cand type ty_cand.

TYPES: BEGIN OF ty_summb,

objid type ZER_SUMMB_SEL-objid,

major type ZER_SUMMB_SEL-major,

major_desc type ZER_SUMMB_SEL-major_desc,

gmajor type ZER_SUMMB_SEL-gmajor,

gmajor_desc type ZER_SUMMB_SEL-gmajor_desc,

end of ty_summb.

data: int_summb type table of ty_summb,

wa_summb type ty_summb.

  • data: int_cand_arab_data type TABLE OF ZCAND_ARAB_DATA ,

  • wa_cand_arab_data type ZCAND_ARAB_DATA.

SELECT OBJID

fname_ar

mname_ar

lname_ar

gfname_ar

FROM hrp9550

into TABLE int_cand

for all entries in candidate

WHERE plvar EQ '01'

AND otype EQ 'NA'

AND objid = CANDIDATE-candidate

AND ENDDA GE sy-datum

AND BEGDA LE sy-datum.

if sy-subrc = 0.

sort int_cand by candidate.

delete ADJACENT DUPLICATES FROM int_cand COMPARING candidate.

SELECT OBJID

major

major_desc

gmajor

gmajor_desc

FROM zer_summb_sel

INTO TABLE int_summb

for all entries in int_cand

wHERE objid = int_cand-candidate.

loop at int_cand into wa_cand.

wa_encoded_data-candidate = wa_cand-candidate.

  • first name conversion

input_val = wa_cand-FNAME_AR.

CALL FUNCTION 'Z_BW_ENCODE_TO_HTML_DATA'

EXPORTING

DATA = input_val

L_ENCODING = 'UTF-8'

IMPORTING

OUTPUT = output_val.

wa_encoded_data-FNAME_AR = output_val.

clear: input_val, output_val.

  • mid name conversion

input_val = wa_cand-MNAME_AR.

CALL FUNCTION 'Z_BW_ENCODE_TO_HTML_DATA'

EXPORTING

DATA = input_val

L_ENCODING = 'UTF-8'

IMPORTING

OUTPUT = output_val.

wa_encoded_data-MNAME_AR = output_val.

clear: input_val, output_val.

  • last name conversion

input_val = wa_cand-LNAME_AR.

CALL FUNCTION 'Z_BW_ENCODE_TO_HTML_DATA'

EXPORTING

DATA = input_val

L_ENCODING = 'UTF-8'

IMPORTING

OUTPUT = output_val.

wa_encoded_data-LNAME_AR = output_val.

clear: input_val, output_val.

  • GF name conversion

input_val = wa_cand-GFNAME_AR.

CALL FUNCTION 'Z_BW_ENCODE_TO_HTML_DATA'

EXPORTING

DATA = input_val

L_ENCODING = 'UTF-8'

IMPORTING

OUTPUT = output_val.

wa_encoded_data-GFNAME_AR = output_val.

  • Read and populate Major details

read table int_summb with key objid = wa_cand-candidate

into wa_summb.

if sy-subrc = 0.

  • MAJOR

wa_encoded_data-major = wa_summb-major.

  • MAJOR_DESC

input_val = wa_summb-major_desc.

CALL FUNCTION 'Z_BW_ENCODE_TO_HTML_DATA'

EXPORTING

DATA = input_val

L_ENCODING = 'UTF-8'

IMPORTING

OUTPUT = output_val.

wa_encoded_data-major_desc = output_val.

  • GMAJOR

wa_encoded_data-gmajor = wa_summb-gmajor.

  • GMAJOR_DESC

input_val = wa_summb-gmajor_desc.

CALL FUNCTION 'Z_BW_ENCODE_TO_HTML_DATA'

EXPORTING

DATA = input_val

L_ENCODING = 'UTF-8'

IMPORTING

OUTPUT = output_val.

wa_encoded_data-gmajor_desc = output_val.

endif.

append wa_encoded_data to ENCODED_DATA.

clear: input_val, output_val, ENCODED_DATA, wa_encoded_data.

endloop.

endif.

ENDFUNCTION.

............................................end.......................................................

'Z_BW_ENCODE_TO_HTML_DATA':

FUNCTION Z_BW_ENCODE_TO_HTML_DATA.

*"----


""Local Interface:

*" IMPORTING

*" REFERENCE(DATA) TYPE CHAR0128

*" REFERENCE(L_ENCODING) TYPE ABAP_ENCOD DEFAULT 'UTF-8'

*" EXPORTING

*" REFERENCE(OUTPUT) TYPE CHAR512

*"----


data: conv type ref to cl_abap_conv_out_ce,

inbuf type string,

outbuf type string,

wf_len type i,

wf_str_len type i,

wf_out type string,

wf_buf type string,

WF_BUF_I TYPE I.

IF NOT DATA IS INITIAL.

clear: wf_len, wf_str_len, wf_out.

wf_str_len = strlen( DATA ).

do.

CALL METHOD CL_ABAP_CONV_OUT_CE=>CREATE

EXPORTING

ENCODING = L_ENCODING

REPLACEMENT = '#'

IGNORE_CERR = ABAP_TRUE

RECEIVING

CONV = CONV.

clear: INBUF, OUTBUF, wf_buf, WF_BUF_I.

INBUF = DATA+wf_len(1).

  • if not INBUF is initial.

CALL METHOD CONV->WRITE

EXPORTING

DATA = INBUF.

CALL METHOD CONV->GET_BUFFER

RECEIVING

BUFFER = WF_BUF.

WF_BUF = OUTBUF.

if INBUF is not initial.

WF_BUF_I = CONV->UCCPI( INBUF ).

wf_buf = WF_BUF_I.

condense wf_buf.

  • endif.

concatenate wf_out '&#' wf_buf ';' into wf_out.

else.

concatenate wf_out ' ' into wf_out.

endif.

  • concatenate wf_out wf_buf into wf_out.

wf_len = wf_len + 1.

if wf_len eq wf_str_len.

exit.

endif.

enddo.

  • OUT-ZZFIRSTNAM_AR = wf_out.

ENDIF.

OUTPUT = wf_out.

ENDFUNCTION.

................................................end..............................................................

Former Member
0 Kudos

Hi Ramkumar,

WebDynpro does not allow us to create HTML & enter JAVA script. As per its architecture HTML+JS are generated at runtime, depending on the UI elements we chose. May be if you give me some info or source on what have you done in the webDynpro application i can help u.

Essentially in webdynpro if creating report like application , i genrally have Search Options on top and a Table to display set of result records. Thus view will have some inputfields, buttons and tables. All the convertion data processing would be done in Assistance class or Controller method , at last step push this result to table which displays it.

Greetings

Prashant

Former Member
0 Kudos

Hi Prashanth,

Thank you for replying me.. this is important task for me...

What my problem is arabic data is not displaying in webdypro abap application in BI system that is unicode system.but same system the bsp application the data is displaying in arabic data in table.

above code i wrote in bsp application.... there i debugged the internal table getting the hexadecimal values but how it converting in to arabic language i don't know in bsp.

but in webdynpro same hexadecimal values only displaying insted of arabic language can you please help me in this.

thank you in advance

Former Member
0 Kudos

Hi Prashanth,

Thank you for replying me.. this is important task for me...

What my problem is arabic data is not displaying in webdypro abap application in BI system that is unicode system.but same system the bsp application the data is displaying in arabic data in table.

above code i wrote in bsp application.... there i debugged the internal table getting the hexadecimal values but how it converting in to arabic language i don't know in bsp.

but in webdynpro same hexadecimal values only displaying insted of arabic language can you please help me in this.

thank you in advance

Former Member
0 Kudos

Hi Ramkumar,

You need do some investigation on using the class CL_GUI_HTML_VIEWIER methods as stated in previous post there are few methods example GET_RECOMMENDED_CHARSET when u call this

method passing the SPRAS - 'A' thats for arabic language on a Unicode system it will return you the

HTML_CHARSET that should be used to display data correctly !!!

SPRAS LASPEZ LAHQ LAISO SPTXT

A L 0 AR Arabic

you can also try class cl_abap_conv_in_ce. Also post this query on the general ABAP forum it will get answered there more quickly.

Greetings

Prashant

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Web Dynpro ABAP automatically encodes its output using the system code page of the application server. Unlike in BSP where you could override the output encoding and mix codepages or use Unicode; in WDA (becuase everything is safe encoded already for you) the encoding is fixed. Therefore in order to output a mixture of code pages, your ABAP application server must be Unicode.

Former Member
0 Kudos

Hi Thomas,

How to change the system language.

In webdynpro i didn't change the code data.Now it's displaying #### insted of arabic like that.

can you please help me how to solve this problem.

Thank you in advacne.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>How to change the system language.

That's the language the user logs in with. So if you want to display Arabic, that language must be installed and available for login. Otherwise Unicode is your only option.