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: 

How to fetch the data to the internal table with out using mandt

Former Member
0 Kudos

Hi all,

Iam giving my code please observer... and give me the reasonable solution.

-


t_mar LIKE STANDARD TABLE OF z_mar.

SELECT mandt

werks " Plant

lifnr " Vendor

FROM z_mar

INTO TABLE t_mar

where sal = 2000.

-


By removing MANDT from select query, it is going to dump.

ex:

---

SELECT

werks " Plant

lifnr " Vendor

FROM z_mar

INTO TABLE t_mar

where sal = 2000.

-


> Now it is going to dump ( here i removed the mandt field ).

Please give me a solution to fetch the data by removing mandt in select statement, with out chaning the internal table structure.

Thanks,

Ravi

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi Ravi,

Give this way


 SELECT
werks " Plant
lifnr " Vendor
FROM z_mar
INTO <b>corresponding fields of</b> TABLE t_mar
where sal = 2000.

Regards,

Santosh

11 REPLIES 11

Former Member
0 Kudos

Hi Ravi,

has t_mar the MANDT as field?

regards, Dieter

Former Member
0 Kudos

Hi,

u need to remove MANDT field from your table entry in Internal table declaration.

Madhavi

Former Member
0 Kudos

hi Ravi,

Give this way


 SELECT
werks " Plant
lifnr " Vendor
FROM z_mar
INTO <b>corresponding fields of</b> TABLE t_mar
where sal = 2000.

Regards,

Santosh

Former Member
0 Kudos

Hi,

Check the highlighted code

SELECT mandt

werks " Plant

lifnr " Vendor

FROM z_mar

<b>INTO corresponding fields of TABLE t_mar</b>

where sal = 2000.

Thank you,

Ramu N.

0 Kudos

Thanks,

But according to our coding standards i must not use Move Corresponding. Will you give me the resonable code with out using move corresponding.

Now Iam modifying the code which is pre-developed.

0 Kudos

Hi,

than you have to use 2 tables.

SELECT mandt

werks " Plant

lifnr " Vendor

FROM z_mar

INTO TABLE t_mar "with MANDT


where sal = 2000.

SELECT
werks " Plant
lifnr " Vendor
FROM z_mar

INTO TABLE t_mar1 "without MANDT

where sal = 2000.

but why don't whant to user move-correspondig?

Regards, Dieter

Message was edited by: Dieter Gröhn

0 Kudos

Hi Ravi

Please try with below code:

types: begin of t_mar,
         werks like z_mar-werks,
         lifnr like z_mar-lifnr,
       end of t_mar.
data: it_mar type STANDARD TABLE OF t_mar,
      wa_mar type t_imar.

SELECT   "mandt
   werks " Plant
   lifnr " Vendor 
   FROM z_mar
   INTO TABLE it_mar
   where sal = 2000.

Kind Regards

Eswar

Former Member
0 Kudos

HI,

By removing MANDT from select query, it is going to dump.

ex:

---

SELECT

werks " Plant

lifnr " Vendor

FROM z_mar

<b>INTO corresponding fields TABLE t_mar</b>where sal = 2000.

Regards

amole

Former Member
0 Kudos

Hi Ravi,

you have to fetch all the fields that are there in the internal table while usign 'into table'.

o.w u can use

into(t_mar-werks, t_mar-lifnr) and need to append each record to the internal table.

-Anu

Former Member
0 Kudos

You might also check whether MANDT is defined as the first field of transparent table Z_MAR. And if so, is it defined with data element MANDT.

Another consideration is why not use:

SELECT * FROM Z_MAR INTO TABLE T_MAR.

Former Member
0 Kudos

hi Ravi,

i also had to avoid move-corresponding and the following is what i did...its extra work and goes around but it will

do the needed work..............

t_mar LIKE STANDARD TABLE OF z_mar.

SELECT *

FROM z_mar

INTO TABLE t_mar

where sal = 2000.

the above gets you all the fields ...but if you still want to narrow it down to just two fields

*****Declaring structure with 2 fields

data:begin of fs_data.

data:werks type z_mar-werks,

lifnr type z_mar-lifnr ,

data:end of fs_data.

*******internal table of above

data:int_data like fs_data occurs 0 with headerline.

*****moving the only 2 required fields

loop at t_mar.

t_mar-werks = int_data-werks.

t_mar-lifnr = int_data-lifnr.

append int_data.

endloop.

Hope you found it useful...

Regards

Bx