Skip to Content
-1

How to select data from the table structure

Feb 11 at 07:38 AM

40

avatar image
Former Member

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......

SQL
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Nic Teunckens Feb 13 at 08:48 AM
0

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 ...

Share
10 |10000 characters needed characters left characters exceeded