oldwired
oldwired

Reputation: 547

How to write code varying according to current client/mandant?

We currently have a SAP System with two different clients 002 and 004 in use. My task is to write a program in ABAP to create a report about user assignments. The report will do mainly the same on both clients, but I have to select different tables on both clients.

Is there a way to distinguish an ABAP code between different clients like:

IF client = 002.
* dothis.
ELSE.
* dothatdifferentthing.
ENDIF.

Thanks in advance.

Upvotes: 3

Views: 3425

Answers (2)

vwegert
vwegert

Reputation: 18493

An additional suggestion - try to do this the object-oriented way, stuffing all the common code into an abstract superclass and create two subclasses which carry only the client-dependent code. Then, based on SY-MANDT, instantiate either of the subclasses. This might help reducing duplicate code...

Upvotes: 5

Chris Carruthers
Chris Carruthers

Reputation: 3985

The current client is available in field sy-mandt.

For example:

IF sy-mandt = '002'.
*dothis.
ELSE.
*dothatdifferentthing.
ENDIF.

Upvotes: 9

Related Questions