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

lost data when using open dataset

Former Member
0 Likes
1,924

Dears,

when i use open dataset to write data to application server, st i found some datas are lost.

And then i use wait 5 seconds before close dataset, and the problem is solved.

But now two lines data lost again, what is the best mechanism to handle this ?

BR.

1 ACCEPTED SOLUTION
Read only

Clemenss
Active Contributor
0 Likes
1,361

Hi IBM China,

did you CLOSE DATASET <file> after transfer? This will flush any buffer.

BTW: Micosoft server? - most probably.

Regargs,

Clemens

9 REPLIES 9
Read only

Former Member
0 Likes
1,361

Hello,

may be ur data is not updated completely.

increase wait.

Regards.

Read only

Clemenss
Active Contributor
0 Likes
1,362

Hi IBM China,

did you CLOSE DATASET <file> after transfer? This will flush any buffer.

BTW: Micosoft server? - most probably.

Regargs,

Clemens

Read only

Former Member
0 Likes
1,361

Dears,

UNIX server.

i did close action. i am not very sure of such kind that add more waiting seconds and maybe better method exists, ths

Read only

Former Member
0 Likes
1,361

How are determining that the data is lost? Are you looking at the file using another application from outside of SAP? You have to wait for your program to complete the file creation with the CLOSE DATASET and exit out completely that issues a commit.

Read only

0 Likes
1,361

with TCODE AL11, en.., maybe i could try commit work

Read only

0 Likes
1,361

AL11 has limitations on how much it can display in terms of length of the record. Is your data loss happening at the end of the record or in the total number of records?

Read only

0 Likes
1,361

records not so much.

yeah, the two problem are both exist for this case.

BTW, in debug mode the file is complete. Then i add wait 5 seconds, and now st this error still happens.

Read only

0 Likes
1,361

Hi IBM China,

I do not trust AL11 too much.

Did you try to OPEN DATASET and the read back the contents - just to compare?

A nice tool is FUNCTION 'ARCHIVFILE_SERVER_TO_CLIENT'. Use it from SE37 to download the file contents to your PC. The look what you really got.

You may use these two forms to read and display a server file:


*&---------------------------------------------------------------------*
*&      Form  read_file
*&---------------------------------------------------------------------*
*       File lesen in String-Table das letzte im Bauch behalten
*----------------------------------------------------------------------*
*      -->P_FILE
*      <--PT_STR
*----------------------------------------------------------------------*
FORM read_file  USING    p_file TYPE file
                CHANGING pt_str TYPE typ_t_string
                         p_maxs TYPE sytleng.
  STATICS:
    l_file TYPE file,
    l_maxs TYPE sytleng,
    lt_str TYPE typ_t_string.
  DATA:
    l_str TYPE string,
    l_len TYPE sytleng.
* Nur zwischenzeitliche Änderungen wären ärgerlich
  IF p_file <> l_file.
    l_file = p_file.
    CLEAR: l_maxs, lt_str.
    OPEN DATASET p_file IN TEXT MODE ENCODING DEFAULT FOR INPUT
      IGNORING CONVERSION ERRORS.
    WHILE sy-subrc = 0.
      READ DATASET p_file INTO l_str LENGTH l_len.
      CHECK sy-subrc = 0.
      IF l_len > l_maxs.
        l_maxs =  l_len.
      ENDIF." l_len > l_maxs.
      APPEND l_str TO lt_str.
    ENDWHILE." sy-subrc = 0.
    CLOSE DATASET p_file.
  ENDIF." p_file <> l_file.
  pt_str = lt_str.
  p_maxs = l_maxs.
ENDFORM.                    " read_file
*&---------------------------------------------------------------------*
*&      Form  showcontent
*&---------------------------------------------------------------------*
*       Anzeige im Control
*----------------------------------------------------------------------*
*      -->PT_DATA
*----------------------------------------------------------------------*
FORM showcontent  USING    pt_data TYPE table
                           p_name  TYPE file
                           p_max   TYPE sytleng.
  STATICS:
    l_top TYPE i VALUE 50,
    l_left TYPE i VALUE 100.
  DATA:
    l_caption  TYPE sylisel,
    l_wordwrap TYPE sytleng,
    l_height   TYPE sytleng,
    l_width    TYPE sytleng,
    l_repid    TYPE syrepid.
  FIELD-SYMBOLS:
    <f> TYPE ANY.
  l_repid = sy-repid.
* damit die boxes nicht genau übereinander liegen
  ADD 5 TO: l_top, l_left.
* Darstellung in max Breite
  l_width = 9 * p_max.
  IF l_width > 1000.
    l_width = 800.
  ENDIF." l_width > 1000.
  DESCRIBE TABLE pt_data LINES sy-tfill.
  l_height = 10 * sy-tfill + 60.
  IF l_height > 400.
    l_height = 300.
  ENDIF." l_height > 1000.
* ggf. Tabelle beschneiden
  PERFORM check_restrict_size CHANGING pt_data.
  CHECK NOT  pt_data IS INITIAL.
  READ TABLE pt_data INDEX 1 ASSIGNING <f>.
  DESCRIBE FIELD <f> LENGTH l_wordwrap IN BYTE MODE.
  l_wordwrap = p_max.
  WRITE p_max TO l_caption LEFT-JUSTIFIED.
  CONCATENATE p_name '(MaxLineLen.' l_caption ')' INTO l_caption
    SEPARATED BY space.
  CREATE OBJECT go_dialogbox
     EXPORTING
       width                     = l_width
       height                    = l_height
     top                         = l_top
     left                        = l_left
     caption                     = l_caption.
  CREATE OBJECT go_event_receiver.
  SET HANDLER go_event_receiver->close FOR go_dialogbox.

  CREATE OBJECT go_editor
    EXPORTING
      parent                     = go_dialogbox"ccc
      wordwrap_mode
        = cl_gui_textedit=>wordwrap_off "wordwrap_at_fixed_position
*        wordwrap_position          = l_wordwrap
      wordwrap_to_linebreak_mode = cl_gui_textedit=>true.

  CALL METHOD go_editor->set_toolbar_mode
    EXPORTING
      toolbar_mode = go_editor->true.
  CALL METHOD go_editor->set_statusbar_mode
    EXPORTING
      statusbar_mode = go_editor->true.
* Set edit mode
  CALL METHOD go_editor->set_readonly_mode.
*   send table to control
  CALL METHOD go_editor->set_font_fixed
    EXPORTING
      mode = cl_gui_textedit=>true.
  CALL METHOD go_editor->set_text_as_r3table
    EXPORTING
      table = pt_data.
* finally flush
  CALL METHOD cl_gui_cfw=>flush
    EXCEPTIONS
      OTHERS = 1.
ENDFORM.                    " showcontent

Regards

Clemens

Read only

Former Member
0 Likes
1,361

can you post your code so we may get if something needed to change, as i never faced this problem with datasets