web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Syntax error on run method

(0) ShareShare
ReportReport
Posted on by

I'm attempting to build onto a previous post where an info log was generated that provided voucher information.

I'm creating a class to present to the user a dialog box with a pick list of customer accounts. When compiling the run method I'm receiving a syntax error. Below is the class I started to create.

First the classDeclaration

class CyborgDialogInput extends RunBase
//this is the class declaration
{
    CustTable               custTable;
    CustTrans               custTrans, countCustTrans; //why is the table buffer created twice?
    DialogField             fieldAccount;
    DialogField             fieldName;
    SysOperationProgress    sysOperationProgress;
    int                     vCount,crow;
    CustAccount             varCustAccount, custAccount;
    str                     strLongRes;
}


Next the Dialog Method

protected Object Dialog()
{
    Dialog  dialog;
    ;     
    dialog          =   super();//what does this method do?
    //Sets the title for the dialog
    dialog.caption( 'Cust Voucher Info');
    //creates the dialog field
    fieldAccount    =   dialog.addField(extendedTypeStr(CustAccount), 'Customer Account');
    
    return  dialog;
}

The get method

public boolean getFromDialog()
{
    //This method is used to capture the selected value
    //from the Dialog method
   custAccount      = fieldAccount.value();
    
    return  super();
    
}


 The run method where I encounter the compile error which just states Syntax error.

The compiler highlights a portion of the line starting with sysOperationProgress

public void run()
{
    custTable           =   custTable::find(custAccount);
    
    //Below is where I encounter the error
    sysOperationProgress Progress = new SysOperationProgress(); --complier highlights from Progress to the end of the line.
    #AviFiles
    
    varCustAccount      = custAccount;
    
    
    select count(RecId) from countCustTrans
            where countCustTrans.AccountNum == varCustAccount
                && countCustTrans.Voucher != '';
     
    vCount = int642int(countCustTrans.RecId);
    
    
    
    
    setPrefix(strFmt('Total Count %1',vCount));
    
     
    crow=1;
    
    
    progress.setCaption(strFmt("Processing %1 records",vCount));
    progress.setAnimation(#AviUpdate);
    progress.setTotal(vCount);
    
    
    while select AccountNum from custTable
        join custTrans
            where(custTrans.AccountNum == custTable.AccountNum) 
                && custTable.AccountNum == varCustAccount
    {
        //sets the variable strLongRes and reduces typing               
        strLongRes = int2str(crow)+" "+custTable.AccountNum+  "-"+ custTrans.Voucher+"-"+date2str(custTrans.TransDate,213,DateDay::Digits2,DateSeparator::Auto,DateMonth::Digits2,DateSeparator::Auto,DateYear::Digits4);
             
        //info method to communicate output of strLongRes
        info(strLongRes);
        //this is calling the class methods of progress to display to the user
        //after running this multiple times it executes faster but I saw it the first run
        progress.setText(strfmt("Exeuting %1 for total of %2", crow,vCount));
        Progress.incCount();
        //increment the variable crow for communication on progress to the user
        crow = crow+1;                         
    }
}


 There are most likely a few other issues with this code and the concept I'm working to understand but there is a simple concept I'm missing. Any help would be appreciated as I take yet another baby step.

Thank you in advance.

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    235,961 Most Valuable Professional on at
    RE: Syntax error on run method

    The answer has to parts. Yes, SysOperation framework is a replacement of RunBase base framework and you should use it for all new development. It's will do many things for you and it also has additional features.

    But it doesn't mean that the RunBase framework is going to disappear. It would require rewriting all classes based on RunBase framework, written in all those years before AX 2012. It doesn't look worth doing.

  • Community Member Profile Picture
    on at
    RE: Syntax error on run method

    All thank you for your input. Below is the working class. Its a neat little program for learners such as myself. Many good concepts were raised.

    Passing arguments from a dialog

    pack/unpack

    SysOperation Framework

    Here is the code....

    Class Declaration

    class CyborgDialogInput extends RunBase
    //this is the class declaration
    {
        CustTable               custTable;
        CustTrans               custTrans, countCustTrans; //why is the table buffer created twice?
        DialogField             fieldAccount;
        DialogField             fieldName;
        SysOperationProgress    sysOperationProgress;
        int                     vCount,crow;
        CustAccount             varCustAccount, custAccount;
        str                     strLongRes;
        #define.CurrentVersion(1)
        #define.Version1(1)
        #localmacro.CurrentList
            custAccount
        #endmacro
    }


    run()

    public void run()
    {
        sysOperationProgress   =   new sysOperationProgress();
        custTable               =   custTable::find(custAccount);
        
    
           
        #AviFiles
    
        varCustAccount      = custAccount;
    
            select count(RecId) from countCustTrans
                where countCustTrans.AccountNum == varCustAccount
                    && countCustTrans.Voucher != '';
            vCount = int642int(countCustTrans.RecId);
    
    
       
        setPrefix(strFmt('Total Count %1',vCount));
    
            crow=1;
        sysOperationProgress.setCaption(strFmt("Processing %1 records",vCount));
        sysOperationProgress.setAnimation(#AviUpdate);
        sysOperationProgress.setTotal(vCount);
    
            while select AccountNum from custTable
            join custTrans
                where(custTrans.AccountNum == custTable.AccountNum)
                    && custTable.AccountNum == varCustAccount
        {
                    strLongRes = int2str(crow)+" "+custTable.AccountNum+  "-"+ custTrans.Voucher+"-"+date2str(custTrans.TransDate,213,DateDay::Digits2,DateSeparator::Auto,DateMonth::Digits2,DateSeparator::Auto,DateYear::Digits4);
                    info(strLongRes);
                    sysOperationProgress.setText(strfmt("Exeuting %1 for total of %2", crow,vCount));
            sysOperationProgress.incCount();
                   crow = crow+1;
        }
    }
    


    getFromDialog()

    public boolean getFromDialog()
    {
        //This method is used to capture the selected value
        //from the Dialog method
       custAccount      = fieldAccount.value();
    
        return  super();
    
    }
    

    dialog()

    protected Object Dialog()
    {
        Dialog  dialog;
        ; //why is this additional semicolon needed?
    
        dialog          =   super();//what does this method do?
        //Sets the title for the dialog
        dialog.caption( 'Cust Voucher Info');
        //creates the dialog field
        fieldAccount    =   dialog.addFieldValue(extendedTypeStr(CustAccount), custAccount);
    
        return  dialog;
    }
    

    main()

    public static void main(Args    _args)
    {
        //SysOperationProgress wprogress = new SysOperationProgress();
       
        CyborgDialogInput custCreate = new CyborgDialogInput();
        
        //Prompt the dialog
        if (custCreate.prompt())
        {
            custCreate.run();
        }
    }


    pack()

    public container    pack()
    {
        return [#CurrentVersion,#CurrentList];
        
    }
    


    unpack()

    public boolean unpack(container _packedValues)
    {
        int     version = RunBase::getVersion(_packedValues);
       // (_packedValues,1);
        boolean ret = true;    
        ;
        switch (version)
        {
            case #CurrentVersion:
                [version, #CurrentList] = _packedValues;
                break;
    
            case 2:
                [version, custAccount]  =   _packedValues;
                break;
            default:
                ret =   false;
                break;
        }
        return ret;
    
    }
  • Community Member Profile Picture
    on at
    RE: Syntax error on run method

    Is the RunBase class being retired in the AX development roadmap and replaced by SysOperation Framework?

  • Community Member Profile Picture
    on at
    RE: Syntax error on run method

    Martin, Your correct I have more due diligence ahead of me.  Like all good cyborgs if we don't adapt we die. Hopefully good folks like yourself will aid in the adaptation and continue to disseminate your expertise. Thank you for your responsiveness.

  • Suggested answer
    Martin Dráb Profile Picture
    235,961 Most Valuable Professional on at
    RE: Syntax error on run method

    As Chaitanya Golla pointed out, there already is a variable called progress defined in RunBase class, therefore you don't have to declare any new variable. But you have to initialize it - if you try to call methods, such as setCaption(), on a null object, you obviously must get an error.

    I suggest you simply call progressInit() before trying to use progress variable for the first time.

  • Martin Dráb Profile Picture
    235,961 Most Valuable Professional on at
    RE: Syntax error on run method

    Unfortunately you don't understand basics of software development, such as scope of variables (which applies to some respondents as well). You created your progress variable in the main(), therefore it exists in the main() method only. It doesn't exist in run() method, for instance (although you may have another variable of the same name there). And because you don't use the variable in main(), it has absolutely no effect. If you remove the declaration, your code will behave exactly the same.

    Regarding SysOperation framework, you'll find a plenty of documentation and blog posts on internet. Pick which one you like.

  • Community Member Profile Picture
    on at
    RE: Syntax error on run method
    
    


    Pralay,

    I took your advice here.

    All preceding code is the same minus moving the SysOperationProgress class from run.

    Here is the code for main()

    It looks like this little application is getting closer to completion but I get an error message which I've already posted in this thread.

    Here is the code for main

    public static void main(Args    _args)
    {
        SysOperationProgress Progress = new SysOperationProgress();
        CyborgDialogInput custCreate = new CyborgDialogInput();
        
        //Prompt the dialog
        if (custCreate.prompt())
        {
            custCreate.run();
        }
    }


     The error is referencing the first line where I reference progress in run.

    progress.setCaption(strFmt("Processing %1 records",vCount));


     I'm thinking that I need to instantiate the RunBase class so when I try it in main it receive a different error in the compiler stating "Object could not be created because class RunBase is abstract."

    I'd say im at a sticking point. Any suggestions?

  • Verified answer
    Chaitanya Golla Profile Picture
    17,225 on at
    RE: Syntax error on run method

    Hi,

    Do the following changes and it will execute:

    1) In the ClassDeclaration, declare SysOperationProgress    sysOperationProgress;

    2) In the run method, instantiate it

    sysOperationProgress = new SysOperationProgress();

    3) Replace progress with sysOperationProgress  in the run method,

       Lines 30 to 32.  

       sysOperationProgress.setCaption(strFmt("Processing %1 records",vCount));

       sysOperationProgress.setAnimation(#AviUpdate);

       sysOperationProgress.setTotal(vCount);

       Line 47 and Line 48

        sysOperationProgress.setText(strfmt("Exeuting %1 for total of %2", crow,vCount));

        sysOperationProgress.incCount();

    4) In the dialog method, replace with this line

    fieldAccount    =   dialog.addFieldValue(extendedTypeStr(CustAccount), custAccount);

    5) Include code for main, pack and unpack to make it complete.

    Thanks,

  • Community Member Profile Picture
    on at
    RE: Syntax error on run method

    Martin, To be honest with you I haven't explored it. Aside from referencing the class based on feedback from others such as yourself and Sohaib I never know it could be used for dialogs.

    I'm all for best practices and efficiency so I'll look into this further.

    Any hints you can provide on where to start?

  • Community Member Profile Picture
    on at
    RE: Syntax error on run method

    Chaitanya,

    I ended up removing the line from the run method and placed it in main. That allowed for the compile to proceed.

    I then ran the class, received a dialog with the pick list but then after selecting a customer I received a different error.

    0042.Capture.JPG

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Syed Haris Shah Profile Picture

Syed Haris Shah 9

#2
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#2
Community Member Profile Picture

Community Member 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans