‎2009 Nov 04 4:53 PM
Hi guys,
I'm trying to pass an internal table from a report to a class method so that it can be processed and converted to binary content for sending as an email attachment in Excel format.
Before converting to binary content the internal table must be looped through and have tabs and carriage returns inserted betweens fields and rows before appended to a string.
The problem is that I want to make this a generic method that can accept any type of internal table so the class can be used with any report.
I have searched on the forums and can't seem to find anything related to this.
Please help!
Thanks.
‎2009 Nov 04 5:00 PM
‎2009 Nov 04 5:00 PM
‎2009 Nov 04 5:35 PM
I don't think there's any need for dynamic internal table creation. If I understand the OP correctly, the table is there, it's just a matter of passing it to a method, and then looping over the fields in each line. It is possible to have generic types for method parameters. Like so:
METHODS test
IMPORTING
it_mytable TYPE STANDARD TABLE .
METHOD test.
DATA:
lv_index TYPE i,
lv_comp_as_string TYPE string.
FIELD-SYMBOLS:
<fs_line> TYPE ANY,
<fs_comp> TYPE ANY.
LOOP AT it_mytable ASSIGNING <fs_line>.
lv_index = 1.
DO.
ASSIGN COMPONENT lv_index OF STRUCTURE <fs_line> TO <fs_comp>.
IF sy-subrc <> 0.
EXIT. " DO-loop
ENDIF.
" Convert field value to string. May generate runtime error.
MOVE <fs_comp> TO lv_comp_as_string.
" Do whatever you need to do with the string
ENDDO.
ENDLOOP.
ENDMETHOD. -- Sebastian
‎2009 Nov 05 12:11 PM
‎2009 Nov 05 12:26 PM
hi,
similar situation for me as well in my case i am concatenating all the fields to a string.
will the same logic works? i mean some times the field symbol( work area) may have 2 fields or 7 fields.
please suggest.thannks alot.
Anil