Printing month of year from date field as label of enum val.

hkrisz79hkrisz79 Member Posts: 13
edited 2007-05-28 in Dynamics AX
Hi there,

I have a problem with a report where I want to print out the name of the month comes from a date field.

I made a display method:

display MonthsOfYear dispMonthOfDate()
{
return mthofyr(custConfirmJour.ConfirmDate);
}


Ok, It's works fine. But, I want to set the printed text to lowercase.
To make clear: It's prints : "May" , and I want to print out: "may"


I switched on the AutoDeclaration for the affected field in the report, and
put in the fetch the

dispMonthOfDate.changeCase(...);

, but it isn't works.


Could somebody help me?
Thanks in advance!
Best Regards

Krisztian Hampuk
AX Consultant

Comments

  • burdee64burdee64 Member Posts: 20
    Hello hkrisz

    Why not just use strlwr() function in your display:



    display MonthsOfYear dispMonthOfDate()
    {
    return strlwr(mthofyr(custConfirmJour.ConfirmDate));
    }


    As for your question:
    I guess that after executing 'fetch' the method 'dispMonthOfYear' is called again to fill that reportfield.
    Put a breakpoint on fetch and on dispMonthOfDate and see in what sequence the code is done...
    Bert van Dijk
    Rotor BV
  • hkrisz79hkrisz79 Member Posts: 13
    burdee64 wrote:
    Hello hkrisz

    Why not just use strlwr() function in your display:



    display MonthsOfYear dispMonthOfDate()
    {
    return strlwr(mthofyr(custConfirmJour.ConfirmDate));
    }


    As for your question:
    I guess that after executing 'fetch' the method 'dispMonthOfYear' is called again to fill that reportfield.
    Put a breakpoint on fetch and on dispMonthOfDate and see in what sequence the code is done...


    Hello burdee,

    I'm afraid of you didn't understand the point of this issue.

    Type of the out put of mthofyr() is INT.
    Do you want to convert to lowercase an INT ?
    I don't think so... :)

    An other thing:

    The return type of my dispMonthOfDate() method is ENUM.
    The MonthsOfYear is a standard enum what contain the months and every
    enum value has a label.

    The good news:

    In the mean time I solved this problem with a simple SWITCH - CASE.

    Here it is:


    display str dispMonthOfDate()
    {
    int month;
    str monthTxt;
    ;

    month = mthofyr(custQuotationJour.QuotationDate);

    switch(month)
    {
    case 1 : monthTxt = label.extractString(literalStr("@SYS24776"));
    break;
    case 2 : monthTxt = label.extractString(literalStr("@SYS24777"));
    break;
    case 3 : monthTxt = label.extractString(literalStr("@SYS24778"));
    break;
    case 4 : monthTxt = label.extractString(literalStr("@SYS24779"));
    break;
    case 5 : monthTxt = label.extractString(literalStr("@SYS24780"));
    break;
    case 6 : monthTxt = label.extractString(literalStr("@SYS24781"));
    break;
    case 7 : monthTxt = label.extractString(literalStr("@SYS24782"));
    break;
    case 8 : monthTxt = label.extractString(literalStr("@SYS24783"));
    break;
    case 9 : monthTxt = label.extractString(literalStr("@SYS24784"));
    break;
    case 10 : monthTxt = label.extractString(literalStr("@SYS24785"));
    break;
    case 11 : monthTxt = label.extractString(literalStr("@SYS24786"));
    break;
    case 12 : monthTxt = label.extractString(literalStr("@SYS24787"));
    break;
    default : break;
    }

    if(custQuotationJour.LanguageId == CompanyInfo::find().LanguageId)
    {
    return strlwr(monthTxt);
    }

    else
    {
    return monthTxt;
    }


    }
    Best Regards

    Krisztian Hampuk
    AX Consultant
  • manish_smanish_s Member Posts: 10
    Hi hkrisz79,
    U can use a simple method mthname(), which returns the month name.
    For eg, a job code:

    static void monthName(Args _args)
    {
    str month;
    date _date;
    ;
    _date = systemDateget();
    month = strlwr(mthname(mthofYr(_date)));
    print month;
    pause;
    }
    I hope that will solve ur problem... \:D/
Sign In or Register to comment.