XMLPort with Multiple Temp Tables

jwilderjwilder Member Posts: 263
I need to create an Export only XMLPort based on 3 Temp Tables. Let's pretend the temp tables are Sales Header, Sales Lines and Sales Comments and are filled (as Temp Table) with another process. Now that I have filled the temp tables with my data I need to call the xmlport to export this data. How do I pass the temp tables so the xmlport can use them (andnot use the real Sales Header, Sales Line and Sales Comment)?

Answers

  • kinekine Member Posts: 12,562
    Add one function into the XMLPort, which takes 3 record variables and will copy the data from them into internal variables for the temp tables. Call this function before calling the EXPORT function of the XMLPOrt, you only need to call the XMLPort through XMLPort variable...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from 'NAV 2009' forum to 'NAV/Navision' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • jwilderjwilder Member Posts: 263
    I have done all of that. Now that I have 3 variables populated in the xmlport how do I reference them in the xmlport. Do I create a line that where the source type = table and do I set the temporary property to true?
  • kinekine Member Posts: 12,562
    You need to take it from other side- first define the element of type table, set it temporary yes, and populate it in the functions. You do not need to create global variables of type record which are temporary... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • jwilderjwilder Member Posts: 263
    Got it thank you!
  • maclmacl Member Posts: 9
    kine wrote:
    You need to take it from other side- first define the element of type table, set it temporary yes, and populate it in the functions. You do not need to create global variables of type record which are temporary... ;-)

    Hi Kamil Sacek

    I have the same problem with passing a temporary record to an xmlport. However I have not exactly understood how to do it. Can you please elaborate and post a code sample. Thanks in advance.

    Best regards
    macl
  • kinekine Member Posts: 12,562
    Instead code sample, could you answer few questions?

    1) Are you able to create function in the XMLPort with few parameters of type Record, to pass data you need to export?
    2) Are you able to go through these data and insert them into XMLPort variables of type record for each element of type table in XMLPort? (it means, do you know how copy records from one variable of type record into another?) Or you can use fromRec.copy(toRec,ShareTable) function in NAV 2009 if you are using this version.
    3) Are you able to call this function before you call .IMPORT or.EXPORT of the XMLPort (of course, you need to define the XMLPort as variable in the calling code)?

    If your answers are yes, than do it. If some is no, just learn it from doc, from this forum, or ask again. ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • jwilderjwilder Member Posts: 263
    You would have a call to your xmlport, something like the first line here:
    OrderDetailXMLPort.SetTempTables(OrderHeader,OrderLine);
    OrderDetailXMLPort.EXPORT;

    To follow through with this example, in your xmlport you would have a function called SetTempTables with 2 paramters. In this case each parameter has the Temporary Property set to Yes and make sure Var = True as well.

    In your XMLPort will need 2 Node Variables of Type Table Table and Temporary = Yes. In this case I called them OrderHeader and OrderLine. These 2 variables are defined in the structure of the xmlport not in C/AL Globals, Variables.

    In the SetTempTable function you would set the passed in temp table to your Node variable like this:
    IF PassOrderHeader.FINDSET THEN BEGIN
    REPEAT
    OrderHeader := PassOrderHeader;
    OrderHeader.INSERT;
    UNTIL PassOrderHeader.NEXT = 0;
    END;

    IF PassOrderLine.FINDSET THEN BEGIN
    REPEAT
    OrderLine := PassOrderLine;
    OrderLine.INSERT;
    UNTIL PassOrderLine.NEXT = 0;
    END;

    Now you can use the OrderHeader and OrderLine variable just like any other record variable in an xmlport.
  • maclmacl Member Posts: 9
    Thank you for your input. Now I got my example to work. I also tried to use the same logic of passing a temp table from a web service codeunit while the xmlport is the ref parameter of the web service function. However in this scenario I didn't get it to work. The content of the temp table was not passed via xmlport to the C# application calling the web service.
  • kinekine Member Posts: 12,562
    And is the parameter marked as passed by refference and not by value?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • maclmacl Member Posts: 9
    No I have passed the parameter by value. I will change it and test it next Tuesday when I will be at the client's site. Thanks for your input.

    Best regards,
    MACL
  • kinekine Member Posts: 12,562
    You cannot pass temp table by value. Passing record by value is passing only actual record values, no filters, no temp table data...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • maclmacl Member Posts: 9
    Now I have passed the parameter by reference and it works!
    Thank you once again for your help.

    Best regards,
    MACL
Sign In or Register to comment.