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

Reg unicode issue

mohan_subramania
Explorer
0 Likes
737

Hi experts,

i need help on following issue, the following code run in non unicode system and the file downloaded without any problem . now the system changed into unicode now its giving error when executing.

it makes error on TRANSFER WA_FI_FINAL TO W_file , the work area contains i, c, n , type datas please give correct code for the unicode

*data : p_file TYPE rlgrap-filename value '/TCD/BI/text1.dat'.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORS.

*Display error messages if any.
IF sy-subrc NE 0.
MESSAGE e000 with 'File cannot be opened'.
EXIT.
ELSE.

*---Data is downloaded to the application server file

CLEAR : WA_FI_FINAL.

LOOP AT IT_FI_FINAL INTO WA_FI_FINAL.
TRANSFER WA_FI_FINAL TO W_file.
ENDLOOP.
ENDIF.

*--Close the Application server file (Mandatory).
CLOSE DATASET p_file.
write: 'File downloaded in Application server'

.

1 ACCEPTED SOLUTION
Read only

former_member156446
Active Contributor
0 Likes
705

I had a similar issue and I solved it in this fashion:


DATA : lf_field TYPE string,
lf_line TYPE string.
FIELD-SYMBOLS: <fs_field>,<fs_comp>.

LOOP AT p_gt_itab ASSIGNING <fs_field>.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs_field> TO <fs_comp>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
lf_field = <fs_comp>.
IF sy-index = 1.
lf_line = lf_field.
ELSE.
CONCATENATE lf_line lf_field INTO lf_line SEPARATED BY c_tab.
ENDIF.
CLEAR lf_field.
ENDDO.
APPEND lf_line TO p_gt_ittab.
ENDLOOP.

6 REPLIES 6
Read only

0 Likes
705

Firstly, in Unicode programs, the file format must be specified more precisely for OPEN DATASET fand, secondly, only purely character-type structures can still be written to text files.

You can use LEGACY TEXT MODE which ensures that the data is stored and read in the old non-Unicode format. In this mode, it is also possible to read or write non-character-type structures. However, be aware that data loss and conversion errors can occur in Unicode systems if there are characters in the structure that cannot be represented in the non-Unicode codepage.

Example.

open dataset DSN in legacy text mode for output.

Regards

Saravanan.

Reward points if useful

Read only

Former Member
0 Likes
705

check this..

report message-id zmsg.

types: begin of it_data ,

matnr like mara-matnr,

end of it_data .

data: wa_final type it_data ,

it_final type standard table of it_data with header line .

parameters:p_file type rlgrap-filename.

start-of-selection.

it_final-matnr = '000000323223'.

append it_final.

it_final-matnr = '000000323223'.

append it_final.

it_final-matnr = '000000323223'.

append it_final.

*data : p_file TYPE rlgrap-filename value '/TCD/BI/text1.dat'.

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORS.

*Display error messages if any.

IF sy-subrc NE 0.

MESSAGE e000 with 'File cannot be opened'.

EXIT.

ELSE.

*---Data is downloaded to the application server file

LOOP AT IT_FINAL INTO WA_FINAL.

TRANSFER WA_FINAL TO p_file.

ENDLOOP.

ENDIF.

*--Close the Application server file (Mandatory).

CLOSE DATASET p_file.

write: 'File downloaded in Application server' .

regards,

venkat.

Read only

Former Member
0 Likes
705

WA_FI_FINAL must be of type c.

Read only

0 Likes
705

Thats right it should be of type C.

Saravanan

Read only

Former Member
0 Likes
705

HI,

Check your structure WA_FI_FINAL.Does it have fileds whose data types are other than C,N,D,T.If yes,then you might need to change the data type of the structure.

Read only

former_member156446
Active Contributor
0 Likes
706

I had a similar issue and I solved it in this fashion:


DATA : lf_field TYPE string,
lf_line TYPE string.
FIELD-SYMBOLS: <fs_field>,<fs_comp>.

LOOP AT p_gt_itab ASSIGNING <fs_field>.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs_field> TO <fs_comp>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
lf_field = <fs_comp>.
IF sy-index = 1.
lf_line = lf_field.
ELSE.
CONCATENATE lf_line lf_field INTO lf_line SEPARATED BY c_tab.
ENDIF.
CLEAR lf_field.
ENDDO.
APPEND lf_line TO p_gt_ittab.
ENDLOOP.