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: 

GUI DOWNLOAD: Splitt Data into Several FIles

Former Member
0 Kudos

Hello,

I would like to download data using the Frond End Service (Class <b>cl_gui_frontend_services</b>) with the method <b>GUI_DOWNLOAD</b>.

In the ABAP side I have a internal table with the relevant information to be downloaded. The data shall not be downloaded at once (because of the large file size); the idea is to “split” the data into packages.

Is there any possibility to split the data into several files? Is the GUI service able to split the data automatically in several files?

Thank you for your help in advance.

Best regards,

Kurt.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

*C-- Have a look.

REPORT ZZDYNFIELDDATE .

DATA : T_MARD TYPE STANDARD TABLE OF MARD.

DATA : T_MARD1 TYPE STANDARD TABLE OF MARD.

SELECT * FROM MARD

INTO TABLE T_MARD UP TO 100 ROWS.

DATA : L_INDEX TYPE SY-INDEX,

L_INDEX1 TYPE SY-INDEX.

T_MARD1[] = T_MARD[].

DELETE T_MARD FROM 51 TO 100.

PERFORM CALL_DOWNLOAD.

T_MARD[] = T_MARD1[].

DELETE T_MARD FROM 1 TO 50.

PERFORM CALL_DOWNLOAD.

&----


*& Form call_download

&----


  • text

----


FORM CALL_DOWNLOAD.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = 'C:\test.txt'

FILETYPE = 'ASC'

APPEND = 'X'

TABLES

DATA_TAB = T_MARD.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. "call_download

4 REPLIES 4

Former Member
0 Kudos

No it can not automatically split for you.

You must code a conditional operation for this.

Something like this:

data: cnt type i.

cnt = 0.

loop at MyTable. "original table with all recs

append MyTable to Output_Tbl. "smaller table to be output

cnt = cnt + 1.

if cnt > 10000. "put 10,000 records per file

  • call gui_download now.

cnt = 0.

endif.

endloop.

0 Kudos

Check out this sample, it will get 1000 records from mara, and write a file for every 100 records.



report zrich_0001 .

data: imara type table of mara with header line.

data: iout type table of mara.
data: xout type mara.
data: tab_number(4) type c.
data: file_name type string.
data: tabix(4) type c.

start-of-selection.


  select * from mara into table imara
              up to 1000 rows.


  loop at imara.
    tabix = sy-tabix.

    xout = imara.
    append xout to iout.

    tab_number =  tabix mod 100.

    if tab_number = 0.

      concatenate 'C:output'  tabix '.txt' into file_name.

      call method cl_gui_frontend_services=>gui_download
        exporting
          filename                = file_name
        changing
          data_tab                = iout
        exceptions
          others                  = 22.
      clear iout.  refresh iout.
      clear xout.

    endif.

  endloop.


Regards,

Rich Heilman

Former Member
0 Kudos

*C-- Have a look.

REPORT ZZDYNFIELDDATE .

DATA : T_MARD TYPE STANDARD TABLE OF MARD.

DATA : T_MARD1 TYPE STANDARD TABLE OF MARD.

SELECT * FROM MARD

INTO TABLE T_MARD UP TO 100 ROWS.

DATA : L_INDEX TYPE SY-INDEX,

L_INDEX1 TYPE SY-INDEX.

T_MARD1[] = T_MARD[].

DELETE T_MARD FROM 51 TO 100.

PERFORM CALL_DOWNLOAD.

T_MARD[] = T_MARD1[].

DELETE T_MARD FROM 1 TO 50.

PERFORM CALL_DOWNLOAD.

&----


*& Form call_download

&----


  • text

----


FORM CALL_DOWNLOAD.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = 'C:\test.txt'

FILETYPE = 'ASC'

APPEND = 'X'

TABLES

DATA_TAB = T_MARD.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. "call_download

0 Kudos

Hello all,

thank you very much for your quick and valuable answer:-)

Best regards,

Kurt.