This website is not affiliated with, sponsored by, or approved by SAP AG.

Lost DB Cursor after GUI_DOWNLOAD

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Lost DB Cursor after GUI_DOWNLOAD

Postby newitdude » Wed May 13, 2009 2:37 pm

Hi,
I have developed a program that get a huge amount of data from a transparent table and due the company requirements, need to be moved as an PC file in order to send it to someone else.
Because of the amount of data (over 800,000 Records), when loading it into the internal table before doing the gui_download, the program dump due storage problems.
In order to solve this problem, i am doing the following.. select...endselect, and when a certain number of records arrive, the program is doing the gui_download, refresh after it the table and then continue with the next group of records. The problem here is that the pointer is lost after the gui_download.

I have a workaround moving it to the Unix server using open dataset... and then using ftp returning to the PC but my end user want to run the program and automatically move it to his laptop.

Do you know why the pointer is lost after the gui_download. Is there any possibility of fetching again the record

Below is an example (with a common table) in case what i have explained is not clear :(


Hope some of you can gimme some help.
Regards,
NID

Code: Select all
*&---------------------------------------------------------------------*
*& Report  ZFNNTEST01
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZFNNTEST01.
tables: ska1.
data:
e_ska1  type ska1.
constants: c_lines type i value 100.
data: begin of l_output occurs 0,
      l_data type char30000,
      end of l_output.
data: w_start(1) type c.
data: l_data type char30000.
data: w_tabln type i.

Parameters: p_ktopl like ska1-ktopl.


Start-of-selection.
PErform _Get_ska1.
*&---------------------------------------------------------------------*
*&      Form  _GET_SKA1
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form _GET_SKA1 .
MOVE SPACE TO W_START.
FREE L_OUTPUT.
Select *
     into corresponding fields of e_ska1
     from ska1
     where ktopl eq p_ktopl.

    add 1 to w_tabln.
    clear l_output.
    CONCATENATE e_SKA1-KTOPL
                '|'
                e_SKA1-SAKNR
                '|'
                e_SKA1-KTOPL
                '|'
                INTO L_OUTPUT-L_DATA.

    append l_output.


    if w_tabln eq c_lines. "Download Records each c_lines
      move 0 to w_tabln.
      move '1' to w_start.
      perform _dwld_data.
      free l_output.
    endif.


endselect.
endform.                    " _GET_SKA1
*&---------------------------------------------------------------------*
*&      Form  _DWLD_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form _DWLD_DATA .
  data: w_file type string.
  move 'C:\MYTESTFILE.DAT' to w_file.

    call function 'GUI_DOWNLOAD'
      exporting
*   BIN_FILESIZE                    =
        filename                        = w_file
        filetype                        = 'ASC'
    append                          = w_start
        confirm_overwrite               = 'X'
* IMPORTING
*   FILELENGTH                      =
      tables
        data_tab                        = l_output
     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 id sy-msgid type sy-msgty number sy-msgno
              with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.

endform.                    " _DWLD_DATA
newitdude
 
Posts: 1
Joined: Wed May 13, 2009 2:15 pm

Re: Lost DB Cursor after GUI_DOWNLOAD

Postby Gothmog » Thu May 14, 2009 3:01 am

There's probably a commit somewhere.
You could get rid of the SELECT... ENDSELECT loop, and use OPEN CURSOR WITH HOLD.
Then FETCH with a suitable package size, append your file, fetch the next package, etc...
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1941
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: Lost DB Cursor after GUI_DOWNLOAD

Postby CyberSailor » Thu Nov 27, 2014 4:24 am

Hi

I"m using the "with hold" addition and it doesn't help.
I"m still getting the "The database cursor is invalid" error, even if I replace the method call with function call :(
Do I something wrong/missing something or the commit work in gui_download is stronger than "with hold" addition?

My code is:

Code: Select all
Open cursor with hold gv_cursor for select *  from cdpos ORDER BY PRIMARY KEY.

While gv_subrc is initial.
  Try.
    Fetch next cursor gv_cursor
      into table gt_cdpos package size gt_i.
    Gv_subrc = sy-subrc.
  catch CX_SY_OPEN_SQL_DB into gv_root.
    gv_string = gv_root->get_text( ).
    message gv_string type 'E'.
  endtry.
  Check gv_subrc is initial.

  Gv_count = gv_count + 1.
  Perform convert_data.
  Call method cl_gui_frontend_services=>gui_download
    exporting
*      bin_filesize              =
      filename                  = gv_fpath
      filetype                  = 'ASC'
      append                    = space
**      write_field_separator     = 'X'
*      header                    = '00'
**      trunc_trailing_blanks     = 'X'
      write_lf                  = 'X'
    changing
      data_tab                  = gt_text
    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
      not_supported_by_gui      = 22
      error_no_gui              = 23
      others                    = 24
          .
  If sy-subrc <> 0.
   Message id sy-msgid type sy-msgty number sy-msgno
              with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  Endif.
  Check not p_test is initial.
  Gv_div = gv_count div p_test.
  Check not gv_div is initial.
  Exit.
Endwhile.
CyberSailor
 
Posts: 187
Joined: Wed Feb 19, 2003 5:04 am
Location: http://mapa.szukacz.pl/?&n=52,48663&e=16,84831&z=2&t=my%20work

Re: Lost DB Cursor after GUI_DOWNLOAD

Postby Gothmog » Thu Nov 27, 2014 6:47 am

It seems the WITH HOLD addition is only useful in the case of database commits executed in Native SQL. :?
If you can't store the file on the application server using OPEN DATASET instead of GUI_DOWNLOAD, you could try using different SELECT.. UP TO n rows.
ORDER BY PROMARY KEY, read the last key received, and use it as a condition for the next SELECT - no database cursor problem, then.
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1941
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home


Return to ABAP

Who is online

Users browsing this forum: Google [Bot], Google Adsense [Bot] and 5 guests





loading...


This website is not affiliated with, sponsored by, or approved by SAP AG.