‎2008 May 03 12:35 PM
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'.
‎2008 May 03 5:06 PM
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.
‎2008 May 03 12:46 PM
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
‎2008 May 03 12:47 PM
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.
‎2008 May 03 12:51 PM
‎2008 May 03 12:52 PM
‎2008 May 03 2:14 PM
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.
‎2008 May 03 5:06 PM
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.