Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Invoice number without a FI document will be empty.

Raxph
Participant
0 Likes
589

Hello everyone,

I am trying to fix a certain already developed function with the goal that the SD Invoice with amount 0 EUR should not be transmitted to FI. As I understood, the below code is used to select the data from FI and SD:

* select order-related invoices
    SELECT * FROM vbfa AS v INTO TABLE gt_vbfa_inv
      FOR ALL ENTRIES IN gt_vbak
      WHERE vbelv = gt_vbak-vbeln
        AND vbtyp_n IN ('M', 'O', 'P', '5', '6')
        AND stufe = '00'
        AND NOT EXISTS ( SELECT * FROM vbfa
                           WHERE vbelv = v~vbeln
                             AND posnv = v~posnn
                             AND vbtyp_n IN ('N', 'S')
                             AND stufe = '00' ) .
    IF sy-subrc = 0.
* select invoice head status
      SELECT DISTINCT * FROM vbuk APPENDING TABLE gt_vbuk_inv
        FOR ALL ENTRIES IN gt_vbfa_inv
        WHERE vbeln = gt_vbfa_inv-vbeln.                  "#EC CI_SUBRC
    ENDIF.

    SORT gt_vbuk_inv BY vbeln.
    DELETE ADJACENT DUPLICATES FROM gt_vbuk_inv COMPARING vbeln.

    IF me->gv_items = abap_true AND gt_vbuk_inv IS NOT INITIAL.
      SELECT * FROM vbrp INTO TABLE gt_vbrp
        FOR ALL ENTRIES IN gt_vbuk_inv
        WHERE vbeln = gt_vbuk_inv-vbeln.                  "#EC CI_SUBRC
    ENDIF.

As far as I can understand from the above written code, is that the table VBFA is used to get the data for FI, while the table VBRP is used to get the data for SD. What I want to achieve is that when the invoice number does not have a FI document, then the invoice number will be empty.

If the tables BKPF(for the FI) and VBRK(for the SD) would be used, then I could have tried the relation:

vbrk-xblnr=bkpf-xblnr.

However, those tables are not used in the function. May I please ask you, how can I fix the code so that when the invoice number does not have a FI document, thus the invoices with a value of 0 EUR will not generate an FI document, then the invoice number will be empty.

Thank you all in advance!

Hello everyone,

I am trying to fix a certain already developed function with the goal that the SD Invoice with amount 0 EUR should not be transmitted to FI. As I understood, the below code is used to select the data from FI and SD:

* select order-related invoices
    SELECT * FROM vbfa AS v INTO TABLE gt_vbfa_inv
      FOR ALL ENTRIES IN gt_vbak
      WHERE vbelv = gt_vbak-vbeln
        AND vbtyp_n IN ('M', 'O', 'P', '5', '6')
        AND stufe = '00'
        AND NOT EXISTS ( SELECT * FROM vbfa
                           WHERE vbelv = v~vbeln
                             AND posnv = v~posnn
                             AND vbtyp_n IN ('N', 'S')
                             AND stufe = '00' ) .
    IF sy-subrc = 0.
* select invoice head status
      SELECT DISTINCT * FROM vbuk APPENDING TABLE gt_vbuk_inv
        FOR ALL ENTRIES IN gt_vbfa_inv
        WHERE vbeln = gt_vbfa_inv-vbeln.                  "#EC CI_SUBRC
    ENDIF.

    SORT gt_vbuk_inv BY vbeln.
    DELETE ADJACENT DUPLICATES FROM gt_vbuk_inv COMPARING vbeln.

    IF me->gv_items = abap_true AND gt_vbuk_inv IS NOT INITIAL.
      SELECT * FROM vbrp INTO TABLE gt_vbrp
        FOR ALL ENTRIES IN gt_vbuk_inv
        WHERE vbeln = gt_vbuk_inv-vbeln.                  "#EC CI_SUBRC
    ENDIF.

As far as I can understand from the above written code, is that the table VBFA is used to get the data for FI, while the table VBRP is used to get the data for SD. What I want to achieve is that when the invoice number does not have a FI document, then the invoice number will be empty.

If the tables BKPF(for the FI) and VBRK(for the SD) would be used, then I could have tried the relation:

vbrk-xblnr=bkpf-xblnr.

However, those tables are not used in the function. May I please ask you, how can I fix the code so that when the invoice number does not have a FI document, thus the invoices with a value of 0 EUR will not generate an FI document, then the invoice number will be empty.

Thank you all in advance!

0 REPLIES 0