Application Development and Automation 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: 
Read only

Conversion from LRAW to String

Former Member
0 Likes
12,211

Hello everyone,

i have met a problem about conversion LRAW to String.

In BW there are a table “/POSDW/TLOGS”. I will output the field “TRANSACTIONDATA” type LRAW.

How can I output the LRAW data.

Are there some BAPIs?

I try to use WSI_RAW_TO_STRING and SCMS-BINARY_TO_STRING. But don’t work.

One for RAW, another for binary.

Which for LRAW?

Can you explain the difference between LRAW and RAW.

or : how can i convert LRAW to RAW?

thx in advance.

Yaning

Edited by: Yaning Liu on Feb 1, 2008 2:23 PM

8 REPLIES 8
Read only

Former Member
0 Likes
5,258

hello experts,

help me.

how can i split the lang LRAW in one short RAW table?

thx

yaning

Read only

Former Member
0 Likes
5,258

hi,

While calling FM 'OPEN_FORM' pass the value of parameter

raw_data_interface = 'X'. You will be getting the raw data in spool.

regs,

Hema.

Read only

Former Member
0 Likes
5,258

Hi,

These Function Modules may come handy to you,

From RAW to CHAR: RS_SCRP_FIELDS_RAW_TO_CHAR

From RAW to LRAW: SO_RAW_72_To_255.

Also refer to SO_RAW_CONVERT.

Reward if this provides any lead.

Read only

0 Likes
5,258

hello prosenjit ,

I have tried to research those BAPIs. but i have no idea.

can you give me one example.

Read only

Former Member
0 Likes
5,258

Hi,

To split LRAW, please try the following function module,

SOTR_SERV_STRING_TO_TABLE.

Regards,

Prosenjit.

Read only

0 Likes
5,258

SOTR_SERV_STRING_TO_TABLE.

This function module can process String. For LRAW it doesn't work.

Read only

Former Member
0 Likes
5,258

Not so simple.

According to sap library [Data Types in the ABAP Dictionary|http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21f2e5446011d189700000e8322d00/frameset.htm]:

1) LRAW is a data dictionary field type with a given length in bytes (minimum of 256), that must be used at the end of a structure or of a table, and it must be immediately preceded by an integer 2 bytes which gives the real used length (from 0 to the field length).

2) LRAW corresponds to a variable of type X in ABAP (X for hexadecimal, which means bytes/binary content).

So, an LRAW field has binary content, it means that it can hold image, pdf, music, movie, or even just characters.

If we are sure it contains characters, it can be converted to a string, but we must know what codepage is used to store the characters in the LRAW. For example, if ASCII is used : letter "A" would be stored in 1 byte with hexa value '41'. If UTF16 + little endian is used, it would be stored in 2 bytes with hexa value '4100'.

Then, when you know the codepage, you need to use classes CL_ABAP_CONV_IN_CE to convert it to a string.

Here is an example with utf16 + BE (big endian) which writes "AB" from original LRAW content '00410042'.

REPORT  Z_UNICODE_ASCII.

  DATA e type ref to cx_root.
  DATA unicode_2_abap TYPE REF TO cl_abap_conv_in_ce.
  DATA lraw_unicode(2886) TYPE x.
  DATA lraw_unicode_length TYPE int2.
  DATA string TYPE string.
  FIELD-SYMBOLS <l_x> TYPE x.

  lraw_unicode = '00410042'. "hex code correspond to AB in UTF16 big endian
  lraw_unicode_length = 4.

  assign lraw_unicode(lraw_unicode_length) to <l_x>.

* Set codepage to be used
  TRY.
      unicode_2_abap = cl_abap_conv_in_ce=>create(
              encoding = '4102' "Unicode 16BE, see table TCP00
              ).
    CATCH cx_root INTO e.
      WRITE 'err1'.
  ENDTRY.

* Determine characters which correspond to utf16 BE X'00410042'
  TRY.
      unicode_2_abap->convert(
            EXPORTING input = <l_x>
            IMPORTING data  = string ).
    CATCH cx_root INTO e.
      WRITE 'err2'.
  ENDTRY.

  write string.

Read only

wbsc
Explorer
0 Likes
2,112

Hi,
this moves the LRAW data directly to the itab.

DATArawstring      TYPE /posdw/rawstring,
      c_processlog   TYPE /posdw/processlog.

SELECT FROM /posdw/plog1s
  FIELDS *
  INTO TABLE @DATA(lt_log).

LOOP AT lt_log ASSIGNING FIELD-SYMBOL(<ls_log>).
  rawstring <ls_log>-processlogdata.
  IMPORT c_processlog-processlog_fd FROM DATA BUFFER rawstring
      ACCEPTING PADDING.
endloop.

Br
SC