Skip to Content
0
May 31, 2011 at 06:54 PM

Problem convert string to table

1948 Views

Hi guys.

I have a long string in BASE64, using the FM SSFC_BASE64_DECODE, I'm able to decode the base64 string to a normal string.

Now, the problem is that i need to convert that long string into a table and then save it as .pdf in the local pc.

I tried using the FM CONVERT_STRING_TO_TABLE but it gives me a dump. This is the code that i have. The w_result is the string in base64 that i get from a webservice.

data: w_result TYPE string, 
        fic_binario TYPE xstring.
DATA: string_binario TYPE string.

  DATA: BEGIN OF lines OCCURS 100,
  tdline(1024) TYPE x.
  DATA: END OF lines.

  CALL FUNCTION 'SSFC_BASE64_DECODE'
    EXPORTING
      b64data = w_result
    IMPORTING
      bindata = fic_binario.

  string_binario = fic_binario.

* Dump
  CALL FUNCTION 'CONVERT_STRING_TO_TABLE'
    EXPORTING
      i_string         = string_binario
      i_tabline_length = 1024
    TABLES
      et_table         = lines.

* Also i tried this: DUMP as well

  DATA: lv_divisor TYPE i,
  lv_resto TYPE i,
  lv_longitud TYPE i,
  lv_indice TYPE i.

  DO.

    lv_longitud = STRLEN( string_binario ).

    lv_divisor = lv_longitud DIV 256.
    lv_resto = lv_longitud DIV 256.

    lv_indice = 256 * sy-index.

    lines-tdline = string_binario+lv_indice(256).

    APPEND lines.
    CLEAR lines.

    IF lv_divisor IS INITIAL.

      EXIT.

    ENDIF.

  ENDDO.

How can i convert that string that I get from the FM SSFC_BASE64_DECODE to a table??? so then i can download it to a local pc????

Regards