‎2007 Aug 24 6:37 PM
HI can any one suggest me how to handle this unicode error "<b>READ DATASET p_path INTO table.".</b>
p_path is of type rlgrap-filename and table is an internal table with 15 fields.
points rewarded.....
‎2007 Aug 24 6:50 PM
Can you transfer the file from application server to the internal table in one step. I think we need to read line by line and append to itab.
-Kriss
‎2007 Aug 24 6:59 PM
Hi,
I think you are working on UNICODE system. If yes then you need to apply OPEN DATASET in the following way
ld_file = p_infile.
OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
ELSE.
DO.
CLEAR: wa_string, wa_uploadtxt.
READ DATASET ld_file INTO wa_string.
IF sy-subrc NE 0.
EXIT.
ELSE.
SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
wa_uploadtxt-name2
wa_uploadtxt-age.
MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
APPEND wa_upload TO it_record.
ENDIF.
ENDDO.
CLOSE DATASET ld_file.
ENDIF.
a®
‎2007 Aug 24 7:29 PM
Hi,
thanks for your reply.
should i take another wa of type string?
‎2007 Aug 24 7:34 PM
‎2007 Aug 24 7:39 PM
hi,
this is the structure of table....
BEGIN OF table OCCURS 0,
docno LIKE bsid-belnr, "Internal document
bukrs LIKE bsid-bukrs, "Company Code
kunnr LIKE knb1-kunnr, "Customer
budat LIKE bsid-budat, "Posting date in the document
bldat LIKE bsid-bldat, "Document date in document
blart LIKE bsid-blart, "Document type
bschl LIKE bsid-bschl, "Posting key
xblnr LIKE bsid-xblnr, "Reference document number
zuonr LIKE bsid-zuonr, "Assignment number
waers LIKE bsid-waers, "Currency Key
wrbtr LIKE bsid-wrbtr, "Amount in document currency
shkzg LIKE bsid-shkzg, "Debit/credit indicator
saknr LIKE bsid-saknr, "G/L account number
kursf LIKE bkpf-kursf, "Currency Rate
dmbtr LIKE bsid-dmbtr, "Amount in local currency
zterm LIKE bsid-zterm, "Terms of payment key
zfbdt LIKE bsid-zfbdt, "Baseline date for due date
umskz LIKE bsid-umskz, "Special G/L Indicator
zlsch LIKE bsid-zlsch, "Payment method
anfae LIKE bsid-anfae, "Bill of Exch.Pay. Req. Due Date
wlzbp LIKE bsed-wlzbp, "State central bank location
wbzog LIKE bsed-wbzog, "Bill of exchange drawee
wort2 LIKE bsed-wort2, "City of bill of exchange drawee
wbank LIKE bsed-wbank, "Bank address
wort1 LIKE bsed-wort1, "City of bill of exchange drawer
wname LIKE bsed-wname, "Name of bill of exchange drawer
sgtxt LIKE bsid-sgtxt, "Item text
mwskz LIKE bsid-mwskz, "Tax on sales/purchases code
name1 LIKE bsec-name1,
name2 LIKE bsec-name2,
name3 LIKE bsec-name3,
name4 LIKE bsec-name4,
pstlz LIKE bsec-pstlz,
ort01 LIKE bsec-ort01,
land1 LIKE bsec-land1,
stras LIKE bsec-stras,
pfach LIKE bsec-pfach,
pstl2 LIKE bsec-pstl2,
pskto LIKE bsec-pskto,
bankn LIKE bsec-bankn,
bankl LIKE bsec-bankl,
banks LIKE bsec-banks,
stcd1 LIKE bsec-stcd1,
stcd2 LIKE bsec-stcd2,
stkzu LIKE bsec-stkzu,
stkza LIKE bsec-stkza,
regio LIKE bsec-regio,
bkont LIKE bsec-bkont,
dtaws LIKE bsec-dtaws,
dtams LIKE bsec-dtams,
spras LIKE bsec-spras.
DATA : END OF table.
‎2007 Aug 25 8:51 AM
You need to read the data into a table of a flat structure with some form of delimiter between the fields, and then split the fields into your table.
For example - the 11th field of your table is WRBTR - internally in SAP this will be a packed field, but the upload file will have characters at this position because you are reading it as text - this will cause a problem. Dates will also cause problems - the field for a date is 8 long, and has YYYYMMDD, but dates in text files are generally 10 long and DD/MM/YYYY or MM/DD/YYYY - 10 chars dont fit into an 8 char field.
so define a table of CHAR(2000) or of STRING, load the data, and then split it and convert each field inside the program.
Andrew
‎2007 Aug 24 7:04 PM
Try this:
OPEN DATASET P_PATH FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC NE 0.
WRITE:/ 'FILE NOT FOUND'.
STOP.
ENDIF.
DO.
READ DATASET P_PATH INTO TABLE.
IF SY-SUBRC <> 0.
EXIT.
ELSE.
APPEND TABLE.
CLEAR TABLE.
ENDIF.
ENDDO.
DESCRIBE TABLE TABLE LINES V_LINES.
IF V_LINES EQ 0.
WRITE:/ 'NO RECORDS IN FILE'.
STOP.
ENDIF.
CLOSE DATASET P_PATH.