4 Dec 2023

How to handle flexible/variable budget code segment with Cost Management API

Default blog image

Recently, I got some questions related to flexible/variable Budget Code Segment. Actually, variable budget code segment is a new added feature, and there are some mystery using it by API, let's clarify it in details today.

Please be noted, setting up budget code template has to be done before adding any real budgets into the system, one real budgets are imported, the budget code template is read only.

Now let's see how to add a normal length fixed budget code segment, it's simple, you just need to specify the length to a number, here is the sample request body

        "name": "Fixed Segment Code 1",
        "type": "code",
        "delimiter": "none",
        "length": 6,
        "position": 0,
        "sampleCode": 6656

Then, how to create a variable budget code segment? The new flag/parameter of isVariableLength which is included in the request body could help achieve this. But due to an internal issue(#ACSC-9897), you need to also specify the length to a number as 20 even for a variable segment, this is a current workaround for the issue #ACSC-9897. Check the following request body:

    "name": "Variable Segment Code 1",
    "type": "info",
    "delimiter": "tab",
    "isVariableLength": true,
    "length": 20,
    "position": 1

Now, let's talk about how to add a real budget based on a budget code template which include variable segment, take the above 2 segments as example, you need to specify the budget code by parameter segmentCodeMap instead of code, within segmentCodeMap, the key is the segment Id and the value should be the code of the segment, please remember code is still required but the value could be ignored for this case, here is an example:

    "parentId": null,
    "code": "666666VARIABLECODE",
    "name": "Budget with Flexible segment",
    "description": "budget description",
    "segmentCodeMap": {
        "b8558da0-8ff8-11ee-815f-1b44e78bf477": "666666",
        "184336a0-8ffd-11ee-815f-1b44e78bf477": "VARIABLECODE"
    "quantity": 1,
    "unitPrice": "1000",
    "unit": "LS"

 You should be all set:)

Related Article