Filename Dataport

Red-EagleRed-Eagle Member Posts: 107
I have a dataport (export) which i want to give the name of the purchase order it's exporting (Purchase Header."No."). Is this possible?

Answers

  • vaprogvaprog Member Posts: 1,139
    You can use the same technique you would use with a report:
    SETRECFILTER;
    DATAPORT.RUN(DATAPORT::"My Export",ShowRequestForm,Rec);
    
    or
    VAR
    MyExport : Dataport "My Export";
    
    BEGIN
      dummyRec := Rec;
      dummyRec.SETRECFILTER;
      MyExport.SETTABLEVIEW(dummyRec);
      MyExport.RUN;
    END;
    
  • matttraxmatttrax Member Posts: 2,309
    If you want to set the filename do a CurrDataport.FILENAME := YourOrder

    If I remember right it needs to be in OnPreDataport.
  • Red-EagleRed-Eagle Member Posts: 107
    I want to get automatically the filename at predefinitioned place for example C:\Temp
    where the filename is for example IO07650.txt. The next purchase order will be then IO07651.txt.
  • matttraxmatttrax Member Posts: 2,309
    If you want to determine the next file name based on pre-existing files you need to create a record variable of subtype File. You can then find the last record in the folder and go from there.
  • Red-EagleRed-Eagle Member Posts: 107
    No i want to take the keyfield Purchase Header.No. as filename that will not be necessary a number what is following on the next one
  • SavatageSavatage Member Posts: 7,142
    Are you still asking? or is this post solved?
    matttrax wrote:
    If you want to set the filename do a CurrDataport.FILENAME := YourOrder
    If I remember right it needs to be in OnPreDataport.

    He means YourOrder can equal

    'c:\temp\'+PurchaseHeader."No."+'.txt';

    I like the Date & time myself..
    SavedFileName := FORMAT(WORKDATE,0,'<Year4>'+'-'+'<Month Text,3>'+'-'+'<Day,2>'+'-'+DELCHR((FORMAT(TIME)),'=',':'))+'.txt';
  • Red-EagleRed-Eagle Member Posts: 107
    Okay now i do understand it. I will test it tomorrow. Thnx you for your help.
  • FDickschatFDickschat Member Posts: 380
    Instead of

    'c:\temp\'+PurchaseHeader."No."+'.txt';

    you might try

    ENVIRON('TEMP') + PurchaseHeader."No." + '.txt';

    This gives you a temp path where the logged in user definitely has write permissions and it exists on all windows versions.
    Frank Dickschat
    FD Consulting
  • Red-EagleRed-Eagle Member Posts: 107
    I tried it, but when i use this code:

    CurrDataport.FILENAME := 'C:\' + "Purchase Line"."Document No." + '.txt';

    I get

    C:\.txt

    I think the problem is that it need to get the value of the "document no." from the requestform which you set in the filter
  • Red-EagleRed-Eagle Member Posts: 107
    Can anybody help me with this?
  • kapamaroukapamarou Member Posts: 1,152
    Red-Eagle wrote:
    "Purchase Line"."Document No."

    Try "Purchase Line".GETFILTER("Document No.");
  • helmhelm Member Posts: 46
    What Dataitem does the dataport run on and where did you write your code? It seems as if the system haven't found the Purchase line when you set the finename. So either you need some SETRANGE and FIND (If Purchase Line is not the Dataitem) or you need to move your code to another trigger.
  • Red-EagleRed-Eagle Member Posts: 107
    Thnx you kapamarou. You solution worked perfect.
Sign In or Register to comment.