06-26-2009 12:57 PM
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
06-26-2009 1:38 PM
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
06-26-2009 1:46 PM
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.
06-26-2009 3:01 PM
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.