2008 May 27 1:45 PM
Hi,
i have a problem with for all entries,
in the selection screen i will enter that s_bukrs.
from the bkpf table a document number will be picked and for that document number i have
2 entries in the bseg table. but when i am doing for all entries its picking only one recOrd from the TABLE BSEG. CAN YOU TELL ME WHAT IS THE REASON.
MY LOGIC IS AS BELOW..
SELECT gjahr belnr budat
FROM bkpf
INTO TABLE i_bkpf
WHERE bukrs IN s_bukrs.
IF sy-subrc EQ 0.
SELECT bukrs belnr shkzg dmbtr matnr
INTO TABLE i_bseg
FROM bseg
FOR ALL ENTRIES IN i_bkpf
WHERE bukrs IN s_bukrs AND
belnr EQ i_bkpf-belnr AND
gjahr EQ i_bkpf-gjahr AND
hkont IN s_saknr.
THANKS,
sURESH
2008 May 27 1:50 PM
try to replace:
FOR ALL ENTRIES IN i_bkpf
WHERE bukrs IN s_bukrs AND
belnr EQ i_bkpf-belnr AND
gjahr EQ i_bkpf-gjahr AND
hkont IN s_saknr.
with
FOR ALL ENTRIES IN i_bkpf
WHERE belnr EQ i_bkpf-belnr AND
gjahr EQ i_bkpf-gjahr
BTW: Did you check in table BSEG also for HKONT, maybe problem lies there and not in your coding.
Edited by: Micky Oestreich on May 27, 2008 2:50 PM
2008 May 27 1:51 PM
Hello,
Are you filling the select-options s_saknr? If you fill it, will be returned only one entry (depending of the type of FI document, normally the accounts are diferent for each record in BSEG).
Regards,
2008 May 27 1:55 PM
Hi David Pietroniro ,
But the GL account also same in BSEG table. so it should pick right ??
2008 May 27 1:58 PM
Hi Suresh,
SELECT bukrs belnr shkzg dmbtr matnr
INTO TABLE i_bseg
FROM bseg
FOR ALL ENTRIES IN i_bkpf
WHERE bukrs IN s_bukrs AND
belnr EQ i_bkpf-belnr AND
gjahr EQ i_bkpf-gjahr AND
hkont IN s_saknr.
I think problem is in where clause because you are again using bukrs IN s_bukrs, when you already have filtered data in i_bkpf according to bukrs, then there is no need for it again. one more thing you have three conditions to be validate apart from bukrs. belnr, gjahr, hkont, there mey be possibility either of the conditions does not match with 2 values data and query is getting failed to extract as you exactly want. Please check first with only:
SELECT bukrs belnr shkzg dmbtr matnr
INTO TABLE i_bseg
FROM bseg
FOR ALL ENTRIES IN i_bkpf
WHERE belnr EQ i_bkpf-belnr.
if you get both the entries or as required. then do changes accordingly.
Rewards if useful.
BR,
Alok
2008 May 27 2:00 PM
Hi suresh,
1. First do a minor change (bold)
IF sy-subrc EQ 0.
SELECT bukrs belnr shkzg dmbtr matnr
INTO TABLE i_bseg
FROM bseg
FOR ALL ENTRIES IN i_bkpf
WHERE bukrs EQ i_bkpf-bukrs AND
belnr EQ i_bkpf-belnr AND
gjahr EQ i_bkpf-gjahr AND
hkont IN s_saknr.
2. Check now whether the records are coming OK.
3. If not then for checking purpose,
simply remove the HKONT condition.
regards,
amit m.
2008 May 27 3:06 PM
Your problem is that FOR ALL ENTRIES eliminates duplicate entries. Simply add BUZEI to the second select (and add BUKRS to the first one):
SELECT bukrs gjahr belnr budat
FROM bkpf
INTO CORRESPONDING FIELDS OF TABLE i_bkpf
WHERE bukrs IN s_bukrs.
IF sy-subrc EQ 0.
SELECT bukrs belnr buzei shkzg dmbtr matnr
INTO CORRESPONDING FIELDS OF TABLE i_bseg
FROM bseg
FOR ALL ENTRIES IN i_bkpf
WHERE bukrs EQ i_bkpf-bukrs AND
belnr EQ i_bkpf-belnr AND
gjahr EQ i_bkpf-gjahr AND
hkont IN s_saknr.
ENDIF.Rob
2008 May 27 3:13 PM
HI,
The simple reason why you are getting one entry instead two entries in BSEG table is might the selected fields have same values in BSEG table. Which means you can retrieve all the key fields even it is not using in your program, becasue the for all entries works like SELECT and Delete adjacent duplicates statements. So the fields which you retrieved has duplicate entries, so one record get delete from your table.
Try to add some more fields (All key fields) in your select query, then your problem will be solved....
Try to change the select like this
Select bukrs belnr GJAHR BUZEI shkzg dmbtr matnr
......
......
Rgds,
Bujji
Edited by: Bujji on May 27, 2008 4:15 PM
2011 Nov 15 5:25 AM
2011 Nov 15 5:59 AM
Dear friend,
for all entries feature gets only unique value from the database so you might get single row,
regards
2011 Nov 15 12:01 PM
ABAP - Keyword Documentation:
With duplicated rows in the resulting set, the addition FOR ALL ENTRIES has the same effect as if addition DISTINCT were specified in the definition of the selection quantity. Unlike DISTINCT, the rows are not deleted from the database system but are deleted on the application server from the resulting set.
2012 Jul 11 6:37 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |