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.
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.
ST_OUTPUT TYPE TY_OUTPUT,
IT_OUTPUT TYPE TABLE OF TY_OUTPUT.
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.
IF IT_OUTPUT IS NOT INITIAL.
LOOP AT IT_OUTPUT INTO ST_OUTPUT.
WRITE:/ ST_OUTPUT-VBELN, ST_OUTPUT-AEDAT,
CLEAR : ST_OUTPUT.
WRITE:/ 'NO RECORDS FOUND'.
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
Hope this helps. Revert for more clarification if required.
<b>Always reward all helpful answers.</b>