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 Problem in Open data Set Statement

Former Member
0 Likes
990

Hi,

I am getting the unicode problem in transfer statement.

Please follow the code.

DATA : BEGIN OF FINALDATA1 OCCURS 0,

TEXT(25) TYPE C,

f0(1) type c value ',',

QUANTITY LIKE S780-ZZPRDPRQTY,

f1(1) type c value ',',

CURRENCY LIKE S780-ZZPRDPURCS,

f2(1) type c value ',',

TRATE1 TYPE P DECIMALS 3,

END OF FINALDATA1.

OPEN: DATASET OFILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. "open the input file "ECC6

IF SY-SUBRC <> 0.

WRITE: 'Input file could not be opened', SY-SUBRC.

STOP.

ENDIF.

LOOP AT FINALDATA1.

  • perform move_neg_sign1.

  • perform move_neg_sign2.

  • perform move_neg_sign3.

*

TRANSFER FINALDATA1 TO OFILE .

ENDLOOP.

In this the unicode problem will comin in runtime mode.

please solve this problem urgently.

Thanks & Regards,

Radhakrishna.Y

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
730

transfer will fail for currency and Quantity fields.

DATA : BEGIN OF FINALDATA1 OCCURS 0,

TEXT(25) TYPE C,

f0(1) type c value ',',

QUANTITY type char10, "they should be character variables

f1(1) type c value ',',

CURRENCY type waers,

f2(1) type c value ',',

TRATE1 TYPE P DECIMALS 3,

END OF FINALDATA1.

data: file type rlgrap-filename.

OPEN: DATASET FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. "open the

IF SY-SUBRC eq 0.

WRITE: 'Input file could not be opened', SY-SUBRC.

STOP.

ENDIF.

LOOP AT FINALDATA1.

"so convert that to char format and send.

TRANSFER FINALDATA1 TO FILE .

ENDLOOP.

5 REPLIES 5
Read only

Former Member
0 Likes
730

Hello,

Use the OPEN DATASET command IN BYNARY MODE saving the data to an XSTRING variable and later on convert it to the desirable data type.

Follow an example:


DATA: file TYPE string VALUE `flights.dat`, 
      wa TYPE spfli. 

FIELD-SYMBOLS <hex_container> TYPE x. 

OPEN DATASET file FOR INPUT IN BINARY MODE. 

ASSIGN wa TO <hex_container> CASTING. 

DO. 
  READ DATASET file INTO <hex_container>. 
  IF sy-subrc = 0. 
    WRITE: / wa-carrid, 
             wa-connid, 
             wa-countryfr, 
             wa-cityfrom, 
             wa-cityto, 
             wa-fltime, 
             wa-distance. 
  ELSE. 
    EXIT. 
  ENDIF. 
ENDDO. 

Regards,

Read only

Former Member
0 Likes
731

transfer will fail for currency and Quantity fields.

DATA : BEGIN OF FINALDATA1 OCCURS 0,

TEXT(25) TYPE C,

f0(1) type c value ',',

QUANTITY type char10, "they should be character variables

f1(1) type c value ',',

CURRENCY type waers,

f2(1) type c value ',',

TRATE1 TYPE P DECIMALS 3,

END OF FINALDATA1.

data: file type rlgrap-filename.

OPEN: DATASET FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. "open the

IF SY-SUBRC eq 0.

WRITE: 'Input file could not be opened', SY-SUBRC.

STOP.

ENDIF.

LOOP AT FINALDATA1.

"so convert that to char format and send.

TRANSFER FINALDATA1 TO FILE .

ENDLOOP.

Read only

0 Likes
730

Hi,

how we convert the quantity, currency and rate fields having decimal values into character format.

my file having data like this.

233,123.000 is the currency

.091 is the rate.

254.678 is the quantity.

my main problem is when i transfer my data from internal table to operating system file,it displays the unicode problem during runtime.

TRANSFER FINALDATA1 TO OFILE(it is a operating system file).

Please provide me profer solution.

Thanks & Regards,

Radhakrishna.Y

Read only

0 Likes
730

data textqty(10) type c.

write quantity to textqty.

This will convert your quantity field to text..keeping the comma's and decimal

Joe

Read only

former_member194669
Active Contributor
0 Likes
730

Hi,

It is necessary to specify as an option, which character set is used in the disk file. Since the legacy system is still using the "old" character set and not Unicode.

Find out the character set in the legacy and use like this way


open dataset fnam for input in legacy text mode code page '1100'.