Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

'SCMS_BINARY_TO_TEXT'

Former Member
0 Likes
3,261

Hi Experts!!

I try use this function:

CALL FUNCTION 'SCMS_BINARY_TO_TEXT'

EXPORTING

input_length = nose

  • FIRST_LINE = 0

  • LAST_LINE = 0

  • APPEND_TO_TABLE = ' '

  • MIMETYPE = ' '

  • WRAP_LINES = ' '

  • ENCODING =

  • IMPORTING

  • OUTPUT_LENGTH =

tables

binary_tab = t_fichero

text_tab = t_fichero2

EXCEPTIONS

FAILED = 1

OTHERS = 2

Does anyone know what value should be put in input_length and that is that value? How it works?

Thanks

Gracias.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,280

Hi,

Input_length mush have to be Integer type. Pls check the below sample code to use this FM.

  • Convert binary to text.

  • Convert binary to text.

CALL FUNCTION 'SCMS_BINARY_TO_TEXT' 
  EXPORTING 
    INPUT_LENGTH          = 100 ---------> integer val as input
*             FIRST_LINE            = 0 
*             LAST_LINE             = 0 
*             APPEND_TO_TABLE       = ' ' 
*             MIMETYPE              = ' ' 
    WRAP_LINES            = 'X' 
*           IMPORTING 
*             OUTPUT_LENGTH         = 
  TABLES 
    BINARY_TAB            = LT_BINARY 
    TEXT_TAB              = LT_TEXT_OUT 
*           EXCEPTIONS 
*             FAILED                = 1 
*             OTHERS                = 2 
          . 
IF SY-SUBRC <> 0. 
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO 
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. 
ENDIF.

Regrads,

Lokesh.

11 REPLIES 11
Read only

Former Member
0 Likes
2,280

Hi,

The input and the output length are of type I.

With Regards,

Sumodh.P

Read only

0 Likes
2,280

The input and the output length of ...???

Read only

Former Member
0 Likes
2,281

Hi,

Input_length mush have to be Integer type. Pls check the below sample code to use this FM.

  • Convert binary to text.

  • Convert binary to text.

CALL FUNCTION 'SCMS_BINARY_TO_TEXT' 
  EXPORTING 
    INPUT_LENGTH          = 100 ---------> integer val as input
*             FIRST_LINE            = 0 
*             LAST_LINE             = 0 
*             APPEND_TO_TABLE       = ' ' 
*             MIMETYPE              = ' ' 
    WRAP_LINES            = 'X' 
*           IMPORTING 
*             OUTPUT_LENGTH         = 
  TABLES 
    BINARY_TAB            = LT_BINARY 
    TEXT_TAB              = LT_TEXT_OUT 
*           EXCEPTIONS 
*             FAILED                = 1 
*             OTHERS                = 2 
          . 
IF SY-SUBRC <> 0. 
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO 
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. 
ENDIF.

Regrads,

Lokesh.

Read only

0 Likes
2,280

Why 100 and not 200 or 1024 o 512, etc.....

In order to use that value? The higher you place more I read from the binary table, why?

I don't understand.....

Read only

0 Likes
2,280

Where is the binary data coming from? Are you uploading it using GUI_UPLOAD? Or the GUI_UPLOAD method of the class CL_FRONTEND_SERVICES? If so, then you can get the length from the function call. It is an exporting parameter.

Regards,

Rich Heilman

Read only

0 Likes
2,280

REPORT Z_IRS_PRUEBAS.

TYPES: BEGIN OF ty_fichero,

line(254) TYPE c,

END OF ty_fichero.

DATA: t_fichero TYPE STANDARD TABLE OF ty_fichero,

t_fichero2 TYPE STANDARD TABLE OF ty_fichero,

wa_fichero TYPE ty_fichero,

l_file TYPE STRING.

l_file = '/ECD/interfaces/ETL/DINAMICO.txt'.

OPEN DATASET l_file FOR INPUT IN BINARY MODE. "DEFAULT.

IF sy-subrc NE 0.

ELSE.

DO.

CLEAR wa_fichero.

READ DATASET l_file INTO wa_fichero-line.

IF sy-subrc NE 0.

EXIT.

ENDIF.

APPEND wa_fichero TO t_fichero.

ENDDO.

CLOSE DATASET l_file.

ENDIF.

DATA: data TYPE REF TO cl_htmlb_fileupload,

w_output_length TYPE i.

DATA bf TYPE xstring.

DATA nose TYPE i.

DESCRIBE FIELD wa_fichero-line LENGTH nose IN BYTE MODE.

CALL FUNCTION 'SCMS_BINARY_TO_TEXT'

EXPORTING

input_length = 42768 --> more number, more data read*

FIRST_LINE = 0

  • LAST_LINE = 0

  • APPEND_TO_TABLE = ' '

  • MIMETYPE = ' '

  • WRAP_LINES = ' '

  • ENCODING =

  • IMPORTING

  • OUTPUT_LENGTH =

tables

binary_tab = t_fichero

text_tab = t_fichero2

EXCEPTIONS

FAILED = 1

OTHERS = 2

.

.

Read only

0 Likes
2,280

Yes, you will need to add up the length one line at a time. See changes below.

REPORT z_irs_pruebas.

TYPES: BEGIN OF ty_fichero,
line(254) TYPE c,
END OF ty_fichero.


DATA: t_fichero TYPE STANDARD TABLE OF ty_fichero,
t_fichero2 TYPE STANDARD TABLE OF ty_fichero,
wa_fichero TYPE ty_fichero,
l_file TYPE string.

DATA:   ls_data             TYPE x255,
        l_length            TYPE i,
        l_tot_len           TYPE i,
        lt_data             TYPE STANDARD TABLE OF x255.

l_file = '/ECD/interfaces/ETL/DINAMICO.txt'.


OPEN DATASET l_file FOR INPUT IN BINARY MODE. "DEFAULT.
IF sy-subrc NE 0.
ELSE.
  DO.
*    CLEAR wa_fichero.
*    READ DATASET l_file INTO wa_fichero-line.
*    IF sy-subrc NE 0.
*      EXIT.
*    ENDIF.
*    APPEND wa_fichero TO t_fichero.
    READ DATASET l_file INTO ls_data MAXIMUM LENGTH 255 LENGTH l_length.
    IF sy-subrc <> 0.
      l_tot_len = l_tot_len + l_length.
      INSERT ls_data INTO TABLE lt_data.
      EXIT.
    ELSE.
      l_tot_len = l_tot_len + l_length.
      INSERT ls_data INTO TABLE lt_data.
    ENDIF.
  ENDDO.

  CLOSE DATASET l_file.
ENDIF.

DATA: data TYPE REF TO cl_htmlb_fileupload,
w_output_length TYPE i.
DATA bf TYPE xstring.


DATA nose TYPE i.
DESCRIBE FIELD wa_fichero-line LENGTH nose IN BYTE MODE.

CALL FUNCTION 'SCMS_BINARY_TO_TEXT'
EXPORTING
input_length = l_tot_len  "<-- Pass calculated length
first_line = 0
* LAST_LINE = 0
* APPEND_TO_TABLE = ' '
* MIMETYPE = ' '
* WRAP_LINES = ' '
* ENCODING =
* IMPORTING
* OUTPUT_LENGTH =
TABLES
binary_tab = lt_data   "<-- Pass binary table
text_tab = t_fichero2
EXCEPTIONS
failed = 1
OTHERS = 2.

Regards,

Rich Heilman

Edited by: Rich Heilman on Apr 20, 2010 10:14 AM

Updated Code Example

Read only

0 Likes
2,280

This is my cuenstions:

How can i calculated length ? (input_length = l_length "<-- Pass calculated length)) i don't know....

Read only

0 Likes
2,280

input_length = l_length

when you use this assignment you need not pass the value again it will allocate the size by itself .

regards sami.

Read only

0 Likes
2,280

oops, I made a mistake. Take the example above, and make this change. Pass the total length variable, not L_LENGTH.

CALL FUNCTION 'SCMS_BINARY_TO_TEXT'
EXPORTING
input_length = l_tot_len  "<-- Pass calculated length
first_line = 0
* LAST_LINE = 0
* APPEND_TO_TABLE = ' '
* MIMETYPE = ' '
* WRAP_LINES = ' '
* ENCODING =
* IMPORTING
* OUTPUT_LENGTH =
TABLES
binary_tab = lt_data   "<-- Pass binary table
text_tab = t_fichero2
EXCEPTIONS
failed = 1
OTHERS = 2.

Regards,

Rich Heilman

Read only

0 Likes
2,280

Sorry.

It´s OK

Thanks.