XMLPort - Filename

kazakaza Member Posts: 9
I am trying to access the filename of the imported file when using an XMLPort.
I have followed a suggestion posted in Mibuso - but I still do not seem to be able to access the file name.

In the XMLPort (fro importing) I have created a function and set the variable equal to the parameter
setFileName(inFile :Text[30]);
gtxtFileName := inFile;

I then set the record variable with the value
myTable.FileName := gFileName;


In the Codeunit that calls the XMLPort, Ih ave included the following code (and have called the setFileName function)

gFile.OPEN(gtxtFileName);
gFile.CREATEINSTREAM(inStreamFile);
gXMLPort.setFileName(gtxtFileNameBuffer);
XMLPORT.IMPORT(50004,inStreamFile); //Import Billling XMLPort
gFile.CLOSE;

Note:- In order to call the setFileName function I could not use the XMLPort ID of 50004 (as required by the IMPORT function) and so I created a global variable called gXMLPort (which relates to XMLPort 50004).

PROBLEM:
The filename does not appear to get passed to the setFilename function. (or is not retained in memory by the global variable - gFileName).

I would appreciate any suggestions why this is not working - or is there any other way to get the filename that is entered into the RequestPage for the XMLPort import?

Thanks
k

Comments

  • ara3nara3n Member Posts: 9,256
    could you paste your setFileName functuion?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • deV.chdeV.ch Member Posts: 543
    This can't work you need to call :

    gXMLPort.SETSOURCE(inStreamFile)
    gXMLPort.IMPORT


    What you did is pass the Filename to another instance of the XMLPort not the one taht is called trough XMLPORT.IMPORT();
  • kazakaza Member Posts: 9
    Thanks very much for your assistance.

    In the above post , I see that I used two different variable names relating to the setFilename Function. That was a typo error in the post, as my code did contain the same variable name in the setFilename function and the variable used for setting the record value....

    I have got the XMLport to work...
    I used the SETSOURCE function, together with the global variable gXMLPort (which references dataport 50001)

    gFile.OPEN(gtxtFileName);
    gFile.CREATEINSTREAM(inStreamFile);
    //XMLPORT.IMPORT(50001,inStreamFile); //50001 => ImportBillling XMLPort
    gXMLPort.setFileName(gtxtFileName);
    gXMLPort.SETSOURCE(inStreamFile);
    gXMLPort.IMPORT;

    gFile.CLOSE;

    Thanks again.
    cheers
    k
Sign In or Register to comment.