On BAPI_BILLINGDOC_CREATEMULTIPLE please help

Question: Dear all,

I am stuck with BAPI_BILLINGDOC_CREATEMULTIPLE.
I want to create a delivery-related billing doc (type ZF2) from a delivery (type ZLF). The sales order is type ZOR1 and item category is ZTN.
The doc types are customized, but still this is a very normal creation of a billing document. From SAPGUI screen, it goes OK, of course.

I have tried a variation of values, such as:

SALESORG = "1000"
DISTR_CHAN = "Z1"
DIVISION = "Z1"
DOC_TYPE = "ZOR1"
ORDBILLTYP = "ZF2 "
SOLD_TO = "0000560054"
ITEM_CATEG = "ZTN"
REQ_QTY = "1"
SALES_UNIT = "PC"
CURRENCY = "USD"
PLANT = "1000"
REF_DOC = "0080000201" <- this is delivery
MATERIAL = "ABCDEFG"
ORIGINDOC = "0000000361" <- this is sales order
ITEM = "000010"

I received errors such as "ZOR1/ZTN cannot be processed using ZF2".
(The error results are the same from VisualBasic and SE37 test screen)
I think I haven't understand which field is for billing type, delivery doc number, sales doc number etc.

Please anybody give me some help ?

Best regards,
T.Yamagiwa

Answer:
All right, here is a self-reply.
There needs to set REF_DOC_CA in oBillingDataIn.

Here is a sample VB code. The logon procedure is omitted.

---(quote)---------------------------------------------
Dim oBAPICtrl As Object
Public myConn As Object 'SAPLogonCtrl.Connection
Public logonOK As Boolean
Public logoffOK As Boolean

Dim boInvoice As Object 'Business object Customer Invoice
Dim oBillingDataIn As Object 'Parameter Header of BAPI method
Dim oReturn As Object 'Parameter Return of BAPI method
Dim oSuccess As Object 'Parameter Success of BAPI method
Dim cTestrun As Variant


Private Sub Command1_Click()

Dim tmperror As Variant
Dim tmperrmsg As Variant
Dim idxRow As Integer

cTestrun = " "

If logonOK Then
'Connect to business object ItCustBillingDoc and BAPI service
Set boInvoice = oBAPICtrl.GetSAPObject("ItCustBillingDoc")
Set oTransaction = oBAPICtrl.GetSAPObject("BapiService")
'Get structure/table objects:
Set oBillingDataIn = oBAPICtrl.DimAs(boInvoice, "CreateMultiple", "BillingDataIn")

'Fill input parameter
oBillingDataIn.Rows.Add
oBillingDataIn.Value(1, "SALESORG") = "1000"
oBillingDataIn.Value(1, "DISTR_CHAN") = "Z1"
oBillingDataIn.Value(1, "DIVISION") = "Z1"
oBillingDataIn.Value(1, "DOC_TYPE") = "ZOR1"
' oBillingDataIn.Value(1, "ORDBILLTYP") = "ZG2 "
oBillingDataIn.Value(1, "SOLD_TO") = "0000560054"
oBillingDataIn.Value(1, "ITEM_CATEG") = "ZTN"
oBillingDataIn.Value(1, "REQ_QTY") = "10.000"
oBillingDataIn.Value(1, "SALES_UNIT") = "PC"
oBillingDataIn.Value(1, "CURRENCY") = "USD"
oBillingDataIn.Value(1, "PLANT") = "1000"
oBillingDataIn.Value(1, "REF_DOC") = "0080000197"
oBillingDataIn.Value(1, "REF_ITEM") = "000010"
oBillingDataIn.Value(1, "MATERIAL") = "SCPH-39001"
' oBillingDataIn.Value(1, "ORIGINDOC") = "0060000016"
' oBillingDataIn.Value(1, "ITEM") = "000010"
oBillingDataIn.Value(1, "REF_DOC_CA") = "J"

boInvoice.CreateMultiple BillingDataIn:=oBillingDataIn, _
Testrun:=cTestrun, _
Return:=oReturn, _
Success:=oSuccess
idxRow = 1
tmperror = " "
While idxRow <= oReturn.Rows.Count
tmperror = oReturn.Value(idxRow, "TYPE")
If tmperror = "E" Then
tmperrmsg = oReturn.Value(idxRow, "TYPE") + " " + _
oReturn.Value(idxRow, "ID") + " " + _
oReturn.Value(idxRow, "NUMBER") + " " + _
oReturn.Value(idxRow, "MESSAGE")
MsgBox tmperrmsg
End If
idxRow = idxRow + 1
Wend
If tmperror <> "E" Then
oTransaction.TransactionCommit
idxRow = 1
While idxRow <= oReturn.Rows.Count
tmperror = oReturn.Value(idxRow, "TYPE")
tmperrmsg = oReturn.Value(idxRow, "TYPE") + " " + _
oReturn.Value(idxRow, "ID") + " " + _
oReturn.Value(idxRow, "NUMBER") + " " + _
oReturn.Value(idxRow, "MESSAGE")
idxRow = idxRow + 1
Wend
idxRow = 1
While idxRow <= oSuccess.Rows.Count
tmperrmsg = oSuccess.Value(idxRow, "REF_DOC") + " " + _
oSuccess.Value(idxRow, "REF_DOC_ITEM") + " " + _
oSuccess.Value(idxRow, "BILL_DOC") + " " + _
oSuccess.Value(idxRow, "BILL_DOC_ITEM")
MsgBox tmperrmsg
idxRow = idxRow + 1
Wend
End If

Else
SAPLogonControl1.Caption = "Logged Off"
End If

End Sub

---(end quote)---------------------------------------------

Hope this would help somebody someday.

T.Yamagiwa
Copyright ?2007 - 2008 www.jt77.com