Axapta 使用在其他类扩展中创建的变量

Axapta 使用在其他类扩展中创建的变量,axapta,microsoft-dynamics,x++,Axapta,Microsoft Dynamics,X++,我需要将布尔变量从一个类传递到另一个类。如何存档此文件? 我有两个类,一个创建并设置布尔值,另一个类需要得到这个值。这都是因为我需要为不同的表单在真值上运行代码。 我应该如何在这里申报新的classB? 它不允许我使用我的类ProdParmReportFinishedWG_扩展 [ExtensionOf(formStr(ProdParmReportFinished))] final class ProdParmReportFinishedWG_Extension { public boolea

我需要将布尔变量从一个类传递到另一个类。如何存档此文件? 我有两个类,一个创建并设置布尔值,另一个类需要得到这个值。这都是因为我需要为不同的表单在真值上运行代码。 我应该如何在这里申报新的classB?
它不允许我使用我的类ProdParmReportFinishedWG_扩展

[ExtensionOf(formStr(ProdParmReportFinished))]
final class ProdParmReportFinishedWG_Extension
{

public boolean TestB;


public boolean parmIsTest(boolean _test = TestB)
{
    TestB = _test;
    return TestB;
}

public void run()
{
    next run();


    if(TestB)
    {
        Ok.enabled(false);
        Info("@SRM:SRM00049");
    }
    else
    {
        Info('im false');
    }
 }

 }


[ExtensionOf(formdatasourcestr(ProdTableListPage, ProdTable))]
final class ProdParmReportFinishedActiveWG_Extension
{
public boolean Test;

    public int active()
{
    int ret;
    next Active();
    ProdTable tableBuffer = this.cursor();
    ProdTable prodtable;
    ProdParmReportFinishedWG_Extension ClassB = new ProdParmReportFinishedWG_Extension();


    ;

    if(tableBuffer.ProdId == tableBuffer.CollectRefProdId
             && tableBuffer.ProdStatus != ProdStatus::ReportedFinished)
    {
               select firstonly RecId,ProdId from ProdTable where
                  ProdTable.CollectRefProdId == tableBuffer.ProdId
                  && ProdTable.Prodstatus != ProdStatus::ReportedFinished
                  && tableBuffer.RecId != prodtable.RecId;
                  {
                      Test = true;
            ClassB.parmIsTest(Test);
            ClassB.Run();

                  }
            }
        else
        {
            Global::info(strFmt("%1 , %2, %3, %4",
            tableBuffer.prodid, tableBuffer.CollectRefProdId, tableBuffer.InventRefType, tableBuffer.ProdStatus));
        }

    return ret;
}

}

有几种方法,您可以尝试以下方法:

例如,在类A中定义并设置布尔变量,在类B中传递布尔变量并使用逻辑

代码示例:

A类

class A
{
    boolean Test;
}

private void Run()
{
    B ClassB = new B();

    ;

    //Your logic to set boolean variable
    Test = true;
    ClassB.parmIsTest(Test);
    ClassB.Run();
}
B类

class B
{
    boolean TestB;
}

public boolean parmIsTest(boolean _test = TestB)
{
    TestB = _test;
    return TestB;
}

public void Run()
{
    //Do your logic
    if(TestB)
    {
        //Your code...
    }
    else
    {
        //Your code...
    }
    //Do your logic END
}

这正是我需要的。试图单独编写,但正如我所看到的,我缺少一点B类的代码。我们将尽快尝试并发表评论。谢谢我应该如何在此上声明B类B值。。[ExtensionOf(formStr(ProdParmReportFinished))]最终类prodparmreportfinishedgw_扩展prodparmreportfinishedgw_扩展类b=新prodparmreportfinishedgw_扩展();既然我不能使用扩展类,我怎么能初始化它呢?但是我怎么能用CoC传递值呢?这里有多个例子