Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Billing Doc

Hi,

This is my program to retrieve the cancelled billing documents.

Here whenever i cancel the billing document, a new document is generated. Now i want to retrieve the cancelled billing documents as well as the new billing documents that r generated when i cancel the existing billing document. Plz tell me how to write the program.

This is my program for retrieving the cancelled billing documents. Now i want the cancelled billing document number as well as the new billing document number that is generated when i cancelled the existing billing document. Plz suggest me how to retrieve that?

Retrieving the Billing doc that are cancelled.

TYPES:

BEGIN OF TY_OUTPUT,

VBELN TYPE VBRK-VBELN,

AEDAT TYPE VBRK-AEDAT,

VBTYP TYPE VBRK-VBTYP,

FKART TYPE VBRK-FKART,

NETWR TYPE VBRK-NETWR,

POSNR TYPE VBRP-POSNR,

FKIMG TYPE VBRP-FKIMG,

END OF TY_OUTPUT.

DATA:

ST_OUTPUT TYPE TY_OUTPUT,

IT_OUTPUT TYPE TABLE OF TY_OUTPUT.

DATA:

S1 TYPE C.

SELECT VBRKVBELN VBRKAEDAT VBRKVBTYP VBRKNETWR VBRKFKART VBRPPOSNR VBRP~FKIMG

INTO TABLE IT_OUTPUT FROM VBRK

INNER JOIN VBRP ON VBRKVBELN EQ VBRPVBELN

WHERE VBRK~FKART EQ S1.

IF SY-SUBRC EQ 0.

SORT IT_OUTPUT BY VBELN.

ENDIF.

IF IT_OUTPUT IS NOT INITIAL.

LOOP AT IT_OUTPUT INTO ST_OUTPUT.

WRITE:/ ST_OUTPUT-VBELN, ST_OUTPUT-AEDAT,

ST_OUTPUT-VBTYP, ST_OUTPUT-NETWR,ST_OUTPUT-POSNR,ST_OUTPUT-FKIMG.

CLEAR : ST_OUTPUT.

ENDLOOP.

ELSE.

WRITE:/ 'NO RECORDS FOUND'.

ENDIF.

Thanks

Tags:
Former Member
Former Member replied

Hi Rams,

The cancelled billing documents can be selected with condition

VBRK-FKTYP = 'N'.

and in this table entry we have the original billing document number maintained in the field

VBRK-SFAKN.

Hope this helps. Revert for more clarification if required.

Regards,

Vikas

<b>Always reward all helpful answers.</b>

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question