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: 

open dataset dump.

Former Member
0 Kudos

hi guys,

I am getting OPEN DATASET SHORTDUMP using below code.

can somebody suggest me alteration of code..

Dump says error in READ statement.

DATA : BEGIN OF IT_EDIT OCCURS 0,

CNO(5) TYPE C,

DATE(8) TYPE C,

VENDOR(10) TYPE C,

MATERIAL(18) TYPE C,

STARTDT(8) TYPE C,

ENDDT(8) TYPE C,

QUANTITY(13) TYPE N,

END OF IT_EDIT.

OPEN DATASET P_INFILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.

DO.

IF NOT SY-SUBRC IS INITIAL.

EXIT.

ELSE.

<b> READ DATASET P_OUFILE INTO IT_EDIT.</b>

APPEND IT_EDIT.

ENDIF.

ENDDO.

CLOSE DATASET P_OUFILE.

Regards

Chandra.

1 ACCEPTED SOLUTION

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

From your code,I understood that you are opening p_infile for input using open dataset.

But closed p_oufile using close_dataset.

6 REPLIES 6

Former Member
0 Kudos

hi Chan,

Declare <b>P_OUFILE</b> as RLGRAP-FILENAME.

i.e,


<b>data : P_OUFILE like RLGRAP-FILENAME.</b>

Regards,

Santosh

Former Member
0 Kudos

Hi,

Post the short dump description..

Thanks,

Naren

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

From your code,I understood that you are opening p_infile for input using open dataset.

But closed p_oufile using close_dataset.

Former Member
0 Kudos

Hi Ambi

As i can see that you are trying to open the dataset for <b>downloading</b> the data, in this case proceed as follows:

  open dataset p_file for <b>input</b> in text mode encoding default.
  if sy-subrc ne 0.
*** Error Message
  else.
*** Supposing itab has the records to be downloaded and 
***   <wa> is the workarea
    loop at itab into <wa>.
         transfer <wa> to p_file.
    endloop.
    close dataset p_file.
  endif.


  Incase of <b>uploading</b> the code should be something like below:

  open dataset p_file for <b>output</b> in text mode encoding default.
  if sy-subrc ne 0.
*** Error Message
  else.
    do.
       read dataset p_file into <wa>.
       if sy-subrc ne 0.
          exit.
       else.
          append <wa> to itab.
       endif.
    enddo.
    close dataset p_file.
  endif.

Hope the above info can give you some idea.

Kind Regards

Eswar

anversha_s
Active Contributor
0 Kudos

hi,

pls chk this sample code.

report zfiles_0001.

Parameters: d1 type localfile default '/usr/sap/TST/SYS/Data1.txt',

d2 type localfile default '/usr/sap/TST/SYS/Data2.txt'.

data: itab type table of string.

data: wa type string.

start-of-selection.

  • Read file

open dataset d1 for input in text mode.

if sy-subrc = 0.

do.

read dataset d1 into wa.

if sy-subrc <> 0.

exit.

endif.

append wa to itab.

enddo.

endif.

close dataset d1.

  • Copy to new file

open dataset d2 for output in text mode.

loop at itab into wa.

transfer wa to d2.

endloop.

close dataset d2.

  • Delete the first

delete dataset d1.

regards

anver

if hlpful pls mark points

Former Member
0 Kudos

hi ambi,

Try out this...

Declare p_infile with LOWER CASE addition, as each and every Unix command must be in lowercase.

Thanks

Vinny