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: 

To obtain customer open and closed items together

Former Member
0 Kudos

Hi Guys,

I have prepared a report to fetch data for customer open and closed items.I have included 3 radio-buttons for open items, closed items and for both.I have prepared a common structure or internal table for both items data. When i run the program for open and for closed items, it runs perfectly. But when i select both items i.e fetch data for open and closed items together, its giving problem. I have written the querry such as if both items radio-button is selected than it will fetch data for open items and than it should fetch for closed items and append it to the open items data in the same table. But it just keeps on loading like going in infinite loop. Can you all help with this?

6 REPLIES 6

Former Member
0 Kudos

Hi Dharmin,

Please see the logic written to fetch the data in FBL5N transaction by passing customer, company code, date and selecting the radio button(Open Item, Closed Item, Both) .

Program: SAPLKKBL

Please ensure that u r passing the comp. code and date  bcoz there might be a chance where large number of documents created for a customer in a day..due to large number of records getting fetched ur program is going to an infinite loop.

Hope, this would help u.

Thanks

Azhar

Former Member
0 Kudos

Hi Dharmin Doshi

Because it's ok when run program with open or closed item, I don't think it's the data problem,

you should debug step by step with all, your program maybe have something wrong.

Thanks&Regards,

Felix Yang

0 Kudos

Hi Felix,

I even tried debugging it but what's happening is for both items, it works ok while fetching open items data but when it goes on to the querry to fetch closed items data..it just keeps loading like if it has gone in infinite loop.I am not getting it, i mean if its works for individual items than why is it showing problem when fetching for both?

0 Kudos

U'd better paste your code for our checking.

0 Kudos

Hi,

This are the querries to fetch data.

p_open - radio-button for open.

p_closed - radio-button for cleared items.

p_both - radio-button to fetch both items.

SELECT bukrs belnr gjahr monat hwaer

FROM bkpf

INTO TABLE gint_bkpf

WHERE bukrs IN so_bukrs

AND belnr IN so_belnr

AND bldat IN so_date "Posting Date

AND budat IN so_augdt. "Clearing Date

CHECK NOT gint_bkpf[] IS INITIAL.

 

*--- Query 2: Extract details from BSID/BSAD

 

IF NOT p_open IS INITIAL OR NOT p_both IS INITIAL.

SELECT bukrs kunnr augdt augbl belnr bldat blart shkzg

wrbtr zfbdt zterm zbd1t zbd2t zbd3t rebzg

FROM bsid

INTO TABLE gint_accounting

FOR ALL ENTRIES IN gint_bkpf

WHERE bukrs EQ gint_bkpf-bukrs

 

* bukrs IN so_bukrs

 

AND gjahr IN so_gjahr

AND belnr EQ gint_bkpf-belnr

AND bldat IN so_date.

 

* AND bldat IN so_date.

 

ENDIF.

IF NOT p_closed IS INITIAL OR NOT p_both IS INITIAL.

SELECT bukrs kunnr augdt augbl belnr bldat blart shkzg

wrbtr zfbdt zterm zbd1t zbd2t zbd3t rebzg

FROM bsad

APPENDING TABLE gint_accounting

FOR ALL ENTRIES IN gint_bkpf

WHERE bukrs EQ gint_bkpf-bukrs

 

* bukrs IN so_bukrs

 

AND gjahr IN so_gjahr

AND belnr EQ gint_bkpf-belnr

AND augdt IN so_augdt.

ENDIF.

DELETE ADJACENT DUPLICATES FROM gint_accounting COMPARING ALL FIELDS.

CHECK NOT gint_accounting[] IS INITIAL.

 

*--- Query 3: Extract Customers from KNA1

 

SELECT kunnr ktokd

FROM kna1

INTO TABLE gint_kna1

FOR ALL ENTRIES IN gint_accounting

WHERE kunnr EQ gint_accounting-kunnr.

DELETE ADJACENT DUPLICATES FROM gint_kna1 COMPARING kunnr.

CHECK gint_kna1[] IS INITIAL.

 

*--- Query 4: Extract Customers detail from KNVV

 

SELECT kunnr kdgrp

FROM knvv

INTO TABLE gint_knvv

FOR ALL ENTRIES IN gint_kna1

WHERE kunnr EQ gint_kna1-kunnr.

0 Kudos

Tables BSID and BSAD have customer number (KUNNR) as part of primary key. SELECT might run for long time if there are very many records in BSAD (which would make sense, because there are usually more cleared items than the open ones). Since KUNNR is not included, I'd guess SELECT is causing full table scan. This is very easy to confirm using one of the performance tools.

By the way, BSID/BSAD are transparent tables and may be JOINed with BKPF (and KNA1 / KNVV for that matter), so there is really no need to get BKPF first and then use FOR ALL ENTRIES.

SELECT ... KNVV should include the other key fields, such as Sales Org.