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: 

Small Doubt Regarding SY-MANDT

Former Member
0 Kudos

Hi All,

SELECT changenr FROM cdhdr CLIENT SPECIFIED INTO CORRESPONDING FIELDS OF TABLE it_cdhdr

WHERE mandant = syst-mandt

AND objectclas = 'MATERIAL'

AND objectid = wa_matl-matnr

AND tcode = 'MM02'.

I have written the select stament as shown above.

In this i have a doubt like adding a field sy-mandt in the where condition will increase the Efficiency of program or not.

regards,

raghu.

11 REPLIES 11

ThomasZloch
Active Contributor
0 Kudos

No it does not. If your program is supposed to select data in the logon client only, then remove the selection on MANDT as well as the CLIENT SPECIFIED addition. MANDT will be added automatically to the SQL statement that hits the database.

Thomas

P561888
Active Contributor

Hi,

If u have any doubt abt the Select go to the ST05 and on the activate Trace.

When ever u written any select statement , it will convert in to the DDL .

ex. Select mantr ersda from mara into table it_mara where matnr in s_matnr.

In this case it has to be converted in to

select matnr ersda from mara into table it_mara where mandt = sy-mandt and matnr in s_matnr.

It is how it will convert ,,,,,

check out the TRACE.

Regards,

Bharani

Former Member
0 Kudos

The answers is NO differnece. If you dont mention sy-mandt the database interface would add the login-in client in where clause during database fetch.

former_member194613
Active Contributor
0 Kudos

you should not add the mandt = sys-mandt, because it is automatically added.

It can happen that you get security warning, because client-specifed should not be used.

Client-speified should only be used in exceptions when data of other clients are needed.

Therefore the usage must be allowed. Normally client should not be added. Sometimes it makes sense to add it in the ON-condition of a join.

Siegfried

Former Member
0 Kudos

Hello,

there will be no problem in the performance point of view whether you use the SY-MANDT or not. I think you wnat some client specific data that's why you ve used the SY-MANDT.

Former Member
0 Kudos

NO.....Not at all...

0 Kudos

hello,

how can you say like this...

can you explain me the reason behind it...

Former Member
0 Kudos

No, because SQL anyways has automatic client handling

Former Member
0 Kudos

Hi Raghawendra,

You don't have to use SY-MANDT in where condition as Client handling is done automatically in Open SQL which is used by ABAP .

For CLIENT SPECIFIED: This is used when you have to access data across the clients and this clause should come in from clause just after the Table Name

ex:SELECT * FROM MARA

CLIENT SPECIFIED

INTO WA_MARA

WHERE MANDT = '003'.

Hope this will help you..

Former Member
0 Kudos

Hi..

No doubt the efficency would be affected but from business point of view there will many things that need to be checked as in:

If you are viewing data from CDHDR and CDPOS which is client specific then you are not viewing complete data.

These tables give us and document changes made to a particular object in SAP but if anything is cross client like company code(lets assume) then changes to it wont be visible in all the clients..

so there can be some key information you can miss out while working on some of the objects.

else in this case its good to make query cross client.

regards

vishal

former_member194613
Active Contributor
0 Kudos

the automatic client handling is one of the features of SAPs Open SQL language.

Standard SQL would of course not add the client.

In some older releases it can make a difference to add the client for joins, because only one client condition is added and sometimes problems appeared that the database did not know that the client is given for all tables. Was maybe in releases around 4.6 and not all databases, no problem anymore.

Siegfried