Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Saving an internal table to SAP directory in csv format

I have to save an itab in SAP system to SAP directory in CSV format. As per my understanding I have to change the content to character type however I get a Casting error. Below is my code:

FORM f_opendata TABLES p_tab TYPE STANDARD TABLE USING
p_work TYPE any.
FIELD-SYMBOLS: <lfs_wa>.
CONCATENATE c_headerfile c_initials sy-datum c_ext INTO v_dtasetfile.
OPEN DATASET v_dtasetfile FOR OUTPUT IN TEXT MODE ENCODING UTF-8.
IF sy-subrc EQ 0.
LOOP AT p_tab INTO p_work.
ASSIGN p_work TO <lfs_wa> CASTING TYPE c.
TRANSFER <lfs_wa> TO v_dtasetfile.
ENDLOOP.
CLOSE DATASET v_dtasetfile.
MESSAGE i899(f2) WITH 'SUCCESS' v_dtasetfile.
ENDIF.
ENDFORM.

This is the error message:

An exception occurred that is explained in detail below. The exception, which is assigned to class 'CX_SY_ASSIGN_CAST_ILLEGAL_CAST', was not caught in procedure "F_OPENDATA" "(FORM)", nor was it propagated by a RAISING clause. Since the caller of the procedure could not have anticipated that the exception would occur, the current program is terminated. The reason for the exception is:

The error occurred at a statement of the form ASSIGN f TO CASTING. ASSIGN f TO CASTING TYPE t. or ASSIGN f TO CASTING LIKE f1. or at table statements with the addition ASSIGNING CASTING.

The following error causes are possible: 1. The type of field f or the target type determined by , t or f1 contains data references, object references, strings or internal tables as components. These components must match exactly as far as their position (offset) and their type are concerned. 2. The specified type t or the type of f1 are not suited for the type of the field symbol. 3. The row type of the related table is not suited for the target type specified by according to the rules described in 1).


0 Answer
Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.