Skip to Content

In SAP Standard it is possible to Cancel the Invoice for which we have already created & completed Returns Order. Similarly we can create Returns Order for an Invoice that is already Canceled.

We felt that is not logical behavior & raised a query to SAP & below is the reply we received:

Quote

Your system works correct, there is no program error.

Creation of a sales documents with reference to a billing document does not prevent any actions done on the billing document.

Furthermore it is also possible to create a return with reference to a canceled billing document.

In transaction VOFA you could set an own copying requirement (field TVFK-GRBED_S) for the used billing document type.

Unquote

So we decided to develop Custom Routines & insert the same at appropriate places. (Routines were created / modified after taken necessary access keys from SAP)

1. Sales Invoice for with Returns Order have be created, should not be allowed to be canceled.

Following was the Routine created:

FORM BEDINGUNG_PRUEFEN_601.

* This Routine is used to restrict cancellation of billing documents against Return Orders.

*{ INSERT ECDK951721 1

DATA : lv_vbeln TYPE vbeln_von.

SY-SUBRC = 0.

IF vbak-vbeln NE space.

SELECT SINGLE vbeln FROM vbfa Into lv_vbeln WHERE vbelv = vbak-vbeln AND

vbtyp_n = ‘H’.

IF SY-SUBRC = 4.

SY-SUBRC = 0.

EXIT.

ELSEIF sy-subrc = 0.

MESSAGE ‘Billing document cannot be canceled as Returns Order was generated against this Invoice’ TYPE ‘E’.

ENDIF.

endif.

*} INSERT

ENDFORM.

The above Routine was assigned at Copying Requirements for Cancellation in Billing Type

Now when we tried to Cancel the Invoice for which Returns Order was created, system gave a error message.

2. Now, for Invoices that are already Canceled, system should not allow to create Returns Order

Here we have to create / modify a Copying Requirement & assign the same at Billing Document to Sales Document Copying Control (T-Code VTAF)

Normally Copying Requirement 021 is assigned at Billing Document to Sales Document Copying Control so the below code was added to the 021 Requirement & new Requirements (601) was created).

Following was the ABAP code added to standard Routine 021 (& new Routine created):

IF vbrk-fksto = ‘X’.

MESSAGE ‘Return Order Cannot be Raised Against Canceled Billing Document’ TYPE ‘E’.

ENDIF.

After assignment of above new Requirements to VTAF Copying Controls, when we try to create Returns Order for Canceled Invoice, system gave a error message.

I am trying to upload images of the above settings, but there seems to be some issue currently.

To report this post you need to login first.

21 Comments

You must be Logged on to comment or reply to a post.

  1. TW Typewriter

    Jignesh,

    Thanks for sharing this document!

    For a SCN thread, I had done some tests in IDES, in the similar lines (user can cancel a billing document, even if this billing document was used as reference to create a return order). I felt that this behavior was “strange”.

    But now after reading the reply from SAP:

    Creation of a sales documents with reference to a billing document does not prevent any actions done on the billing document.

    Furthermore it is also possible to create a return with reference to a canceled billing document.

    I have few comments, which I feel are important for a functional consultant to consider (analyze):

    1. Billing document & its link with the subsequent RE order, delivery: The actions on the billing document do not change the fact that goods have been delivered to the customer.

    E.g. user cancels a billing document that does not mean if customer is dissatisfied with the goods he/she can not return the goods!

    Thus even if billing document is cancelled, the subsequent RE order and RE delivery should be very much possible.

    The financial / money part is to be review here.

    Billing document cancelled means that the customer does NOT have to pay for the goods. Thus in turn in the RE process, the RE credit memo should not be created.

    This can be done by the user, he/she can put a billing block in the order.

    2. Creating a RE order with reference to a cancelled billing document:

    Same logic as in point 1.

    Side comment 1: The entire business process should be analyzed, not a part thereof.

    Before configuration, all the variant situations must be taken in to consideration. Furthermore, what “manual” steps need to be done (or desired to be done) by the company / users.

    Lastly, good instruction manual, training needs to be in place.

    Side comment 2: I shall be reviewing the logic part, as I see a definite scope of learning (for me).

    (0) 
    1. Jignesh Mehta Post author

      Hello TW,

      Thank you for your interest & comments.

      I too have some notes here:

      1. Reversal of Sales Invoice: Firstly generally it is not advised to reversel a Sales Invoice. One should ideally settle the dispute with sursequent Debit / Credit Memo. Thus If Invoice is cancelled, there is no need to create subsequent document like Credit Memo, which the current system allows & need to be controlled.

      2. Regarding money part, as the Invoice is anyways cancelled, thus Customer need not pay anything. Thus if you allow creating subsequent Document like Dredit Memo, it can lead to issue of free credit to Customer which is not required. I believe we all have came across many cases where Billing Block is removed by user himself, as the senior is very busy & he shares his SAp password with subordinates. I understand this is not accepted, but we all know this happens practically. Thus if there is control in system, such errors (frauds) can be avoided.

      Thanks,

      Jignesh Mehta

      (0) 
      1. TW Typewriter

        Jignesh,

        Thanks for your reply!

        What changes / updates have you done in version 2?

        Maybe you could have indicated the updated part in your document

        e.g. version2 update: …………

        (0) 
        1. Jignesh Mehta Post author

          Hello TW,

          There are very minor changes in version 2 – like change in subject line, removal of signature, etc, as suggested by a moderator.

          Thanks,

          Jignesh Mehta

          (0) 
  2. ' MoazzaM '

    Thanks for sharing the the idea and its control parameters. it totally depends on client’s requirement that they want to go for this check or not. As TW sir has mentioned these checks can be by passed by some clients but still it is very informative and useful technique for SD functional consultant. 

    Thanks again.

    (0) 
  3. Former Member

    Dear Jignesh Sir

    Fist I would like to thank you for giving such a awesome document,

    But I would like to add that the code which you provided will not work.

    FORM BEDINGUNG_PRUEFEN_601.

    * This Routine is used to restrict cancellation of billing documents against Return Orders.

    *{ INSERT ECDK951721 1

    DATA : lv_vbeln TYPE vbeln_von.

    SY-SUBRC = 0.

    IF vbak-vbeln NE space.

    SELECT SINGLE vbeln FROM vbfa Into lv_vbeln WHERE vbelv = vbak-vbeln AND

    vbtyp_n = ‘H’.

    IF SY-SUBRC = 4.

    SY-SUBRC = 0.

    EXIT.

    ELSEIF sy-subrc = 0.

    MESSAGE ‘Billing document cannot be canceled as Returns Order was generated against this Invoice’ TYPE ‘E’.

    ENDIF.

    endif.

    *} INSERT

    ENDFORM.

    here you are taking reference, i.e. VBAK now suppose there is a sale order with two deliveries and two billing and there is return for only single billing and next one is fine. In this case it will always have VBTYP_N =H into the corresponding VBFA and hence it will get sy-subrc=0.And as per your code it will also not allow to cancel normal billing invoice, We have tested the same.

    Now I would like to add that in this code if you will reference VBRK-SFAKN instead of VBAK-VBELN. 🙂 , it will work fine.

    Please update the document with the same changes.

    TW Typewriter  Sir, Thanks for sharing valuable inputs.

    Thanking you!

    Ashish Mishra

    (0) 
    1. TW Typewriter

      Ashish,

      Very good post! Thank you!

      Two points:

      1. Jignesh in order to check whether a RE order is created or not, and then to allow the cancelling of a billing document (or not): Why are you checking the sales order (VBAK-VBELN)? Why don’t you check billing document (VBRK-VBELN)? In your logic?

      2. Ashish please explain the below:

      Now I would like to add that in this code if you will reference VBRK-SFAKN instead of VBAK-VBELN. 🙂 , it will work fine.

      How cancellation billing document instead of Sales order shall work?

      I feel instead of Sales order, billing document should be considered.

      If for a billing document, a return order is created. System should populate the error message

      Else, the cancellation billing document should be allowed to be created.

      (0) 
      1. TW Typewriter

        Jignesh,

        After going throught the code for both points, I noticed that in essence the structure is more or less same for both points:

        i.e.

        Invoice has some conditions, then appropriate action CAN be taken

        (e.g. Invoice cancelled, then no RE order can be created

        Invoice used as reference to create RE order, then no cancellation of invoice possible)

        For point 2 you have used table VBRK

        Then why for point 1, you have used table VBAK? 🙂

        Is this a typing error (in this document)? or is the code being written with VBAK? (w.r.t point1)

        (0) 
        1. Jignesh Mehta Post author

          Hello T W,

          Hope you have gone through the document thoroughly.

          The first requirement is to control cancellation of Invoice, if Returns Order is created. We may still allow subsequent credit memo & debit memo to be created even after Invoice is cancelled. Thus we are going to Doucment Flow (VBFA) to check whether there is subsequent Document created with reference to current Invoice (which is being cancalled), if yes then check whether the Document category is H (Returns), if yes, do not allow to cancel the Invoice.

          For point no. 2 we are trying to create a Returns Order & need to check whether the Invoice (with whose reference the Returns order is created) is cancelled or not. So we are going to VBRK table.

          Hope this clarifies.

          Thanks,

          (0) 
          1. TW Typewriter

            Jignesh,

            Based on your previous post, please help me understand point 1.

            There is no issue with point 2.

            IF vbak-vbeln NE space.

            SELECT SINGLE vbeln FROM vbfa Into lv_vbeln WHERE vbelv = vbak-vbeln AND

            vbtyp_n = ‘H’.

            IF SY-SUBRC = 4.

            SY-SUBRC = 0.

            EXIT.

            Is my understanding of the above code correct?

            In table VBFA, logic is checking if

            Preceeding document VBELV = Sales order

            Subsequent document category VBTYP_N = H

            If there are NO entries, (meaning there are no subsequent RE orders created), then billing document can be cancelled.

            My question is why you are considering Sales order, WHY not consider Billing document (VBRK-VBELN) in VBFA-VBELV?

            This shall solve Ashish’s point of 1sales order > deliveries > 2 billing documents,

            for 1 of the billing documents RE order is created.

            Then for the other billing document, cancellation is still possible.

            A$HI$H $AP please comment on the above.

            (0) 
    2. Jignesh Mehta Post author

      Hello Ashish,

      The scenario at our client site is One Order – One Delivery – One Billing. Thus there is case (possibility) of multiple Delivery & multiple Invoice. So the code given above suffices the purpose. What you have pointed out may be true, but as that was not the requirement here, we have not tried it.

      Thanks,

      Jignesh Mehta

      (0) 
      1. Former Member

        Dear Sir

        It will work in case of

        VA01>VL01N>VF01>VA01(RE)and it will stop when you will throw VF11, i.e. ONE>ONE>ONE Relationship.

        But this code will also not allow to cancel

        VA01>VL01N>VF01>VF11

        Thanking you!

        Ashish Mishra

        (0) 
        1. Jignesh Mehta Post author

          Hello Ashish,

          We have tested & implemented this at a client site. Even the client has done positive & negative testing & they were satisfied.

          Also let us not point out mistakes here. Every person has his / her own way of execution & coding. What is important is pluging the loophole in the system which users can misuse.

          Thanks,

          Jignesh Mehta

          (0) 
          1. Former Member

            Hello Jignesh

            Thus I asked you to make correction! and I have also express my thanks to you for this wonderful doc, and FYI I was not pointing any mistake there: Hope you will take this in Positive Spirit

            Ashish Mishra

            (0) 
              1. TW Typewriter

                Jignesh,

                Would you have preferred members just (only) saying “Good document” etc.?

                Personally for me, when a member just says “good document” or just presses the “Like” button, he/she has not really thought over the content of the document.

                By agreeing, disagreeing, extending with the content, the members are conveying that the document/ article was worth investing time in.

                And that, for me, is the best complement to the author.

                Side comment: If some one corrects me, that is the learning which I get from participating in forums like these.

                Side comment2: Please continue sharing! Thank you!

                (0) 

Leave a Reply