Skip to Content
0
Former Member
Dec 10, 2004 at 03:39 AM

Null character removal in sap using a function module

506 Views

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