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: 

Open and closed invoices

Former Member
0 Kudos

hi experts,

I have to capture the parked, open and closed invoices in a report in reference to vendor...

I got the parked invoice condition from the table BSTAT either v or w.

But i am not getting the idea how to capture the open and closed invoices...

Some one suggested me to use the ITEMSET structure but i donno how to capture those values can anyone suggest me how to do it...?

SIRI

6 REPLIES 6

Former Member
0 Kudos

Hi,

Try this..

  • If the clearing document is blank then the document is open..

IF BSEG-AUGBL IS INITIAL.

  • Open

  • If the clearing document is populated then the document is closed.

Else.

  • Closed.

ENDIF.

Thanks,

Naren

0 Kudos

Naren,

here is sample code you posted last week in one of the thread for someone...

mine also same requirement ....

can add your condition what u r saying right now to this below code......

SELECT BUKRS BELNR GJAHR

FROM BKPF

INTO TABLE T_BKPF

WHERE BUKRS = P_BUKRS

AND BSTAT IN ( ' ' , 'A' ) " ' ' - Normal document, A - Parked doc

AND BLART = P_BLART

AND CPUDT IN SO_CPUDT " Selection screen input.

.

IF NOT T_BKPF[] IS INITIAL.

SELECT BUKRS BELNR GJAHR BUZEI EBELN AUGBL AUGBT

INTO TABLE T_BSEG

FOR ALL ENTRIES IN T_BKPF

WHERE BUKRS = T_BKPF-BUKRS

AND BELNR = T_BKPF-BELNR

AND GJAHR = T_BKPF-GJAHR

AND EBELN IN SO_EBELN " selection-screen input

.

ENDIF.

i will compare my code with that....

SIRI

Former Member
0 Kudos

Hi

You will get the all OPEN invoices of a Vendor from <b>BSIK</b> table

and all CLOSED invoices from <b>BSAK</b> table

You will get all the info w.r.t to invoices from the above tables

If needed use the <b>tables RKPF and RSEG tables.</b>

Anyhow you got the PARKED invoices using the status BSTAT either v or w.

Reward Points if useful

Regards

Anji

Former Member
0 Kudos

Hi,

you can use the same query...Also check the new code after the select..

SELECT BUKRS BELNR GJAHR <b>BSTAT</b>

FROM BKPF

INTO TABLE T_BKPF

WHERE BUKRS = P_BUKRS

AND BSTAT IN ( ' ' , 'A' ) " ' ' - Normal document, A - Parked doc

AND BLART = P_BLART

AND CPUDT IN SO_CPUDT " Selection screen input.

.

IF NOT T_BKPF[] IS INITIAL.

SELECT BUKRS BELNR GJAHR BUZEI EBELN AUGBL AUGBT

INTO TABLE T_BSEG

FOR ALL ENTRIES IN T_BKPF

WHERE BUKRS = T_BKPF-BUKRS

AND BELNR = T_BKPF-BELNR

AND GJAHR = T_BKPF-GJAHR

AND EBELN IN SO_EBELN " selection-screen input

.

ENDIF.

LOOP AT T_BKPF.

  • Parked

IF T_BKPF-BSTAT = 'A'.

WRITE: / T_BKPF-BELNR , ' - Parked'.

  • process the next record.

CONTINUE.

ENDIF.

  • Check for Open / Closed.

LOOP AT T_BSEG WHERE BELNR = T_BKPF-BELNR

AND BUKRS = T_BKPF-BUKRS

AND GJAHR = T_BKPF-GJAHR

AND AUGBL <> ' '.

EXIT.

ENDLOOP.

  • If the return code is 0 then the document is cleared..

IF sy-subrc = 0.

WRITE: / T_BKPF-BELNR , ' - Closed'.

  • Else the document is not cleared.

ELSE.

WRITE: / T_BKPF-BELNR , ' - Open'.

ENDIF.

ENDLOOP.

Thanks,

Naren

0 Kudos

Naren,

you mean to say AUGBL is the key rite...

acutally in my report requirement i am having one selection screen in that i have 3 radio buttons for open, closed and parked options...

if user selects one radio button from those then i have to display correspoding records in the output...

can u more specific in your code naren...

SIRI

Former Member
0 Kudos

Hi,

<b>* Parked records.</b>

IF P_PARK = 'X'.

  • Delete the records that are not parked.

DELETE T_BKPF WHERE BSTAT <> 'A'.

ENDIF.

<b>

  • For Open and closed invoices.</b>

IF P_OPEN = 'X' OR P_CLOS = 'X'.

LOOP AT T_BKPF.

<b>* Check for Open / Closed.</b>

LOOP AT T_BSEG WHERE BELNR = T_BKPF-BELNR

AND BUKRS = T_BKPF-BUKRS

AND GJAHR = T_BKPF-GJAHR

AND AUGBL <> ' '.

EXIT.

ENDLOOP.

  • If the return code is 0 then the document is cleared..

IF sy-subrc = 0 AND P_CLOS = 'X'.

<b>* Move the values to the output internal table.</b>

T_CLOSED-BELNR = T_BKPF-BELNR.

APPEND T_CLOSED.

  • Else the document is not cleared.

ELSEIF sy-subrc <> 0 AND P_OPEN = 'X'.

<b>

  • Move the values to the output internal table.</b>

T_OPEN-BELNR = T_BKPF-BELNR.

APPEND T_OPEN.

ENDIF.

ENDLOOP.

ENDIF.

Thanks,

Naren