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: 

Execute ABAP command from string

cline_jomard-ek
Explorer
0 Kudos

Hello ABAP experts,

I have to generate a file with a o lot of fields that are calculated from other fields. I have a list to detailed each rule.

For example : field 09 = field 05+ field 06+ field 07+ field 08

field 15 = (field 05+ field 06) * 0.15

...

I wanted to stored the description of each rule in a table in order not to hard code these rules in the program. As the rules are dirfferents, I thought that the best solution was to write directly the ABAP code for the calculation in an external table z_table like this :

Field                Instruction
f_09                 f_09 = f_05 + f_06 + f_07 + f_08
f_15                 f_15 = (f_05 + f_06) * 0.15
... 

I ask me if it is then possible to execute the content of the string z_table-instruction ?

I hope to be clear. don't hesitate to ask me question if I am unclear.

Many thanks in advance.

1 ACCEPTED SOLUTION

ThomasZloch
Active Contributor
0 Kudos

You might get there by generating a dynamic, temporary program using the ABAP statement GENERATE SUBROUTINE POOL (see online help).

You will have to add data declarations to make an executable subroutine out of these calculations, which will return the final result to the calling program.

Thomas

P.S. you should make sure that the table holding the ABAP code does not contain malicious statements like "DELETE FROM BSEG WHERE..." or similar

3 REPLIES 3

ThomasZloch
Active Contributor
0 Kudos

You might get there by generating a dynamic, temporary program using the ABAP statement GENERATE SUBROUTINE POOL (see online help).

You will have to add data declarations to make an executable subroutine out of these calculations, which will return the final result to the calling program.

Thomas

P.S. you should make sure that the table holding the ABAP code does not contain malicious statements like "DELETE FROM BSEG WHERE..." or similar

cline_jomard-ek
Explorer
0 Kudos

I don't need anymore the solution for this.

I used another way.

0 Kudos

Could you please tell us the solution you used or the way you found to solve it?

Regards,

Matías.