Skip to Content
1
May 27, 2014 at 05:39 AM

Meaning of wave line in TRANSLATE lv_text using '~'

834 Views

Hi Sir/Madam,


I have a question of the meaning of wave line "~" in TRANSLATE l_v_buffer USING '~'.

I debuged in the process of this statement,

It is seems that the work area (lwa_output) did not changed.


I konw how does the demo in SAP ABAPDOCU work, but I do not know what the wave used for here?

*******************************************************************************

CALL FUNCTION 'CONVERT_OTF_2_PDF'
EXPORTING
use_otf_mc_cmd = 'X'
IMPORTING
bin_filesize = lv_size
TABLES
otf = ut_otf
doctab_archive = lt_doc
lines = lt_pdf_output
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.
* ----> Convert 132 chars long (PDF) to 255 chars long to be used
* as attachment
REFRESH fp_lt_pdf[].

LOOP AT lt_pdf_output INTO lwa_output.
TRANSLATE lwa_output USING '~'.
CONCATENATE l_v_buffer lwa_output INTO l_v_buffer.
ENDLOOP.
TRANSLATE l_v_buffer USING '~'.

DO.
l_wa_contpdf = l_v_buffer.
APPEND l_wa_contpdf TO fp_lt_pdf.
SHIFT l_v_buffer LEFT BY 255 PLACES.
IF l_v_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDIF.


**************************************************************************

... USING pattern

Effect

If you specify USING, the characters in text are converted according to the rule specified in pattern. pattern must be a character-type data object whose contents are interpreted as a sequence of character pairs. text is searched for the first character of each pair, starting with the first pair, and each location found is replaced with the second character of the pair. The search is case-sensitive. If pattern contains a character multiple times as the first character of a pair, only the first pair is taken into account. A character in text that has already been replaced cannot be replaced again in the same TRANSLATE statement. Therefore, if the second character of a pair in pattern appears as the first character of a subsequent pair, the second pair affects only the original characters in text.

Trailing blanks in data objects text and pattern are taken into account for data objects. If pattern contains an uneven number of characters, the last character is ignored. If pattern is a blank string, no replacements take place.

Example

Converts the characters "A" to "B", "a" to "b", and vice versa. text contains "Abracadabra" after the conversion.

DATA text TYPE string.
text = `Barbcbdbarb`.
TRANSLATE text USING 'ABBAabba'.




Regards