Application Development 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: 

download file with fields with decimal values.

Former Member
0 Kudos

Hi,

I need to download infotype records to a file.

I need a comma deleimited file.

I have got all the details from Infotype to my internal table 'IT_OUTPUT_OPR'

my code is as follows:

LOOP AT IT_OUTPUT_OPR.

CLEAR IT_FILE_OPR.

NUM = 0.

DO.

  • Get name of next structure field into <f>

ASSIGN COMPONENT SY-INDEX OF STRUCTURE IT_OUTPUT_OPR TO <F>.

IF SY-SUBRC <> 0. EXIT. ENDIF. " No more fields in structure

LEN = STRLEN( <F> ).

IT_FILE_OPR+NUM = <F>. " Write field to output table

NUM = NUM + LEN.

WRITE: ',' TO IT_FILE_OPR+NUM(DELIMIT_LEN).

NUM = NUM + DELIMIT_LEN.

ENDDO.

APPEND IT_FILE_OPR.

ENDLOOP.

my internal table contains 'decimal' fields too.

so I am getting the following runtim error: 'OBJECTS_NOT_CHARLIKE'

at the position:

LEN = STRLEN( <F> ).

Please could anyone tell me how could this issue be resolved?

any pointers in this regard would be helpful.

Thanks,

Saher

3 REPLIES 3

Former Member
0 Kudos

Hi,

Try using another internal table with all fields of type c. Dump all data from your internal table to this internal table. C type field can hold any type of data and then use the same code.

Hope this helps.

Regards,

Sachin

0 Kudos

My internal table is of type table of an Infotype. if I declare another internal table of type c, then these 2 tables are not type compatible, so I cannot append the records.

Former Member
0 Kudos

Try something like following

LOOP AT IT_OUTPUT_OPR.
     CLEAR IT_FILE_OPR.
     NUM = 0.
     DO.
 *  Get name of next structure field into <f>
       ASSIGN COMPONENT SY-INDEX OF STRUCTURE IT_OUTPUT_OPR TO <F>.
       IF SY-SUBRC <> 0. EXIT. ENDIF.   " No more fields in structure
*       LEN = STRLEN( <F> ).    "DELETE
       DESCRIBE FIELD <F> OUTPUT-LENGTH  LEN. "INSERT
       IT_FILE_OPR+NUM = <F>.   " Write field to output table
       NUM = NUM + LEN.
 
       WRITE: ',' TO IT_FILE_OPR+NUM(DELIMIT_LEN).
       NUM = NUM + DELIMIT_LEN.
     ENDDO.
     APPEND  IT_FILE_OPR.
   ENDLOOP.