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: 

How to read partial file from application server

Former Member
0 Kudos

Experts,

I have a file in app server which is having around 600,000 records, needs to be apload into SAP.

While uploading the file i am getting dump due to insufficeint memory of my ITAB.

I am getting error something like "No more storage space available for extending an internal table."

So i wanted to Change my program logic to implement block processing like read a block, process, clear internal tables, read next block, etc.

My question is how to read app server file by BLOCK wise like want to read like 100,000 in first loop and 100,001 to 200,000 in second loop and so on...

Any syntax would be a great help.

or If you could share any sample program would also be great help.

Thanks

kaki

1 ACCEPTED SOLUTION

Former Member
0 Kudos

HI,

Maybe this could be of any help;

DATA: l_pos TYPE i,

l_no_of_loops TYPE i,

reclen TYPE i VALUE 100,

fname(80) TYPE C.

PERFORM read_file. " Do this until EOF

FORM read_file.

l_pos = 10000 * l_no_of_loops * reclen.

OPEN DATASET fname FOR INPUT IN BINARY MODE AT POSITION l_pos.

DO 10000 TIMES.

READ DATASET fname INTO wa_ftp_table.

APPEND wa_ftp_table TO it_ftp_table.

ENDDO.

l_no_of_pos = l_no_pos + 1.

  • Take care of the data read into the internale table.

FREE it_ftp_table.

ENDFORM.

7 REPLIES 7

Former Member
0 Kudos

Something like:

OPEN...
DO...
  if count > 10000
    process itab
    refresh itab
    count = 0.
  endif.
  READ...
  if sy-subrc <> 0.
    exit.
  endif.
ENDDO.

Rob

0 Kudos

Hi Rob,

My existing code is like this. Pls help how to approach.

DO.

READ DATASET G_GET_FILE INTO FTP_FILE.

IF SY-SUBRC = 0.

APPEND FTP_FILE.

CLEAR FTP_FILE.

ELSE.

EXIT.

ENDIF.

ENDDO.

0 Kudos

Hi,

If you want to read first 100 lines only .. then write as ...

DO 100 times.

READ DATASET G_GET_FILE INTO FTP_FILE.

IF SY-SUBRC = 0.

APPEND FTP_FILE.

CLEAR FTP_FILE.

ENDIF.

ENDDO.

Regards,

Srini.

0 Kudos

Rob told you how to do....Surely, he doesn't need to also write the code for you.

Former Member
0 Kudos

HI,

Maybe this could be of any help;

DATA: l_pos TYPE i,

l_no_of_loops TYPE i,

reclen TYPE i VALUE 100,

fname(80) TYPE C.

PERFORM read_file. " Do this until EOF

FORM read_file.

l_pos = 10000 * l_no_of_loops * reclen.

OPEN DATASET fname FOR INPUT IN BINARY MODE AT POSITION l_pos.

DO 10000 TIMES.

READ DATASET fname INTO wa_ftp_table.

APPEND wa_ftp_table TO it_ftp_table.

ENDDO.

l_no_of_pos = l_no_pos + 1.

  • Take care of the data read into the internale table.

FREE it_ftp_table.

ENDFORM.

0 Kudos

Hi Andreas,

Your logic is helped. Rewarded.

Thanks

Former Member
0 Kudos

Have a F1 look on OPEN DATASET.

You can open a dataset at a specific position using AT POSITION.

Thus enabling you to read and process in blocks.

-


Please hug me!