Passing a date parmeter to a function

BokkBokk Member Posts: 138
edited 2003-04-29 in Navision Attain
I'm quite new at Navision and could use some help. I have written a codeunit to summarize some detail journal lines and then export the summary to a flat file. The user needs to be able to enter an end date. Because there is no Request form, I created a small form to enter the date with a command button to process it. In the OnPush trigger of command button, I put code that called a function in my codeunit and passed a ByVal parameter with the date. The codeunit does not seem to like the datatype of the parmeter. An error message indicates the parameter is not a valid date. I did try using the VARIANT2DATE function, but that didn't seem to work.

Should I use a form like this to get the date?
How do I get the function to recognize the date so I can filter on it?

Thanks,
Shelley
SGM

Comments

  • Francis_MalengierFrancis_Malengier Member Posts: 28
    Did you take a look at the variable of the type Dialog ?
    I think you can use this one instead of creating an extra form to ask for the date.

    Another remark : If you want to create a file, it's better to use a dataport instead of a codeunit


    Francis
  • svives1svives1 Member Posts: 5
    I hope that this help you you can put it in the code unit.
    But I think that using a Data port is more easy program a export/import of values.


    Variables
    Name DataType Subtype Length
    Mov_ Contab Record G/L Entry
    Window Dialog
    Date1 Date
    date2 Date



    //Ask for date
    Window.OPEN ('Insert Min Data filter #1#######'+
    'Insert Max Data Filter #2#######',Date1,date2);

    Window.INPUT(1,Date1);
    Window.INPUT(2,date2);
    Window.CLOSE;
    //control filters
    IF(date2 > Date1) THEN ERROR ('Error');
    IF((Date1 =0D) AND (date2=0D)) THEN ERROR('Error');
    //aplicate filters
    "Mov_ Contab".RESET;
    "Mov_ Contab".INIT;
    IF(Date1<>0D) AND (date2<>0D) THEN
    BEGIN
    "Mov_ Contab".SETFILTER("Mov_ Contab"."Posting Date",'%1..%2',Date1,date2);
    END
    ELSE
    BEGIN
    IF(Date1<>0D) THEN "Mov_ Contab".SETFILTER("Mov_ Contab"."Posting Date",'%1',Date1);
    IF(date2<>0D) THEN "Mov_ Contab".SETFILTER("Mov_ Contab"."Posting Date",'%1',date2);
    END;

    //....
    MESSAGE("Mov_ Contab".GETFILTERS);

    Bye :)

    PD: Sorry my English is auful
    Sònia Vives Rosich
  • BokkBokk Member Posts: 138
    I was a bit unclear. I want to send the date (as a filter) into a codeunit where I summarize my detail journal lines, then I do call a dataport to create the flat file.

    I will try the dialog window and see if I can get the date that way.

    Thank you very much!
    SGM
Sign In or Register to comment.