‎2006 Mar 20 5:29 AM
I want to filter the data from BSEG table for a given period. Since, there is no document date in BSEG, I have done the following.
First : I have taken the data from BKPF table for a given period into an internal table IT_BKPF.
Then, Looping at IT_BKPF, i am reading the table BSEG for BELNR field. But the system gives the following error.
" Field BELNR is unkown. It is in neither in one of the specified tables not defined by "DATA statment. "DATA" statement"
I have declared the tables BSEG, BKPF.
My code is given below for your reference.
LOOP AT IT_BKPF.
READ TABLE BSEG WITH KEY BELNR = IT_BKPF-BELNR.
IF SY-SUBRC = 0.
MOVE : BSEG-BUKRS TO IT_GROSS-BUKRS,
BSEG-BELNR TO IT_GROSS-BELNR,
BSEG-DMBTR TO IT_GROSS-DMBTR,
BSEG-SHKZG TO IT_GROSS-SHKZG.
APPEND IT_GROSS.
ENDIF.
ENDLOOP.
Pls let me know what is the error and how to solve the same.
Regards,
A S VINCENT
‎2006 Mar 20 5:37 AM
select * from bseg into table it_bseg
for all entries of it_bkpf
where belnr = it_bkpf-belnr
.
LOOP AT IT_BSEG.
MOVE : IT_BSEG-BUKRS TO IT_GROSS-BUKRS,
IT_BSEG-BELNR TO IT_GROSS-BELNR,
IT_BSEG-DMBTR TO IT_GROSS-DMBTR,
IT_BSEG-SHKZG TO IT_GROSS-SHKZG.
APPEND IT_GROSS.
ENDIF.
ENDLOOP.
‎2006 Mar 20 5:35 AM
your immediate problem is that you are trying to do a read of an internal table BSEG rather than doing a select from the database table BSEG.
‎2006 Mar 20 5:37 AM
select * from bseg into table it_bseg
for all entries of it_bkpf
where belnr = it_bkpf-belnr
.
LOOP AT IT_BSEG.
MOVE : IT_BSEG-BUKRS TO IT_GROSS-BUKRS,
IT_BSEG-BELNR TO IT_GROSS-BELNR,
IT_BSEG-DMBTR TO IT_GROSS-DMBTR,
IT_BSEG-SHKZG TO IT_GROSS-SHKZG.
APPEND IT_GROSS.
ENDIF.
ENDLOOP.
‎2006 Mar 20 5:38 AM
you would probably be better off doing something like:
select BSEGBUKRS BSEGBELNR BSEGDMBTR BSEGSHKZG inTO corresponding fields of table IT_GROSS
from bseg
for all entries in it_bkpf
where bseg~belnr = it_bkpf-belnr.
‎2006 Mar 20 5:42 AM
Hi Vincent ,
try the below code , the other thing that you have to do before running the below code is .
1.) did u define internal table properly
2.) did you do "select * from bkpf into it_bkpf
check this and run the below code , i think this should sove your problem
Do reward points if found useful.
-
select * from bseg into table it_gross
for all entries in it_bkpf
where belnr = it_bkpf
-
‎2006 Mar 20 5:43 AM
Hello Vincent,
Problem here, from what i saw is, BSEG is a cluster table in the database.So, it has to be read using SELECT query.
Try using the follwing code:
SELECT BUKRS BELNR DMBTR SHKZG FROM BSEG
INTO TABLE IT_GROSS FOR ALL ENTRIES IN IT_BKPF
WHERE BELNR = IT_BKPF-BELNR.
check for sy-subrc.
Hope this would be of use to you,
Please revert for further help.
Regards,
Partha