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 select data from the table structure

Former Member
0 Kudos

Hi, All Expert Abap.

Help me, How to select data from the table structure then issued in the internal table with the conditions.

example :


DATA: it_bill TYPE STANDARD TABLE OF ZRECEIPT WITH HEADER LINE,
wa_bill type ZRECEIPT.

SELECT

mseg~werks

mseg~lgort
mseg~mblnr
mseg~matnr
mseg~bwart
mseg~bwtar
mseg~menge
mseg~meins
mkpf~budat
makt~maktx
INTO CORRESPONDING FIELDS OF TABLE it_bill FROM mseg
INNER JOIN mkpf on mseg~mblnr = mkpf~mblnr
INNER JOIN makt on mseg~matnr = makt~matnr
WHERE mseg~werks = Plant and mseg~lgort = Sloc.

LOOP AT IT_BILL into wa_bill.

WRITE 😕 wa_bill-mblnr, wa_bill-matnr, wa_bill-bwart, wa_bill-bwtar, wa_bill-menge, wa_bill-meins, wa_bill-budat, wa_bill-maktx.

ENDLOOP.

At the time of debugging does not appear its data. Plz help me......

1 REPLY 1

NTeunckens
Active Contributor
0 Kudos

This code should work, however we can't see what input you are using. Check your 'Plant' and 'SLoc' input if you are not getting any data ...

Or are you just not 'seeing it correctly' in Debugging. As you are using a Table "WITH HEADER LINE" you should look at "IT_BILL[]" :

IT_BILL[1]-MBLNR = <first_value> ....
IT_BILL[2]-MBLNR = <second_value> ...

However, this code is not optimal and some pointers would be :

  • The use of "WITH HEADER LINE" isn't recommended anymore and is considered bad practise / obsolete ...
  • If possible you should avoid using "INTO CORRESPONDING FIELDS" ...
  • You are not using all of the KEYS of the Tables, which affects performance (for example : Table MSEG also holds "MJAHR" as an important Key ... (See SAP-Note 821722 on MSEG-MKPF join)
  • This Query will possibly fetch huge amounts of data, as you are not using the other Keys or any Date-Range ...


Again, you should be able to get this to work, but it is far from optimal and I would suggest Optimizing the Query / Report. One resource would be the use of Trx."SLIN" to Evaluate your Development running all Checks ...