‎2010 Apr 20 12:37 PM
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.
‎2010 Apr 20 1:11 PM
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.
‎2010 Apr 20 12:47 PM
Hi,
The input and the output length are of type I.
With Regards,
Sumodh.P
‎2010 Apr 20 12:50 PM
‎2010 Apr 20 1:11 PM
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.
‎2010 Apr 20 2:21 PM
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.....
‎2010 Apr 20 2:28 PM
‎2010 Apr 20 2:35 PM
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
.
.
‎2010 Apr 20 2:50 PM
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
‎2010 Apr 20 2:59 PM
This is my cuenstions:
How can i calculated length ? (input_length = l_length "<-- Pass calculated length)) i don't know....
‎2010 Apr 20 3:11 PM
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.
‎2010 Apr 20 3:14 PM
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
‎2010 Apr 20 3:26 PM