Skip to Content
avatar image
Former Member

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 20, 2007 at 06:05 AM

    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>

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 20, 2007 at 05:59 AM

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

    Fred

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 20, 2007 at 06:08 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 20, 2007 at 06:15 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded