on 12-10-2004 3:39 AM
Little background :
1) we are using a lot of interfaces with legacy and the data in sap has null characters for example : phone#123 .
the prob is not on sap side but on bw side when i extract this data it converts to hex format and the load fails.
2) so i wrote a abap function module for the extractor which uses the function modules SRET_TEXT_TO_BINARY and SRET_BINARY_TO_TEXT and passed the variable that has the null character and replaced it with space.
3) the prob is i get null characters in a lot of fields now and i am not sure how i can pass it to SRET_BINARY_TO_TEXT OR SRET_TEXT_TO_BINARY as they are SAP standard and it takes in just a single variable. i have all my fields in a internal table .
I apologize for the the length of the message but any help is greatly appreciated.I want to know how to pass a internal table with null in all fields to a standard function module bec . The code is below :
=======================================================
CALL FUNCTION 'SRET_TEXT_TO_BINARY'
EXPORTING
TEXT = input
TEXT_LENGTH = -1
LAISO = '00'
IV_CATID = ' '
IV_RFC_FOR_INITIALIZE = ' '
IMPORTING
OUTPUT_LENGTH =
XBUFFER = v_hexa
EXCEPTIONS
FAILED = 1
OTHERS = 2
.
IF SY-SUBRC = 0.
*Replacing all NULL (X'00') values with SPACE (X'20')
REPLACE ALL OCCURRENCES OF c_null IN v_hexa WITH c_space IN BYTE MODE.
CALL FUNCTION 'SRET_BINARY_TO_TEXT'
EXPORTING
XBUFFER = v_hexa
LAISO = '00'
IV_CATID = ' '
IV_RFC_FOR_INITIALIZE = ' '
IMPORTING
OUTPUT_LENGTH =
TEXTBUFFER = output
EXCEPTIONS
FAILED = 1
OTHERS = 2
Hi,
try this:
data trhex(4) type x value '0020'.
translate record using trhex.
Grx Andreas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can try the CONDENSE statement.
Regards
Elini.P
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The entire code :
=======================================================
FUNCTION YFR1_CA_U_NULL_SPACE.
*"----
""Local interface:
*" IMPORTING
*" REFERENCE(INPUT) TYPE C
*" EXPORTING
*" REFERENCE(OUTPUT) TYPE C
*" EXCEPTIONS
*" LENGTH_TOO_LONG
*" FAILED
*"----
This function provides the functionality of replacing the NULL
characters with SPACE .
*----
DATA : v_hexa(100) TYPE X ,
c_space(2) TYPE X VALUE '0020' ,
c_null(2) TYPE X VALUE '0000' ,
v_length TYPE i .
COMPUTE v_length = STRLEN( input ) .
IF v_length > '100'.
RAISE length_too_long .
ENDIF .
CALL FUNCTION 'SRET_TEXT_TO_BINARY'
EXPORTING
TEXT = input
TEXT_LENGTH = -1
LAISO = '00'
IV_CATID = ' '
IV_RFC_FOR_INITIALIZE = ' '
IMPORTING
OUTPUT_LENGTH =
XBUFFER = v_hexa
EXCEPTIONS
FAILED = 1
OTHERS = 2
.
IF SY-SUBRC = 0.
*Replacing all NULL (X'00') values with SPACE (X'20')
REPLACE ALL OCCURRENCES OF c_null IN v_hexa WITH c_space IN BYTE MODE.
CALL FUNCTION 'SRET_BINARY_TO_TEXT'
EXPORTING
XBUFFER = v_hexa
LAISO = '00'
IV_CATID = ' '
IV_RFC_FOR_INITIALIZE = ' '
IMPORTING
OUTPUT_LENGTH =
TEXTBUFFER = output
EXCEPTIONS
FAILED = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
RAISE FAILED .
ENDIF.
ELSE.
RAISE FAILED .
ENDIF .
ENDFUNCTION.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.