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

solutions regarding runtime error

aris_hidalgo
Contributor
0 Likes
924

Hello experts,

I recently had my program transported on prod server and the program produces a run time error. The error pointed out in my sort statement and when I checked the db table where I get the records I found out that it contains almost 3 million recs. So when I sort the itab it causes the run time error. i have posted below my code so you guys can check it out. Any suggestions and comments would be highly appreciated. Thanks a lot guys and take care!

*get all records from table ztm0019 and append to itab.

SELECT * FROM ztm0019

APPENDING TABLE t_ztm0019.

*populate itab t_ztm0019_tmp.

t_ztm0019_tmp[] = t_ztm0019[].

CLEAR t_ztm0019[].

*sort itab according to latest date and time grouped by serial no.

SORT t_ztm0019_tmp BY sernr datum DESCENDING uzeit DESCENDING. "--> here is the error occurs

DELETE ADJACENT DUPLICATES FROM t_ztm0019_tmp COMPARING

sernr

bwart

mblnr.

LOOP AT t_ztm0019_tmp.

*read first record from itab.

READ TABLE t_ztm0019_tmp INDEX sy-index.

IF t_ztm0019_tmp-bwart EQ '702'

OR t_ztm0019_tmp-bwart EQ '708'

OR t_ztm0019_tmp-bwart EQ '712'

OR t_ztm0019_tmp-bwart EQ '718'.

LOOP AT t_ztm0019_tmp WHERE sernr = t_ztm0019_tmp-sernr.

APPEND t_ztm0019_tmp TO t_ztm_acc_variance.

CLEAR t_ztm0019_tmp.

DELETE t_ztm0019_tmp.

ENDLOOP.

ELSE.

APPEND t_ztm0019_tmp TO t_ztm0019.

CLEAR t_ztm0019_tmp.

DELETE t_ztm0019_tmp.

ENDIF.

CONTINUE. " Go for next SERNR

ENDLOOP.

*inserts or updates records in db table ztm_acc_variance based on itab

MODIFY ztm_acc_variance FROM TABLE t_ztm_acc_variance.

*inserts or update unaccounted variances from itab

MODIFY ztm0019 FROM TABLE t_ztm0019.

*deletes records from db table ztm0019 based on matching entries in itab

DELETE ztm0019 FROM TABLE t_ztm_acc_variance.

1 ACCEPTED SOLUTION
Read only

suresh_datti
Active Contributor
0 Likes
905

Hi,

May be you can avoid the SORT by declaring the internal table t_ztm0019 as a SORTED Table.

Regards,

Suresh Datti

8 REPLIES 8
Read only

suresh_datti
Active Contributor
0 Likes
906

Hi,

May be you can avoid the SORT by declaring the internal table t_ztm0019 as a SORTED Table.

Regards,

Suresh Datti

Read only

0 Likes
905

Hi Suresh,

Howe can I make my itab as a sorted table? Also, If you notice my select statement above, the itab already has a record and I am appending all the records from the db table.

Read only

0 Likes
905

What is the error?

Read only

0 Likes
905

Hello,

here is the error:

The current ABAP/4 program was meant to sort a dataset (internal table or extract) for reasons of capacity, this was not possible due to to insufficient main storage space. Therefore, the external sort was called and resulted in the follwing error:

the system could not write the sorted file to the temporary file /usr/sap/prd...

Read only

0 Likes
905

Viray,

Your production system does not have enough physical (or available) memory at the time that you are running your program.

If possible, run the program on a specific server that has a larger amount of memory (or ask your company to buy more memory... good luck).

Or... if possible, reduce the fields that are returned from your SELECT statement. If not ALL of them are required in your business logic, you can reduce memory usage dramatically (especially with 3M+ records) when you only return the required fields.

Meaning instead of -

SELECT * from ZXXXXXX

do a

SELECT FIELD1 FIELD2 FIELD3 FIELD4 from ZXXXXX

Read only

0 Likes
905

OR....

you could try to select into 2 separate internal tables. In these SELECTS, use the ORDER BY clause to make the DB server do the sorting for you.

This MIGHT still not work if your app servers are weak, though. But it is worth a try.

Reward points accordingly.

Read only

Former Member
0 Likes
905

HI Viray,

if you think that gives you problem..

then try this,,

SELECT * FROM ztm0019
APPENDING TABLE t_ztm0019.

*populate itab t_ztm0019_tmp.
loop at t_ztm0019.
  APPEND t_ztm0019 TO t_ztm0019_tmp SORTED BY sernr datum .
endloop.

here it is sorted by descending order ..

regards

satesh

Read only

Former Member
0 Likes
905

HI viraylab,

I think that your program is not any issue. If you can run it in your development server but it not display any error. I agree with John's viewpoint. I think you should connect with your basic. good luck.