cancel
Showing results for 
Search instead for 
Did you mean: 

Billing Doc

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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>

Answers (3)

Answers (3)

Former Member
0 Kudos

HI,

do modifications where i have indicates as bold.change the position of the two fields in selection list.

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:

<b>S1 TYPE VBRK-FKART.</b>

SELECT VBRKVBELN VBRKAEDAT VBRKVBTYP <b>VBRKFKART VBRK~NETWR</b>

VBRPPOSNR VBRPFKIMG 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.

<b>reward if helpful</b>

rgds,

bharat.

Former Member
0 Kudos

Check the XBLNR field in the VBRK table against the cancelled document number. There you will get the original billing document number which was cancelled.

Please mark points if the solution was useful.

Regards,

Manoj

FredericGirod
Active Contributor
0 Kudos

You could play also with VBFA to get the link between SD documents

Fred