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: 

ABAP Read dataset character limitations

former_member599326
Participant
0 Kudos
1,392

I am using statement READ DATASET lv_file INTO lv_data. I have total 10713 characters in line. But it is not reading all the characters. It truncates after 256 characters. Is there any solution to read all the 10713 characters in line.

REPORT z_fvi_l2bs.

***********************************************************************

* TABLES

***********************************************************************

TABLES : adr6.

***********************************************************************

* GLOBAL VARIABLE DECLARATIONS

***********************************************************************

DATA : directory(30),

lv_file TYPE rlgrap-filename,

lv_data TYPE string.

TYPES:BEGIN OF ty_file,

var1 type string,

END OF ty_file.

DATA : gt_file TYPE TABLE OF ty_file,

gs_file LIKE LINE OF gt_file.

FIELD-SYMBOLS : <fs_file> TYPE ty_file.

***********************************************************************

* SELECTION-SCREEN

***********************************************************************

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS: p_dt TYPE sy-datum OBLIGATORY DEFAULT sy-datum,

p_app_s TYPE rlgrap-filename OBLIGATORY.

SELECT-OPTIONS : s_toid FOR adr6-smtp_addr NO INTERVALS.

SELECTION-SCREEN END OF BLOCK b1.

***********************************************************************

* START OF SELECTION

***********************************************************************

START-OF-SELECTION.

PERFORM read_appserver_file.

*&---------------------------------------------------------------------*

*& Form READ_APPSERVER_FILE

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM read_appserver_file .

REFRESH gt_file.

CLEAR gs_file.

CLEAR lv_file.

lv_file = p_app_s.

CLEAR lv_data.

OPEN DATASET lv_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc EQ 0.

DO.

READ DATASET lv_file INTO lv_data.

IF sy-subrc EQ 0.

gs_file-var1 = lv_data.

APPEND gs_file TO gt_file.

CLEAR gs_file.

ELSE.

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET lv_file.

ELSE.

MESSAGE 'unable to open the file' TYPE 'I'.

ENDIF.

ENDFORM. " READ_APPSERVER_FILE

1 ACCEPTED SOLUTION

former_member599326
Participant
1,249

this is resolved. I transfer the file to AL11 in binary mode through tcode 'CG3Z'. Earlier I was transferring through ASC mode.

12 REPLIES 12

matt
Active Contributor
1,249

In the question editor there is a handy button "code". If you use that your code can be nicely formatted and easier to read.

By the way, you do that FORMs are obsolete. And if you're going to use prefixes, like L for local variables, don't defined them as globals.

SURYA_ABAP
Participant
0 Kudos
1,249

Hi santosh.b2,

Try this, not sure.

LV_DATA type C length 30000.

0 Kudos
1,249

The OP has defined DATA like below, which is sufficient, no need to use type C:

lv_data TYPE string.

Sandra_Rossi
Active Contributor
1,249

Your code is fine. I think you're wrong when you say "It truncates after 256 characters." How did you come to this conclusion? (debugger? The default debug view/dynpro truncates at 256 characters)

0 Kudos
1,249

then how can i transfer all the line data to internal table fields?

e.g.

READ DATASET lv_file INTO lv_data.

IF sy-subrc EQ 0.

gs_file-var1 = lv_data+10500(5). " this statement not working, no data comes to gs_file-var1.

APPEND gs_file TO gt_file.

also below statement not working...

data : gv_no type i.
loop at gt_file ASSIGNING <fs_file>.
gv_no = <fs_file>-var1+10685(6).
ENDLOOP.

0 Kudos
1,249

You answer to my question with another question, so it will be difficult to help you more...

Maybe you are mistaken by the content of your file because it contains LF in a middle of a line and your lines end with CRLF. Please attach your file so that people can help you troubleshoot your issue.

0 Kudos
1,249
test-new.txt

Thanks for your reply. file attached herewith.

0 Kudos
1,249

this is cobol generated file

0 Kudos
1,249

Your file is just one line, there are no CRLF inside it. So, I guess that you read the whole file in just one READ, and you are mislead by the debugger default view which makes you think that you read only 256 characters, so we're back to the initial situation of my comment. Surendra answered how the debugger works, I hope it's clear to you now.

SURYA_ABAP
Participant
1,249

Hi santosh.b2,,

You can view data in debugging by changing view from text to tabular format,

former_member599326
Participant
1,250

this is resolved. I transfer the file to AL11 in binary mode through tcode 'CG3Z'. Earlier I was transferring through ASC mode.

1,249

Thanks for the feedback.

So your program was fine, it was your file that you didn't load correctly on the server.

As you have seen, CG3Y and CG3Z are very limited. They should be used only with EH&S module (Environment, Health & Safety) as explained in the note 1949906 - Download and upload of files. Folder which can be used on the server is restricted, ASC mode truncates lines at 256 characters, ASC mode converts LF/CRLF and may change the character encoding of characters, and using the BIN mode leaves the file unchanged but may lead to having files not in the right character encoding/not the right LF/CRLF characters.