I used a blog when developing this sample. You can download to ready use XPO from there .
1- Create a new Class Library type C# project at Visual Studio.
2- Press right click at project name, select Add service reference and write https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL to Address, write Sorgula to Namespace and press GO so service reference will be shown.
3- Add your project to AOT with Add to AOT .
4- Go to project properties and make
Debug Target = No
Deploy to Client = Yes
Deploy to EP = No
Deploy to Server = Yes
Deploy to SSRS = No
5.
Deploy project and down all AX clients. If you don't down all clients at deploy, deploy will fail accoring to blog writer.
This is my sample job:
//Metin Emre, 2.10.2014
static void TCIDTest(Args _args)
{
CLRObject clientType;
TCKimlik.Sorgula.KPSPublicSoapClient cl;
System.Exception ex;
boolean s,erOccured;
System.Exception e;
str ret;
new InteropPermission(InteropKind::ClrInterop).assert();
try
{
clientType = CLRInterop::getType("TCKimlik.Sorgula.KPSPublicSoapClient");
cl = AifUtil::createServiceClient(clientType);
s = cl.TCKimlikNoDogrula(11111111111,"METİN","EMRE",1999);
}
catch(Exception::CLRError)
{
Ex=CLRInterop::getLastException();
ret = Ex.ToString();
if (!strScan(ret,"Not a valid citizen ID",1,strLen(Ret)))
{
info(Ex.ToString());
erOccured = true;
}
}
if (!erOccured)
info(strFmt("%1",s));
}
11111111111 is citizen ID, name and surname after citizen ID and the last born year. If all these are correct, returns true else false.
25 Aralık 2014 Perşembe
29 Eylül 2014 Pazartesi
AX 2012 - R3 Installation
In first check minimum system requirements . MS-SQL collate doesn't installed as turkish. With turkish like SAP
and Oracle you'll have problems about "i" letter of turkish, after AX 2012 install, at database sync, installation will fail.
I used Dilip's Blog for installation instead of Microsoft's long and complex white paper. Installation of AX 2012 is so easy of it's mine change. :)
In first Active Directory should be installed. There are plenty of pages about AD installation at Google.
I just used basic AX 2012 like Dilip's, let SSRS etc. installation later. AX 2012 setup gives prerequisities links and configures some of prerequisities automatically. I didn't faced any problem at installation.
After installation I upload demo data again from a blog page . Demo installation was harder than AX 2012 installation.
I installed SQL Server SSRS add-in and configured look from a blog . Anyway for developing SSRS reports (Doesn't require for deploy) don't forget install Business Intelligence Development Studio from SQL Server Setup. SSRS configure was so easy; in order run Service account, Web service URL, Database, Report Manager URL tabs with defaults was enough.
Again I used another Dilip page for SSRS install. I haven't got any trouble and didn't need Dilip's manual complete way for install, reports deployed smootly. :)
I used Dilip's Blog for installation instead of Microsoft's long and complex white paper. Installation of AX 2012 is so easy of it's mine change. :)
In first Active Directory should be installed. There are plenty of pages about AD installation at Google.
I just used basic AX 2012 like Dilip's, let SSRS etc. installation later. AX 2012 setup gives prerequisities links and configures some of prerequisities automatically. I didn't faced any problem at installation.
After installation I upload demo data again from a blog page . Demo installation was harder than AX 2012 installation.
I installed SQL Server SSRS add-in and configured look from a blog . Anyway for developing SSRS reports (Doesn't require for deploy) don't forget install Business Intelligence Development Studio from SQL Server Setup. SSRS configure was so easy; in order run Service account, Web service URL, Database, Report Manager URL tabs with defaults was enough.
Again I used another Dilip page for SSRS install. I haven't got any trouble and didn't need Dilip's manual complete way for install, reports deployed smootly. :)
26 Eylül 2014 Cuma
AX 2012 - If batch jobs cannot start?
If you look up Home->Inquiries->Batch jobs->My batch jobs and see batch jobs don't start.
Go System administration->Setup->System->Server configuration and check there is a record at Batch server schedule with proper time gap (00:00 -23:59) and be careful about Maximum batch threads value bigger than zero.
Also problem maybe about there is no attached server to batch group :
Administration -> setup -> Batch Groups
Find empty batch group and go Batch Servers tab, look for Selected server field has correct server value.
Go System administration->Setup->System->Server configuration and check there is a record at Batch server schedule with proper time gap (00:00 -23:59) and be careful about Maximum batch threads value bigger than zero.
Also problem maybe about there is no attached server to batch group :
Administration -> setup -> Batch Groups
Find empty batch group and go Batch Servers tab, look for Selected server field has correct server value.
15 Eylül 2014 Pazartesi
AX 2012 - Create a new financial dimension which related a table(s)
I found the easy way that the way from a blog which referred Microsoft'un related white paper:
1-Duplicate one of views from AOT which beginned DimAttribute and new views name should be begin same DimAttribute word.
2. Main datasource name should be BackingEntity unrelated what name used with original table name.
3. All field names of view should be like these whatever original names:
Key - data source tables Surrogate key field. Like RecId...
Value - data source tables primary key . Like AccountNum...
Name - Description field. Like Description or CustomerName...
There are two ways to use this new dimension implementation:
AOS restart
or
DimensionCache::clearAllScopes();
command.
1-Duplicate one of views from AOT which beginned DimAttribute and new views name should be begin same DimAttribute word.
2. Main datasource name should be BackingEntity unrelated what name used with original table name.
3. All field names of view should be like these whatever original names:
Key - data source tables Surrogate key field. Like RecId...
Value - data source tables primary key . Like AccountNum...
Name - Description field. Like Description or CustomerName...
There are two ways to use this new dimension implementation:
AOS restart
or
DimensionCache::clearAllScopes();
command.
11 Eylül 2014 Perşembe
AX 2012 - Get an individual dimension value from a LedgerDimension value
I used a data model about ledger dimension from a blog when I create this page. Unfortunately I couldn't understand code written at that blog and wrote this code:
DimensionDefault d = 5637183219;
DimensionAttributeValueCombination dimensionAttributeValueCombination;
DimensionAttributeValueGroupCombination dimensionAttributeValueGroupCombination;
DimensionAttributeValueGroup dimensionAttributeValueGroup;
DimensionAttributeLevelValue dimensionAttributeLevelValue;
DimensionAttributeValue dimensionAttributeValue;
DimensionAttribute dimensionAttribute;
select dimensionAttributeValueCombination
where dimensionAttributeValueCombination.RecId == d
join dimensionAttributeValueGroupCombination
where dimensionAttributeValueGroupCombination.DimensionAttributeValueCombination ==
dimensionAttributeValueCombination.RecId
join dimensionAttributeValueGroup
where dimensionAttributeValueGroup.RecId == dimensionAttributeValueGroupCombination.DimensionAttributeValueGroup
join dimensionAttributeLevelValue
where dimensionAttributeLevelValue.DimensionAttributeValueGroup == dimensionAttributeValueGroup.RecId
join dimensionAttributeValue
where dimensionAttributeValue.RecId == dimensionAttributeLevelValue.DimensionAttributeValue
join dimensionAttribute
where dimensionAttribute.RecId == dimensionAttributeValue.DimensionAttribute &&
DimensionAttribute.Name == "Project";
info(DimensionAttributeLevelValue.DisplayValue);
Update:
The code at up doesn't worked for PurchTable defaultDimension field.
I got this code from Andesoft'un web site :
DimensionDefault d = 5637169331;
DimensionAttributeValueSet dimAttrValueSet;
DimensionAttributeValueSetItem dimAttrValueSetItem;
DimensionAttributeValue dimAttrValue;
DimensionAttribute dimAttr;
Common dimensionValueEntity;
DimensionValue dimensionValue;
DimensionAliasName dimensionName;
dimAttrValueSet = DimensionAttributeValueSet::find(D);
while select dimAttrValueSetItem
where dimAttrValueSetItem.DimensionAttributeValueSet == dimAttrValueSet.RecId
{
dimAttrValue = DimensionAttributeValue::find(dimAttrValueSetItem.DimensionAttributeValue);
dimAttr = DimensionAttribute::find(DimAttrValue.DimensionAttribute);
dimensionvalueentity = DimensionDefaultingControllerBase::findBackingEntityInstance(
curext(),DimAttr,dimAttrvalue.EntityInstance);
dimensionvalue = dimattrvalue.getValue();
info(strFmt("%1 %2",Dimensionvalue, DimAttr.Name));
}
DimensionDefault d = 5637183219;
DimensionAttributeValueCombination dimensionAttributeValueCombination;
DimensionAttributeValueGroupCombination dimensionAttributeValueGroupCombination;
DimensionAttributeValueGroup dimensionAttributeValueGroup;
DimensionAttributeLevelValue dimensionAttributeLevelValue;
DimensionAttributeValue dimensionAttributeValue;
DimensionAttribute dimensionAttribute;
select dimensionAttributeValueCombination
where dimensionAttributeValueCombination.RecId == d
join dimensionAttributeValueGroupCombination
where dimensionAttributeValueGroupCombination.DimensionAttributeValueCombination ==
dimensionAttributeValueCombination.RecId
join dimensionAttributeValueGroup
where dimensionAttributeValueGroup.RecId == dimensionAttributeValueGroupCombination.DimensionAttributeValueGroup
join dimensionAttributeLevelValue
where dimensionAttributeLevelValue.DimensionAttributeValueGroup == dimensionAttributeValueGroup.RecId
join dimensionAttributeValue
where dimensionAttributeValue.RecId == dimensionAttributeLevelValue.DimensionAttributeValue
join dimensionAttribute
where dimensionAttribute.RecId == dimensionAttributeValue.DimensionAttribute &&
DimensionAttribute.Name == "Project";
info(DimensionAttributeLevelValue.DisplayValue);
Update:
The code at up doesn't worked for PurchTable defaultDimension field.
I got this code from Andesoft'un web site :
DimensionDefault d = 5637169331;
DimensionAttributeValueSet dimAttrValueSet;
DimensionAttributeValueSetItem dimAttrValueSetItem;
DimensionAttributeValue dimAttrValue;
DimensionAttribute dimAttr;
Common dimensionValueEntity;
DimensionValue dimensionValue;
DimensionAliasName dimensionName;
dimAttrValueSet = DimensionAttributeValueSet::find(D);
while select dimAttrValueSetItem
where dimAttrValueSetItem.DimensionAttributeValueSet == dimAttrValueSet.RecId
{
dimAttrValue = DimensionAttributeValue::find(dimAttrValueSetItem.DimensionAttributeValue);
dimAttr = DimensionAttribute::find(DimAttrValue.DimensionAttribute);
dimensionvalueentity = DimensionDefaultingControllerBase::findBackingEntityInstance(
curext(),DimAttr,dimAttrvalue.EntityInstance);
dimensionvalue = dimattrvalue.getValue();
info(strFmt("%1 %2",Dimensionvalue, DimAttr.Name));
}
Etiketler:
AX,
ax 2012,
AXAPTA,
ledger dimension,
ledgerdimension,
value attribute
10 Eylül 2014 Çarşamba
AX 2012 - Get an individual dimension value from a DefaultDimension
I used another blogs code when writing this code:
DimensionAttributeValueSetStorage dimStorage;
Counter i;
DimensionAttribute dimAttributeCostCenter;
DimensionAttributeValue dimAttributeValue;
DimensionDefault d = 5637168596;
dimStorage = DimensionAttributeValueSetStorage::find(d);
info(dimStorage.getDisplayValueByDimensionAttribute(DimensionAttribute::findByName("Project").RecId));
DimensionAttributeValueSetStorage dimStorage;
Counter i;
DimensionAttribute dimAttributeCostCenter;
DimensionAttributeValue dimAttributeValue;
DimensionDefault d = 5637168596;
dimStorage = DimensionAttributeValueSetStorage::find(d);
info(dimStorage.getDisplayValueByDimensionAttribute(DimensionAttribute::findByName("Project").RecId));
AX 2012 - Add a new dimension value to Default dimension
I wrote this code from one of Eyüp Tezar's code:
DimensionDefault DefDim;
DimensionAttribute dimensionAttribute;
DimensionAttributeValue newValue;
DimensionAttributeValueSetStorage dimensionStorage;
DefDim = mytable.Defaultdimension;
dimensionAttribute = DimensionAttribute::find(myDimRecid);
newValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,
myDimValue,false,true);
dimensionStorage = DimensionAttributeValueSetStorage::find(DefDim);
dimensionStorage.addItem(newValue);
DefDim = dimensionStorage.save();
//------------------- another dimension ------------------------
dimensionAttribute = DimensionAttribute::findbyName("Project");
newValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,
myDimValue2,false,true);
dimensionStorage = DimensionAttributeValueSetStorage::find(DefDim);
dimensionStorage.addItem(newValue);
DefDim = dimensionStorage.save();
DimensionDefault DefDim;
DimensionAttribute dimensionAttribute;
DimensionAttributeValue newValue;
DimensionAttributeValueSetStorage dimensionStorage;
DefDim = mytable.Defaultdimension;
dimensionAttribute = DimensionAttribute::find(myDimRecid);
newValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,
myDimValue,false,true);
dimensionStorage = DimensionAttributeValueSetStorage::find(DefDim);
dimensionStorage.addItem(newValue);
DefDim = dimensionStorage.save();
//------------------- another dimension ------------------------
dimensionAttribute = DimensionAttribute::findbyName("Project");
newValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,
myDimValue2,false,true);
dimensionStorage = DimensionAttributeValueSetStorage::find(DefDim);
dimensionStorage.addItem(newValue);
DefDim = dimensionStorage.save();
Etiketler:
add,
AX,
ax 2012,
AXAPTA,
default dimension,
defaultdimension
8 Eylül 2014 Pazartesi
AX 2012 - New taxtrans table structure
Taxtrans table structure changed with AX 2012. There's a good white paper of Microsoft about this. There's a sample join below:
select generalJournalAccountEntry
join generalJournalEntry
where generalJournalEntry.RecId == generalJournalAccountEntry.GeneralJournalEntry &&
generalJournalEntry.RecId == _RecId
join subledgerVoucherGeneralJournalEntry
where subledgerVoucherGeneralJournalEntry.GeneralJournalEntry == generalJournalEntry.RecId
join dimensionAttributeValueCombination
where dimensionAttributeValueCombination.RecId == generalJournalAccountEntry.LedgerDimension
join mainAccount
where mainAccount.RecId == dimensionAttributeValueCombination.MainAccount;
select generalJournalAccountEntry
join generalJournalEntry
where generalJournalEntry.RecId == generalJournalAccountEntry.GeneralJournalEntry &&
generalJournalEntry.RecId == _RecId
join subledgerVoucherGeneralJournalEntry
where subledgerVoucherGeneralJournalEntry.GeneralJournalEntry == generalJournalEntry.RecId
join dimensionAttributeValueCombination
where dimensionAttributeValueCombination.RecId == generalJournalAccountEntry.LedgerDimension
join mainAccount
where mainAccount.RecId == dimensionAttributeValueCombination.MainAccount;
AX 2012 - Where's LedgerTrans?
LedgerTrans gone with AX 2012 and came some new tables. You have to join these tables. There's a good white paper of Microsoft's about this issue. Some fields renamed and/or moved different tables, all of these explained at this white paper. There's a sample join below:
select generalJournalAccountEntry
join generalJournalEntry
where generalJournalEntry.RecId == generalJournalAccountEntry.GeneralJournalEntry &&
generalJournalEntry.AccountingDate >= beginDate && generalJournalEntry.AccountingDate <= endDate
join subledgerVoucherGeneralJournalEntry
where subledgerVoucherGeneralJournalEntry.GeneralJournalEntry == generalJournalEntry.RecId
join dimensionAttributeValueCombination
where dimensionAttributeValueCombination.RecId == generalJournalAccountEntry.LedgerDimension
join mainAccount
where mainAccount.RecId == dimensionAttributeValueCombination.MainAccount &&
mainAccount.MainAccountId == myAccount
select generalJournalAccountEntry
join generalJournalEntry
where generalJournalEntry.RecId == generalJournalAccountEntry.GeneralJournalEntry &&
generalJournalEntry.AccountingDate >= beginDate && generalJournalEntry.AccountingDate <= endDate
join subledgerVoucherGeneralJournalEntry
where subledgerVoucherGeneralJournalEntry.GeneralJournalEntry == generalJournalEntry.RecId
join dimensionAttributeValueCombination
where dimensionAttributeValueCombination.RecId == generalJournalAccountEntry.LedgerDimension
join mainAccount
where mainAccount.RecId == dimensionAttributeValueCombination.MainAccount &&
mainAccount.MainAccountId == myAccount
3 Eylül 2014 Çarşamba
AX 2012 - Set voucher to LedgerJournalTrans table
When use AXLedgerJournalTrans class, voucher set as automatically. But if you add record directly to table you have to set voucher:
numberSeq = numberSeq::newGetVoucherFromCode(NumberSequenceTable::find(ledgerJournalTable.ledgerJournalName().NumberSequenceTable).NumberSequence);
LedgerJournalTrans.Voucher = numberSeq.voucher();
numberSeq = numberSeq::newGetVoucherFromCode(NumberSequenceTable::find(ledgerJournalTable.ledgerJournalName().NumberSequenceTable).NumberSequence);
LedgerJournalTrans.Voucher = numberSeq.voucher();
Etiketler:
AX,
ax 2012,
AXAPTA,
ledgerjournaltrans,
voucher
2 Eylül 2014 Salı
AX 2012 - Add splitter to form
It's more easy to add splitter control to AX 2012 than 2009. I'll tell horizontal splitter:
Add a group for top part of form. I named it as Hsplitter. Set AutoDeclaration = Yes and Style = SplitterHorizontalContainer. Add another group for down part of form. Give a name to top group. I named it as TopGroup, also set AutoDeclaration = Yes for this group too. Make bottom groups Height as Column Height. Splitter group should be betwen of other two.
Add this line to form's classDeclaration:
SysFormSplitter_Y HorizontalSplitter;
If splitter will be vertical should be SysFormSplitter_X.
Add this line to form's init method:
HorizontalSplitter = new SysFormSplitter_Y(HSplitter,TopGroup, element);
If vertical, should be new SysFormSplitter_X ...
That's all...
Add a group for top part of form. I named it as Hsplitter. Set AutoDeclaration = Yes and Style = SplitterHorizontalContainer. Add another group for down part of form. Give a name to top group. I named it as TopGroup, also set AutoDeclaration = Yes for this group too. Make bottom groups Height as Column Height. Splitter group should be betwen of other two.
Add this line to form's classDeclaration:
SysFormSplitter_Y HorizontalSplitter;
If splitter will be vertical should be SysFormSplitter_X.
Add this line to form's init method:
HorizontalSplitter = new SysFormSplitter_Y(HSplitter,TopGroup, element);
If vertical, should be new SysFormSplitter_X ...
That's all...
8 Ağustos 2014 Cuma
AX 2012 - CIL Error 351
Sometimes you can get this error:
Description: CIL generation: The given key was not present in the dictionary.
Path: \XppIL
Line: 1
Method/Property: XppIL
Error: Err:351
Sync DataDictionary and remove all errors at AOT.
Down AOS. Delete all files from this directory except subfolders:
C:\Program Files\Microsoft Dynamics AX\60\Server\AX2012R2_Dev\bin\XppIL
Description: CIL generation: The given key was not present in the dictionary.
Path: \XppIL
Line: 1
Method/Property: XppIL
Error: Err:351
Sync DataDictionary and remove all errors at AOT.
Down AOS. Delete all files from this directory except subfolders:
C:\Program Files\Microsoft Dynamics AX\60\Server\AX2012R2_Dev\bin\XppIL
5 Ağustos 2014 Salı
AX 2012 - Add defaultdimension control to form
You can look for LedgerJournalTable form for how to do.
Add a relation with DimensionAttributeValueSet table's RecId field for which field added from DimensionDefault EDT.
Add a tab page named tabFinancialDimensions and change properties like below:
AutoDeclaration = true
caption = @SYS101181
HideIfEmpty = No
NeedPermission = Manual
Add this line to forms classDeclaration method:
DimensionDefaultingController dimensionDefaultingController;
Add this code part to forms init method:
public void init()
{
boolean allowEdit = true;
super();
dimensionDefaultingController = DimensionDefaultingController::constructInTabWithValues(false, true, allowEdit, 0, this, tabFinancialDimensions, "@SYS101181");
dimensionDefaultingController.parmAttributeValueSetDataSource(MyTable_ds, fieldStr(MyTable, DefaultDimension));
dimensionDefaultingController.parmValidateBlockedForManualEntry(true);
}
Add this method to tab page:
public void pageActivated()
{
dimensionDefaultingController.pageActivated();
super();
}
Update table data source methods like below:
public void delete()
{
super();
DimensionDefaultingController.deleted();
}
public void write()
{
ttsBegin;
DimensionDefaultingController.writing();
super();
ttsCommit;
}
public int active()
{
int ret;
ret = super();
DimensionDefaultingController.activated();
return ret;
}
Add a relation with DimensionAttributeValueSet table's RecId field for which field added from DimensionDefault EDT.
Add a tab page named tabFinancialDimensions and change properties like below:
AutoDeclaration = true
caption = @SYS101181
HideIfEmpty = No
NeedPermission = Manual
Add this line to forms classDeclaration method:
DimensionDefaultingController dimensionDefaultingController;
Add this code part to forms init method:
public void init()
{
boolean allowEdit = true;
super();
dimensionDefaultingController = DimensionDefaultingController::constructInTabWithValues(false, true, allowEdit, 0, this, tabFinancialDimensions, "@SYS101181");
dimensionDefaultingController.parmAttributeValueSetDataSource(MyTable_ds, fieldStr(MyTable, DefaultDimension));
dimensionDefaultingController.parmValidateBlockedForManualEntry(true);
}
Add this method to tab page:
public void pageActivated()
{
dimensionDefaultingController.pageActivated();
super();
}
Update table data source methods like below:
public void delete()
{
super();
DimensionDefaultingController.deleted();
}
public void write()
{
ttsBegin;
DimensionDefaultingController.writing();
super();
ttsCommit;
}
public int active()
{
int ret;
ret = super();
DimensionDefaultingController.activated();
return ret;
}
Etiketler:
AX,
ax 2012,
AXAPTA,
defaultdimension,
form
4 Ağustos 2014 Pazartesi
AX 2012 - SSRS How to suppress zero as blank?
Put this instead of put field (At this time PurchPrice) itself:
=IIF(Fields!PurchPrice.Value = 0 ,"",Fields!PurchPrice.Value)
=IIF(Fields!PurchPrice.Value = 0 ,"",Fields!PurchPrice.Value)
17 Temmuz 2014 Perşembe
AX 2012 - When Developing SSRS Report, if Visual Studio Table Window Disappears?
View->Report Data
AX 2012 - My New Field's Value Disappearing when Editing VendInvoiceInfoTable
I add a new field to VendInvoiceInfoTable When try to edit with VendEditInvoice
form I saw my new field's value is empty. After a long research I found out Axapta copy source record to another record and edit this new record. Meanwhile Axapta skips my new field. Axapta uses table method copyFromHeader while copying. Add my new line:
this.VendorRequestedWorkerEmail = _header.VendorRequestedWorkerEmail;
//my new field
this.myNewField = _header.myNewField;
Problem overed. Same method valid for related VendInvoiceInfoLine table too.
this.VendorRequestedWorkerEmail = _header.VendorRequestedWorkerEmail;
//my new field
this.myNewField = _header.myNewField;
Problem overed. Same method valid for related VendInvoiceInfoLine table too.
Etiketler:
AX,
ax 2012,
AXAPTA,
cannot,
disappear,
lost,
new field,
update,
value,
vendinvoiceinfotable
AX - 2012 What Comes Instead of TypeId?
You'll see TypeId doesn't work at AX 2012. Instead of that AX 2012'de you may use EnumStr for enums and diğer ExtendedTypeStr for other data types.
11 Temmuz 2014 Cuma
AX 2012 - Send marked records to SSRS RDP Report
SSRS DP Class don't accept table or container data types as parm method. I searched at forums and saw str data type adviced. But I think this's not best approach. At last learned best way already in standard AX SSRS reports. At this link there's a PDF file tells look for check report. I generated this report with look form ChequeDP and ChequeController classes:
Controller class:
class declaration:
class myController extends SrsReportRunController
{
#define.ReportName('myreport.Report')
myTMPTable myTMPTable;
}
public static void main(Args _args)
{
SysLastValue SysLastValue;
myController controller = new myController();
controller.parmReportName(#ReportName);
controller.parmArgs(_args);
controller.DeleteTmpData();
controller.init();
controller.startOperation();
}
protected void prePromptModifyContract()
{
SrsTmpTblMarshallerContract contract = this.parmReportContract().parmRdpContract() as SrsTmpTblMarshallerContract;
new SRSReportRunPermission().assert();
contract.parmTmpTableDataRecId(SRSTmpTblMarshaller::SendTmpTblToDataProvider(myTMPTable));
}
public void init()
{
FormDataSource ds;
TransDate transDate;
VendTrans vendTrans;
if (!this.parmArgs() ||
!this.parmArgs().record() ||
this.parmArgs().dataset() != tableNum(VendTrans))
throw error("Report should be call with correct parameter!..");
ds = this.parmArgs().record().dataSource();
vendTrans = ds.getFirst(1);
transDate = vendTrans.transDate;
PaymentReceipt.VendAccount = vendTrans.AccountNum;
for (vendTrans = ds.getFirst(1); vendTrans != null; vendTrans = ds.getNext())
{
myTMPTable.Date = vendTrans.TransDate;
...
myTMPTable.insert();
}
}
DP Class:
// <ETG - memre > GN: T: 11.07.2014 A:
[SRSReportParameterAttribute(classStr(SrsTmpTblMarshallerContract))]
public class mpDP extends SRSReportDataProviderBase
{
myTMPTAble myTMPTable;
}
private void initTmpTable()
{
SrsTmpTblMarshallerContract contract = this.parmDataContract() as SrsTmpTblMarshallerContract;
new SRSReportRunPermission().assert();
myTMPTable = SRSTmpTblMarshaller::getTmpTbl(contract.parmTmpTableDataRecId());
SRSTmpTblMarshaller::deleteTmpTblData(contract.parmTmpTableDataRecId());
CodeAccessPermission::revertAssert();
}
public void processReport()
{
CompanyInfo Company;
VendTable vendTable;
AmountMST amount;
TempStr NumtoTxt;
LedgerJournalTrans LedgerTrans;
this.initTmpTable();
...
}
Controller class:
class declaration:
class myController extends SrsReportRunController
{
#define.ReportName('myreport.Report')
myTMPTable myTMPTable;
}
public static void main(Args _args)
{
SysLastValue SysLastValue;
myController controller = new myController();
controller.parmReportName(#ReportName);
controller.parmArgs(_args);
controller.DeleteTmpData();
controller.init();
controller.startOperation();
}
protected void prePromptModifyContract()
{
SrsTmpTblMarshallerContract contract = this.parmReportContract().parmRdpContract() as SrsTmpTblMarshallerContract;
new SRSReportRunPermission().assert();
contract.parmTmpTableDataRecId(SRSTmpTblMarshaller::SendTmpTblToDataProvider(myTMPTable));
}
public void init()
{
FormDataSource ds;
TransDate transDate;
VendTrans vendTrans;
if (!this.parmArgs() ||
!this.parmArgs().record() ||
this.parmArgs().dataset() != tableNum(VendTrans))
throw error("Report should be call with correct parameter!..");
ds = this.parmArgs().record().dataSource();
vendTrans = ds.getFirst(1);
transDate = vendTrans.transDate;
PaymentReceipt.VendAccount = vendTrans.AccountNum;
for (vendTrans = ds.getFirst(1); vendTrans != null; vendTrans = ds.getNext())
{
myTMPTable.Date = vendTrans.TransDate;
...
myTMPTable.insert();
}
}
DP Class:
// <ETG - memre > GN: T: 11.07.2014 A:
[SRSReportParameterAttribute(classStr(SrsTmpTblMarshallerContract))]
public class mpDP extends SRSReportDataProviderBase
{
myTMPTAble myTMPTable;
}
private void initTmpTable()
{
SrsTmpTblMarshallerContract contract = this.parmDataContract() as SrsTmpTblMarshallerContract;
new SRSReportRunPermission().assert();
myTMPTable = SRSTmpTblMarshaller::getTmpTbl(contract.parmTmpTableDataRecId());
SRSTmpTblMarshaller::deleteTmpTblData(contract.parmTmpTableDataRecId());
CodeAccessPermission::revertAssert();
}
public void processReport()
{
CompanyInfo Company;
VendTable vendTable;
AmountMST amount;
TempStr NumtoTxt;
LedgerJournalTrans LedgerTrans;
this.initTmpTable();
...
}
2 Temmuz 2014 Çarşamba
AX 2012 - Add segmented entry control to a form for a ledger dimension
If you add segmented entry control directly to form you'll see lookups etc.. won't work. Look at the this clear Microsoft's whitepaper:
http://msdn.microsoft.com/en-us/library/hh300644.aspx
http://msdn.microsoft.com/en-us/library/hh300644.aspx
Etiketler:
AX,
ax 2012,
AXAPTA,
control,
form,
ledger dimension,
ledgerdimension,
segmented entry
25 Haziran 2014 Çarşamba
AX 2012 - Refresh form data
A Subroutine of you called refreshs data. Form's data doesn't refresh. To solve this issue you have to call first research and then refresh. Research doesn't broke your query filters and if you call it with true parameter it goes to current record after refresh:
LedgerJournalTrans_DS.research(true);
LedgerJournalTrans_DS.refresh();
If your subroutine is a SysOperation class and your screen doesn't refresh anyway, don't forget add this to your controller class:
controller.parmExecutionMode(SysOperationExecutionMode::Asynchronous);
If you don't, your research and refresh methods run before your classes completed it's job.
LedgerJournalTrans_DS.research(true);
LedgerJournalTrans_DS.refresh();
If your subroutine is a SysOperation class and your screen doesn't refresh anyway, don't forget add this to your controller class:
controller.parmExecutionMode(SysOperationExecutionMode::Asynchronous);
If you don't, your research and refresh methods run before your classes completed it's job.
24 Haziran 2014 Salı
AX 2012 - Default dimension
//http://axvuongbao.blogspot.com.tr/2013/08/how-to-create-default-dimension-from-x.html
public static DimensionDefault CreateDefaultDim(Container _a,Container _v)
{
DimensionAttributeValueSetStorage valueSetStorage = new DimensionAttributeValueSetStorage();
DimensionDefault result;
int i;
DimensionAttribute dimensionAttribute;
DimensionAttributeValue dimensionAttributeValue;
//_attr is dimension name in table DimensionAttribute
container conAttr = _a;
container conValue = _v;
boolean _createIfNotFound = true;
str dimValue;
for (i = 1; i <= conLen(conAttr); i++)
{
dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));
if (dimensionAttribute.RecId == 0)
{
continue;
}
dimValue = conPeek(conValue,i);
if (dimValue != "")
{
// _createIfNotFound is "true". A dimensionAttributeValue record will be created if not found.
dimensionAttributeValue=
dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,_createIfNotFound);
// Add the dimensionAttibuteValue to the default dimension
valueSetStorage.addItem(dimensionAttributeValue);
}
}
result = valueSetStorage.save();
return result;
}
Sample usage:
LedgerJournalTrans.DefaultDimension = MyUtility::CreateDefaultDim("[Contract],[Project]","[0001],[MyBigProject]")
If you get Unable to return DimensionAttributeValue record for ... error than you try create a dimension combination values unavailable in system.
public static DimensionDefault CreateDefaultDim(Container _a,Container _v)
{
DimensionAttributeValueSetStorage valueSetStorage = new DimensionAttributeValueSetStorage();
DimensionDefault result;
int i;
DimensionAttribute dimensionAttribute;
DimensionAttributeValue dimensionAttributeValue;
//_attr is dimension name in table DimensionAttribute
container conAttr = _a;
container conValue = _v;
boolean _createIfNotFound = true;
str dimValue;
for (i = 1; i <= conLen(conAttr); i++)
{
dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));
if (dimensionAttribute.RecId == 0)
{
continue;
}
dimValue = conPeek(conValue,i);
if (dimValue != "")
{
// _createIfNotFound is "true". A dimensionAttributeValue record will be created if not found.
dimensionAttributeValue=
dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,_createIfNotFound);
// Add the dimensionAttibuteValue to the default dimension
valueSetStorage.addItem(dimensionAttributeValue);
}
}
result = valueSetStorage.save();
return result;
}
Sample usage:
LedgerJournalTrans.DefaultDimension = MyUtility::CreateDefaultDim("[Contract],[Project]","[0001],[MyBigProject]")
If you get Unable to return DimensionAttributeValue record for ... error than you try create a dimension combination values unavailable in system.
Etiketler:
AX,
ax 2012,
AXAPTA,
default dimension,
defaultdimension
20 Haziran 2014 Cuma
AX 2012 - Query; set Date value with strfmt.
If you want to set date value with strfmr for Axapta queries you have to use Date2StrXpp function:
...
QBR2.value(strFmt(' ( TransDate >= %1 )' , Date2StrXpp(TransDate) ));
...
...
QBR2.value(strFmt(' ( TransDate >= %1 )' , Date2StrXpp(TransDate) ));
...
17 Haziran 2014 Salı
AX 2012 Add validate method, groupping and labeling parameters with RDP class
Class Declaration:
[
DataContractAttribute,
SysOperationGroupAttribute("DateGroup", "Date Range", "1", FormArrangeMethod::Vertical),
SysOperationGroupAttribute("Other", "Other Filters", "1", FormArrangeMethod::Vertical)
]
class myContract implements SysOperationValidatable
{
...
}
Parm method:
[DataMemberAttribute('StartDate'),
SysOperationGroupMemberAttribute("DateGroup"),
SysOperationDisplayOrderAttribute("1")]
public StartDate parmStartDate(StartDate _StartDate = startDate)
{
startDate = _StartDate;
return StartDate;
}
Validate method:
public boolean validate()
{
boolean isValid = true;
if ( !endDate || !StartDate)
isValid = checkfailed("You have to enter first/last dates!..");
return isValid;
}
[
DataContractAttribute,
SysOperationGroupAttribute("DateGroup", "Date Range", "1", FormArrangeMethod::Vertical),
SysOperationGroupAttribute("Other", "Other Filters", "1", FormArrangeMethod::Vertical)
]
class myContract implements SysOperationValidatable
{
...
}
Parm method:
[DataMemberAttribute('StartDate'),
SysOperationGroupMemberAttribute("DateGroup"),
SysOperationDisplayOrderAttribute("1")]
public StartDate parmStartDate(StartDate _StartDate = startDate)
{
startDate = _StartDate;
return StartDate;
}
Validate method:
public boolean validate()
{
boolean isValid = true;
if ( !endDate || !StartDate)
isValid = checkfailed("You have to enter first/last dates!..");
return isValid;
}
AX 2012 Add Query to SSRS report when developing with RDP
Add query attribute to data provider class:
[
SRSReportQueryAttribute (querystr(Cust)),
SRSReportParameterAttribute(classstr(myReportContract))
]
class myReportDP extends SRSReportDataProviderBase
{
...
}
Get query like this:
[SysEntryPointAttribute(false)]
public void processReport()
{
QueryRun qRun;
Query query;
...
query = this.parmQuery();
...
Do not forget make Dynamics Filter property to true at SSRS report Dataset if you want to see select query button.
[
SRSReportQueryAttribute (querystr(Cust)),
SRSReportParameterAttribute(classstr(myReportContract))
]
class myReportDP extends SRSReportDataProviderBase
{
...
}
Get query like this:
[SysEntryPointAttribute(false)]
public void processReport()
{
QueryRun qRun;
Query query;
...
query = this.parmQuery();
...
Do not forget make Dynamics Filter property to true at SSRS report Dataset if you want to see select query button.
AX 2012 - Sysoperation class sample
Contract Class:
classDeclaration method:
[DataContractAttribute]
class myTestContract
{
TransDate transDate;
str packedQuery;
LedgerJournalId JournalId;
}
Other methods:
//------ for get Query -------------
public Query getQuery()
{
return new Query(SysOperationHelper::base64Decode(packedQuery));
}
//---------- parm method sample --------------
[DataMemberAttribute
, SysOperationControlVisibilityAttribute(false)]
public LedgerJournalId parmJournalId(LedgerJournalId _JournalId = JournalId)
{
JournalId = _JournalId;
return JournalId;
}
//--------------------- call query with parmQuery ----------------
[DataMemberAttribute,
AifQueryTypeAttribute('_packedQuery', querystr(myQuery))
]
public str parmQuery(str _packedQuery = packedQuery)
{
packedQuery = _packedQuery;
return packedQuery;
}
//-------------- send query with SetQuery -----------------------
public void setQuery(Query _query)
{
packedQuery = SysOperationHelper::base64Encode(_query.pack());
}
DataService Class:
ClassDeclaration metodu:
class myDataService
{
}
Batch job method:
[SysEntryPointAttribute]
public void Go(myContract _contract)
{
QueryRun qRun;
Query query;
QueryBuildDataSource QBDS;
QueryBuildRange QBR,QBR2;
CustTable CustTable;
LedgerJournalId JournalId;
TransDate PaymDate;
LedgerJournalTrans journalTrans;
JournalId = _contract.parmJournalId();
query = _contract.getQuery();
QBDS = query.dataSourceTable(tablenum(CustTable));
QBR = QBDS.findRange(fieldnum(CustTable,CustAccount));
if (!QBR)
QBR = QBDS.addRange(fieldnum(CustTable,CustAccount));
QBR.value(queryValue("000001"));
qRun = new QueryRun(query);
while(qRun.next())
{
CustTable = qRun.get(tableNum(CustTable));
...
}
Controller Class:
class declaration:
class MyController extends SysOperationServiceController
{
}
public static MyController newFromArgs(Args _args)
{
MyController controller;
MyContract contract;
LedgerJournalTable LedgerJournalTable;
if ( !_args || !_args.caller() )
throw error("This class needs parameter!..");
ledgerJournalTable = _args.caller().ledgerJournalTable();
controller = new ETGVendAdvanceReqController();
controller.initializeFromArgs(_args);
contract = Controller.getDataContractObject("_contract");
contract.parmPaymDate(today());
contract.parmJournalId(ledgerJournalTable.JournalNum);
return Controller;
}
public static void main(Args _args)
{
MyController controller;
controller = MyController::newFromArgs(_args);
controller.parmExecutionMode(SysOperationExecutionMode::Asynchronous);
controller.startOperation();
}
Menu item parameters:
Object - MyController
ObjectType - class
Parameters - MyDataService.Go
classDeclaration method:
[DataContractAttribute]
class myTestContract
{
TransDate transDate;
str packedQuery;
LedgerJournalId JournalId;
}
Other methods:
//------ for get Query -------------
public Query getQuery()
{
return new Query(SysOperationHelper::base64Decode(packedQuery));
}
//---------- parm method sample --------------
[DataMemberAttribute
, SysOperationControlVisibilityAttribute(false)]
public LedgerJournalId parmJournalId(LedgerJournalId _JournalId = JournalId)
{
JournalId = _JournalId;
return JournalId;
}
//--------------------- call query with parmQuery ----------------
[DataMemberAttribute,
AifQueryTypeAttribute('_packedQuery', querystr(myQuery))
]
public str parmQuery(str _packedQuery = packedQuery)
{
packedQuery = _packedQuery;
return packedQuery;
}
//-------------- send query with SetQuery -----------------------
public void setQuery(Query _query)
{
packedQuery = SysOperationHelper::base64Encode(_query.pack());
}
DataService Class:
ClassDeclaration metodu:
class myDataService
{
}
Batch job method:
[SysEntryPointAttribute]
public void Go(myContract _contract)
{
QueryRun qRun;
Query query;
QueryBuildDataSource QBDS;
QueryBuildRange QBR,QBR2;
CustTable CustTable;
LedgerJournalId JournalId;
TransDate PaymDate;
LedgerJournalTrans journalTrans;
JournalId = _contract.parmJournalId();
query = _contract.getQuery();
QBDS = query.dataSourceTable(tablenum(CustTable));
QBR = QBDS.findRange(fieldnum(CustTable,CustAccount));
if (!QBR)
QBR = QBDS.addRange(fieldnum(CustTable,CustAccount));
QBR.value(queryValue("000001"));
qRun = new QueryRun(query);
while(qRun.next())
{
CustTable = qRun.get(tableNum(CustTable));
...
}
Controller Class:
class declaration:
class MyController extends SysOperationServiceController
{
}
public static MyController newFromArgs(Args _args)
{
MyController controller;
MyContract contract;
LedgerJournalTable LedgerJournalTable;
if ( !_args || !_args.caller() )
throw error("This class needs parameter!..");
ledgerJournalTable = _args.caller().ledgerJournalTable();
controller = new ETGVendAdvanceReqController();
controller.initializeFromArgs(_args);
contract = Controller.getDataContractObject("_contract");
contract.parmPaymDate(today());
contract.parmJournalId(ledgerJournalTable.JournalNum);
return Controller;
}
public static void main(Args _args)
{
MyController controller;
controller = MyController::newFromArgs(_args);
controller.parmExecutionMode(SysOperationExecutionMode::Asynchronous);
controller.startOperation();
}
Menu item parameters:
Object - MyController
ObjectType - class
Parameters - MyDataService.Go
AX 2012 - How to read/write Vendor/Customer to LedgerJournalTrans table?
This information store in ledgerDimension field. When writing:
LedgerJournalTrans.LedgerDimension = DimensionStorage::getDynamicAccount(myVendAccount, LedgerJournalACType::Vend);
When reading you can look up for AccountDisplay or accountNameFind methods or:
DimensionStorage::ledgerDimension2AccountNum(ledgerJournalTrans.OffsetLedgerDimension)
DimensionStorage::ledgerDimension2AccountNum(ledgerJournalTrans.LedgerDimension)
CustTable::findByLedgerDimension(ledgerJournalTrans.LedgerDimension) VendTable::findByLedgerDimension(ledgerJournalTrans.LedgerDimension)
LedgerJournalTrans.LedgerDimension = DimensionStorage::getDynamicAccount(myVendAccount, LedgerJournalACType::Vend);
When reading you can look up for AccountDisplay or accountNameFind methods or:
DimensionStorage::ledgerDimension2AccountNum(ledgerJournalTrans.OffsetLedgerDimension)
DimensionStorage::ledgerDimension2AccountNum(ledgerJournalTrans.LedgerDimension)
CustTable::findByLedgerDimension(ledgerJournalTrans.LedgerDimension) VendTable::findByLedgerDimension(ledgerJournalTrans.LedgerDimension)
4 Nisan 2014 Cuma
AX 2012 - Generate RDP (Report Data Provider)
Data Provider class:
------------Class Declaration-------------------
[SRSReportParameterAttribute(classStr(myCustInvoicePrintContract))]
class myCustInvoicePrintDP extends SRSReportDataProviderbase
{
CustInvoicePrintTMP InvoicePrint;
CustInvoicePrintTransTMP InvoicePrintTrans;
CustInvoicePrintTaxTMP InvoicePrintTax;
CustInvoicePrintFootTMP InvoicePrintFoot;
RecId RecId;
}
-----------------Table methods for SSRS---------------------------
[SRSReportDataSetAttribute(tableStr(CustInvoicePrintTMP))]
public CustInvoicePrintTMP getCustInvoicePrint()
{
select * from InvoicePrint;
return InvoicePrint;
}
[SRSReportDataSetAttribute(tableStr(CustInvoicePrintTransTMP))]
public CustInvoicePrintTransTMP getCustInvoicePrintTrans()
{
select * from InvoicePrintTrans;
return InvoicePrintTrans;
}
------------------GetParameter method--------------------------------
private void getReportParameters()
{
myCustInvoicePrintContract Contract = this.parmDataContract();
if (Contract)
{
RecId = Contract.parmRecordId();
}
}
------------------- processReport method where data filled--------
[SysEntryPointAttribute(false)]
public void processReport()
{
CustInvoiceJour InvoiceJour;
CustInvoiceTrans InvoiceTrans;
TaxTrans taxTrans;
TaxOnItem taxOnItem;
TaxGroupData taxGroupData;
AmountMST Tax;
this.getReportParameters();
InvoiceJour = CustInvoiceJour::findRecId(RecId);
InvoicePrint.InvoiceDate = InvoiceJour.InvoiceDate;
InvoicePrint.InvoiceName = InvoiceJour.invoiceName();
InvoicePrint.TaxOfficeName_TR = CustTable::find(InvoiceJour.InvoiceAccount).TaxOfficeName_TR;
...
InvoicePrint.insert();
while select InvoiceTrans where
InvoiceTrans.SalesId == InvoiceJour.SalesId && InvoiceTrans.InvoiceId == InvoiceJour.InvoiceId &&
InvoiceTrans.InvoiceDate == InvoiceJour.InvoiceDate && InvoiceTrans.numberSequenceGroup == InvoiceJour.numberSequenceGroup
{
select taxOnItem
where taxOnItem.TaxItemGroup == InvoiceTrans.TaxItemGroup
join taxGroupData
where taxGroupData.TaxCode == taxOnItem.TaxCode &&
taxGroupData.TaxGroup == InvoiceTrans.TaxGroup;
InvoicePrintTrans.TaxValue = TaxData::find(TaxOnItem.TaxCode, InvoiceTrans.InvoiceDate, 0).TaxValue;
InvoicePrintTrans.Qty = InvoiceTrans.Qty;
...
InvoicePrintTrans.insert();
Tax = Tax::calcTaxAmount(InvoiceTrans.TaxGroup,taxOnItem.TaxItemGroup,InvoiceTrans.InvoiceDate,
InvoiceTrans.CurrencyCode,InvoiceTrans.LineAmount,TaxModuleType::Sales);
...
InvoicePrintTax.insert();
}
}
...
}
Controller class:
--------------Class Declaration------------------
class myCustInvoicePrintController extends SrsReportRunController
{
#define.ReportName('CustInvoicePrint.Report')
myCustInvoicePrintContract contract;
CustInvoiceJour custInvoiceJour;
}
Get parameter
protected void prePromptModifyContract()
{
if (this.parmArgs() &&
this.parmArgs().record() &&
this.parmArgs().dataset() == tableNum(CustInvoiceJour))
{
custInvoiceJour = this.parmArgs().record();
}
if (!Contract)
{
Contract = this.parmReportContract().parmRdpContract();
}
contract.parmRecordId(custInvoiceJour.RecId);
super();
}
public static myCustInvoicePrintController construct(Args _args)
{
myCustInvoicePrintController controller = new myCustInvoicePrintController();
controller.parmArgs(_args);
return controller;
}
public static void main(Args _args)
{
SysLastValue SysLastValue;
myCustInvoicePrintController controller = new myCustInvoicePrintController();
controller.parmReportName(#ReportName);
controller.parmArgs(_args);
if(CSReportPrint::find(SysUserInfo::find().RecId,CSReportType::Invoice1).PrinterName)
{
controller.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::Printer);
controller.parmReportContract().parmPrintSettings().printerName(CSReportPrint::find(SysUserInfo::find().RecId,CSReportType::Invoice1).PrinterName);
}
controller.parmShowDialog(false); //don't show dialog at screen
controller.startOperation();
}
Contract class:
---------------class declaration---------------------------
[DataContractAttribute]
class myCustInvoicePrintContract
{
RecId recordId;
}Get parameter
[DataMemberAttribute('RecordId')]
public recId parmRecordId(recId _recordId = recordId)
{
recordId = _recordId;
return recordId;
}
------------Class Declaration-------------------
[SRSReportParameterAttribute(classStr(myCustInvoicePrintContract))]
class myCustInvoicePrintDP extends SRSReportDataProviderbase
{
CustInvoicePrintTMP InvoicePrint;
CustInvoicePrintTransTMP InvoicePrintTrans;
CustInvoicePrintTaxTMP InvoicePrintTax;
CustInvoicePrintFootTMP InvoicePrintFoot;
RecId RecId;
}
-----------------Table methods for SSRS---------------------------
[SRSReportDataSetAttribute(tableStr(CustInvoicePrintTMP))]
public CustInvoicePrintTMP getCustInvoicePrint()
{
select * from InvoicePrint;
return InvoicePrint;
}
[SRSReportDataSetAttribute(tableStr(CustInvoicePrintTransTMP))]
public CustInvoicePrintTransTMP getCustInvoicePrintTrans()
{
select * from InvoicePrintTrans;
return InvoicePrintTrans;
}
------------------GetParameter method--------------------------------
private void getReportParameters()
{
myCustInvoicePrintContract Contract = this.parmDataContract();
if (Contract)
{
RecId = Contract.parmRecordId();
}
}
------------------- processReport method where data filled--------
[SysEntryPointAttribute(false)]
public void processReport()
{
CustInvoiceJour InvoiceJour;
CustInvoiceTrans InvoiceTrans;
TaxTrans taxTrans;
TaxOnItem taxOnItem;
TaxGroupData taxGroupData;
AmountMST Tax;
this.getReportParameters();
InvoiceJour = CustInvoiceJour::findRecId(RecId);
InvoicePrint.InvoiceDate = InvoiceJour.InvoiceDate;
InvoicePrint.InvoiceName = InvoiceJour.invoiceName();
InvoicePrint.TaxOfficeName_TR = CustTable::find(InvoiceJour.InvoiceAccount).TaxOfficeName_TR;
...
InvoicePrint.insert();
while select InvoiceTrans where
InvoiceTrans.SalesId == InvoiceJour.SalesId && InvoiceTrans.InvoiceId == InvoiceJour.InvoiceId &&
InvoiceTrans.InvoiceDate == InvoiceJour.InvoiceDate && InvoiceTrans.numberSequenceGroup == InvoiceJour.numberSequenceGroup
{
select taxOnItem
where taxOnItem.TaxItemGroup == InvoiceTrans.TaxItemGroup
join taxGroupData
where taxGroupData.TaxCode == taxOnItem.TaxCode &&
taxGroupData.TaxGroup == InvoiceTrans.TaxGroup;
InvoicePrintTrans.TaxValue = TaxData::find(TaxOnItem.TaxCode, InvoiceTrans.InvoiceDate, 0).TaxValue;
InvoicePrintTrans.Qty = InvoiceTrans.Qty;
...
InvoicePrintTrans.insert();
Tax = Tax::calcTaxAmount(InvoiceTrans.TaxGroup,taxOnItem.TaxItemGroup,InvoiceTrans.InvoiceDate,
InvoiceTrans.CurrencyCode,InvoiceTrans.LineAmount,TaxModuleType::Sales);
...
InvoicePrintTax.insert();
}
}
...
}
Controller class:
--------------Class Declaration------------------
class myCustInvoicePrintController extends SrsReportRunController
{
#define.ReportName('CustInvoicePrint.Report')
myCustInvoicePrintContract contract;
CustInvoiceJour custInvoiceJour;
}
Get parameter
protected void prePromptModifyContract()
{
if (this.parmArgs() &&
this.parmArgs().record() &&
this.parmArgs().dataset() == tableNum(CustInvoiceJour))
{
custInvoiceJour = this.parmArgs().record();
}
if (!Contract)
{
Contract = this.parmReportContract().parmRdpContract();
}
contract.parmRecordId(custInvoiceJour.RecId);
super();
}
public static myCustInvoicePrintController construct(Args _args)
{
myCustInvoicePrintController controller = new myCustInvoicePrintController();
controller.parmArgs(_args);
return controller;
}
public static void main(Args _args)
{
SysLastValue SysLastValue;
myCustInvoicePrintController controller = new myCustInvoicePrintController();
controller.parmReportName(#ReportName);
controller.parmArgs(_args);
if(CSReportPrint::find(SysUserInfo::find().RecId,CSReportType::Invoice1).PrinterName)
{
controller.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::Printer);
controller.parmReportContract().parmPrintSettings().printerName(CSReportPrint::find(SysUserInfo::find().RecId,CSReportType::Invoice1).PrinterName);
}
controller.parmShowDialog(false); //don't show dialog at screen
controller.startOperation();
}
Contract class:
---------------class declaration---------------------------
[DataContractAttribute]
class myCustInvoicePrintContract
{
RecId recordId;
}Get parameter
[DataMemberAttribute('RecordId')]
public recId parmRecordId(recId _recordId = recordId)
{
recordId = _recordId;
return recordId;
}
10 Mart 2014 Pazartesi
AXAPTA - Find VAT rate and amount at document lines
while select InvoiceTrans where
InvoiceTrans.SalesId == InvoiceJour.SalesId && InvoiceTrans.InvoiceId == InvoiceJour.InvoiceId &&
InvoiceTrans.InvoiceDate == InvoiceJour.InvoiceDate && InvoiceTrans.numberSequenceGroup == InvoiceJour.numberSequenceGroup
{
InvoicePrintTrans.Name = InvoiceTrans.Name;
select taxOnItem
where taxOnItem.TaxItemGroup == InvoiceTrans.TaxItemGroup
join taxGroupData
where taxGroupData.TaxCode == taxOnItem.TaxCode &&
taxGroupData.TaxGroup == InvoiceTrans.TaxGroup;
TaxValue = TaxData::find(TaxOnItem.TaxCode, InvoiceTrans.InvoiceDate, 0).TaxValue;
Tax = Tax::calcTaxAmount(InvoiceTrans.TaxGroup,taxOnItem.TaxItemGroup,InvoiceTrans.InvoiceDate,
InvoiceTrans.CurrencyCode,InvoiceTrans.LineAmount,TaxModuleType::Sales);
info(strFmt("VAT rate %1 VAT amount",TaxValue,Tax));
}
InvoiceTrans.SalesId == InvoiceJour.SalesId && InvoiceTrans.InvoiceId == InvoiceJour.InvoiceId &&
InvoiceTrans.InvoiceDate == InvoiceJour.InvoiceDate && InvoiceTrans.numberSequenceGroup == InvoiceJour.numberSequenceGroup
{
InvoicePrintTrans.Name = InvoiceTrans.Name;
select taxOnItem
where taxOnItem.TaxItemGroup == InvoiceTrans.TaxItemGroup
join taxGroupData
where taxGroupData.TaxCode == taxOnItem.TaxCode &&
taxGroupData.TaxGroup == InvoiceTrans.TaxGroup;
TaxValue = TaxData::find(TaxOnItem.TaxCode, InvoiceTrans.InvoiceDate, 0).TaxValue;
Tax = Tax::calcTaxAmount(InvoiceTrans.TaxGroup,taxOnItem.TaxItemGroup,InvoiceTrans.InvoiceDate,
InvoiceTrans.CurrencyCode,InvoiceTrans.LineAmount,TaxModuleType::Sales);
info(strFmt("VAT rate %1 VAT amount",TaxValue,Tax));
}
26 Şubat 2014 Çarşamba
AXAPTA - Call a class extended from another with name string
There are three ways:
1- classFactory.createClass(className2Id('MyClass'))
2- test1 test;
DictClass d;
d = new DictClass(className2Id("test1"));
test = d.makeObject(222);
test.MyTest();
3. Just for AX 2012 için extension framework . I'll look up this later.
1- classFactory.createClass(className2Id('MyClass'))
2- test1 test;
DictClass d;
d = new DictClass(className2Id("test1"));
test = d.makeObject(222);
test.MyTest();
3. Just for AX 2012 için extension framework . I'll look up this later.
4 Şubat 2014 Salı
AX 2012 - Company logo
mylogo = FormLetter::companyLogo();
AX 2012 - Test RDP class at Axapta side
How do you test your RDP classes developed for SSRS reports at AX side?
DGHCreditDetailsDP dp = new DGHCreditDetailsDP();
DGHCreditDetailsDC dc = new DGHCreditDetailsDC();
Query q;
dc.parmTransDate(str2Date("28.12.2013",123));
q = dp.parmQuery();
q.dataSourceTable(tableNum(BankAccountTrans)).addRange(Fieldnum(BankAccountTrans,accountid)).value("102 02 034 002");
dp.parmDataContract(dc);
dp.processReport();
DGHCreditDetailsDP dp = new DGHCreditDetailsDP();
DGHCreditDetailsDC dc = new DGHCreditDetailsDC();
Query q;
dc.parmTransDate(str2Date("28.12.2013",123));
q = dp.parmQuery();
q.dataSourceTable(tableNum(BankAccountTrans)).addRange(Fieldnum(BankAccountTrans,accountid)).value("102 02 034 002");
dp.parmDataContract(dc);
dp.processReport();
6 Ocak 2014 Pazartesi
AX 2012 - Create SSRS report PDF output
I got help from Martin Drab's blog for create PDF with AX 2012:
void CreatePDF(Str60 _Subject,Notes _Body)
{
MYReportPurchController controller;
MYReportPurchContract rdpContract = new MyReportPurchContract();
SRSPrintDestinationSettings settings;
Args args = new args();
str fileName;
args.record(this);
controller = MYReportPurchController::construct(args);
// Define report and report design to use
controller.parmReportName(ssrsReportStr(EtgPurchOrderForm,PrecisionDesign1));
// Use execution mode appropriate to your situation
controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
// Suppress report dialog
// Explicitly provide all required parameters
controller.parmReportContract().parmRdpContract(rdpContract);
//rdpContract.
// Change print settings as needed
settings = controller.parmReportContract().parmPrintSettings();
settings.overwriteFile(true);
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
//settings.
#WinAPI
fileName = WinApi::getTempPath() +this.PurchOrderDocNum+".PDF";
settings.fileName(fileName);
// Execute the report
controller.parmShowDialog(false);
controller.startOperation();
}
Or send selected records to PDF by RDP report:
SMAServiceOrderTable serviceOrder;
MultiSelectionHelper helper;
FormRun caller = _args.caller();
FormDataSource SMAServiceOrderTable_DS;
SRSPrintDestinationSettings settings;
ETGServiceReportContract contract = new ETGServiceReportContract();
SrsReportRunController controller;
Filename fileName;
int counter;
SysMailer mailer = new SysMailer();
SysEmailParameters parameters = SysEmailParameters::find();
Dialog dialog;
DialogField field;
Email email;
dialog = new Dialog("Servis Raporu Gönderme");
field = dialog.addField(ExtendedTypeStr(email));
dialog.run();
if (!dialog.closedOK())
return;
email = field.value();
if (email == "")
throw error("Bir mail adresi girmelisiniz!..");
SMAServiceOrderTable_DS = caller.dataSource();
helper = MultiSelectionHelper::createFromCaller(caller);
if (parameters.SMTPRelayServerName)
{
mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
else
{
mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
mailer.fromAddress('noreply@sinbo.com.tr');
mailer.tos().appendAddress(email);
mailer.htmlBody('<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-9">Sayın Yetkili,<br><br> Servis raporu kopyanız ektedir.<br><br>Saygılarımızla,<br><br><br>Sinbo');
mailer.subject('Sinbo Servis Raporu');
mailer.bodyCharSet("Windows-1254");
helper.createQueryRanges(SMAServiceOrderTable_DS.queryBuildDataSource(),fieldStr(SMAServiceOrderTable,RecId));
serviceOrder = helper.getFirst();
while(serviceOrder)
{
controller = new SrsReportRunController();
controller.parmReportName(ssrsReportStr(ETGServiceReport, Report));
contract = controller.parmReportContract().parmRdpContract();
controller.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::Screen);
controller.parmShowDialog(false);
contract.parmServiceOrderId(serviceOrder.ServiceOrderId);
counter++;
fileName = WinApi::getTempPath() + strFmt("Servis Raporu %1.PDF",counter);
settings = controller.parmReportContract().parmPrintSettings();
settings.overwriteFile(true);
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.fileName(fileName);
controller.startOperation();
mailer.attachments().add(fileName);
serviceOrder = helper.getNext();
}
if (counter == 0)
return;
infolog.clear();
mailer.sendMail();
void CreatePDF(Str60 _Subject,Notes _Body)
{
MYReportPurchController controller;
MYReportPurchContract rdpContract = new MyReportPurchContract();
SRSPrintDestinationSettings settings;
Args args = new args();
str fileName;
args.record(this);
controller = MYReportPurchController::construct(args);
// Define report and report design to use
controller.parmReportName(ssrsReportStr(EtgPurchOrderForm,PrecisionDesign1));
// Use execution mode appropriate to your situation
controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
// Suppress report dialog
// Explicitly provide all required parameters
controller.parmReportContract().parmRdpContract(rdpContract);
//rdpContract.
// Change print settings as needed
settings = controller.parmReportContract().parmPrintSettings();
settings.overwriteFile(true);
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
//settings.
#WinAPI
fileName = WinApi::getTempPath() +this.PurchOrderDocNum+".PDF";
settings.fileName(fileName);
// Execute the report
controller.parmShowDialog(false);
controller.startOperation();
}
Or send selected records to PDF by RDP report:
SMAServiceOrderTable serviceOrder;
MultiSelectionHelper helper;
FormRun caller = _args.caller();
FormDataSource SMAServiceOrderTable_DS;
SRSPrintDestinationSettings settings;
ETGServiceReportContract contract = new ETGServiceReportContract();
SrsReportRunController controller;
Filename fileName;
int counter;
SysMailer mailer = new SysMailer();
SysEmailParameters parameters = SysEmailParameters::find();
Dialog dialog;
DialogField field;
Email email;
dialog = new Dialog("Servis Raporu Gönderme");
field = dialog.addField(ExtendedTypeStr(email));
dialog.run();
if (!dialog.closedOK())
return;
email = field.value();
if (email == "")
throw error("Bir mail adresi girmelisiniz!..");
SMAServiceOrderTable_DS = caller.dataSource();
helper = MultiSelectionHelper::createFromCaller(caller);
if (parameters.SMTPRelayServerName)
{
mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
else
{
mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
mailer.fromAddress('noreply@sinbo.com.tr');
mailer.tos().appendAddress(email);
mailer.htmlBody('<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-9">Sayın Yetkili,<br><br> Servis raporu kopyanız ektedir.<br><br>Saygılarımızla,<br><br><br>Sinbo');
mailer.subject('Sinbo Servis Raporu');
mailer.bodyCharSet("Windows-1254");
helper.createQueryRanges(SMAServiceOrderTable_DS.queryBuildDataSource(),fieldStr(SMAServiceOrderTable,RecId));
serviceOrder = helper.getFirst();
while(serviceOrder)
{
controller = new SrsReportRunController();
controller.parmReportName(ssrsReportStr(ETGServiceReport, Report));
contract = controller.parmReportContract().parmRdpContract();
controller.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::Screen);
controller.parmShowDialog(false);
contract.parmServiceOrderId(serviceOrder.ServiceOrderId);
counter++;
fileName = WinApi::getTempPath() + strFmt("Servis Raporu %1.PDF",counter);
settings = controller.parmReportContract().parmPrintSettings();
settings.overwriteFile(true);
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.fileName(fileName);
controller.startOperation();
mailer.attachments().add(fileName);
serviceOrder = helper.getNext();
}
if (counter == 0)
return;
infolog.clear();
mailer.sendMail();
AXAPTA - Send email
private void SendMail2(str _FileName,Str60 _Subject,Notes _Body)
{
str Toaddress;
System.Net.Mail.MailMessage Msg = new System.Net.Mail.MailMessage();
System.Net.Mail.MailAddress fromMail;
System.Net.Mail.MailAddressCollection toadrr;
System.Net.Mail.SmtpClient smCL = new System.Net.Mail.SmtpClient();
System.Net.NetworkCredential credential;
str bodygrd,sSmtpServer;
CLRObject exc;
CLRObject innerExc;
CLRObject clrExcMessage;
str strError;
SysEmailParameters EmailParm;
str pass;
System.Net.Mail.AttachmentCollection mailAttachementCollection;
System.Net.Mail.Attachment mailAttachment;
;
toaddress="test@hotmail.com";
EmailParm = SysEmailParameters::find();
pass = SysEmailParameters::password();
credential = new System.Net.NetworkCredential(EmailParm.SMTPUserName,pass);
fromMail = new System.Net.Mail.MailAddress(EmailParm.SMTPUserName);
new InteropPermission(InteropKind::ClrInterop).assert();
try
{
Msg.set_From(fromMail);
toadrr = Msg.get_To();
toadrr.Add(new System.Net.Mail.MailAddress(toaddress));
Msg.set_Subject(_Subject);
Msg.set_Body(_body);
Msg.set_IsBodyHtml(true);
sSmtpServer = EmailParm.SMTPRelayServerName;
smCL.set_Host(sSmtpServer);
mailAttachementCollection = msg.get_Attachments();
mailAttachment = new System.Net.Mail.Attachment(_fileName);
mailAttachementCollection.Add(mailAttachment);
smCL.set_Port(EmailParm.SMTPPortNumber);
smCL.set_EnableSsl(true);
smCL.set_Credentials(credential);
smCL.Send(Msg);
} catch( Exception::CLRError )
{
exc = CLRInterop::getLastException();
if( exc )
{
clrExcMessage = exc.get_Message();
innerExc = exc.get_InnerException();
while(innerExc != null)
{
clrExcMessage = innerExc.get_Message();
innerExc = innerExc.get_InnerException();
}
strError = CLRInterop::getAnyTypeForObject( clrExcMessage );
throw error(strError);
}
}
}
{
str Toaddress;
System.Net.Mail.MailMessage Msg = new System.Net.Mail.MailMessage();
System.Net.Mail.MailAddress fromMail;
System.Net.Mail.MailAddressCollection toadrr;
System.Net.Mail.SmtpClient smCL = new System.Net.Mail.SmtpClient();
System.Net.NetworkCredential credential;
str bodygrd,sSmtpServer;
CLRObject exc;
CLRObject innerExc;
CLRObject clrExcMessage;
str strError;
SysEmailParameters EmailParm;
str pass;
System.Net.Mail.AttachmentCollection mailAttachementCollection;
System.Net.Mail.Attachment mailAttachment;
;
toaddress="test@hotmail.com";
EmailParm = SysEmailParameters::find();
pass = SysEmailParameters::password();
credential = new System.Net.NetworkCredential(EmailParm.SMTPUserName,pass);
fromMail = new System.Net.Mail.MailAddress(EmailParm.SMTPUserName);
new InteropPermission(InteropKind::ClrInterop).assert();
try
{
Msg.set_From(fromMail);
toadrr = Msg.get_To();
toadrr.Add(new System.Net.Mail.MailAddress(toaddress));
Msg.set_Subject(_Subject);
Msg.set_Body(_body);
Msg.set_IsBodyHtml(true);
sSmtpServer = EmailParm.SMTPRelayServerName;
smCL.set_Host(sSmtpServer);
mailAttachementCollection = msg.get_Attachments();
mailAttachment = new System.Net.Mail.Attachment(_fileName);
mailAttachementCollection.Add(mailAttachment);
smCL.set_Port(EmailParm.SMTPPortNumber);
smCL.set_EnableSsl(true);
smCL.set_Credentials(credential);
smCL.Send(Msg);
} catch( Exception::CLRError )
{
exc = CLRInterop::getLastException();
if( exc )
{
clrExcMessage = exc.get_Message();
innerExc = exc.get_InnerException();
while(innerExc != null)
{
clrExcMessage = innerExc.get_Message();
innerExc = innerExc.get_InnerException();
}
strError = CLRInterop::getAnyTypeForObject( clrExcMessage );
throw error(strError);
}
}
}
3 Ocak 2014 Cuma
AXAPTA - Merge more than one purchaseses selected lines and show at PurchEditLines form
Args args = new Args();
PurchFormLetter purchFormLetter;
purchTable purchTable;
VendReceiptsListTrans ListTrans;
PurchParmLine purchParmLine;
PurchParmTable purchParmTable;
Object dialog;
vendReceiptsListJour Jour;
boolean err;
VendPackingSlipTrans PackingTrans;
;
select purchTable where purchTable.PurchId == this.PurchId; //select first purchtable record
//-------------- prepare purchformletter class -----
purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
purchFormLetter.parmSourceTable(purchTable);
purchFormLetter.initLinesQuery();
purchformletter.createParmUpdate();
purchFormLetter.transDate(this.PackingSlipDate);
// purchformletter.documentNum(
purchformletter.chooseLines();
//--------------- add other purchtable records -----
while select OrigpurchId from ListTrans
group by ListTrans.OrigPurchId
where ListTrans.ReceiptsListId == this.ReceiptsListId && ListTrans.OrigPurchId != this.PurchId
{
select purchTable where purchTable.PurchId == ListTrans.OrigPurchId;
purchformletter.updateQueryAndChooseLines(purchTable);
}
//---------------- delete unnecessary purchase lines --------------------
select firstonly forupdate purchParmLine
where purchParmLine.ParmId == purchformletter.parmId();
if (purchParmLine.RecId == 0)
{
box::stop("There isn't any purchline applicable");
return;
}
// box::warning("111");
ttsbegin;
while select forupdate purchParmLine
where purchParmLine.ParmId == purchformletter.parmId()
{
select firstonly ListTrans where ListTrans.ReceiptsListId == this.ReceiptsListId && ListTrans.OrigPurchId == purchParmLine.OrigPurchId &&
ListTrans.ItemId == purchParmLine.ItemId && purchParmLine.InventTransId == ListTrans.InventTransId;
// info(strfmt("%1 %2",purchparmline.ItemId,listtrans.ItemId));
//---eğer bu sipariş satırı giriş listesinde yoksa sil-------------
if (ListTrans.RecId == 0)
{
// info("---sil---");
purchParmLine.delete();
continue;
}
//----miktarı giriş listesinden al----------------------------------
purchParmLine.ReceiveNow = ListTrans.PurchQty;
purchParmLine.InventNow = ListTrans.PurchQty;
// purchParmLine.modifiedReceiveNow();
purchParmLine.setQty(DocumentStatus::PackingSlip, false, true);
purchParmLine.setLineAmount();
purchParmLine.update();
}
update_recordset purchParmTable setting num = this.packingSlipId,
TransDate = this.PackingSlipDate,
DocumentDate = this.PackingSlipDate
where purchParmTable.ParmId == purchformletter.parmId();
ttscommit;
if (this.packingSlipId)
purchformletter.reArrange(true); //------------ merge purchases like push rearrange button at purcheditlines form ----
dialog = purchformletter.dialog();
dialog.run() ;
dialog.wait();
if (dialog.closedOk())
{
purchFormLetter.proforma(false);
purchFormLetter.printFormLetter(true);
purchFormLetter.specQty(PurchUpdate::ReceiveNow);
purchFormLetter.progressHide();
purchformletter.run();
select firstonly PackingTrans join ListTrans
where PackingTrans.purchId == ListTrans.OrigPurchId &&
ListTrans.ReceiptsListId == this.ReceiptsListId;
if (PackingTrans.RecId != 0)
{
ttsbegin;
update_recordset Jour setting VendReceiptsListJourStatus = DTVendReceiptsListJourStatus::PackingSlip
where Jour.RecId == this.RecId;
ttscommit;
}
}
PurchFormLetter purchFormLetter;
purchTable purchTable;
VendReceiptsListTrans ListTrans;
PurchParmLine purchParmLine;
PurchParmTable purchParmTable;
Object dialog;
vendReceiptsListJour Jour;
boolean err;
VendPackingSlipTrans PackingTrans;
;
select purchTable where purchTable.PurchId == this.PurchId; //select first purchtable record
//-------------- prepare purchformletter class -----
purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
purchFormLetter.parmSourceTable(purchTable);
purchFormLetter.initLinesQuery();
purchformletter.createParmUpdate();
purchFormLetter.transDate(this.PackingSlipDate);
// purchformletter.documentNum(
purchformletter.chooseLines();
//--------------- add other purchtable records -----
while select OrigpurchId from ListTrans
group by ListTrans.OrigPurchId
where ListTrans.ReceiptsListId == this.ReceiptsListId && ListTrans.OrigPurchId != this.PurchId
{
select purchTable where purchTable.PurchId == ListTrans.OrigPurchId;
purchformletter.updateQueryAndChooseLines(purchTable);
}
//---------------- delete unnecessary purchase lines --------------------
select firstonly forupdate purchParmLine
where purchParmLine.ParmId == purchformletter.parmId();
if (purchParmLine.RecId == 0)
{
box::stop("There isn't any purchline applicable");
return;
}
// box::warning("111");
ttsbegin;
while select forupdate purchParmLine
where purchParmLine.ParmId == purchformletter.parmId()
{
select firstonly ListTrans where ListTrans.ReceiptsListId == this.ReceiptsListId && ListTrans.OrigPurchId == purchParmLine.OrigPurchId &&
ListTrans.ItemId == purchParmLine.ItemId && purchParmLine.InventTransId == ListTrans.InventTransId;
// info(strfmt("%1 %2",purchparmline.ItemId,listtrans.ItemId));
//---eğer bu sipariş satırı giriş listesinde yoksa sil-------------
if (ListTrans.RecId == 0)
{
// info("---sil---");
purchParmLine.delete();
continue;
}
//----miktarı giriş listesinden al----------------------------------
purchParmLine.ReceiveNow = ListTrans.PurchQty;
purchParmLine.InventNow = ListTrans.PurchQty;
// purchParmLine.modifiedReceiveNow();
purchParmLine.setQty(DocumentStatus::PackingSlip, false, true);
purchParmLine.setLineAmount();
purchParmLine.update();
}
update_recordset purchParmTable setting num = this.packingSlipId,
TransDate = this.PackingSlipDate,
DocumentDate = this.PackingSlipDate
where purchParmTable.ParmId == purchformletter.parmId();
ttscommit;
if (this.packingSlipId)
purchformletter.reArrange(true); //------------ merge purchases like push rearrange button at purcheditlines form ----
dialog = purchformletter.dialog();
dialog.run() ;
dialog.wait();
if (dialog.closedOk())
{
purchFormLetter.proforma(false);
purchFormLetter.printFormLetter(true);
purchFormLetter.specQty(PurchUpdate::ReceiveNow);
purchFormLetter.progressHide();
purchformletter.run();
select firstonly PackingTrans join ListTrans
where PackingTrans.purchId == ListTrans.OrigPurchId &&
ListTrans.ReceiptsListId == this.ReceiptsListId;
if (PackingTrans.RecId != 0)
{
ttsbegin;
update_recordset Jour setting VendReceiptsListJourStatus = DTVendReceiptsListJourStatus::PackingSlip
where Jour.RecId == this.RecId;
ttscommit;
}
}
Etiketler:
AX,
AXAPTA,
more,
multiply,
one,
purchase,
purcheditlines,
purchformletter,
purchtable
Kaydol:
Kayıtlar (Atom)