Automatically running a datport

amankakaramankakar Member Posts: 44
Hi guys,
I want to periodically run a dataport,NAS does not allow dataports to be run.its a text file that i am importing,can xml ports help.
can odbc or cfront help...

please give some ideas since clinet license does not have job schedular

Comments

  • matttraxmatttrax Member Posts: 2,309
    We ran into this problem too. Unfortunately we just had to convert the dataports to codeunits. There we put the code to open the file, parse the line, and fill in the fields as we found them.

    Not a lot of fun, but it should do to the job.
  • AlbertvhAlbertvh Member Posts: 516
    Hi

    You can create a codeunit to run your dataport and schedule it thruogh the job scheduler
    CLEAR(MyDataport);
    MyDataport.FILENAME := FileName;
    MyDataport.IMPORT := TRUE;
    MyDataport.RUN();
    

    Make sure that the dataport has the property UseReqForm set to No


    Regards
    Albert
  • SavatageSavatage Member Posts: 7,142
    amankakar wrote:
    clinet license does not have job schedular
  • AlbertvhAlbertvh Member Posts: 516
    Sorry didn't see that.
    Maybe you could set it up in codeunit 1 with an OnTimer property.

    Albert
  • mark_aumark_au Member Posts: 40
    Hi, i've had the same problem recently, i ended up stealing a function from these forums which made work a bit easier, and adding it to a codeunit and calling the codeunit with NAS. Here is the function:
    FUNCTION GetFieldContent
    
    PARAMETERS
    ----------
    Var	Name	DataType	Subtype	Length
    No	parFieldNo	Integer		
    No	parTxt	Text		1024
    
    LOCAL VARIABLES
    ---------------
    Name	DataType	Subtype	Length
    ReturnString	Text		1024
    FieldsFound	Integer		
    boo	Integer		
    CounterPOS	Integer		
    
    RETURN VALUE
    ------------
    Type = Text
    Length = 1024
    
    CODE
    ----
    
    ReturnString := ''; 
    FieldsFound := 1; 
    boo := -1; 
    REPEAT 
      CounterPOS += 1; 
      IF parTxt[CounterPOS] = '"' THEN 
        boo *= -1 
      ELSE BEGIN 
        IF (parTxt[CounterPOS] = ',') AND (boo = -1) THEN 
          FieldsFound += 1 
        ELSE 
          IF FieldsFound = parFieldNo THEN 
            ReturnString := ReturnString + COPYSTR(parTxt,CounterPOS,1); 
      END; 
    UNTIL (CounterPOS = STRLEN(parTxt)) OR (FieldsFound > parFieldNo); 
    
    EXIT(ReturnString);
    

    Basically i open the file, and in a repeat loop load the next line into a very large text variable, which i pass to that function along with the field number i want, for example:

    Customer.Name := getfieldcontent(1,templine) will pull the content of the first field in "templine" (my variable storing the line) and assign it to the customer name.

    It wasn't much fun because of the massive amount of fields i was importing, but the above function made my life much easier, and we haven't had any troubles with it yet.

    Hope that helps.
  • julkifli33julkifli33 Member Posts: 1,087
    i'm getting error with that code
    Function/Trigger Line No. Description
    OnRun 1 Type "Dataport" not supported
    OnRun 2 Type "Dataport" not supported
    OnRun 3 Type "Dataport" not supported
    OnRun 4 Type "Dataport" not supported
    OnRun 2 Function 'FILENAME' is obsolete for Microsoft Dynamics NAV Server.
    OnRun 3 Function 'IMPORT' is obsolete for Microsoft Dynamics NAV Server.
    OnRun 4 Function 'RUN' is obsolete for Microsoft Dynamics NAV Server.
  • eriahieriahi Member Posts: 8
    hi julkifli33 ,

    I m asking did you found a solution for that error , i wrote the same code into a codeunit and i exspose this codeunit as webservice , when i call this webservice(from a c sharp code) , i have exactlly the same error that you have . can you tell me please why i have this error ?? ! :(
  • SogSog Member Posts: 1,023
    Ofcourse you get errors when copying that code.
    The post is from 2007, when NAV 2009 wasn't out yet. Dataports don't exist in that version, everything is xml-port.
    Also Filename, import and run are obsolete for the RTC. If you want that code to run, you need to check with isservicetier.
    Remember, it's not copy/paste but think/copy/paste
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • eriahieriahi Member Posts: 8
    Thks Sog for the information ;)
Sign In or Register to comment.