开发者

Getting the index of an array element of EDT Dimension

开发者 https://www.devze.com 2023-03-03 02:23 出处:网络
I need to write a job where i could fetch开发者_StackOverflow中文版 the index of an array element of EDT Dimension

I need to write a job where i could fetch开发者_StackOverflow中文版 the index of an array element of EDT Dimension e.g. In my EDT Dimension i have array elements A B C when i click over them for properties I see the index for A as 1, B as 2 and C as 3. Now with a job ui want to fetch the index value. Kindly Assist.


I'm not sure if I did understand the real problem. Some code sample could help.
The Dimensions Table has some useful methods like arrayIdx2Code.

Maybe the following code helps:

static void Job1(Args _args)
{
    Counter         idx;
    Dimension       dimension;
    DimensionCode   dimensionCode;
    str             name;
    ;
    for (idx = 1; idx <= dimof(dimension); idx++)
    {
        dimensionCode = Dimensions::arrayIdx2Code(idx);
        name = enum2str(dimensionCode);
        // if (name == 'B') ...
        info(strfmt("%1: %2", idx, name));
    }
}


I found a way but still looking if there is any other solution.

static void Job10(Args _args)
{

    Dicttype    dicttype;
    counter     i;
    str         test;
    ;
    test = "Client";
    dicttype = new dicttype(132);//132 here is the id of edt dimension 

    for (i=1;i<=dicttype.arraySize();i++)
    {
        if ( dicttype.label(i) == test)
        {
            break;
        }
    }
    print i;
    pause;

}


Array elements A B C from your example are nothing else but simple labels - they cannot be used as identifiers. First of all, for user convenience the labels can be modified anytime, then even if they aren't, the labels are different in different languages, and so on and so forth.

Overall your approach (querying DictType) would be correct but I cannot think of any scenario that would actually require such a code.

If you clarified your business requirements someone could come up with a better solution.

0

精彩评论

暂无评论...
验证码 换一张
取 消