‎2006 Mar 15 6:06 AM
Hi,
I have selected the data from BKPF depending on the BUKRS & selecton screen dates.
Now I want to select data from BSEG depending on bukrs obtained in the above step & KUNNR which is in another internal T_CUST ... Will the select statement below ensure that the T_BSEG table will have the correct values of the documents no's corresponding to the customers in table T_CUST ??
Get BSEG data for all values in BKPF
IF NOT T_BKPF[] IS INITIAL.
SELECT BUKRS
BELNR
GJAHR
BUZEI
BUZID
BSCHL
KOART
SHKZG
DMBTR
KUNNR
INTO TABLE T_BSEG_TEMP
FROM BSEG
FOR ALL ENTRIES IN T_BKPF
WHERE BUKRS = T_BKPF-BUKRS AND
BELNR = T_BKPF-BELNR AND
GJAHR = T_BKPF-GJAHR.
ENDIF.
FORM GET_BSEG_DATA .
Get BSEG data for all customers
IF NOT T_CUST[] IS INITIAL.
SELECT BUKRS
BELNR
GJAHR
BUZEI
BUZID
BSCHL
KOART
SHKZG
DMBTR
KUNNR
INTO TABLE T_BSEG
FROM BSEG
FOR ALL ENTRIES IN T_CUST
WHERE KUNNR = T_CUST-KUNNR.
ENDIF.
ENDFORM. " GET_BSEG_DATA
‎2006 Mar 15 6:11 AM
Hi SB,
It will work perfectly..
do you have any problem with the query..?
regards
satesh
‎2006 Mar 15 6:10 AM
‎2006 Mar 15 6:10 AM
hI sb
YES, THE SELECT STATEMENT WILL FETCH DATA FOR THE REQUIRED CUSTOMERS.
REGARDS
KISHORE
‎2006 Mar 15 6:11 AM
Hi SB,
It will work perfectly..
do you have any problem with the query..?
regards
satesh
‎2006 Mar 15 6:20 AM
My requirement is to get data from BSEG where bukrs = bkpf-bukrs and belnr= bkpf-belnr & knunnr = t_cust kunnr .. I was not sure about how to write a <b> "single select statement" with "where conditions from two different tables"</b> .... so only I split up the tables as t_bseg & t_bseg_temp and also split up up the where condition ... but then by splitting up the where condition I was not sure whether the right BELNR & BUKRS will be selected just by giving the condition where KUNNR = T_CUST-KUNNR ...
‎2006 Mar 15 6:33 AM
Hi SB,
Try to merge the two internal tables (bkpf and t_cust) into the 3rd internal table say t_temp and now you can write the select statement by using the 3rd internal table in FOR-ALL-ENTRIES option where bukrs = t_temp-bukrs and belnr = t_temp-belnr and kunnr = t_temp-kunnr.
Regards,
Phani.
‎2006 Mar 15 6:36 AM
Hi SB
MERGE THE TWO INTERNAL TABLE T_BKPF AND T_CUST INTO ANOTHER INTERNAL TABLE THEN USE FOR ALL ENTRIES FOPR THE SELECT STATEMENT.
REGARDS
KISHORE
‎2006 Mar 15 7:15 AM
hi SB,
We can Merge two Internal tables with the help of <b>Innerjoins</b> and collect the joined data in to third internal table and then use for all entries for the select statement ... but since BSEG is cluster table inner join shouldn't be used to merge cluster table data
.... So first with the help of one select statement merge the data of two internal tables in to third table and then use for all entries for the third internal table ..
hope this helps,
Regards,
Santosh
‎2006 Mar 15 7:43 AM
hi,
your 2nd part is <b>very bad</b> for performance:
FOR ALL ENTRIES IN T_CUST
WHERE KUNNR = T_CUST-KUNNRbetter select bsid and bsad
Andreas
‎2006 Mar 15 11:46 AM
Hi,
I am getting customer number with the help of account group ... Is there any table where I can get that the customer & account group as primary fields??
‎2006 Mar 15 11:56 AM
I am getting customer number with the help of account group and Company code ... Is there any table where I can get that the customer & account group & Company code as primary fields??
Ignore my previous msg.
‎2006 Mar 15 11:59 AM
‎2006 Mar 15 2:35 PM
‎2006 Mar 15 6:12 AM
Hi,
The data would be inconsistent, better way is to merge all into one final internal table and handle it appropriately.