Application Development 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: 

BAPI for creating sales invoice

Former Member
0 Kudos

Hi,

I use BAPI_SALESORDER_CREATEFROMDAT2 to create salesorder. Is there another BAPI or function to convert this salesorder to invoice?

9 REPLIES 9

former_member188685
Active Contributor
0 Kudos

Hi,

check the FM <b>GN_INVOICE_CREATE</b>, it will create the Invoice.

Regards

vijay

0 Kudos

How do I tell to BAPI_BILLINGDOC_CREATEMULTIPLE (or GN_INVOICE_CREATE) that it should create invoice from existing sales order?

0 Kudos

Hi Erki,

you need to fill the communication structures KOMFK,KOMFKGN,KOMFKKO,KOMFKTX etc..and pass it to FM.

CALL FUNCTION 'GN_INVOICE_CREATE'
      EXPORTING
        DELIVERY_DATE   = DELIVERY_DATE
        INVOICE_DATE    = INVOICE_DATE
        INVOICE_TYPE    = 'ZFX'
        PRICING_DATE    = PRICING_DATE
        VBSK_I          = X_VBSK
        WITH_POSTING    = 'D'
        ID_NO_ENQUEUE   = 'X'        
      TABLES
        XKOMFK          = IT_KOMFK
        XKOMFKGN        = IT_KOMFKGN
        XKOMFKKO        = IT_KOMFKKO
        XKOMFKTX        = IT_KOMFKTX
        XKOMV           = IT_KOMV
        XTHEAD          = IT_HEAD
        XVBFS           = IT_VBFS
        XVBPA           = IT_VBPA
        XVBRK           = IT_VBRK
        XVBRP           = IT_VBRP
        XVBSS           = IT_VBSS
        SUCCESS_DOC_OUT = IT_SUCCESS.

Regards

vijay

0 Kudos

Hi,

I debugged vf01 and found that it uses RV_INVOICE_CREATE. It only needs xkomfk-vbeln field as order number and creates invoice correctly.

My invoices are automatically printed to spool.

My goal is to get the OTF spool, convert it to PDF and stream it to PHP web application.

<b>PDF part works OK, only missing link is how to get spool number after rv_invoice_create?</b>

br,

erki

0 Kudos

Hi Erki,

Are you sure that will generate the Spool, if that is the case you can read the spool table TSP01 with the Username,date. in your program have a code like this...

before generating the spool(i mean calling the FM) take the latest spool with the help of username,date.

then call your FM, then later again select the Spool using user,date. compare both the spool numbers , if they are not same, then consider the second one as the spool number generated . if they are same then no spool generated.

Regards

vijay

0 Kudos

Hello,

as I just found out, you have to call the fm RV_INVOICE_DOCUMENT_ADD, too. My coding (working) looks like this:

it_komfk-vbeln = '0000000111'.

it_komfk-vbtyp = 'J'.

append it_komfk.

CALL FUNCTION 'RV_INVOICE_CREATE'

EXPORTING

vbsk_i = wa_VBSK

IMPORTING

VBSK_E = wa_vbsk_e

tables

xkomfk = it_KOMFK

xkomv = it_KOMV

xthead = it_THEADVB

xvbfs = it_VBFS

xvbpa = it_VBPAVB

xvbrk = it_VBRKVB

xvbrp = it_VBRPVB

xvbss = it_VBSS.

CALL FUNCTION 'RV_INVOICE_DOCUMENT_ADD'

EXPORTING

vbsk_i = wa_vbsk_e

WITH_POSTING = 'A'

tables

xkomfk = it_KOMFK

xkomv = it_KOMV

xthead = it_THEADVB

xvbfs = it_VBFS

xvbpa = it_VBPAVB

xvbrk = it_VBRKVB

xvbrp = it_VBRPVB

xvbss = it_VBSS.

regards,

Johannes.

0 Kudos

hi.. rv_invoice_create is returning values but when the same structures are passed to

rv_invoice_document_add it is not returning anything...

Former Member
0 Kudos

Pass the sales order number and its item to field DOC_NUMBER and ITM_NUMBER of structure BILLINGDATAIN.

0 Kudos

Does not work, it requires also other fields and then creates invoice based on that data not on sales order data.

Is there an easier way to reference only sales order number to create matching invoice?