X++ Code to Create Ledger and Inventory Journal names

Following job creates the journal names for all the different types of Journal type that have been defined in Ledger and  Inventory modules.
These journal names will be used for Posting Inventory and Ledger Journals in DAX.
 
void create_JournalNames()
    {
         
        LedgerJournalType     ledgerJournalType;
        LedgerJournalName   ledgerJournalName;
        Enumerator                  enumerator;
        DictEnum                     dictEnum;
        InventJournalName     inventJournalName;
        Counter                        i;
        InventItemType            inventItemType;
        InventJournalType       inventJournalType;
        str                                 itemTypeTxt;
        ;

        select firstonly numseqTable ;

        dictEnum = new DictEnum(enumnum(ledgerJournalType));

        // This block will loop until the end element of enum
        for (i=0;idictEnum.values();i++)
        {
            ledgerJournalType = str2enum(LedgerJournalType,dictEnum.value2Name(i));

            ledgerJournalName.clear();
            ledgerJournalName.initValue();

            ledgerJournalName.JournalName   = strfmt("%1%2_J",substr(enum2str(ledgerJournalType),1,3),i);
            ledgerJournalName.VoucherSeries = numseqTable.NumberSequence;
            ledgerJournalName.Name          = strfmt("%1 Journal",ledgerJournalType);
            ledgerJournalName.JournalType   = ledgerJournalType;

            if (ledgerJournalName.validateWrite())
                ledgerJournalName.insert();

        }

        dictEnum = new DictEnum(enumnum(inventJournalType));

        for (i=0;idictEnum.values();i++)
        {
            inventJournalType = str2enum(inventJournalType,dictEnum.value2Name(i));

            inventJournalName.clear();
            inventJournalName.initValue();

  
inventJournalName.JournalNameId   =strfmt("%1%2_J",substr(enum2str(inventJournalType),1,3),i);

            inventJournalName.Description     = strfmt("%1 Journal",inventJournalType);
            inventJournalName.JournalType     = inventJournalType;

            if (inventJournalName.validateWrite())
                inventJournalName.insert();

        }

    }

Enjoyyyy X++ Cooding !!!!!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.