SYSTEM_IMODE_TOO_LARGE ...????????

I need to load a cluster table from SAP into my target table.
It is a total custom flow and not one that comes with the rapid mart.
Every time i try to load it, I get the following error.

3720 5340 R3C-150605 1/26/2009 11:29:10 AM |Dataflow DF_CD_ConditionsTransData_SAP
3720 5340 R3C-150605 1/26/2009 11:29:10 AM The SAP job was canceled for host <>, job name <R3_CD_Conditionstransdata 01/26/>, job count <11043401>, job log from SAP <
3720 5340 R3C-150605 1/26/2009 11:29:10 AM 01/26/2009 11:04:35 Job started
3720 5340 R3C-150605 1/26/2009 11:29:10 AM 01/26/2009 11:04:35 Step 001 started (program ZW72003656, variant &0000000000000, user ID DIUSER)
3720 5340 R3C-150605 1/26/2009 11:29:10 AM 01/26/2009 11:28:55 ABAP/4 processor: SYSTEM_IMODE_TOO_LARGE
3720 5340 R3C-150605 1/26/2009 11:29:10 AM 01/26/2009 11:28:55 Job cancelled
3720 5340 R3C-150605 1/26/2009 11:29:10 AM >.
892 3208 R3C-150605 1/26/2009 11:29:10 AM |Dataflow DF_CD_ConditionsTransData_SAP
892 3208 R3C-150605 1/26/2009 11:29:10 AM The SAP job was canceled for host <>, job name <R3_CD_Conditionstransdata 01/26/>, job count <11043401>, job log from SAP <
892 3208 R3C-150605 1/26/2009 11:29:10 AM 01/26/2009 11:04:35 Job started
892 3208 R3C-150605 1/26/2009 11:29:10 AM 01/26/2009 11:04:35 Step 001 started (program ZW72003656, variant &0000000000000, user ID DIUSER)
892 3208 R3C-150605 1/26/2009 11:29:10 AM 01/26/2009 11:28:55 ABAP/4 processor: SYSTEM_IMODE_TOO_LARGE
892 3208 R3C-150605 1/26/2009 11:29:10 AM 01/26/2009 11:28:55 Job cancelled
892 3208 R3C-150605 1/26/2009 11:29:10 AM >.

Nebody face the same issue before ? Ne work arounds ???
Thanks


zohebmu (BOB member since 2009-01-08)

When you look at the ABAP it will contain some ITABs (ABAP in-memory tables) which grow too big. Now the big question is, what ITABs do you have, what store large amounts of data and how can we optimize it? Some ideas:

a) An ITAB is used if the R/3 dataflow has multiple queries. Hence the goal should be the have one query only. (We can do better ABAP generation here, I know)
b) If a source table in the R/3 dataflow has the cache property set, it will read into an ITAB.
c) If you have a lookup with pre_load_cache, its data is written into an ITAB.

Just for completeness: https://www.sdn.sap.com/irj/scn/wiki?path=/display/BOBJ/How+to+read+the+ABAP


Werner Daehn :de: (BOB member since 2004-12-17)

Werner Thanks for your time.
In the DF there are no lookups and there are no multiple queries as well.
I tried caching the table also but got the same results.
So the point about the ITABS, I saw it in there but could not exactly place where you were going with it, hence have attached the ABAP generated with the flow.
Our SAP Basis guys here have been pretty clueless on the this and the option of getting a patch to upgrade R/3 is not going to happen.
So is there any work around for this maybe the ABAP can be modified??
Hopefully the attached ABAP helps.

Thanks again

REPORT ZAL_ABAP message-id 26 line-size 255
no standard page heading.

  • ZCDCODA.
    PARAMETER DOWNLOAD(1) DEFAULT ‘N’ lower case. "N-svr,Y-clnt
    PARAMETER EXECMODE(1) DEFAULT ‘B’ lower case. "D-dlg,B-btch
    PARAMETER OUT_DIR(48) DEFAULT "output file dir
    ‘/sapcd/temp_report’ lower case.
    PARAMETER IN_DIR(48) DEFAULT "input file dir
    ‘/sapcd/temp_report’ lower case.

PARAMETER P_DF_VK(40) DEFAULT "R/3 Dataflow object key
‘’ lower case.
PARAMETER P_DI_GEN(40) DEFAULT "DI version that generated ABAP
‘’ lower case.

*** Machine generated ABAP. Do not modify. ***
*** Copyright Business Objects Data Integration, Inc. ***
*

  • Date Time:
  • 01/26/09 11:04:29
  • SAP used for generated this ABAP:
  • Release: 620
  • Host : cdsap6d
  • R3 Dataflow Name:
  • R3_CD_Conditionstransdata
  • R3 Dataflow comments:
  • Extracts general material data from TVFST SAP R/3 source sys
    *tem
  • table with descriptions in default language (full extract)
  • ABAP program name in R3:
  • ZCDCODA
  • Generated ABAP file name:
  • D:/DI/ABAP/Conditionstransdata.aba
    TABLES KONV.

DATA: begin of ITAB2 occurs 0,
STUNR(3) TYPE N,
ZAEHK(2) TYPE N,
KPOSN(6) TYPE N,
KNUMV(10) TYPE C,
KSCHL(4) TYPE C,
KPEIN(16) TYPE P DECIMALS 0,
KVSL1(3) TYPE C,
KUMZA(16) TYPE P DECIMALS 0,
KUMNE(16) TYPE P DECIMALS 0,
KWERT(16) TYPE P DECIMALS 2,
KNUMH(10) TYPE C,
KOPOS(2) TYPE N,
KBETR(16) TYPE P DECIMALS 2.
DATA: end of ITAB2.

DATA: begin of ITAB3 occurs 0,
STUNR(3) TYPE N,
ZAEHK(2) TYPE N,
KPOSN(6) TYPE N,
KNUMV(10) TYPE C,
KSCHL(4) TYPE C,
KPEIN(16) TYPE P DECIMALS 0,
KVSL1(3) TYPE C,
KUMZA(16) TYPE P DECIMALS 0,
KUMNE(16) TYPE P DECIMALS 0,
KWERT(16) TYPE P DECIMALS 2,
KNUMH(10) TYPE C,
KOPOS(2) TYPE N,
KBETR(16) TYPE P DECIMALS 2.
DATA: end of ITAB3.

data: append_flag(1) value ’ ',
cntbuf type i,
delimleng type i.

CONSTANTS C_DF_VK(40) VALUE ‘1621’.
CONSTANTS C_DI_GEN(40) VALUE ‘12.1.0.0’.
DATA WARN_MSG(50).

start-of-selection.

PERFORM FORM2.
PERFORM FORM4.
FREE ITAB3.
PERFORM FORM3.
FREE ITAB2.

end-of-selection.

CLEAR WARN_MSG.

IF NOT P_DF_VK IS INITIAL.
IF P_DF_VK <> C_DF_VK.
CONCATENATE ‘$$Warning$’
C_DF_VK
‘$’ INTO WARN_MSG.
ENDIF.
ENDIF.
IF NOT P_DI_GEN IS INITIAL.
IF P_DI_GEN <> C_DI_GEN.
IF WARN_MSG IS INITIAL.
CONCATENATE ‘$$Warning$$’
C_DI_GEN
INTO WARN_MSG.
ELSE.
CONCATENATE WARN_MSG
C_DI_GEN
INTO WARN_MSG.
ENDIF.
ENDIF.
ENDIF.

IF NOT WARN_MSG IS INITIAL.
IF EXECMODE = ‘D’.
WRITE WARN_MSG.
NEW-LINE.
ELSE.
MESSAGE S000 with WARN_MSG.
ENDIF.
ENDIF.

write ‘* Program Complete *’.
write ‘Copyright Business Objects Data Integration, Inc.’.

FORM FORM2.
DATA ALTMP1(3) TYPE N.
DATA ALTMP2(2) TYPE N.
DATA ALTMP3(6) TYPE N.
DATA ALTMP4(10) TYPE C.
DATA ALTMP5(4) TYPE C.
DATA ALTMP6(16) TYPE P DECIMALS 0.
DATA ALTMP7(3) TYPE C.
DATA ALTMP8(16) TYPE P DECIMALS 0.
DATA ALTMP9(16) TYPE P DECIMALS 0.
DATA ALTMP10(16) TYPE P DECIMALS 2.
DATA ALTMP11(10) TYPE C.
DATA ALTMP12(2) TYPE N.
DATA ALTMP13(16) TYPE P DECIMALS 2.

SELECT
STUNR
ZAEHK
KPOSN
KNUMV
KSCHL
KPEIN
KVSL1
KUMZA
KUMNE
KWERT
KNUMH
KOPOS
KBETR
INTO CORRESPONDING FIELDS OF KONV
FROM KONV
.
ALTMP1 = KONV-STUNR.
ALTMP2 = KONV-ZAEHK.
ALTMP3 = KONV-KPOSN.
ALTMP4 = KONV-KNUMV.
ALTMP5 = KONV-KSCHL.
ALTMP6 = KONV-KPEIN.
ALTMP7 = KONV-KVSL1.
ALTMP8 = KONV-KUMZA.
ALTMP9 = KONV-KUMNE.
ALTMP10 = KONV-KWERT.
ALTMP11 = KONV-KNUMH.
ALTMP12 = KONV-KOPOS.
ALTMP13 = KONV-KBETR.
move ALTMP1 to ITAB3-STUNR.
move ALTMP2 to ITAB3-ZAEHK.
move ALTMP3 to ITAB3-KPOSN.
move ALTMP4 to ITAB3-KNUMV.
move ALTMP5 to ITAB3-KSCHL.
move ALTMP6 to ITAB3-KPEIN.
move ALTMP7 to ITAB3-KVSL1.
move ALTMP8 to ITAB3-KUMZA.
move ALTMP9 to ITAB3-KUMNE.
move ALTMP10 to ITAB3-KWERT.
move ALTMP11 to ITAB3-KNUMH.
move ALTMP12 to ITAB3-KOPOS.
move ALTMP13 to ITAB3-KBETR.
append ITAB3.
ENDSELECT.
ENDFORM.

FORM FORM4.
SORT ITAB3 BY
STUNR
ZAEHK
KPOSN
KNUMV
KSCHL
KPEIN
KVSL1
KUMZA
KUMNE
KWERT
KNUMH
KOPOS
KBETR.
delete adjacent duplicates from ITAB3 comparing all fields.

ITAB2[] = ITAB3[].
ENDFORM.

FORM FORM3.
data: outfile(128), ldfile(50).
ldfile = ‘Conditionsdata.dat’.
concatenate out_dir ldfile into outfile
separated by ‘/’.
data dlmtlen type i value ‘1’.
data ht(1) type x value ‘7F’.
data return_code type i.
perform write_delimited_file
tables ITAB2
using outfile
append_flag
ht
dlmtlen
download
changing return_code.

case return_code.
when 1.
IF EXECMODE = ‘D’.
WRITE: /5 ‘No line selected’.
ELSE.
MESSAGE E098.
ENDIF.
when 2.
IF EXECMODE = ‘D’.
WRITE: /5 'Open File Error – ', 25 OUTFILE.
ELSE.
MESSAGE E107 WITH OUTFILE.
ENDIF.
when 3.
IF EXECMODE = ‘D’.
WRITE: /5 'Data exceed length limit (8192) '.
ELSE.
MESSAGE E000 WITH
'Data exceed length limit (8192) '.
ENDIF.
when 4.
IF EXECMODE = ‘D’.
WRITE: /5 ‘Call function WS_DOWNLOAD error’.
ELSE.
MESSAGE E000 WITH
‘Call function WS_DOWNLOAD error’.
ENDIF.
endcase.
ENDFORM.

FORM SUBSTRING USING SRC BEG LEN CHANGING RET.

DATA: VA1 TYPE I.
DATA: VA2 TYPE I.
DATA: VA3 TYPE I.

VA3 = STRLEN( SRC ).

IF BEG = 0. VA1 = 0.
ELSE.
IF BEG < 0.
VA1 = VA3 + BEG.
IF VA1 < 0. VA1 = 0.
ENDIF.
ELSE. VA1 = BEG - 1.
ENDIF.
ENDIF.

IF LEN < 0. VA2 = 0.
ELSE. VA2 = VA3 - VA1.
ENDIF.

IF VA2 > LEN. VA2 = LEN.
ENDIF.

IF VA2 < 1. MOVE ‘’ TO RET.
ELSE. MOVE SRC+VA1(VA2) TO RET.
ENDIF.

ENDFORM.

form write_delimited_file
tables datatab
using file
append
delimit
dlength
dwnload
changing rc.

data: type1,
appd(1),
temp(32),
time1(8),
date1(10),
output(8192),
rcount type i,
offset type i,
tablen type i,
maxlen type i value ‘8192’.

data: begin of clientab occurs 0,
output(8192),
end of clientab.

field-symbols: .
field-symbols .
data delim2(16).
data l_filename type string.

appd = append.
if appd is not initial.
appd = ‘X’.
endif.
move file to l_filename.
describe table datatab lines tablen.

if dwnload = ‘Y’.
clear clientab. refresh clientab.
rcount = 0.
else.
if appd = space.
open dataset file for output in text mode ENCODING
DEFAULT.
else.
open dataset file for appending in text mode ENCODING
DEFAULT.
endif.
if sy-subrc <> 0.
rc = 2. exit.
endif.
endif.

loop at datatab.
clear: tablen, offset, output.
do.
assign component sy-index of
structure datatab to .
if sy-subrc <> 0. exit. endif.
if sy-index > 1.
assign delimit(dlength) TO CASTING TYPE C.
delim2 = .
write delim2(dlength) to output+offset(dlength).
add dlength to offset.
endif.

  describe field <f> type type1.                    
                                                    
  if type1 = 'I' or type1 = 'N'.                    
      type1 = 'P'.                                  
  endif.                                            
                                                    
  case type1.                                       
    when 'D'.                                       
      if <f> = '00000000'.                          
         <f> = ' '.                                 
      else.                                         
         move <f> to time1.                         
         assign time1 to <f>.                       
      endif.                                        
    when 'F'.                                       
      if <f> = '0.0'.                               
        temp = '0.0'.                               
      else.                                         
         write <f> to temp exponent 0.              
      endif.                                        
      condense temp no-gaps.                        
      translate temp using ',.'.                    
      assign temp to <f>.                           
    when 'P'.                                       
      if <f> < 0.                                   
         write '-' to output+offset(1).             
         add 1 to offset.                           
         <f> = <f> * ( -1 ).                        
      endif.                                        
      move <f> to temp.                             
      condense temp no-gaps.                        
      translate temp using ',.'.                    
      assign temp to <f>.                           
  endcase.                                          
                                                    
  sy-fdpos = strlen( <f> ).                         
                                                    
  tablen = offset + sy-fdpos.                       
  if tablen > maxlen.                               
     rc = 3. exit.                                  
  endif.                                            
  write <f> to output+offset(sy-fdpos).             
  add sy-fdpos to offset.                           
enddo.                                              
                                                    
if dwnload = 'Y'.                                   
   clientab-output = output.                        
   append clientab.                                 
   rcount = rcount + 1.                             
   if rcount >= 50.                                 
      SY-BATCH = SPACE.                             
      CALL FUNCTION 'GUI_DOWNLOAD'                  
        EXPORTING                                   
          FILENAME = l_filename                     
          FILETYPE = 'ASC'                          
          APPEND   = appd                           
          WRITE_FIELD_SEPARATOR = 'X'               
  •        IMPORTING                                  
    
  •          FILELENGTH =                             
          TABLES                                      
            DATA_TAB = clientab                       
          EXCEPTIONS                                  
            OTHERS = 1.                               
        if sy-subrc <> 0.                             
           rc = 4.                                    
        endif.                                        
        clear clientab. refresh clientab.             
        rcount = 0. appd = 'A'.                       
     endif.                                           
    

    else.
    transfer output to file.
    endif.
    endloop.

    if dwnload = ‘Y’.
    SY-BATCH = SPACE.
    CALL FUNCTION ‘GUI_DOWNLOAD’
    EXPORTING
    FILENAME = l_filename
    FILETYPE = ‘ASC’
    APPEND = appd
    WRITE_FIELD_SEPARATOR = ‘X’

  •     IMPORTING                                     
    
  •       FILELENGTH =                                
       TABLES                                         
         DATA_TAB = clientab                          
       EXCEPTIONS                                     
         OTHERS = 1.                                  
        if sy-subrc <> 0.                             
           rc = 4.                                    
        endif.                                        
    

    else.
    close dataset file.
    endif.
    endform.


zohebmu (BOB member since 2009-01-08)

Your ABAP can’t work, it has smilies inside the code. :mrgreen:

Just kiddin’

The interesting part is this

append ITAB3. 
ENDSELECT. 
ENDFORM. 

FORM FORM4. 
SORT ITAB3 BY 
STUNR
...
delete adjacent duplicates from ITAB3 comparing all fields.

As you see you have an ITAB there that does overflow. And it comes from the one thing I forgot to mention as a possible reason for an ITAB: the Query has the distinct flag checked in the second tab.

Correct?


Werner Daehn :de: (BOB member since 2004-12-17)

Yes you are correct , there was a distinct selection criteria within the R/3 data flow. After removal of the Distinct, here is the ABAP generated:

REPORT ZAL_ABAP message-id 26 line-size 255
no standard page heading.

  • ZCDCODA.
    PARAMETER DOWNLOAD(1) DEFAULT ‘N’ lower case. "N-svr,Y-clnt
    PARAMETER EXECMODE(1) DEFAULT ‘B’ lower case. "D-dlg,B-btch
    PARAMETER OUT_DIR(48) DEFAULT "output file dir
    ‘/sapcd/temp_report’ lower case.
    PARAMETER IN_DIR(48) DEFAULT "input file dir
    ‘/sapcd/temp_report’ lower case.

PARAMETER P_DF_VK(40) DEFAULT "R/3 Dataflow object key
‘’ lower case.
PARAMETER P_DI_GEN(40) DEFAULT "DI version that generated ABAP
‘’ lower case.

*** Machine generated ABAP. Do not modify. ***
*** Copyright Business Objects Data Integration, Inc. ***
*

  • Date Time:
  • 01/27/09 17:46:35
  • SAP used for generated this ABAP:
  • Release: 620
  • Host : cdsap6d
  • R3 Dataflow Name:
  • R3_CD_Conditionstransdata
  • R3 Dataflow comments:
  • Extracts general material data from TVFST SAP R/3 source sys
    *tem
  • table with descriptions in default language (full extract)
  • ABAP program name in R3:
  • ZCDCODA
  • Generated ABAP file name:
  • D:/DI/ABAP/Conditionstransdata.aba
    TABLES KONV.

DATA: begin of ITAB2 occurs 0,
STUNR(3) TYPE N,
ZAEHK(2) TYPE N,
KPOSN(6) TYPE N,
KNUMV(10) TYPE C,
KSCHL(4) TYPE C,
KPEIN(16) TYPE P DECIMALS 0,
KVSL1(3) TYPE C,
KUMZA(16) TYPE P DECIMALS 0,
KUMNE(16) TYPE P DECIMALS 0,
KWERT(16) TYPE P DECIMALS 2,
KNUMH(10) TYPE C,
KOPOS(2) TYPE N,
KBETR(16) TYPE P DECIMALS 2.
DATA: end of ITAB2.

data: append_flag(1) value ’ ',
cntbuf type i,
delimleng type i.

CONSTANTS C_DF_VK(40) VALUE ‘1773’.
CONSTANTS C_DI_GEN(40) VALUE ‘12.1.0.0’.
DATA WARN_MSG(50).

start-of-selection.

PERFORM FORM2.
PERFORM FORM3.
FREE ITAB2.

end-of-selection.

CLEAR WARN_MSG.

IF NOT P_DF_VK IS INITIAL.
IF P_DF_VK <> C_DF_VK.
CONCATENATE ‘$$Warning$’
C_DF_VK
‘$’ INTO WARN_MSG.
ENDIF.
ENDIF.
IF NOT P_DI_GEN IS INITIAL.
IF P_DI_GEN <> C_DI_GEN.
IF WARN_MSG IS INITIAL.
CONCATENATE ‘$$Warning$$’
C_DI_GEN
INTO WARN_MSG.
ELSE.
CONCATENATE WARN_MSG
C_DI_GEN
INTO WARN_MSG.
ENDIF.
ENDIF.
ENDIF.

IF NOT WARN_MSG IS INITIAL.
IF EXECMODE = ‘D’.
WRITE WARN_MSG.
NEW-LINE.
ELSE.
MESSAGE S000 with WARN_MSG.
ENDIF.
ENDIF.

write ‘* Program Complete *’.
write ‘Copyright Business Objects Data Integration, Inc.’.

FORM FORM2.
DATA ALTMP1(3) TYPE N.
DATA ALTMP2(2) TYPE N.
DATA ALTMP3(6) TYPE N.
DATA ALTMP4(10) TYPE C.
DATA ALTMP5(4) TYPE C.
DATA ALTMP6(16) TYPE P DECIMALS 0.
DATA ALTMP7(3) TYPE C.
DATA ALTMP8(16) TYPE P DECIMALS 0.
DATA ALTMP9(16) TYPE P DECIMALS 0.
DATA ALTMP10(16) TYPE P DECIMALS 2.
DATA ALTMP11(10) TYPE C.
DATA ALTMP12(2) TYPE N.
DATA ALTMP13(16) TYPE P DECIMALS 2.

SELECT
STUNR
ZAEHK
KPOSN
KNUMV
KSCHL
KPEIN
KVSL1
KUMZA
KUMNE
KWERT
KNUMH
KOPOS
KBETR
INTO CORRESPONDING FIELDS OF KONV
FROM KONV
.
ALTMP1 = KONV-STUNR.
ALTMP2 = KONV-ZAEHK.
ALTMP3 = KONV-KPOSN.
ALTMP4 = KONV-KNUMV.
ALTMP5 = KONV-KSCHL.
ALTMP6 = KONV-KPEIN.
ALTMP7 = KONV-KVSL1.
ALTMP8 = KONV-KUMZA.
ALTMP9 = KONV-KUMNE.
ALTMP10 = KONV-KWERT.
ALTMP11 = KONV-KNUMH.
ALTMP12 = KONV-KOPOS.
ALTMP13 = KONV-KBETR.
move ALTMP1 to ITAB2-STUNR.
move ALTMP2 to ITAB2-ZAEHK.
move ALTMP3 to ITAB2-KPOSN.
move ALTMP4 to ITAB2-KNUMV.
move ALTMP5 to ITAB2-KSCHL.
move ALTMP6 to ITAB2-KPEIN.
move ALTMP7 to ITAB2-KVSL1.
move ALTMP8 to ITAB2-KUMZA.
move ALTMP9 to ITAB2-KUMNE.
move ALTMP10 to ITAB2-KWERT.
move ALTMP11 to ITAB2-KNUMH.
move ALTMP12 to ITAB2-KOPOS.
move ALTMP13 to ITAB2-KBETR.
append ITAB2.
cntbuf = cntbuf + 1.
if download = ‘N’.
if cntbuf > 5000.
perform FORM3.
clear cntbuf.
refresh ITAB2.
append_flag = ‘A’.
endif.
endif.
ENDSELECT.
ENDFORM.

FORM FORM3.
data: outfile(128), ldfile(50).
ldfile = ‘Conditionsdata.dat’.
concatenate out_dir ldfile into outfile
separated by ‘/’.
data dlmtlen type i value ‘1’.
data ht(1) type x value ‘7F’.
data return_code type i.
perform write_delimited_file
tables ITAB2
using outfile
append_flag
ht
dlmtlen
download
changing return_code.

case return_code.
when 1.
IF EXECMODE = ‘D’.
WRITE: /5 ‘No line selected’.
ELSE.
MESSAGE E098.
ENDIF.
when 2.
IF EXECMODE = ‘D’.
WRITE: /5 'Open File Error – ', 25 OUTFILE.
ELSE.
MESSAGE E107 WITH OUTFILE.
ENDIF.
when 3.
IF EXECMODE = ‘D’.
WRITE: /5 'Data exceed length limit (8192) '.
ELSE.
MESSAGE E000 WITH
'Data exceed length limit (8192) '.
ENDIF.
when 4.
IF EXECMODE = ‘D’.
WRITE: /5 ‘Call function WS_DOWNLOAD error’.
ELSE.
MESSAGE E000 WITH
‘Call function WS_DOWNLOAD error’.
ENDIF.
endcase.
ENDFORM.

FORM SUBSTRING USING SRC BEG LEN CHANGING RET.

DATA: VA1 TYPE I.
DATA: VA2 TYPE I.
DATA: VA3 TYPE I.

VA3 = STRLEN( SRC ).

IF BEG = 0. VA1 = 0.
ELSE.
IF BEG < 0.
VA1 = VA3 + BEG.
IF VA1 < 0. VA1 = 0.
ENDIF.
ELSE. VA1 = BEG - 1.
ENDIF.
ENDIF.

IF LEN < 0. VA2 = 0.
ELSE. VA2 = VA3 - VA1.
ENDIF.

IF VA2 > LEN. VA2 = LEN.
ENDIF.

IF VA2 < 1. MOVE ‘’ TO RET.
ELSE. MOVE SRC+VA1(VA2) TO RET.
ENDIF.

ENDFORM.

form write_delimited_file
tables datatab
using file
append
delimit
dlength
dwnload
changing rc.

data: type1,
appd(1),
temp(32),
time1(8),
date1(10),
output(8192),
rcount type i,
offset type i,
tablen type i,
maxlen type i value ‘8192’.

data: begin of clientab occurs 0,
output(8192),
end of clientab.

field-symbols: .
field-symbols .
data delim2(16).
data l_filename type string.

appd = append.
if appd is not initial.
appd = ‘X’.
endif.
move file to l_filename.
describe table datatab lines tablen.

if dwnload = ‘Y’.
clear clientab. refresh clientab.
rcount = 0.
else.
if appd = space.
open dataset file for output in text mode ENCODING
DEFAULT.
else.
open dataset file for appending in text mode ENCODING
DEFAULT.
endif.
if sy-subrc <> 0.
rc = 2. exit.
endif.
endif.

loop at datatab.
clear: tablen, offset, output.
do.
assign component sy-index of
structure datatab to .
if sy-subrc <> 0. exit. endif.
if sy-index > 1.
assign delimit(dlength) TO CASTING TYPE C.
delim2 = .
write delim2(dlength) to output+offset(dlength).
add dlength to offset.
endif.

  describe field <f> type type1.                    
                                                    
  if type1 = 'I' or type1 = 'N'.                    
      type1 = 'P'.                                  
  endif.                                            
                                                    
  case type1.                                       
    when 'D'.                                       
      if <f> = '00000000'.                          
         <f> = ' '.                                 
      else.                                         
         move <f> to time1.                         
         assign time1 to <f>.                       
      endif.                                        
    when 'F'.                                       
      if <f> = '0.0'.                               
        temp = '0.0'.                               
      else.                                         
         write <f> to temp exponent 0.              
      endif.                                        
      condense temp no-gaps.                        
      translate temp using ',.'.                    
      assign temp to <f>.                           
    when 'P'.                                       
      if <f> < 0.                                   
         write '-' to output+offset(1).             
         add 1 to offset.                           
         <f> = <f> * ( -1 ).                        
      endif.                                        
      move <f> to temp.                             
      condense temp no-gaps.                        
      translate temp using ',.'.                    
      assign temp to <f>.                           
  endcase.                                          
                                                    
  sy-fdpos = strlen( <f> ).                         
                                                    
  tablen = offset + sy-fdpos.                       
  if tablen > maxlen.                               
     rc = 3. exit.                                  
  endif.                                            
  write <f> to output+offset(sy-fdpos).             
  add sy-fdpos to offset.                           
enddo.                                              
                                                    
if dwnload = 'Y'.                                   
   clientab-output = output.                        
   append clientab.                                 
   rcount = rcount + 1.                             
   if rcount >= 50.                                 
      SY-BATCH = SPACE.                             
      CALL FUNCTION 'GUI_DOWNLOAD'                  
        EXPORTING                                   
          FILENAME = l_filename                     
          FILETYPE = 'ASC'                          
          APPEND   = appd                           
          WRITE_FIELD_SEPARATOR = 'X'               
  •        IMPORTING                                  
    
  •          FILELENGTH =                             
          TABLES                                      
            DATA_TAB = clientab                       
          EXCEPTIONS                                  
            OTHERS = 1.                               
        if sy-subrc <> 0.                             
           rc = 4.                                    
        endif.                                        
        clear clientab. refresh clientab.             
        rcount = 0. appd = 'A'.                       
     endif.                                           
    

    else.
    transfer output to file.
    endif.
    endloop.

    if dwnload = ‘Y’.
    SY-BATCH = SPACE.
    CALL FUNCTION ‘GUI_DOWNLOAD’
    EXPORTING
    FILENAME = l_filename
    FILETYPE = ‘ASC’
    APPEND = appd
    WRITE_FIELD_SEPARATOR = ‘X’

  •     IMPORTING                                     
    
  •       FILELENGTH =                                
       TABLES                                         
         DATA_TAB = clientab                          
       EXCEPTIONS                                     
         OTHERS = 1.                                  
        if sy-subrc <> 0.                             
           rc = 4.                                    
        endif.                                        
    

    else.
    close dataset file.
    endif.
    endform.


zohebmu (BOB member since 2009-01-08)

See, no ITAB and hence no memory consumed anymore.


Werner Daehn :de: (BOB member since 2004-12-17)

Thanks a lot. :smiley:
But I have another issue now, this job keeps running and clusters the sap directory with a 8 gig dat file after 9 hrs and then fails cause thats the disk space allocated to it.
I have asked the admins to increase the space but if this job goes running
this long I need to find better ways of doing this.
Is there a work around or a smarter way of doing this ?

Thanks again


zohebmu (BOB member since 2009-01-08)

KONV is a large table. But do you really need a 1:1 copy with all its rows? If the answer is yes, there is not much you can do about it. Only idea I have is splitting the task, e.g. first run reads all KONV rows where xxx = 1, etc


Werner Daehn :de: (BOB member since 2004-12-17)