Skip to Content
0
Former Member
Mar 25, 2009 at 07:56 AM

dynamic source code generation

86 Views

Hi guys,

I would like to declare TYPES with five fields dynamically in my program and then use the same type in program later on. For that i have written the following code.

it_code-line = 'TYPES : BEGIN OF TY_TABLE,'.

APPEND it_code. CLEAR it_code.

CONCATENATE f1 'TYPE' f1 ',' INTO it_code separated by space.

APPEND it_code. CLEAR it_code.

CONCATENATE f2 'TYPE' f2 ',' INTO it_code separated by space.

APPEND it_code. CLEAR it_code.

CONCATENATE f3 'TYPE' f3 ',' INTO it_code separated by space.

APPEND it_code. CLEAR it_code.

CONCATENATE f4 'TYPE' f4 ',' INTO it_code separated by space.

APPEND it_code. CLEAR it_code.

CONCATENATE f5 'TYPE' f5 ',' INTO it_code separated by space.

APPEND it_code. CLEAR it_code.

it_code-line = 'END OF TY_TABLE.'.

APPEND it_code. CLEAR it_code.

INSERT REPORT 'ZIBM_DYN_INCLUDE' FROM it_code.

But i am getting syntax error ' Type TY_TABLE is unknown'. How to rectify this error.

Your help will be deeply appreciated.

Thanks,

Ibrahim