x++


Regarding X++ query


How i convert below SQL query into X++ code.I uses a empltable and join this table with HRPPARTYPOSITIONTABLERELAT2226,and in HRPPARTYPOSITIONTABLERELAT2226
used self join..
enter code here
select e.EMPLID,
LastDate.TITLE,
e.DIMENSION3_,
LastDate.ORGANIZATIONUNITID,
LastDate.DESCRIPTION,
e.JOINDATE,
e.CITEXITDATE,
LastDate.VALIDTODATETIME
from EMPLTABLE e,
(select *
from HRPPARTYPOSITIONTABLERELAT2226 bc1
where VALIDTODATETIME = (
Select MAX(VALIDTODATETIME)
from HRPPARTYPOSITIONTABLERELAT2226 bc2
where bc2.REFERENCE= bc1.REFERENCE)) LastDate
where e.EMPLID = LastDate.REFERENCE and EMPLSTATUS != 1 and LastDate.DATAAREAID = 'new'
From the table names it seems you are on version AX 2009 or earlier. And the requirement behind your SQL query seems to be to show some employee data along with some additional data from the last position they held.
Unfortunately as far as I know there is no way like in SQL to do this in one query. You need at least two. One way to do it is to first determine all the last positions held by employees by doing an aggregated query on the HRPPartyPositionTableRelationship table. From these results you can then select the corresponding EmplTable and full HRPPartyPositionTableRelationship records.
This could look like the following code. Note that this is not an exact representation of your query, but I'm sure you can add the missing field lists and criteria on your own.
EmplTable emplTable;
HRPPartyPositionTableRelationship hrpPartyPositionTableRelationship;
HRPPartyPositionTableRelationship hrpPartyPositionTableRelationshipLatest;
;
while select Reference, maxof(ValidToDateTime) from hrpPartyPositionTableRelationshipLatest
group by Reference
where hrpPartyPositionTableRelationshipLatest.HRMReferenceType == HRMVirtualNetworkReferenceType::Employee
{
select emplTable where emplTable.EmplId == hrpPartyPositionTableRelationshipLatest.Reference
join hrpPartyPositionTableRelationship where hrpPartyPositionTableRelationship.HRMReferenceType == HRMVirtualNetworkReferenceType::Employee
&& hrpPartyPositionTableRelationship.Reference == emplTable.EmplId
&& hrpPartyPositionTableRelationship.ValidToDateTime == hrpPartyPositionTableRelationshipLatest.ValidToDateTime;
info(strFmt('%1, %2, %3, %4', emplTable.EmplId, hrpPartyPositionTableRelationship.Title, hrpPartyPositionTableRelationship.Description, hrpPartyPositionTableRelationship.ValidToDateTime));
}

Related Links

Passing FromControl in a lookup override method
Reference control from datamethod in generated design
Extended EDT does not compare dates
How to display a tooltip in Dynamics AX 4.0?
how to disable intellisense in ax2012's code editor?
How do you “Run” a class
General quesions about Dynamics Ax
Convert date into julian date
How to change the level of AX info messages
X++ unbound control
WeekOfYear in X++ using .net lib
How to tell what module has called the program
Getting the index of an array element of EDT Dimension
Destroy Object in X++
not able to run job in batch
Creating a folder on fileSystem dynamics ax

Categories

HOME
service-worker
shell
assembly
facebook-oauth
prism
jmeter
apache-jena
nunit
angular2-material
camera
r-googlesheets
appcelerator
rom
parameters
limit
bookmarks
title
teechart
spin
mql5
dkim
alamofire
opengl-es-3.0
supervisor
endpoint
gkturnbasedmatch
bitnami
red5
jersey-1.0
xmonad
href
ios10.2
google-api-client
jquery-multiselect
asymptotic-complexity
dotspatial
linkedhashmap
arduino-ide
raft
android-augmented-reality
verifiable-c
subclipse
install.packages
lpsolve
contract
dapper-simplecrud
x++
openresty
dtsearch
arq
compiler-design
oracleclient
cup
check-mk
oozie-coordinator
mathcad
swingworker
builtins
signalr.client
beamer
boost-serialization
nio2
jparsec
mobiledoc-kit
file-move
mod-proxy
airbrake
linked-tables
ms-access-2000
contrast
tweenlite
insight.database
xml-namespaces
unix-socket
wxformbuilder
high-resolution
jammer
hidapi
abstract-data-type
joomla3.1
android-loadermanager
tree-balancing
mkv
jquery-address
fsevents
lr
maven-1
lobo-cobra
complex-event-processing
pbcopy

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App