2009 Jul 06 10:20 AM
hi,
Pl give me one example to create invoice using bapi base on delivery number (PGI).
hi,
Pl give me one example to create invoice using bapi base on delivery number (PGI).
2009 Jul 06 10:41 AM
Hi,
This BAPI helps to create invoice number,
BAPI_BILLINGDOC_CREATE :This will call VF01 tcode where u can pass delivery number.
BAPI_BILLINGDOC_CREATEFROMDATA:I In this , fill the parameters of BILLING_DATA_IN , in this ther is field ref_doc where u can pass the delivery number,
For example:
data:wa type BAPIVBRK,
it type table of BAPIVBRK.
wa-DOC_TYPE = 'ZF2'.
wa-PLANT = '1601'.
wa-REF_DOC = delivery number.
append wa to it.
like this u can pass the fields
then call this BAPI.
BAPI_BILLINGDOC_CREATEMULTIPLE :This will create the mutilple billing documents.
If u want more details regarding this got BAPI transaction , u will get all the details or u can view with SE37 also.
Thanks & Regards,
Anagha Deshmukh
2009 Jul 06 10:55 AM
Hi Krupa
i have came across the same requirment and i used a bdc program for that.
Try this
if sy-tcode eq 'VF01' and xvbrk-vkorg eq 'JMG'.
data:
lw_charg type lips-charg, " Batch number
lw_mblnr type mseg-mblnr, " Number of Material Document
lw_mjahr type mseg-mjahr, " Document number
lw_vbelv type vbfa-vbelv, " Delivery document
lw_fkdat type rv60a-fkdat, " Billing date
lw_fbuda type rv60a-fbuda, " Services rendered
lw_prsdt type rv60a-prsdt, " Pricing date
lw_date_format(10) type c. " System date
DATA:
t_bdc TYPE TABLE OF bdcdata, " BDC table
fs_bdc TYPE bdcdata. " BDC workarea
get parameter id: 'FKDAT' field lw_fkdat,
'FBUDA' field lw_fbuda,
'PRSDT' field lw_prsdt.
select charg " Batch
from lips
into lw_charg
where vbeln eq xkomfk-vbeln.
endselect.
*if lw_charg is initial.
* exit.
*endif. " If lw_charg is initial
select mblnr " Material document
mjahr " Year
from mseg
into (lw_mblnr,lw_mjahr)
where bwart eq '633'
and xauto eq space
and charg eq lw_charg
and bukrs eq 'VCL'.
endselect.
* if lw_mblnr is initial or lw_mjahr is initial.
* exit.
* endif. " If lw_mblnr is initial
2009 Jul 06 12:36 PM
2009 Jul 06 10:56 AM
Contiuation..........
select vbelv " Delivery Doc.
from vbfa
into lw_vbelv
where vbeln eq lw_mblnr
and vbtyp_v eq 'J'
and MJAHR eq lw_mjahr.
endselect.
*if lw_vbelv is initial.
*exit.
*endif. " If lw_vbelv is initial
fs_bdc-program = 'SAPMV60A'.
fs_bdc-dynpro = '0102'.
fs_bdc-dynbegin = 'X'.
APPEND fs_bdc TO t_bdc.
CLEAR fs_bdc.
fs_bdc-fnam = 'BDC_OKCODE'.
fs_bdc-fval = 'SICH'.
APPEND fs_bdc TO t_bdc.
CLEAR fs_bdc.
fs_bdc-fnam = 'RV60A-FKART'.
fs_bdc-fval = 'ZVF2'.
APPEND fs_bdc TO t_bdc.
CLEAR fs_bdc.
if not lw_fbuda is initial.
write lw_fbuda to lw_date_format.
fs_bdc-fnam = 'RV60A-FBUDA'.
fs_bdc-fval = lw_date_format.
APPEND fs_bdc TO t_bdc.
CLEAR: fs_bdc,
lw_date_format.
endif.
if not lw_fkdat is initial.
write lw_fkdat to lw_date_format.
fs_bdc-fnam = 'RV60A-FKDAT'.
fs_bdc-fval = lw_date_format.
APPEND fs_bdc TO t_bdc.
CLEAR: fs_bdc,
lw_date_format.
endif.
if not lw_prsdt is initial.
write lw_prsdt to lw_date_format.
fs_bdc-fnam = 'RV60A-PRSDT'.
fs_bdc-fval = lw_date_format.
APPEND fs_bdc TO t_bdc.
CLEAR: fs_bdc,
lw_date_format.
endif.
fs_bdc-fnam = 'KOMFK-VBELN(01)'.
fs_bdc-fval = lw_vbelv.
APPEND fs_bdc TO t_bdc.
CLEAR fs_bdc.
CALL TRANSACTION 'VF01' USING t_bdc mode 'P' update 'A'.
endif. " IF SY-TCODE EQ 'VF01'
ENDENHANCEMENT.Regards
Hareesh
2009 Jul 06 1:24 PM
Use this code
* Pass the delivery no to the FM to create the invoice
wa_vbsk-smart = u2018Fu2019.
wa_komfk-vbeln = nast-objky. u201CuF0DF-----delivery number
APPEND wa_komfk TO it_komfk.
CLEAR wa_komfk.
* To fill the message structure
* l_wa_error-vbeln_vl = nast-objky. " Delivery No.
* l_wa_error-fkart = wa_ztab-bil_doc_type." Billing Doc type
CALL FUNCTION 'RV_INVOICE_CREATE'
EXPORTING
* delivery_date = 0
invoice_date = v_date u201C<- date
* invoice_type = ' '
* pricing_date = 0
vbsk_i = wa_vbsk
with_posting = u2018Du2019
* select_date = 0
i_no_vblog = ' '
i_analyze_mode = ' '
id_utasy = ' '
id_utswl = ' '
id_utsnl = ' '
id_no_enqueue = ' '
id_new_cancellation = ' '
** IMPORTING
* VBSK_E =
* OD_BAD_DATA =
* DET_REBATE =
TABLES
xkomfk = it_komfk
xkomv = it_komv
xthead = it_thead
xvbfs = it_vbfs
xvbpa = it_vbpa
xvbrk = it_xvbrk
xvbrp = it_vbrp
xvbss = it_vbss
* XKOMFKGN =
* XKOMFKKO =
.
2009 Jul 06 1:50 PM
hi kartik,
as u told i write but not working so please tell where is my mistake?
data: lt_vbsk LIKE vbsk,
lt_xkomfk LIKE komfk OCCURS 0 WITH HEADER LINE,
lt_xvbfs LIKE vbfs OCCURS 0 WITH HEADER LINE,
lt_xkomv LIKE komv OCCURS 0 WITH HEADER LINE,
lt_xthead LIKE theadvb OCCURS 0 WITH HEADER LINE,
lt_xvbpa LIKE vbpavb OCCURS 0 WITH HEADER LINE,
lt_xvbrk LIKE vbrkvb OCCURS 0 WITH HEADER LINE,
lt_xvbrp LIKE vbrpvb OCCURS 0 WITH HEADER LINE,
lt_xvbss LIKE vbss OCCURS 0 WITH HEADER LINE.
REFRESH lt_xkomfk.
lt_xkomfk-VBELN = '4888073'.
lt_xkomfk-VBTYP = 'J'.
append lt_xkomfk.
lt_vbsk-smart = 'F'.
lt_vbsk-ernam = sy-uname.
BREAK DEVELOPER.
CALL FUNCTION 'RV_INVOICE_CREATE'
EXPORTING
* DELIVERY_DATE = 0
* INVOICE_DATE = 0
* INVOICE_TYPE = ' '
* PRICING_DATE = 0
vbsk_i = lt_vbsk
*WITH_POSTING = 'B'
WITH_POSTING = 'D'
* SELECT_DATE = 0
* I_NO_VBLOG = ' '
* I_ANALYZE_MODE = ' '
* ID_UTASY = ' '
* ID_UTSWL = ' '
* ID_UTSNL = ' '
* ID_NO_ENQUEUE = ' '
* ID_NEW_CANCELLATION = ' '
* I_BLART = ' '
IMPORTING
VBSK_E = lt_vbsk
* OD_BAD_DATA =
* DET_REBATE =
tables
xkomfk = lt_xkomfk
xkomv = lt_xkomv
xthead = lt_xthead
xvbfs = lt_xvbfs
xvbpa = lt_xvbpa
xvbrk = lt_xvbrk
xvbrp = lt_xvbrp
xvbss = lt_xvbss.
* XKOMFKGN =
* XKOMFKKO =
BREAK DEVELOPER.
if sy-subrc eq 0.
commit work.
endif.
2009 Jul 08 1:57 PM
2009 Oct 05 10:58 AM
Hi Krupa,
How did u solved the issue ? I am facing the similar kind of problem.
Thanks,
Nitesh
2009 Oct 05 11:30 AM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |