Application Development and Automation 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: 
Read only

conditional compiling in abap

Former Member
1,101

Is it possible, to use "compiler directives" in ABAP (as known in other programming languages), especially "conditional compiling".

I would like this technique, for a conditional compiling in following situation:

DDIC-TABLE M_VMVD ist available up to R/3-Release 4.6C

Since Release 4.70 this table is replaced by SHP_VIEW_EXVE.

If possible, i want to write <u>one</u> coding for both releases.

It is not sufficient to use a "normal" if - command, because syntax-check will detect an error (table xy is not known).

Here a - fictional - example, what i think about:

*# IF_COMPILER_RELEASE <  470.  (fictional Compiler-Directive)
select single vbeln into my_vbeln from m_vmvmd where lifex = my_lifex.
*# ELSE_COMPILER_DIRECTIVE (fictional)
select single vbeln into my_vbeln from shp_view_exve where lifex = my_lifex.
*# ENDIF_COMPILER_DIRECTIVE  (fictional)

I know, that there was a conditional-compiling-technique for differing R/2 and R/3.

It was something like that:

*#R2    write: / 'Compiled with R/2'.
*#R3   write: / 'Compiled with R/3'.

Best Regards

Juergen

1 ACCEPTED SOLUTION
Read only

Former Member
862

I dont thisnk there is anything like traditional conditional compiling.

you could, however, do something like this:


data: tablename(20) type c.
data: my_vbeln type vbeln.

if sy-saprl = '470'.
  move 'M_MVMD' to tablename.
else.
  move 'SHP_VIEW_EXVE' to tablename.
endif.

select single vbeln into my_vbeln from (tablename)
  where lifex = my_lifex.

(this was all keyed from memory, so you may have to tweak it a bit, but i did try it and it works)

4 REPLIES 4
Read only

Former Member
863

I dont thisnk there is anything like traditional conditional compiling.

you could, however, do something like this:


data: tablename(20) type c.
data: my_vbeln type vbeln.

if sy-saprl = '470'.
  move 'M_MVMD' to tablename.
else.
  move 'SHP_VIEW_EXVE' to tablename.
endif.

select single vbeln into my_vbeln from (tablename)
  where lifex = my_lifex.

(this was all keyed from memory, so you may have to tweak it a bit, but i did try it and it works)

Read only

Former Member
0 Likes
862

Having worked within SAP, since I had to adapt my coding for every release,

I am sure there was no such possibility. That was a little more than one year ago,

though...

Read only

Former Member
0 Likes
862

Hi jurgen,

1. compiler directives are not supported in abap r/3,

in the way, they are used in c and c++.

2. However,

3. For your requirement, we can use

select with dynamic table name,

and an if condition.

4. To get a taste of it, just copy paste.

5.

REPORT abc.

*----


data : bukrs like t001-bukrs.

data : tabname(30) type c.

tabname = 'T001'.

*----


CONDITIONAL , NORMAL IF

  • IF REL < 470.

  • tabname = 'XYZT001'.

  • ENDIF.

select single bukrs

from (tabname)

into bukrs.

WRITE 😕 BUKRS.

regards,

amit m.

Read only

Former Member
0 Likes
862

Thanks!