Skip to Content
0
Former Member
Oct 25, 2005 at 06:48 PM

BSEG download

805 Views

Hello All,

My program is downloading the bkpf and bseg tables into text files. BKPF works and BSEG is failed in downloading.

Do you have any ideas why?

Here is my code.

DATA: i_bkpf TYPE bkpf OCCURS 0 WITH HEADER LINE,

i_bseg TYPE bseg OCCURS 0 WITH HEADER LINE,

i_payr TYPE payr OCCURS 0 WITH HEADER LINE,

i_lfa1 TYPE lfa1 OCCURS 0 WITH HEADER LINE,

i_lfb1 TYPE lfb1 OCCURS 0 WITH HEADER LINE,

i_t003 TYPE t003 OCCURS 0 WITH HEADER LINE,

i_payr_temp TYPE payr OCCURS 0 WITH HEADER LINE,

i_bkpf_temp TYPE bkpf OCCURS 0 WITH HEADER LINE,

i_bseg_temp TYPE bseg OCCURS 0 WITH HEADER LINE.

DATA: i_rec_count(5),

i_lines like sy-tabix.

FORM bkpf_bseg.

DATA: l_progress TYPE string,

l_count TYPE i,

l_mod TYPE i,

l_char(20).

SELECT * FROM bkpf INTO i_bkpf

WHERE blart IN s_blart and

gjahr in s_gjahr and

budat in s_budat.

SELECT * FROM bseg APPENDING TABLE i_bseg

WHERE bukrs = i_bkpf-bukrs AND

belnr = i_bkpf-belnr AND

gjahr = i_bkpf-gjahr.

APPEND i_bkpf.

ADD 1 TO l_count.

l_mod = l_count MOD 1000.

IF l_mod = 0.

WRITE l_count TO l_char.

CONCATENATE l_char text-c00 INTO l_progress

SEPARATED BY space.

PERFORM progress USING l_progress.

ENDIF.

ENDSELECT.

IF sy-subrc = 0.

PERFORM download USING 'I_BKPF' s_bkpf.

PERFORM download USING 'I_BSEG' s_bseg.

REFRESH: i_bkpf, i_bseg.

ENDIF.

ENDFORM. " bkpf_bseg

FORM download USING p_table p_file.

data: l_file type string,

l_progress(50).

l_file = p_file.

concatenate text-c05 p_table into l_progress separated by space.

perform progress using l_progress.

CASE p_table.

WHEN 'I_BKPF'.

LOOP AT I_BKPF.

ADD 1 TO I_REC_COUNT.

MOVE i_bkpf to i_bkpf_temp.

APPEND i_bkpf_temp.

IF I_REC_COUNT = 50000.

CLEAR I_REC_COUNT.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = l_file

filetype = 'ASC'

write_field_separator = '#'

append = 'X'

TABLES

data_tab = i_bkpf_temp

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 <> 0.

MESSAGE i003(zfi) WITH text-e00 p_table sy-subrc.

ENDIF.

REFRESH i_bkpf_temp.

ENDIF.

ENDLOOP.

  • Check if the total number of entries are less than 50000 at the end of the above loop.

DESCRIBE TABLE i_bkpf_temp lines i_lines.

IF NOT i_lines IS initial.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = l_file

filetype = 'ASC'

write_field_separator = '#'

append = 'X'

TABLES

data_tab = i_bkpf_temp

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 <> 0.

MESSAGE i003(zfi) WITH text-e00 p_table sy-subrc.

ENDIF.

ENDIF.

CLEAR I_REC_COUNT.

REFRESH i_bkpf_temp.

WHEN 'I_BSEG'.

LOOP AT I_BSEG.

ADD 1 TO I_REC_COUNT.

MOVE i_bseg to i_bseg_temp.

APPEND i_bseg_temp.

IF I_REC_COUNT = 50000.

CLEAR I_REC_COUNT.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = l_file

filetype = 'ASC'

write_field_separator = '#'

append = 'X'

TABLES

data_tab = i_bseg_temp

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 <> 0.

MESSAGE i003(zfi) WITH text-e00 p_table sy-subrc.

ENDIF.

REFRESH i_bseg_temp.

ENDIF.

ENDLOOP.

DESCRIBE TABLE i_bseg_temp lines i_lines.

IF NOT i_lines is initial.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = l_file

filetype = 'ASC'

write_field_separator = '#'

append = 'X'

TABLES

data_tab = i_bseg_temp

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 <> 0.

MESSAGE i003(zfi) WITH text-e00 p_table sy-subrc.

ENDIF.

ENDIF.

CLEAR I_REC_COUNT.

REFRESH i_bseg_temp.

ENDFORM.

It downloads for every 50000 records. In the last loop if the records are less than 50000 then these will be

downloaded separately at the end.

In the above i_bkpf_temp has 18000 records and i_bseg_temp has 48000 records.

When it downloads the i_bseg_temp table, it gets hung and gives timeout error message saying program terminated because of other tasks are waiting on resources.

Thanks for the great help.

Sobhan.