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

Problem using Select... different tables in different systems (MANDT)...

Former Member
0 Likes
1,303

Hi guys,

My problem is that SAP create different tables in DEV, QAS and PRD. My program runs well in DEV, but when i transported it to QAS,it gave a dump, error the table is not found. Correct, that's why SAP created the table in QAS with another name... why¿? no idea.

I was thinking to do sth like this.


      case sy-mandt.
      when '0100'.
        select single target1 into wa1-fipex
        from FMFMOADCC1000034                 " table used in DEV
        where sour1_from = wa1-hkont and sour1_to = wa1-hkont.
      when '0200'.
        select single target1 into wa1-fipex
        from FMFMOATCC2000012                " table used in QAS
        where sour1_from = wa1-hkont and sour1_to = wa1-hkont.

      endcase.

but it doesnt work, because the table of QAS doesnt exit in DEV. , but how can i do it??

Can i create a dynamic select? or any ideas, how to solve that problem???

Thanks

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,265

Hello,

I dont know why you are doing this but a simple hack will solve your woes


    DATA: DYNTAB TYPE TABNAME.
 
    case sy-mandt.
      when '0100'.
         dyntab = 'FMFMOADCC1000034'.
      when '0200'.
         dyntab = 'FMFMOATCC2000012'.
      endcase.

        select single target1 into wa1-fipex
        from (dyntab)                " table used in QAS
        where sour1_from = wa1-hkont and sour1_to = wa1-hkont.

I think this should suffice ...

BR,

Suhas

12 REPLIES 12
Read only

Former Member
0 Likes
1,265

Hi,

Whats the issue you are facing with the code you have used? since you are selecting based on the sy-mandt it will pick the appropriate select statement.

Vikranth

Read only

0 Likes
1,265

Hi,

nop, because in DEV, SAP gave me an error, the table FMFMOATCC2000012 doesnt exit. It is correct, in mandt 100, that table doesnt exit, but in 200 exits. and opposite.

?¿?¿ Any idea.

Read only

0 Likes
1,265

You have to call the function module ABADR_DRULE_TABLENAMES_GET and get the tablename and change your select statement to be a dynamic table select.

Read only

0 Likes
1,265

Ok but if the client number of DEV is 0100, the control wont even go to the select of 0200 i,e the table FMFMOATCC2000012 . Then how are you getting this error?

Read only

0 Likes
1,265

yes, it is correct.

Try to make a select using a table that it doesnt exit in SAP, it gives u an error

TABLE NAME is not defined in the ABAP Dictionary as a table, projection view, or database view.

So it is not possible to use it.

Thanks

Read only

0 Likes
1,265

Yes i understood now. I thought you were getting a dump. but the select wont even pass the syntax check.

Read only

0 Likes
1,265

One more option could be as follows,

the table DD02T stores all the table names. You could make a select on this table and frame your actual select query dynamically



data: w_tabname type dd02t-tabname.

select single tabname 
from dd02t
into w_tabname
where tabname = 'FMFMOADCC1000034' OR
            tabname = 'FMFMOATCC2000012 '.

if sy-subrc = 0.

select single target1 
into wa1-fipex
from ( w_tabname )               
where sour1_from = wa1-hkont and 
            sour1_to = wa1-hkont.
endif.

Vikranth

Read only

Former Member
0 Likes
1,265

What creates these tables(tcode, process)?

Read only

0 Likes
1,265

SAP created those tables in FMDERIVER

SAP gives different names in different systems. Crazy..

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,266

Hello,

I dont know why you are doing this but a simple hack will solve your woes


    DATA: DYNTAB TYPE TABNAME.
 
    case sy-mandt.
      when '0100'.
         dyntab = 'FMFMOADCC1000034'.
      when '0200'.
         dyntab = 'FMFMOATCC2000012'.
      endcase.

        select single target1 into wa1-fipex
        from (dyntab)                " table used in QAS
        where sour1_from = wa1-hkont and sour1_to = wa1-hkont.

I think this should suffice ...

BR,

Suhas

Read only

Former Member
0 Likes
1,265

Thanks.

That was the answer that i was looking for.

Regards to all.

Read only

Former Member
0 Likes
1,265

[Note 1231815|https://websmp206.sap-ag.de/~form/handler?_APP=01100107900000000342&_EVENT=REDIR&_NNUM=1231815&_NLANG=E] gives the proper solution.

Rob