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

memory problems when converting huge ABAP tables to XML files.

Former Member
0 Likes
966

Hi,

I have a question.

I need to convert ABAP tables to XML files.

There is huge records in ABAP tables in millions.

When i convert these records in chunks of 25lakhs.

There is a problem at ixml_document..throwing memory allocaton failed.(even when i run in background).

how to solve this problem as i have run huge records which might range in billions..

Edited by: Thomas Zloch on Nov 29, 2010 5:24 PM - subject adjusted

Hi,

I have a question.

I need to convert ABAP tables to XML files.

There is huge records in ABAP tables in millions.

When i convert these records in chunks of 25lakhs.

There is a problem at ixml_document..throwing memory allocaton failed.(even when i run in background).

how to solve this problem as i have run huge records which might range in billions..

Edited by: Thomas Zloch on Nov 29, 2010 5:24 PM - subject adjusted

5 REPLIES 5
Read only

franois_henrotte
Active Contributor
0 Likes
885

you should split your data into several xml files

if you really need the whole into one single file you can use a file utility to merge files later

Read only

0 Likes
885

How can i use this can u let me know?

i have no idea on this?

Read only

0 Likes
885

how to solve this problem as i have run huge records which might range in billions..

Wow...someone needs to archive. What is the point of generating a file with a billion records in it, if in fact, you're not exagerating?

Read only

GrahamRobbo
SAP Mentor
SAP Mentor
0 Likes
885

Brad is absolutely right - are you sure you realise what you are doing?

Anyway - check out [Simple Transformations|http://help.sap.com/saphelp_nw04/helpdata/en/e3/7d4719ca581441b6841f1054ff1326/frameset.htm] they are very efficient.

Cheers

Graham Robbo

Read only

former_member1125862
Participant
0 Likes
885

Hi Vadnalav,

Please find the below code.

I think this will solve your problem.

TYPE-POOLS: truxs.

*&----


    • Global Variables

*&----


DATA: w_tabname type w_tabname,

w_dref TYPE REF TO data,

dy_line type ref to data.

DATA: itab TYPE truxs_t_text_data,

IT_MARA LIKE MARA OCCURS 0 WITH HEADER LINE.

data: begin of f_itab occurs 0,

str(5000) type c,

end of f_itab.

data :

temp(5000) type c,

count type i.

field-symbols: <f> type any.

*----


    • Selection Screen with Parameters

*&----


SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME.

PARAMETERS: p_table(30) TYPE c DEFAULT 'MARA'.

PARAMETERS: p_out LIKE rlgrap-filename.

PARAMETERS: p_pc AS CHECKBOX.

SELECTION-SCREEN END OF BLOCK block1.

*----


    • AT SELECTION-SCREEN

*&----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_out.

PERFORM get_local_file_name(zcommon_forms) USING p_out 'P_PC'.

*&----


    • Start of Program

*&----


START-OF-SELECTION.

PERFORM download_data.

&----


*& Form DOWNLOAD_DATA

&----


FORM download_data .

*

FIELD-SYMBOLS: <t_itab> TYPE STANDARD TABLE,

<dyn_wa>.

data : lv_len type i.

DATA: r_cdata TYPE REF TO data.

data : lt_length like dd03l occurs 0 with header line.

data lv_char(255) type c.

w_tabname = p_table.

CREATE DATA w_dref TYPE TABLE OF (w_tabname).

ASSIGN w_dref->* TO <t_itab>.

create data dy_line like line of <t_itab>.

assign dy_line->* to <dyn_wa>.

SELECT *

FROM (w_tabname)

INTO TABLE <t_itab> .

IF sy-subrc EQ 0.

  • ---------------------------------------------

do.

assign component sy-index of structure <dyn_wa> to <f>.

if sy-subrc <> 0.

exit.

else.

count = count + 1.

endif.

enddo.

loop at <t_itab> into <dyn_wa>.

do count times.

assign component sy-index of structure <dyn_wa> to <f>.

clear lv_char.

lv_char = <f>.

lv_len = strlen( lv_char ).

if lv_len ne 0.

CREATE DATA r_cdata TYPE c LENGTH lv_len.

FIELD-SYMBOLS <cdata> TYPE ANY.

ASSIGN r_cdata->* TO <cdata>.

<cdata> = <f>.

endif.

concatenate temp '~' <cdata> into temp.

clear : lv_len,<cdata>.

  • concatenate temp '~' lv_char into temp.

enddo.

shift temp.

condense temp no-gaps.

append temp to f_itab.

clear temp.

endloop.

ENDIF.

*Download File

IF f_itab[] IS NOT INITIAL.

PERFORM download_file TABLES f_itab

USING p_pc

p_out

'ASC'.

ENDIF.

ENDFORM. " DOWNLOAD_DATA

&----


*& Form DOWNLOAD_FILE

&----


FORM download_file TABLES fp_data_tab

USING fp_pc TYPE any

fp_outfile TYPE rlgrap-filename

fp_filtyp TYPE rlgrap-filetype.

DATA : LV_DEL TYPE CHAR01,

LV_FILE TYPE STRING,

v_lines type i.

describe table fp_data_tab lines v_lines.

if v_lines = 0.

write : /'There are no records to download' color col_negative.

exit.

else.

write: / 'Data will be downloaded to file :' color col_total,

fp_outfile,

/ 'Number of records to be downloaded :' color col_total,

v_lines.

endif.

IF fp_pc EQ space. "DOWN LOAD FILE TO APPLICATION SERVER

**********OPEN FILE ******************************************

IF FP_FILTYP = 'BIN'.

OPEN DATASET fp_outfile FOR OUTPUT IN BINARY MODE .

ELSE.

OPEN DATASET fp_outfile FOR OUTPUT IN TEXT MODE TYPE 'NT'.

ENDIF.

IF sy-subrc NE 0.

WRITE : / 'ERROR OPENING FILE :' , fp_outfile COLOR COL_NEGATIVE.

STOP.

ENDIF .

LOOP AT fp_data_tab.

***transfer

TRANSFER fp_data_tab TO fp_outfile.

ENDLOOP.

***close file p_otfile.

CLOSE DATASET fp_outfile.

ELSE. "DOWN LOAD FILE TO PC

LV_FILE = fp_outfile.

IF fp_filtyp = 'DAT'.

LV_DEL = '|'.

ENDIF.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = LV_FILE

FILETYPE = 'ASC'

  • APPEND = ' '

WRITE_FIELD_SEPARATOR = LV_DEL

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • CONFIRM_OVERWRITE = ' '

  • NO_AUTH_CHECK = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = fp_data_tab

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

NO_AUTHORITY = 5

UNKNOWN_ERROR = 6

HEADER_NOT_ALLOWED = 7

SEPARATOR_NOT_ALLOWED = 8

FILESIZE_NOT_ALLOWED = 9

HEADER_TOO_LONG = 10

DP_ERROR_CREATE = 11

DP_ERROR_SEND = 12

DP_ERROR_WRITE = 13

UNKNOWN_DP_ERROR = 14

ACCESS_DENIED = 15

DP_OUT_OF_MEMORY = 16

DISK_FULL = 17

DP_TIMEOUT = 18

FILE_NOT_FOUND = 19

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

OTHERS = 22.

IF sy-subrc NE 0.

WRITE : / 'FILE ERROR !!!!', fp_outfile COLOR COL_NEGATIVE.

STOP.

ENDIF.

ENDIF.

ENDFORM. "DOWNLOAD_FILE

This will download the date by seperating '~'.

You can download to 'XML' by changing the FM.

I think this code will help you.