on 2014 May 12 7:11 PM
Dear Expert,
Project field in SAP B1 8.82 is now a choosefromlist.
When I add a document, e.g., the good receipt PO, the project code that I have selected in the accounting tab --> project can't be filled in the journal entry.
So, I want that the project field value appears in the journal entry good receipt PO transaction before I add the journal entry. Please kindly let me know the code because my code is not working as expected.
I appreciate your help. Thank you
Steve
Request clarification before answering.
hi.
Your requirement is little bit confusion
you are posting goods rece po , and your selecting bp project, and adding the document.
automatically one je will be passed based upon the receipt po
but i je project is not updating ........
u want to update the project field at je am correct....
first check it is it possible through the b1 default functionality like changing some settings in the system..
if u ask me is it possible through the coding i think yes..
if i be in your place
first u have to check whether the goods receipt document is posted successfully or not
below code will be execute or fire once the document will be posted successfully..
Try
If (pVal.BeforeAction = False And pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED And pVal.ActionSuccess = True And pVal.ItemUID = "1" And pVal.FormTypeEx = "143") Then
oForm = oApplication.Forms.GetFormByTypeAndCount("142", 1)
here u have to apply your logic....
first u have to get the project code from goods receipt table from max doc entry
means last record of the goods receipt
using recordset method save in any string
dim prjcode as string = recordset value.
now second step is u have to update the project code into je am i correct.
again u have to check it je max record which means which records u is last one
and also the je passed by goods receipt or u have to check it..
in header level plz check origin and ref3 and remarks field...
and then u have to update the je using je object using coding..
have a look on below one for your reference..
End If
Catch ex As Exception
oApplication.MessageBox(ex.Message)
End Try
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I want the project code from OPDN automatically updated project code of the JE line. So, if the project code in the OPDN is Sales then the project code in the OPDN Journal Entry line is Sales.
By using SAP B1 standard, there is no possibility to do that. It must use SDK add-on.
If BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_UPDATE Or _
BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD Then
Dim oForm As SAPbouiCOM.Form
oForm = M_SBOApplication.Forms.Item(BusinessObjectInfo.FormUID)
Dim oSBO As SAPbouiCOM.ComboBox
If BusinessObjectInfo.FormTypeEx = "170" Or BusinessObjectInfo.FormTypeEx = "426" Then
oSBO = CType(oForm.Items.Item("95").Specific, SAPbouiCOM.ComboBox)
Else
oSBO = CType(oForm.Items.Item("157").Specific, SAPbouiCOM.ComboBox)
End If
oJE.Project = oSBO.Selected.Value()
oJE.Lines.ProjectCode = oSBO.Selected.Value()
Dim i As Integer
For i = 1 To oJE.Lines.Count - 1
oJE.Lines.SetCurrentLine(i)
oJE.Lines.ProjectCode = oSBO.Selected.Value()
Pls kindly help
Rgds,
Steve
hi. Are u there..
The below code is working for me no doubt
i had tested working good.
have a look on below image..
the below code will fire only after adding the record successfully ok
not at the time of adding the record.. put the break point at any line and check it..
Try
If (pVal.BeforeAction = False And pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED And pVal.ActionSuccess = True And pVal.ItemUID = "1" And pVal.FormTypeEx = "143") Then
oForm = oApplication.Forms.GetFormByTypeAndCount(oForm.TypeEx, 1)
Dim orec As SAPbobsCOM.Recordset
orec = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
Dim Rsql As String
Rsql = "select t0.docnum,t0.docentry,t0.project from opdn t0 where t0.docentry in(select max(t0.docentry)from opdn t0)"
orec.DoQuery(Rsql)
Dim ProjCode As String = orec.Fields.Item("project").Value
Dim Docnum As Integer = orec.Fields.Item("docnum").Value
Dim orec1 As SAPbobsCOM.Recordset
orec1 = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
Dim Rsql1 As String
Rsql1 = "select ojdt.TransId,ojdt.BaseRef from ojdt where ojdt.BaseRef = " & Docnum & ""
orec1.DoQuery(Rsql1)
Dim journalEntryNume As Integer = orec1.Fields.Item("TransId").Value
Dim ret As Integer
Dim je As SAPbobsCOM.JournalEntries
je = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries)
If (je.GetByKey(journalEntryNume)) Then
je.ProjectCode = ProjCode
ret = je.Update()
If (ret <> 0) Then
MessageBox.Show(oCompany.GetLastErrorDescription())
Return
Else
MessageBox.Show("Poject Code update successfully")
End If
End If
End If
Catch ex As Exception
oApplication.MessageBox(ex.Message)
End Try
Hi,
I'll use your code to solve my problem.
My problem is I want to insert project code in the JE line but not in the JE header.
Here the error message of my problem:
Unable to cast COM object of type 'System.__ComObject' to interface type 'SAPbouiCOM.ChooseFromList'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{797380A5-C3B0-4395-B8A3-9CABF6DED2C6}' failed...
Please kindly help to solve this issue
Rgds,
Steve
Steve, i use this code in order to Update a Journal Entry Line, you can change for your specific issue.
Public Sub UpdateJournal(oCompany As SAPbobsCOM.Company, DocEntry As String, DocNumFV As String)
Dim rstJrnNumer As SAPbobsCOM.Recordset
Dim Qry As String = ""
Dim JrnNumber As Integer = 0
Dim DocNumFact As String = ""
Dim oJournal As SAPbobsCOM.JournalEntries
Dim lRstCode As Integer = 0
Dim nResult As Integer = 0
Dim errString As String = ""
Qry = "Select T0.DocNum, T1.TransId From OPCH T0 Inner Join OJDT T1 On T0.TransId = T1.TransId Where T0.DocEntry=" & DocEntry
rstJrnNumer = CType(oCompany.GetBusinessObject(BoObjectTypes.BoRecordset), Recordset)
Try
rstJrnNumer.DoQuery(Qry)
If Not rstJrnNumer.EoF Then
DocNumFact = rstJrnNumer.Fields.Item("DocNum").Value.ToString.Trim
JrnNumber = CInt(rstJrnNumer.Fields.Item("TransId").Value)
End If
oJournal = CType(oCompany.GetBusinessObject(BoObjectTypes.oJournalEntries), SAPbobsCOM.JournalEntries)
Try
If oJournal.GetByKey(JrnNumber) Then
For i As Integer = 0 To oJournal.Lines.Count - 1
oJournal.Lines.SetCurrentLine(i)
oJournal.Lines.Reference1 = DocNumFV
oJournal.Lines.ReferenceDate1 = DateTime.Now
oJournal.Lines.Add()
Next i
lRstCode = oJournal.Update
If lRstCode <> 0 Then
Call oCompany.GetLastError(nResult, errString)
Throw new System.Exception(errString)
Else
''Your Action Here
End If
End If
Catch ex1 As System.Exception
Throw New System.Exception(ex1.Message)
Finally
Marshal.ReleaseComObject(oJournal)
oJournal = Nothing
End Try
Catch ex2 As Exception
Throw New System.Exception(ex2.Message)
Finally
Marshal.ReleaseComObject(rstJrnNumer)
rstJrnNumer = Nothing
End Try
End Sub
Cheers,
Pablo
Hi Pablo,
THanks for the code but I can't see the code that can be used in solving my problem.
I need the code that can be used to insert the project code in the JE line from project code in its document. E.g., if the GRPO doc using Ash in the BP project, then the JE line of the GRPO doc must also use Ash after the GRPO created.
Pls kindly help me to solve this issue.
Rgds,
Steve
hi.
If oJournal.GetByKey(JrnNumber) Then
For i As Integer = 0 To oJournal.Lines.Count - 1
oJournal.Lines.SetCurrentLine(i)
oJournal.Lines.Reference1 = DocNumFV
oJournal.Lines.ReferenceDate1 = DateTime.Now
oJournal.Lines.Add()
Next i
in the above loop just change the code means just add one more line..
If oJournal.GetByKey(JrnNumber) Then
For i As Integer = 0 To oJournal.Lines.Count - 1
oJournal.Lines.SetCurrentLine(i)
oJournal.Lines.projectcdoe="yourstring"
' oJournal.Lines.Reference1 = DocNumFV
' oJournal.Lines.ReferenceDate1 = DateTime.Now
oJournal.Lines.updte()
Next i
Hi,
Nice solution but still problem persists. The project code may not be hardcode from a document only.
All of documents must enter the project code in the accounting tab. Then, the addon should insert the project code in the journal entry line after all of the documents already added.
So, it is not only good receipt PO, it is also AP invoice, DO, AR invoice, payment, etc.
Please provide a solution for this issue.
THanks,
Steve
| User | Count |
|---|---|
| 59 | |
| 30 | |
| 21 | |
| 11 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.