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

Read Dataset problem??

Former Member
0 Likes
930

Hi All,

I am getting a short dump when I try "READ DATASET g_unixfile INTO internal-table." to read a file into an internal table.

I have opened the file using th code>>"OPEN DATASET g_unixfile FOR INPUT IN TEXT MODE ENCODING DEFAULT."

and closed it using>>"CLOSE DATASET g_unixfile."

I have used the G_unixfile as 104 Characters and internal table as:

DATA: BEGIN OF g_t_tdata OCCURS 50,

g_recdata(104),

END OF g_t_tdata.

Please can anyone tell why I am getting a Dump?? at Read dataset??

Regards,

Shashank.

8 REPLIES 8
Read only

Former Member
0 Likes
899

Can you see what is the SY_SUBRC value returned after OPEN DATASET.

That might be 4 and because of this READ is failing.

Also make sure that file exists at the specified location.

ashish

Read only

Former Member
0 Likes
899

hi,

Try increasing the size of the field of Internal table to fit the data in the file. So just check it out in this way

DATA: BEGIN OF g_t_tdata OCCURS 50,

g_recdata<b>(2000)</b>,

END OF g_t_tdata.

Read only

Former Member
0 Likes
899

Hi,

Can you paste your whole code?

Regards,

Atish

Read only

0 Likes
899

Hi Atish,

This is whole MAIN code.

Its syntatically correct but giving dump....on execution.

CODE>>

DATA: g_eventid LIKE tbtco-eventid,

g_eventparm LIKE tbtcm-eventparm.

DATA: g_file(30).

DATA: g_file1(10).

****Changes made later******

DATA: g_unixfile(104) TYPE c, " Unix File Name

g_unixfile1(104) TYPE c,

g_old_filename TYPE string,

g_new_unixfilename(80),

g_zzadirect LIKE filename-pathintern.

DATA: BEGIN OF g_t_tdata OCCURS 50, " Upload data into this itab

g_recdata(104),

END OF g_t_tdata.

****Changes made later******

                          • Selection screen>>

PARAMETERS : p_direct LIKE filepath-pathintern OBLIGATORY DEFAULT 'ZIN_COMPLETE'." Unix Directory

PARAMETERS :p_filenm LIKE t9aif-zzafilenam OBLIGATORY DEFAULT 'AFS.FNBLOD.4310.DATE.TIME'. " File Name

*************CONSTANTS

CONSTANTS : c_zzaibfform(2) VALUE 'LA'.

**********START-OF-SELECTION****************

START-OF-SELECTION.

g_file = p_filenm.

g_file1 = g_file+11(4).

****Changes made later******

SELECT SINGLE zzadirect INTO g_zzadirect

FROM t9aig

WHERE zzaibfform EQ c_zzaibfform.

  • IF sy-subrc = 0.

MOVE p_filenm TO g_old_filename.

CALL FUNCTION 'FILE_GET_NAME_USING_PATH'

EXPORTING

logical_path = g_zzadirect

file_name = g_old_filename

IMPORTING

file_name_with_path = g_unixfile

EXCEPTIONS

path_not_found = 1

missing_parameter = 2

operating_system_not_found = 3

file_system_not_found = 4

OTHERS = 5.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

OPEN DATASET g_unixfile FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc NE 0.

MESSAGE e099 WITH text-011.

ENDIF.

CONCATENATE 'AFS.FNBPFI.' g_file1 '.LOAD.TXT' INTO g_new_unixfilename.

CALL FUNCTION 'FILE_GET_NAME_USING_PATH'

EXPORTING

logical_path = g_zzadirect

file_name = g_new_unixfilename

IMPORTING

file_name_with_path = g_unixfile1

EXCEPTIONS

path_not_found = 1

missing_parameter = 2

operating_system_not_found = 3

file_system_not_found = 4

OTHERS = 5.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

  • Open the data files.

OPEN DATASET g_unixfile1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc NE 0.

MESSAGE e099 WITH text-012.

ENDIF.

  • Extract the data from input data file and store in to new data file

DO.

READ DATASET g_unixfile INTO g_t_tdata-g_recdata.

IF sy-subrc <> 0.

EXIT.

ENDIF.

TRANSFER g_t_tdata-g_recdata TO g_unixfile1.

ENDDO.

CLOSE DATASET g_unixfile.

CLOSE DATASET g_unixfile1.

Read only

0 Likes
899

Hi,

Try by increasing field length

DATA: BEGIN OF g_t_tdata OCCURS 50, " Upload data into this itab

g_recdata(2000),

END OF g_t_tdata.

Regards,

Atish

Read only

0 Likes
899

I tried but doesnt work.....

Read only

0 Likes
899

What is the error being reported by the dump?

Rob

Read only

0 Likes
899

Hi Shashank,

Can you remove ENCODING DEFAULT and try.

Regards,

Atish