mibuso.com

Microsoft Business Solutions online community
It is currently Mon Dec 29, 2014 7:45 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: [Solved] Passing a Temporary Record to/from a Dataport?
PostPosted: Wed Aug 09, 2006 9:08 pm 
Offline

Joined: Wed Jul 19, 2006 3:25 pm
Posts: 6
Location: Winnipeg, Canada
Country: Portugal (pt)
Hello Everyone,
I was wondering if you can pass a temporary table to a dataport for export.

I have tried it by including the following line in a codeunit that contain a function that populates the temp table with the desired records;

Quote:
DATAPORT.RUNMODAL(50066,TRUE,gtbUNIINSmallParcel);


but I get an error message when it tried to execute telling me that the dataport does not have a DataItem that uses the table specified in the function SetTableView.
The Dataport has the table listed in the dataitem and it is the same table the temp record is based on.

So why am I getting this error? Can this even be done? I am trying to do with through a temp table so that I do not have to create a new table that is similar to one that I have already created that has the fields that I need. I know that I can use variables in the dataport to include values contained in various tables, but that would mean that I would have to use coded logic to filter the records rather than true filters and therefore would have to scan the entire table everytime I run the report.

If remove the temp table from the RUNMODAL command there is no error (but the dataport uses the data that is in the table - Obviously).

Joe
P.S. I know that isn't the Canadian flag... I just thought I would use my Ethnic flag instead of my residence flag.


Last edited by Joe Cool on Thu Aug 10, 2006 6:38 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 09, 2006 9:18 pm 
Offline

Joined: Thu Aug 26, 2004 12:50 pm
Posts: 479
Location: Kent
Country: United Kingdom (uk)
you will have to pass in the recordset and populate the export from the passed in table.

I would use an integer and variables to export

_________________
Analyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com


Top
 Profile E-mail WWW  
 
 Post subject:
PostPosted: Wed Aug 09, 2006 10:02 pm 
Offline

Joined: Wed Jul 19, 2006 3:25 pm
Posts: 6
Location: Winnipeg, Canada
Country: Portugal (pt)
David Cox wrote:
you will have to pass in the recordset and populate the export from the passed in table.

I would use an integer and variables to export


Thanks for the reply, but I don't understand what you are saying.
I guess that I should have mentioned that I am a Navision Newbie.
I thought I was passing the recordset in the RUNMODAL command.

gtbUNIINSmallParcel = the Temp Record that is populated in the Codeunit.
50066 = the Dataport.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 10, 2006 7:29 am 
Offline
Moderator
MVP Microsoft Dynamics NAV
NAV TechDays 2014 attendee

Joined: Wed Jul 02, 2003 9:13 am
Posts: 7705
Location: Milan
Country: Italy (it)
In the dataport, you need to make a global record variable "tmpTheTempTable" as temptable (property Temptable=Yes).
The dataitem of your dataport must work on the virtual table integer. In the dataportfields, you have to put the fields of the temptable.
You need a function in your dataport to fill up the temptable. Something like:
Code: Select all
Function ImportTempTable (VAR ItmpTheTempTable : as temptable)
ItmpTheTempTable.RESET;
IF ItmpTheTempTable.FIND('-') THEN
  REPEAT
    tmpTheTempTable := ItmpTheTempTable;
    tmpTheTempTable.INSERT(FALSE);
  UNTIL ItmpTheTempTable.NEXT = 0;


In the OnPreDataItem-trigger:
Code: Select all
tmpTheTempTable.RESET;
SETRANGE(Number,1,tmpTheTempTable.COUNT);


In the OnBeforeExportRecord-trigger:
Code: Select all
IF Number = 1 THEN
  tmpTheTempTable.FIND('-')
ELSE
  tmpTheTempTable.NEXT;



In the calling program:
Make a global variable for the dataport
For calling the dataport:
Code: Select all
CLEAR(dtpYourDataport);
dtpYourDataport.ImportTempTable(tmpTheTempTable);
dtpYourDataport.RUNMODAL;

_________________
Regards,Alain Krikilion
Use the SEARCH,Luke! || No PM,please use the forum. || May the <SOLVED>-attribute be in your title! || Read Forum Rules before making a posting

»»» Mark your calendar: NAV TechDays 2015 - 19 & 20 November 2015 (!) ««« Visit the conference website: http://www.navtechdays.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 10, 2006 6:42 pm 
Offline

Joined: Wed Jul 19, 2006 3:25 pm
Posts: 6
Location: Winnipeg, Canada
Country: Portugal (pt)
Thanks.
I didn't know that you could set a DataItem entered as Integer and what that did. Once I figured that out, I realized that I could contain all the code and the temporay table within the dataport.

Joe 8)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 09, 2007 7:17 pm 
Offline

Joined: Mon Jan 08, 2007 7:18 pm
Posts: 77
Location: Krakow
Country: Poland (pl)
What about import to temporary table? What is the trick?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 10, 2007 2:39 pm 
Offline
Moderator
MVP Microsoft Dynamics NAV
NAV TechDays 2014 attendee

Joined: Wed Jul 02, 2003 9:13 am
Posts: 7705
Location: Milan
Country: Italy (it)
AST wrote:
What about import to temporary table? What is the trick?

Less or more the same.
You put the table on which your temptable is based in the dataitem with properties AutoSave,AutoUpdate,AutoReplace = No.

global:
tmpTheTable as TEMPORARY record

OnBeforeImportRecord-trigger:
Code: Select all
CLEAR("The Table");


OnAfterImportRecord-trigger:
Code: Select all
tmpTheTable := "The Table";
tmpTheTable.INSERT(FALSE);


This function must be called after launching the dataport:
Code: Select all
Function ExportTempTable (VAR OtmpTheTempTable : as temptable)
OtmpTheTempTable.RESET;
OtmpTheTempTable.DELETEALL(FALSE);

tmpTheTable.RESET;
IF tmpTheTable.FIND('-') THEN
  REPEAT
    OtmpTheTempTable := tmpTheTable;
    OtmpTheTempTable.INSERT(FALSE);
  UNTIL tmpTheTable.NEXT = 0;

_________________
Regards,Alain Krikilion
Use the SEARCH,Luke! || No PM,please use the forum. || May the <SOLVED>-attribute be in your title! || Read Forum Rules before making a posting

»»» Mark your calendar: NAV TechDays 2015 - 19 & 20 November 2015 (!) ««« Visit the conference website: http://www.navtechdays.com


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 10, 2007 2:41 pm 
Offline
Moderator
MVP Microsoft Dynamics NAV
NAV TechDays 2014 attendee

Joined: Wed Jul 02, 2003 9:13 am
Posts: 7705
Location: Milan
Country: Italy (it)
[Topic moved from Navision Attain forum to Navision Tips & Tricks forum]
[Changed the title from "[SOLVED] Passing a Temporary Record to a Dataport?" to "[SOLVED] Passing a Temporary Record to/from a Dataport?"]

_________________
Regards,Alain Krikilion
Use the SEARCH,Luke! || No PM,please use the forum. || May the <SOLVED>-attribute be in your title! || Read Forum Rules before making a posting

»»» Mark your calendar: NAV TechDays 2015 - 19 & 20 November 2015 (!) ««« Visit the conference website: http://www.navtechdays.com


Top
 Profile  
 
 Post subject: Re: Passing a Temporary Record to/from a Dataport?
PostPosted: Fri Jun 17, 2011 7:06 am 
Offline

Joined: Thu May 01, 2008 12:57 pm
Posts: 386
Location: Ahmedabad, India
Country: India (in)
Hello Kriki,

Thanks for your great Tip regarding "Import Data in Temporary Table through Dataport".
I have did the code as you have suggested for the same task.

I wrote one codeunit as below.

Code: Select all
OnRun()
LocationDtp.RUNMODAL;
LocationDtp.ExportTempTable(LocationTmpTable);
LocationListFrm.SETTABLEVIEW(LocationTmpTable);
LocationListFrm.RUNMODAL;


Where variables are:
LocationDtp-Dataport-Location
LocationListFrm-Form-Location List
LocationTmpTable-Record-Location-Temporary=yes.

Dataport "Location" with properties AutoSave,AutoUpdate,AutoReplace = No.
having code as:

Code: Select all
Documentation()
Location - OnPreDataItem()
Location - OnBeforeExportRecord()
Location - OnAfterExportRecord()
Location - OnBeforeImportRecord()
CLEAR(Location);

Location - OnAfterImportRecord()
LocTmp := Location;
LocTmp.INSERT(FALSE);

Location - OnPostDataItem()

ExportTempTable(VAR OtmpTheTempTable : TEMPORARY Record Location)OtmpTheTempTable.RESET;
OtmpTheTempTable.DELETEALL(FALSE);

LocTmp.RESET;
IF LocTmp.FIND('-') THEN
  REPEAT
    OtmpTheTempTable := LocTmp;
    OtmpTheTempTable.INSERT(FALSE);
  UNTIL LocTmp.NEXT = 0;


Where variables are:
Parameters of ExportTempTable Function:
Var-Name-DataType-Subtype
Yes-OtmpTheTempTable-Record-Location

Global Variables:
Name-DataType-Subtype
LocTmp-Record-Location
LocationListFrm-Form-Location List

After I run the Codeunit, it is now viewing the Temporary Table Data in the form.
It is working fine now.

Thanks for sharing such a gr8 tip.

_________________
Ravi_Thakkar
Ahmedabad, Gujarat, India
E Mail : ravi.thakkar@hotmail.com


Top
 Profile E-mail  
 
 Post subject: Re: Passing a Temporary Record to/from a Dataport?
PostPosted: Mon Jun 20, 2011 9:04 am 
Offline
Moderator
MVP Microsoft Dynamics NAV
NAV TechDays 2014 attendee

Joined: Wed Jul 02, 2003 9:13 am
Posts: 7705
Location: Milan
Country: Italy (it)
It's nice to see that my tips are put to good use! :D

_________________
Regards,Alain Krikilion
Use the SEARCH,Luke! || No PM,please use the forum. || May the <SOLVED>-attribute be in your title! || Read Forum Rules before making a posting

»»» Mark your calendar: NAV TechDays 2015 - 19 & 20 November 2015 (!) ««« Visit the conference website: http://www.navtechdays.com


Top
 Profile  
 
 Post subject: Re: Passing a Temporary Record to/from a Dataport?
PostPosted: Mon Jun 20, 2011 9:19 am 
Offline

Joined: Thu May 01, 2008 12:57 pm
Posts: 386
Location: Ahmedabad, India
Country: India (in)
True Kriki.

I am having an issue in the same method with the XML PORT in RTC.

ExportTempTable returns Blank table from the XML PORT.

I think XMLport does not run Modally, and that's why I am facing the issue.
Any suggestion regarding the same?

_________________
Ravi_Thakkar
Ahmedabad, Gujarat, India
E Mail : ravi.thakkar@hotmail.com


Top
 Profile E-mail  
 
 Post subject: Re: Passing a Temporary Record to/from a Dataport?
PostPosted: Mon Jun 20, 2011 4:38 pm 
Offline
Moderator
MVP Microsoft Dynamics NAV
NAV TechDays 2014 attendee

Joined: Wed Jul 02, 2003 9:13 am
Posts: 7705
Location: Milan
Country: Italy (it)
Have you tried the XML-port with a classic client? Just to be sure it is a RTC problem and not something else.

_________________
Regards,Alain Krikilion
Use the SEARCH,Luke! || No PM,please use the forum. || May the <SOLVED>-attribute be in your title! || Read Forum Rules before making a posting

»»» Mark your calendar: NAV TechDays 2015 - 19 & 20 November 2015 (!) ««« Visit the conference website: http://www.navtechdays.com


Top
 Profile  
 
 Post subject: Re: Passing a Temporary Record to/from a Dataport?
PostPosted: Tue Jun 21, 2011 9:43 am 
Offline

Joined: Mon Dec 11, 2006 9:34 am
Posts: 2883
Location: Bergamo
Country: Italy (it)
i just made a test xmlport (used as dataport) (--> sorry, it is a real xmlport, not an xmlport as dataport) that works like a charm, using the temporary property of the table element.
I did it while testing webservices and see where i can go
Code: Select all
OBJECT XMLport 50600 xmlwebservice
{
  OBJECT-PROPERTIES
  {
    Date=20/06/11;
    Time=17.55.33;
    Modified=Yes;
    Version List=;
  }
  PROPERTIES
  {
    UseDefaultNamespace=Yes;
    OnPostXMLport=BEGIN
                    ERROR(FORMAT(Location.COUNT));
                  END;

  }
  ELEMENTS
  {
    { [{80D3A770-4659-442E-890D-16964E055A84}];  ;RootLocation        ;Element ;Text    ;
                                                  MaxOccurs=Once }

    { [{E06FC085-52D9-4301-A107-15DC5822CD34}];1 ;Location            ;Element ;Table   ;
                                                  SourceTable=Table14;
                                                  Temporary=Yes }

    { [{9E0DD462-6DDC-4D68-9435-BDC5FBE21631}];2 ;Code                ;Element ;Field   ;
                                                  DataType=Code;
                                                  SourceField=Location::Code }

    { [{A921CED9-96DF-4FD3-A6AD-8C12D2A114C6}];2 ;Name                ;Element ;Field   ;
                                                  DataType=Text;
                                                  SourceField=Location::Name }

  }
  EVENTS
  {
  }
  REQUESTPAGE
  {
    PROPERTIES
    {
    }
    CONTROLS
    {
    }
  }
  CODE
  {

    BEGIN
    END.
  }
}


_________________
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: