11-09-2007 4:06 PM
Hello All:
I aming using a bapi to create a sales order and want a serial process to create a individual bill document for the created sales order!
I have tried many things trying to replicate the VF01 process.
BAPI_Billingdoc_createmultiple --> I can't put any net value into it. There is a conditiondatain structure, but I don't understand use of data_index. Appearantly whatever value I put in cond_type and Cond_value doesn't reflect on the bill documents. Also this bapi seems to be creating from value I set not the sales order it create from!
BAPI_Billingdoc_createfromdata --> Same data structure pass in as the createmultiple. However no return log returns document #. When I check in system status. The sales order is in status of processing. Appearantly not finished processing yet. But the Bapi has finished his work.
RV_INVOICE_CREATE --> I have tried to use this FM as well. By just put in information of XKOMFX-Mandt and XKOMFX-VBELN and POSNR. But when I ran all it does it give me a message VF063 "check the log". What log to check? where to check it?
Since in VF01 it's a simple 1 click process. Isn't there a bapi that I can just put in sales order reference and it pop back the Billing document # (or error messages if there are any)..
I appreciate any help on this! Thank You
Sincerely Yours
Bo Peng
11-09-2007 4:11 PM
Hello Bo,
I have used RV_INVOICE_CREATE FM to create invoice with reference Sales order .
Check the below code :
DATA: VBSK_I LIKE VBSK.
data : v_vbeln like vbak-vbeln.
DATA: XKOMFK LIKE KOMFK OCCURS 0 WITH HEADER LINE,
XKOMV LIKE KOMV OCCURS 0 WITH HEADER LINE,
XTHEAD LIKE THEADVB OCCURS 0 WITH HEADER LINE,
XVBFS LIKE VBFS OCCURS 0 WITH HEADER LINE,
XVBPA LIKE VBPAVB OCCURS 0 WITH HEADER LINE,
XVBRK LIKE VBRKVB OCCURS 0 WITH HEADER LINE,
XVBRP LIKE VBRPVB OCCURS 0 WITH HEADER LINE,
XVBSS LIKE VBSS OCCURS 0 WITH HEADER LINE,
XKOMFKGN LIKE KOMFKGN OCCURS 0 WITH HEADER LINE.
refresh: XKOMFK, XKOMV,
XTHEAD, XVBFS,
XVBPA, XVBRK,
XVBRP, XVBSS.
clear : XKOMFK, XKOMV,
XTHEAD, XVBFS,
XVBPA, XVBRK,
XVBRP, XVBSS,
VBSK_I.
VBSK_I-SMART = 'F'.
XKOMFK-VBELN = P_VBELN.
<b>XKOMFK-VBTYP = 'C'</b>. " -> Sales order to Invoice
APPEND XKOMFK.
Invoice Creation Function Module
CALL FUNCTION 'RV_INVOICE_CREATE'
EXPORTING
VBSK_I = VBSK_I
WITH_POSTING = 'C'
TABLES
XKOMFK = XKOMFK
XKOMV = XKOMV
XTHEAD = XTHEAD
XVBFS = XVBFS
XVBPA = XVBPA
XVBRK = XVBRK
XVBRP = XVBRP
XVBSS = XVBSS.
if sy-subrc eq 0.
COMMIT WORK AND WAIT.
endif.
Thanks
Seshu
11-09-2007 4:11 PM
Hello Bo,
I have used RV_INVOICE_CREATE FM to create invoice with reference Sales order .
Check the below code :
DATA: VBSK_I LIKE VBSK.
data : v_vbeln like vbak-vbeln.
DATA: XKOMFK LIKE KOMFK OCCURS 0 WITH HEADER LINE,
XKOMV LIKE KOMV OCCURS 0 WITH HEADER LINE,
XTHEAD LIKE THEADVB OCCURS 0 WITH HEADER LINE,
XVBFS LIKE VBFS OCCURS 0 WITH HEADER LINE,
XVBPA LIKE VBPAVB OCCURS 0 WITH HEADER LINE,
XVBRK LIKE VBRKVB OCCURS 0 WITH HEADER LINE,
XVBRP LIKE VBRPVB OCCURS 0 WITH HEADER LINE,
XVBSS LIKE VBSS OCCURS 0 WITH HEADER LINE,
XKOMFKGN LIKE KOMFKGN OCCURS 0 WITH HEADER LINE.
refresh: XKOMFK, XKOMV,
XTHEAD, XVBFS,
XVBPA, XVBRK,
XVBRP, XVBSS.
clear : XKOMFK, XKOMV,
XTHEAD, XVBFS,
XVBPA, XVBRK,
XVBRP, XVBSS,
VBSK_I.
VBSK_I-SMART = 'F'.
XKOMFK-VBELN = P_VBELN.
<b>XKOMFK-VBTYP = 'C'</b>. " -> Sales order to Invoice
APPEND XKOMFK.
Invoice Creation Function Module
CALL FUNCTION 'RV_INVOICE_CREATE'
EXPORTING
VBSK_I = VBSK_I
WITH_POSTING = 'C'
TABLES
XKOMFK = XKOMFK
XKOMV = XKOMV
XTHEAD = XTHEAD
XVBFS = XVBFS
XVBPA = XVBPA
XVBRK = XVBRK
XVBRP = XVBRP
XVBSS = XVBSS.
if sy-subrc eq 0.
COMMIT WORK AND WAIT.
endif.
Thanks
Seshu
11-09-2007 4:25 PM
Thank You Seshu:
This works very well. Except it doesn't pop back billdoc information afterwards. Non does it return error message when it can't create invoice! Is my understanding correct? Again. thank you very much.
11-09-2007 5:21 PM
Yep,it will not give any message.
Make sure that XVBRK-VBELN should not be initial. XVBRK-VBELN is initial then some issue while creating the invoice.
Hope you got it.
Thanks
Seshu
11-12-2007 8:35 PM
Hello Seshu:
When you say commit work and wait. What is the wait for? For some reason when I execute it in SE37 it works fine. But when I execute it in .NET it does not create invocie! The sales order creates just fine.
Sincerely Yours
Bo Peng
11-12-2007 8:47 PM
Hello Bo,
You should not use this FM becuase this is normal function module.
Please use below FM :
BAPI_BILLINGDOC_CREATEFROMDATA
Thanks
Seshu
11-12-2007 8:58 PM
Hello Seshu:
Thank you for the very fast reply, but I have tried to use BAPI_BILLINGDOC_CREATEFROMDATA. the problem is that I have to fill in everything detail wise for the sales order, and it seems that it's only invoicing against the data that I put in and not the actually order it's against. And that's not a huge problem. But I can't seem to get the net value right. It always become 0 for whatever I put in. Do you might also have some sample code regarding this BAPI that I can use?
Thanks a million!
11-12-2007 9:33 PM
Hello Bo,
Simple way is - Copy the FM RV_INVOICE_CREATE to Z FM.
Now change the attributes to Remote enabled.
This should work .
Thanks
Seshu
11-12-2007 9:39 PM
Hello Seshu>
While I do the copying. should I delete the enhencements? I don't really know how to deal with it right now!
Sincerely Yours
Bo Peng
11-12-2007 10:02 PM
First Create Function group
goto SE80 -> workbench->edit -> click on function groups tab -> use custom function group ( Starting with z* or Y*)-> now click on create button(F5)->
You get one pop up window -> give description -> click on save -> use package -> save under one request.
Now goto SE37 -> enter RV_INVOICE_CREATE FM -> click on copy.
now you get pop up window -> to function module ( Use ZRV_INVOICE_CREATE ,use Custom function group).
now it gets copied -> click on change -> attributes -> change into remote enabled module.
here you get many syntax errors :
do not use blank data types
suppose in importing parameters :
I_ANALYZE_MODE -> this should be I_ANALYZE_MODE LIKE VBRK-FKTYP
now look at each includes -> copy the variables and other source code from RV_INVOICE_CREATE FM Function group to your function group includes.
do it manually ,it will take while.
Thanks
Seshu
11-12-2007 10:05 PM
If you get difficulty to copying then try to look at below code :
REPORT ZTEST_INVOICE .
data : i_BAPIVBRK like BAPIVBRK occurs 0 with header line.
data i_BAPIRET1 like BAPIRET1 occurs 0 with header line.
data : i_BAPIVBRKSUCCESS like BAPIVBRKSUCCESS occurs 0 with header line.
parameters : p_vbeln like vbak-vbeln obligatory.
start-of-selection.
i_bapivbrk-DOC_NUMBER = p_vbeln.
i_bapivbrk-REF_DOC_CA = 'C'.
append i_bapivbrk.
CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE'
EXPORTING
CREATORDATAIN =
TESTRUN =
POSTING =
TABLES
BILLINGDATAIN = i_bapivbrk
CONDITIONDATAIN =
CCARDDATAIN =
RETURN = i_BAPIRET1
SUCCESS = i_BAPIVBRKSUCCESS
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN =
Note : i did not test it since i did not have proper data.
Thanks
Seshu
11-12-2007 10:21 PM
Thank you so much Seshu:
Onlything needs to be changed is i_bapivbrk-REF_DOC = p_vbeln. Everything works great! Thank so much!
Sincerely Yours
Bo Peng
11-12-2007 9:07 PM
Hi,
In the BAPI BAPI_BILLINGDOC_CREATEFROMDATA you have to pass the PRICE_DATE in the parameter BILLING_DATA_IN
BILLING_DATA_IN-PRICE_DATE = SY-DATUM
to get the pricing.
Thanks
Naren
11-12-2007 9:10 PM
Hello Narendran:
I understand. I don't want to use system price list, I have specific values for each item. This is a special sales order, Unless it can pass data from the original sales order which have those price, then I need a place to identify the special prices.
I have tried to use the CONDITIONDATAIN. But can't figure out how to use the DATA_INDEX. and unable to pass any value into it!
Sincerely
02-01-2008 3:30 AM
It was very interesting to see the whole process. Sheshu Can you please help me with this. My problem is what kind of changes do they do in RV_INVOICE_CREATE for before invoice cancellation. The user_exit used is
CALL CUSTOMER-FUNCTION '002'
TABLES
xkomfk = xkomfk.
What all scenario's might come under such situations. Can you pls reply to this.
I would appreciate your help.
krishna