Application Development 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: 

How to convert a char(x) column in a table to a raw(x) column in a different table

crew_reynolds1
Explorer
0 Kudos

Team,

I have a table called CONTENT with one column, LINE char(1022).
I have another table CONTENT_RAW with one column, LINE RAW(1022)
I have a third table CONTENT_RAW2 with one column, LINE RAW(1022)

CONTENT is filled with 19 rows of a 1022 character value of HEX data in char format.
CONTENT_RAW is filled 19 rows of 1022 bytes (RAW). This data is sent in from a VBA app that reads the bytes from a file converts them to 2-char HEX values and builds up the string for CONTENT_RAW (good data, proven to work with BDS_BUSINESSDOCUMENT_CREA_TAB.

The requirement is to take in the CONTENT char data, convert the char HEX values into bytes that can then be concatenated to the table CONTENT_RAW2 table (RAW(1022)).

The result SHOULD be that the resulting CONENT_RAW2 table look precisely like the know good data in CONTENT_RAW.

I am able to do all of the conversion from CHAR to BYTE and build up an XSTRING of those bytes which I assign to CONTENT_RAW2-LINE.

After I do the conversion and compare a known good CONTENT_RAW-LINE with the CONTENT_RAW2-LINE that I built, both are XTRINGS that are exactly alike HEX value for HEX value, byte for byte according to ABAPs variable viewer.

Still, this line fails.

if content_raw2-line NE content_raw-line.
write: 'nope'. <<< I get this every time.
endif.

WHY can I not create a RAW table entry from and XSTRING that matches it exactly byte for byte?

Thanks for any insight,
Crew Reynolds

1 REPLY 1

iftah_peretz
Active Contributor
0 Kudos

Hi,

In the "ABAPs variable viewer" you compared the "Val." columns or the "Hexadecimal Value" columns for both the variables? For all of the 1022 characters?

Also, you stated that these are table fields, if I look at the documentation under RAW, I see:

"The built-in type RAW, mapped to the ABAP type x, is used to describe byte fields with a maximum length of 32000 characters (only 255 characters for table fields)."

What do you make of it?