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

RV_INVOICE_CREATE - Problem when running for a batch - Urgent

Former Member
0 Likes
1,477

Hi,

We have requirement to split order related billing. I am using function module,

CALL FUNCTION 'RV_INVOICE_CREATE'

EXPORTING

INVOICE_TYPE = RV60A-FKART

INVOICE_DATE = RV60A-FKDAT

PRICING_DATE = RV60A-PRSDT

DELIVERY_DATE = RV60A-FBUDA

SELECT_DATE = RV60A-SELDAT

VBSK_I = VBSK

WITH_POSTING = 'B'

IMPORTING

VBSK_E = VBSK

TABLES

XKOMFK = XKOMFK

XTHEAD = XTHEAD

XVBFS = XVBFS

XVBSS = XVBSS

XVBRK = XVBRK

XVBRP = XVBRP

XVBPA = XVBPA

XKOMV = XKOMV.

The problem I am fasing is that when we run it for single it runs perfectly. But when runs for a big range some of the documents fails.

I am checking Order lock before this process too.

If any one has inputs on this it will be a great help.

Thanks in advance.

Mahendra

Hi,

We have requirement to split order related billing. I am using function module,

CALL FUNCTION 'RV_INVOICE_CREATE'

EXPORTING

INVOICE_TYPE = RV60A-FKART

INVOICE_DATE = RV60A-FKDAT

PRICING_DATE = RV60A-PRSDT

DELIVERY_DATE = RV60A-FBUDA

SELECT_DATE = RV60A-SELDAT

VBSK_I = VBSK

WITH_POSTING = 'B'

IMPORTING

VBSK_E = VBSK

TABLES

XKOMFK = XKOMFK

XTHEAD = XTHEAD

XVBFS = XVBFS

XVBSS = XVBSS

XVBRK = XVBRK

XVBRP = XVBRP

XVBPA = XVBPA

XKOMV = XKOMV.

The problem I am fasing is that when we run it for single it runs perfectly. But when runs for a big range some of the documents fails.

I am checking Order lock before this process too.

If any one has inputs on this it will be a great help.

Thanks in advance.

Mahendra

5 REPLIES 5
Read only

Former Member
0 Likes
1,165

hi check this


   LOOP AT POSTAB WHERE FKTYP = 'A' AND VBTYP = 'C'.
      PERFORM XKOMFK_FUELLEN(SAPMV60S).
      CALL FUNCTION 'RV_INVOICE_CREATE'
           EXPORTING
                WITH_POSTING  = ' '
                VBSK_I        = XVBSK
                DELIVERY_DATE = RV60A-FBUDA
                PRICING_DATE  = RV60A-PRSDT
                INVOICE_DATE  = RV60A-FKDAT
                INVOICE_TYPE  = RV60A-FKART
                SELECT_DATE   = POSTAB-FKDAT  "nicht in 2.1/2.2
           IMPORTING
                VBSK_E        = XVBSK
           TABLES
                XKOMV         = XKOMV
                XVBPA         = XVBPA
                XVBRP         = XVBRP
                XVBRK         = XVBRK
                XKOMFK        = XKOMFK
                XTHEAD        = XTHEAD
                XVBFS         = YVBFS
                XVBSS         = YVBSS.
      CALL FUNCTION 'DEQUEUE_EVVBAKE'
           EXPORTING
                VBELN = POSTAB-VBELN.
      DESCRIBE TABLE XVBRK LINES SY-SUBRC.
      IF SY-SUBRC = 0.
        DELETE POSTAB.
        REFRESH XKOMFK.
      ELSE.
        CALL FUNCTION 'RV_INVOICE_REFRESH'
             EXPORTING
                  WITH_POSTING = ' '
             TABLES
                  XKOMFK       = XKOMFK
                  XKOMV        = XKOMV
                  XTHEAD       = XTHEAD
                  XVBFS        = XVBFS
                  XVBSS        = XVBSS
                  XVBPA        = XVBPA
                  XVBRK        = XVBRK
                  XVBRP        = XVBRP.

      ENDIF.
    ENDLOOP.

regards

vijay

Read only

0 Likes
1,165

Thanks.

But where can we get POSTAB-VBELN?

Mahendra

Read only

Former Member
0 Likes
1,165
<b>CALL FUNCTION 'RV_READ_INVOICE_INDEX'
       EXPORTING
            COMWA                = VBCO7
            NO_BILLING_BLOCK     = VBCO7-NO_FAKSK
            DEFAULT_BILLING_TYPE = RV60A-FKART
       TABLES
            LVKDFI  = POSTAB
            S_KUNNR = S_KUNNR
            S_VBELN = S_VBELN
            S_LLAND = S_LLAND
            S_FKART = S_FKART
            S_SORTKRI = S_SORTKRI
            S_VTWEG   = S_VTWEG
            S_SPART   = S_SPART.</b>* 
  IF   1 = 2  AND
       SY-UCOMM = 'SAMH'.
    REFRESH XKOMFK.
    LOOP AT POSTAB WHERE FKTYP = 'A' AND VBTYP = 'C'.
      PERFORM XKOMFK_FUELLEN(SAPMV60S).
      CALL FUNCTION 'RV_INVOICE_CREATE'
           EXPORTING
                WITH_POSTING  = ' '
                VBSK_I        = XVBSK
                DELIVERY_DATE = RV60A-FBUDA
                PRICING_DATE  = RV60A-PRSDT
                INVOICE_DATE  = RV60A-FKDAT
                INVOICE_TYPE  = RV60A-FKART
                SELECT_DATE   = POSTAB-FKDAT  "nicht in 2.1/2.2
           IMPORTING
                VBSK_E        = XVBSK
           TABLES
                XKOMV         = XKOMV
                XVBPA         = XVBPA
                XVBRP         = XVBRP
                XVBRK         = XVBRK
                XKOMFK        = XKOMFK
                XTHEAD        = XTHEAD
                XVBFS         = YVBFS
                XVBSS         = YVBSS.
      CALL FUNCTION 'DEQUEUE_EVVBAKE'
           EXPORTING
                VBELN = POSTAB-VBELN.
      DESCRIBE TABLE XVBRK LINES SY-SUBRC.
      IF SY-SUBRC = 0.
        DELETE POSTAB.
        REFRESH XKOMFK.
      ELSE.
        CALL FUNCTION 'RV_INVOICE_REFRESH'
             EXPORTING
                  WITH_POSTING = ' '
             TABLES
                  XKOMFK       = XKOMFK
                  XKOMV        = XKOMV
                  XTHEAD       = XTHEAD
                  XVBFS        = XVBFS
                  XVBSS        = XVBSS
                  XVBPA        = XVBPA
                  XVBRK        = XVBRK
                  XVBRP        = XVBRP.

      ENDIF.
    ENDLOOP.
  ENDIF.
* Sammelgang ----------------------------------------------------------
*------ Aktivitaetskennzeichen initialisieren -------------------------*
  LOOP AT POSTAB.
    POSTAB-ACTIV = '0'.
    POSTAB-SELKZ = 'X'.
    POSTAB-ZAEHL = SY-TABIX.
* Einstellen Vorgabedaten wegen Splittkriterium
* Fakturaart
    IF RV60A-FKART IS INITIAL.
      POSTAB-V_FKART = POSTAB-FKART.
    ELSE.
      POSTAB-V_FKART = RV60A-FKART.
    ENDIF.
* Fakturadatum
    IF POSTAB-V_FKART <> TVFK-FKART.
      SELECT SINGLE * FROM TVFK WHERE FKART = POSTAB-V_FKART.
      TVFKD_RC = SY-SUBRC.
      IF SY-SUBRC = 0.
        IF TVFK-NUMKI <> TVFKD-NUMKI.
          SELECT SINGLE * FROM TVFKD WHERE NUMKI = TVFK-NUMKI.
          TVFKD_RC = SY-SUBRC.
        ENDIF.
      ENDIF.
    ENDIF.
    IF TVFKD_RC = 0.
      POSTAB-V_FKDAT = TVFKD-FKDAT.
      IF POSTAB-FKTYP = 'A'.
        READ TABLE AUFTRAG WITH KEY POSTAB-VBELN BINARY SEARCH.
        IF SY-SUBRC = 0.
          POSTAB-V_FKDAT = AUFTRAG-FKDAT.
        ELSE.
          AUFTRAG-VBELN = POSTAB-VBELN.
          AUFTRAG-FKDAT = POSTAB-V_FKDAT.
          INSERT AUFTRAG INDEX SY-TABIX.
        ENDIF.
      ENDIF.
    ELSE.
      IF RV60A-FKDAT IS INITIAL.
        POSTAB-V_FKDAT = POSTAB-FKDAT.
* Zusammenführung von Aufträgen.
        IF POSTAB-FKTYP = 'A'.
          READ TABLE AUFTRAG WITH KEY POSTAB-VBELN BINARY SEARCH.
          IF SY-SUBRC = 0.
            POSTAB-V_FKDAT = AUFTRAG-FKDAT.
          ELSE.
            AUFTRAG-VBELN = POSTAB-VBELN.
            AUFTRAG-FKDAT = POSTAB-FKDAT.
            INSERT AUFTRAG INDEX SY-TABIX.
          ENDIF.
        ENDIF.
      ELSE.
        POSTAB-V_FKDAT = RV60A-FKDAT.
      ENDIF.
    ENDIF.
    MODIFY POSTAB.
    DESCRIBE TABLE SELTAB LINES SY-TFILL.
    CHECK SY-TFILL <> 0.
    PERFORM SELEKTION_PRUEFEN USING RCODE.
    IF RCODE <> 0.
      DELETE POSTAB.
    ENDIF.
  ENDLOOP.

Read only

0 Likes
1,165

Thanks Vijay.

I will try this.

Mahendra

Read only

0 Likes
1,165

Vijay,

we are facing this issue in a different context can I have ur contact details as it's urgent.