Creates a new journal, or saves changes to an existing journal that has a Working or Submitted status.
To successfully call SaveJournal, the connected user must be assigned to the Journals Administrator or Create Journals role, and must have All access to the journal’s security class. |
The arguments for journal line items consist of arrays. The arrays have a one-to-one correspondence; for example, the second elements in the varadAmount and vararlAccount arguments’ arrays specify the amount and account for a journal’s second line item.
SaveJournal is almost identical to SaveTextJournal; the only difference is that SaveJournal passes line item amounts in a Double array while SaveTextJournal passes line item amounts in a String array. For more information, see SaveTextJournal.
To create a journal from a template, use GetTemplate to get the template’s information, then pass the applicable GetTemplate return values to SaveJournal. For information on GetTemplate, see GetTemplate. |
<IHsvJournalsEx>.SaveJournal lScenario, lYear, lPeriod, lValue, nType, nStatus, nAttribute, bstrLabel, bstrDescription, bstrGroup, lSingleEntity, lSingleParent, lSecurityClass, vararnDebitCreditUnit, varadAmount, vararbstrDescription, vararlEntity, vararlParent, vararlAccount, vararlICP, vararlCustom1, vararlCustom2, vararlCustom3, vararlCustom4, plJournalID
Long (ByVal). The member ID of the Scenario dimension member. | |
Long (ByVal). The member ID of the Value dimension member for the journal’s currency. | |
Integer (ByVal). Specifies the journal’s type. Pass one of the HFMConstants type library constants listed in Journal Type Constants. | |
Integer (ByVal). Specifies the journal’s status. Pass one of the HFMConstants type library constants listed in Journal Status Constants. | |
Integer (ByVal). Specifies whether the journal must be balanced. Pass one of the HFMConstants type library constants listed in Balance Type Constants. | |
String (ByVal). The description of the journal. You can pass a blank string if there is no description. | |
String (ByVal). The journal group to which the journal is assigned. You can pass a blank string if the journal is not being assigned to a journal group. | |
Long (ByVal). For single entity journals, specify the member ID of the journal’s base entity. For multi-entity journals, pass a value of -1. | |
Long (ByVal). For single entity journals, specify the member ID of the journal’s parent entity. For multi-entity journals, pass a value of -1. | |
Long (ByVal). The ID of the journal’s security class. To get this ID, pass the security class name to HsvSecurityAccess.GetSecurityClassID. For more information, see GetSecurityClassID. | |
Integer array (ByVal). Specifies whether the line items are debits or credits. Pass one of the HFMConstants type library constants listed in Debit/Credit Constants. | |
Long array (ByVal). The member IDs for the base entities of the line items. For single-entity items, set the IDs in this array to the same member ID that is in the lSingleEntity argument. | |
Long array (ByVal). The member IDs for the parent entities of the line items. For single-entity items, set the IDs in this array to the same member ID that is in the lSingleParent argument. | |
Long array (ByVal). The member IDs of the accounts for the line items. | |
Long array (ByVal). The member IDs of the line items’ Intercompany Partner dimension members. | |
Long array (ByVal). The member IDs of the line items’ Custom 1 dimension members. | |
Long array (ByVal). The member IDs of the line items’ Custom 2 dimension members. | |
Long array (ByVal). The member IDs of the line items’ Custom 3 dimension members. | |
Long array (ByVal). The member IDs of the line items’ Custom 4 dimension members. | |
Long. The purpose of this argument depends upon whether you are creating a new journal or updating an existing journal:
|
This example uses SaveJournal in a custom function that creates journals from a template. The custom function is named CreateJournal, and takes the following items as arguments:
The example gets the template’s information with GetTemplate; note how most of GetTemplate’s return values are passed to SaveJournal.
Function CreateJournal(lScenID As Long, lYearID _ As Long, lPerID As Long, lValID As Long, sTemplate _ As String, sJnlName As String, daAmount() As Double, _ iaDebCredUnit() As Integer) As Long Dim cHsvJournals As HsvJournals Dim cIHsvJournalEx As IHsvJournalsEx Dim lTempID As Long, iType As Integer, iAttr As Integer Dim sLabel As String, sDescHead As String, sGroup As String Dim lSecId As Long, lSingleEnt As Long, lSinglePar As Long Dim iTempType As Integer, lTempVal As Long, vaEntryIDs Dim vaDebCredUnit, vaAmt, vaItemDesc, vaEnt, vaPar, vaAcct Dim vaICP, vaCust1, vaCust2, vaCust3, vaCust4, lJnlID As Long 'm_cSession is an HsvSession object reference Set cHsvJournals = m_cSession.Journals Set cIHsvJournalEx = m_cSession.Journals 'Get the template's ID lTempID = cHsvJournals.GetJournalTemplateItemID(sTemplate) 'Get the template's data cIHsvJournalEx.GetTemplate lTempID, iType, iAttr, sLabel, _ sDescHead, sGroup, lSecId, lSingleEnt, lSinglePar, _ iTempType, lTempVal, vaEntryIDs, vaDebCredUnit, vaAmt, _ vaItemDesc, vaEnt, vaPar, vaAcct, vaICP, vaCust1, _ vaCust2, vaCust3, vaCust4 'Create the journal. cIHsvJournalEx.SaveJournal lScenID, lYearID, lPerID, lValID, _ iType, 1, iAttr, sJnlName, "", "", lSingleEnt, lSinglePar, _ lSecId, iaDebCredUnit, daAmount, vaItemDesc, vaEnt, _ vaPar, vaAcct, vaICP, vaCust1, vaCust2, vaCust3, _ vaCust4, lJnlID 'Assign the return value CreateJournal = lJnlID End Function