01-26-2006 6:14 PM
Consider the following code - <b>Is it possible to execute the statement/expression stored in variables expression1, expression2 and expression3?</b> The result should be:
sum = 5 , subname = 'First' & i_output should be sorted by lifnr and ebeln.
*---DATA DECLARATIONS
DATA: sum TYPE i,
op1 TYPE i,
op2 TYPE i,
name TYPE string,
subname TYPE string,
offset TYPE i,
expression1 TYPE string,
expression2 TYPE string,
expression3 TYPE string.
DATA: BEGIN OF i_output OCCURS 0,
lifnr TYPE lfa1-lifnr,
ebeln TYPE ekko-ebeln,
ebelp TYPE ekpo-ebelp,
END OF i_output.
*---BUILD EXPRESSION 1
op1 = 2.
op2 = 3.
expression1 = 'sum = op1 + op2'.
*---BUILD EXPRESSION 2
name = ' First Name'.
offset = 5.
expression2 = 'subname = name+1(offset)'.
*---POPULATE ITAB I_OUTPUT
MOVE: '111111' TO i_output-lifnr,
'PO1' TO i_output-ebeln,
'010' TO i_output-ebelp.
APPEND i_output.
MOVE: '111511' TO i_output-lifnr,
'PO1' TO i_output-ebeln,
'020' TO i_output-ebelp.
APPEND i_output.
MOVE: '111111' TO i_output-lifnr,
'PO3' TO i_output-ebeln,
'010' TO i_output-ebelp.
APPEND i_output.
MOVE: '114111' TO i_output-lifnr,
'PO2' TO i_output-ebeln,
'010' TO i_output-ebelp.
APPEND i_output.
MOVE: '111121' TO i_output-lifnr,
'PO2' TO i_output-ebeln,
'020' TO i_output-ebelp.
APPEND i_output.
CLEAR i_output.
*---BUILD EXPRESSION 3
expression3 = 'sort i_output by lifnr ebeln'.
Thanks in advance!
01-26-2006 6:26 PM
You can achieve this by generating a subroutine pool dynamically, passing the code lines (expressions) as an internal table. Here is the syntax:
GENERATE SUBROUTINE POOL itab NAME name.
Hope this helps,
Bhanu
01-26-2006 6:45 PM
But, how can you pass some value/data (say a table which has to be sorted) from the main report to the subroutine-pool?
01-26-2006 7:12 PM
> You can achieve this by generating a subroutine pool
> dynamically, passing the code lines (expressions) as
> an internal table. Here is the syntax:
>
> GENERATE SUBROUTINE POOL itab NAME name.
>
> Hope this helps,
> Bhanu
Hey Banu, thanks!
Message was edited by: Sam