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

unicode error READ DATASET p_path INTO table.

Former Member
0 Likes
942

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.....

7 REPLIES 7
Read only

former_member192429
Active Participant
0 Likes
890

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

Read only

former_member194669
Active Contributor
0 Likes
890

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®

Read only

0 Likes
890

Hi,

thanks for your reply.

should i take another wa of type string?

Read only

0 Likes
890

Hi,

Yes

a®

Read only

0 Likes
890

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.

Read only

0 Likes
890

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

Read only

Former Member
0 Likes
890

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.