2013 Nov 04 4:03 PM
Hi AbapGurus,
I have a ".txt" file in application server as shown below (headings are not there, only for reference provided here): -
PO_NUMBER PO_ITEM ACCTASSCAT ITEM_CAT MATERIAL SHORT_TEXT ITEM_TEXT QUANTITY PO_UNIT NET_PRICE MAT_GRP PLANT STGE_LOC DELIVERY_DATE
101#10#K#D#repair of machine#"Para 1
Call for Papers...
some more texts...
.....Very long text.....
........
#1#AU#500#01#1001#IM01#8/12/2013
I have a internal table in my program, the field ITEM_TEXT are of string/char(50000) type.
Now during reading file from application server using READ DATASET, it is giving dump.
I have used statements like this.
DATA ls_TEXT(5000) TYPE C.
** Opening file on application server
OPEN DATASET lv_filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc IS INITIAL.
DO.
READ DATASET lv_filename INTO ls_TEXT.
IF sy-subrc IS INITIAL.
** Spliting file into fields and then appending to form a internal table
SPLIT ls_TEXT AT cl_abap_char_utilities=>horizontal_tab INTO
gs_poitem-po_number
gs_poitem-po_item
gs_poitem-acctasscat
gs_poitem-item_cat
gs_poitem-material
gs_poitem-short_text
gs_poitem-item_text
gs_poitem-quantity
gs_poitem-po_unit
gs_poitem-net_price
gs_poitem-mat_grp
gs_poitem-plant
gs_poitem-stge_loc
gs_poitem-delivery_date.
APPEND gs_poitem TO gt_poitem.
CLEAR gs_poitem.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
Now the good thing is when it found # then it split into other fields, which is fine. but problem is when it found "Enter / New line" in ITEM_TEXT field then again it splits into other fields, which is wrong.
Also if I change "cl_abap_char_utilities=>horizontal_tab" to "#" then it doesn't split.
So Gurus, how can I read file from application server having one field containing very long text in internal table. or is there any other work around to read file.
If a sample code is there then it would be great helpful.
Regards,
Hi AbapGurus,
I have a ".txt" file in application server as shown below (headings are not there, only for reference provided here): -
PO_NUMBER PO_ITEM ACCTASSCAT ITEM_CAT MATERIAL SHORT_TEXT ITEM_TEXT QUANTITY PO_UNIT NET_PRICE MAT_GRP PLANT STGE_LOC DELIVERY_DATE
101#10#K#D#repair of machine#"Para 1
Call for Papers...
some more texts...
.....Very long text.....
........
#1#AU#500#01#1001#IM01#8/12/2013
I have a internal table in my program, the field ITEM_TEXT are of string/char(50000) type.
Now during reading file from application server using READ DATASET, it is giving dump.
I have used statements like this.
DATA ls_TEXT(5000) TYPE C.
** Opening file on application server
OPEN DATASET lv_filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc IS INITIAL.
DO.
READ DATASET lv_filename INTO ls_TEXT.
IF sy-subrc IS INITIAL.
** Spliting file into fields and then appending to form a internal table
SPLIT ls_TEXT AT cl_abap_char_utilities=>horizontal_tab INTO
gs_poitem-po_number
gs_poitem-po_item
gs_poitem-acctasscat
gs_poitem-item_cat
gs_poitem-material
gs_poitem-short_text
gs_poitem-item_text
gs_poitem-quantity
gs_poitem-po_unit
gs_poitem-net_price
gs_poitem-mat_grp
gs_poitem-plant
gs_poitem-stge_loc
gs_poitem-delivery_date.
APPEND gs_poitem TO gt_poitem.
CLEAR gs_poitem.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
Now the good thing is when it found # then it split into other fields, which is fine. but problem is when it found "Enter / New line" in ITEM_TEXT field then again it splits into other fields, which is wrong.
Also if I change "cl_abap_char_utilities=>horizontal_tab" to "#" then it doesn't split.
So Gurus, how can I read file from application server having one field containing very long text in internal table. or is there any other work around to read file.
If a sample code is there then it would be great helpful.
Regards,
2013 Nov 04 4:24 PM
I have a feeling there is a limit of 1000 chars, but I may be wrong. Could you post your dump message (ST22) here so that I can delve further.
Also there is a difference anyway in your declaration:
I have a internal table in my program, the field ITEM_TEXT are of string/char(50000) type.
Now during reading file from application server using READ DATASET, it is giving dump.
I have used statements like this.
DATA ls_TEXT(5000) TYPE C.
** Opening file on application server
OPEN DATASET lv_filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc IS INITIAL.
DO.
READ DATASET lv_filename INTO ls_TEXT.
2013 Nov 04 5:41 PM
Thanks Anthony !!
the dump is : -
Short text
A character set conversion is not possible.
What happened?
At the conversion of a text from codepage '4110' to codepage '4103':
- a character was found that cannot be displayed in one of the two
codepages;
- or it was detected that this conversion is not supported
The running ABAP program 'ZPO_UPLOAD' had to be terminated as the
conversion
would have produced incorrect data.
The number of characters that could not be displayed (and therefore not
be converted), is 1. If this number is 0, the second error case, as
mentioned above, has occurred.
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_CONVERSION_CODEPAGE', was not
caught in
procedure "READ_FILE" "(FORM)", nor was it propagated by a RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
Characters are always displayed in only a certain codepage. Many
codepages only define a limited set of characters. If a text from a
codepage should be converted into another codepage, and if this text
contains characters that are not defined in one of the two codepages, a
conversion error occurs.
Moreover, a conversion error can occur if one of the needed codepages
'4110' or '4103' is not known to the system.
If the conversion error occurred at read or write of screen, the file
name was 'T:\Load_Files\PO Item.txt'. (further information about the
file: "X 1563").
2013 Nov 04 4:34 PM
2013 Nov 04 6:13 PM
Hi Anthony,
if I use variant IGNORING CONVERSION ERRORS in OPEN DATASET statement then dump will lost but the problem is when it split at # first line comes fine in internal table but other lines goes wrong. System breaks ITEM_TEXT field at Enter and append in other field (here in PO_NUMBER). like as shown below: -
PO_NUMBER PO_ITEM ACCTASSCAT ITEM_CAT MATERIAL SHORT_TEXT ITEM_TEXT QUANTITY PO_UNIT NET_PRICE MAT_GRP PLANT STGE_LOC DELIVERY_DATE
101 10 K D repairs "Para 1. " Coming correct in internal table
Call for P
Fusion 201
New call f
The call f
Fusion is
* Internat
* Internat
* National
* The Asso
All text comes in first PO_NUMBER field rather than ITEM_TEXT field in form of many rows in internal table.
however it should come like
101 10 K D repairs "Para 1. Call for P ...... * Asso " Only one record
If there is any other way to read a file from application server having long text in one of field then let me know. highly appreciated.
Regards,
2013 Nov 05 7:35 AM
Have you tried this:
OPEN DATASET lv_filename FOR INPUT IN TEXT MODE ENCODING NON-UNICODE WITH SMART LINEFEED.
Also, in my first reply I mentioned difference in your data declaration where you have 5000, and 50000. Has this been corrected?
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |