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: 

LRAW Internal table data to Readable internal table conversion

former_member334777
Active Participant
0 Kudos

Hi All,

I am looking for some method by which we can convert internal table data of datatype LRAW to readable conversion.Our data is derived from excel data which was placed on application server.

I have tried most of the possible solution on sdn to convert this LRAW data to Readable format but data is appearing like Chinese characters or not readable characters.

When I am downloading this LRAW internal table data with help of FM GUI_DOWNLOAD then data gets downloaded correctly but my requirement is to convert LRAW data in readable internal table data.

Any help on this is appreciated.

BR,

Praveen

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi praveen,

this is a demo - so that you check and learn from it - if it helps.

sample data (filename.xls)

REPORT  ZR_EXCEL_INTERNAL_TABLE.

TYPE-POOLS truxs.

PARAMETERS p_file TYPE  rlgrap-filename OBLIGATORY.

TYPES: BEGIN OF TY,
         field1 type i,
         field2 type C LENGTH 20,
         END OF TY.

DATA : it_zhpsm TYPE TABLE OF ty,
       wa_zhpsm TYPE ty,
       it_type   TYPE truxs_t_text_data.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name  = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name     = p_file.

START-OF-SELECTION.
 
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_tab_raw_data             = it_type
i_filename                 = p_file
TABLES
i_tab_converted_data       = it_zhpsm
EXCEPTIONS
conversion_failed          = 1
OTHERS                     = 2
.

loop AT IT_ZHPSM into WA_ZHPSM.
   WRITE: / WA_ZHPSM-FIELD1, WA_ZHPSM-FIELD2.
ENDLOOP.

14 REPLIES 14

Former Member
0 Kudos

hi praveen,

can you share the file which has LRAW data to check and advise accordingly.

Former Member
0 Kudos

the data seems to be unicode bytes or compressed bytes or encrypted.

please check the source.

matt
Active Contributor
0 Kudos

The data in your database will be the binary data you've loaded. It will have that structure. If you read an ordinary text file as binary, for example, it will have 0x0A and 0x0D bytes for carriage return linefeed. You'll see in the LRAW just the hexadecimal content of the text file. When you convert it to text, you'll get a string of text with the 0x0A and 0x0D displayed as #.

Excel data is rather more complex than a text file, and you have to write conversion routines. The reason that you can read it in Excel is that Excel takes the binary data and parses it into a readable format, as part of what it does as a program.

XLSX format is zipped xml. To read it directly, you'll need to take your LRAW data, unzip it (there are classes for this), and the parse the XML (search for how to do this).

XLS format is proprietry. To read that, get the Java source code of POI, and rewrite it as ABAP.

Or you can search for function modules that convert Excel data into internal tables. If there are any.

0 Kudos

Hi Mathew,

Could you please have sample code for downloading .xls or xlsx format file from application server to internal table in readable format?

I tried all the options but it is not working fine.

Data is getting translated into chinese characters.

BR,

Praveen

matt
Active Contributor
0 Kudos

No. You may not ask for samples, documents, links or other material on this site.

Which part of my explanation are you not understanding?

Former Member
0 Kudos

hi praveen,

can you share your excel format with sample data so that it can be checked and advise accordingly.

Former Member
0 Kudos

hi praveen,

this is a demo - so that you check and learn from it - if it helps.

sample data (filename.xls)

REPORT  ZR_EXCEL_INTERNAL_TABLE.

TYPE-POOLS truxs.

PARAMETERS p_file TYPE  rlgrap-filename OBLIGATORY.

TYPES: BEGIN OF TY,
         field1 type i,
         field2 type C LENGTH 20,
         END OF TY.

DATA : it_zhpsm TYPE TABLE OF ty,
       wa_zhpsm TYPE ty,
       it_type   TYPE truxs_t_text_data.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name  = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name     = p_file.

START-OF-SELECTION.
 
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_tab_raw_data             = it_type
i_filename                 = p_file
TABLES
i_tab_converted_data       = it_zhpsm
EXCEPTIONS
conversion_failed          = 1
OTHERS                     = 2
.

loop AT IT_ZHPSM into WA_ZHPSM.
   WRITE: / WA_ZHPSM-FIELD1, WA_ZHPSM-FIELD2.
ENDLOOP.

0 Kudos

Hi Abdul,

Our file is placed on application server that not on presentation server.

I did this for presentation server but I don't have solution for application server.

BR,

Praveen

0 Kudos

can you share your excel format with sample data so that it can be checked and advise accordingly.

0 Kudos

This message was moderated.

matt
Active Contributor
0 Kudos

Posting containing email address removed. You may not post email addresses on this site. The sharing privately of information is very much discouraged.

matt
Active Contributor
0 Kudos

Praveen Singh wrote:

Hi Abdul,

Our file is placed on application server that not on presentation server.

I did this for presentation server but I don't have solution for application server.

BR,

Praveen

Then rewrite the above code so that it reads from the application server. There is an expectation here that you know the basics of ABAP coding. This is not a simple task. You may be better served handing over to someone more experienced. The concepts required are not something that can be taught in a few forum posts.

0 Kudos

matt
Active Contributor
0 Kudos

Good stuff. (Though the formatting could do with a bit of work ).