Difference between revisions of "SAP ABAP XSTRING"

From SapWiki
Line 34: Line 34:
 
                   IMPORTING buffer = l_xstring ).
 
                   IMPORTING buffer = l_xstring ).
  
l_xstring = cl_abap_codepage=>convert_to( source = l_string codepage = 'UTF-8' ).
+
" convert xstring to string for output
 +
cl_abap_conv_in_ce=>create( input = l_xstring )->read( IMPORTING data = l_string ).
 
</nowiki>
 
</nowiki>
  
 
* ejemplo 2
 
* ejemplo 2
 
  <nowiki>
 
  <nowiki>
  lo_c2x = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).
+
l_xstring = cl_abap_codepage=>convert_to( source = l_string codepage = 'UTF-8' ).
  lo_c2x->convert( EXPORTING data  = l_string
 
                  IMPORTING buffer = l_xstring ).
 
  
 
   CALL METHOD cl_http_utility=>if_http_utility~decode_utf8
 
   CALL METHOD cl_http_utility=>if_http_utility~decode_utf8
Line 49: Line 48:
 
       unencoded = l_string.
 
       unencoded = l_string.
 
</nowiki>
 
</nowiki>
 +
 
==Leer archivo de texto como UTF-8==
 
==Leer archivo de texto como UTF-8==
 
  <nowiki>
 
  <nowiki>

Revision as of 22:42, 17 February 2021

Leer atchivo de texto como binario

DATA: lo_c2x  TYPE REF TO cl_abap_conv_out_ce.

DATA l_string TYPE string.
DATA l_string2 TYPE string.
DATA l_xstring TYPE xstring.
DATA l_filename TYPE string.

CALL METHOD cl_faa_tenv_services=>gui_upload_xstring
  EXPORTING
    id_fullpath = l_filename
  IMPORTING
    ed_xstring  = l_xstring.

" convert xstring to string for output
cl_abap_conv_in_ce=>create( input = l_xstring )->read( IMPORTING data = l_string ).

WHILE l_string IS NOT INITIAL.
  SPLIT l_string AT cl_abap_char_utilities=>cr_lf INTO l_string2 l_string.
  IF NOT l_string2 CO cl_abap_char_utilities=>cr_lf.
    MOVE l_string2 TO it_entrada.
    APPEND it_entrada.
  ENDIF.

ENDWHILE.

string to xstring => xstring to string

  • ejemplo 1
  lo_c2x = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).
  lo_c2x->convert( EXPORTING data   = l_string
                   IMPORTING buffer = l_xstring ).

" convert xstring to string for output
cl_abap_conv_in_ce=>create( input = l_xstring )->read( IMPORTING data = l_string ).

  • ejemplo 2
l_xstring = cl_abap_codepage=>convert_to( source = l_string codepage = 'UTF-8' ).

  CALL METHOD cl_http_utility=>if_http_utility~decode_utf8
    EXPORTING
      encoded   = l_xstring
    RECEIVING
      unencoded = l_string.

Leer archivo de texto como UTF-8

  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                = l_filename
      filetype                = 'ASC'
      CODEPAGE                = '4110'
    TABLES
      data_tab                = it_entrada
    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 .
    endif.

Grabar XSTRING en equipo como binario

Leer archivo XML

desde un string en BASE64 obtener PDF binario

Leer Arhivo PDF y Visualizarlo