Thursday, 16 June 2016

Axapta 2009 This transaction has been marked for settlement by another user.

one of end user of AR is got stuck for knock off the account.
Then I  make  a solution that logon to database server of the AX 2009 then write a query
select * from SPECTRANS
then select a amount in table where Red Dot is came and put in the query
select * from SPECTRANS where BALANCE01=398.700
now check that record is came
Now delete that record by writing a query
delete from SPECTRANS where  BALANCE01=398.700
now again go to check the settlement transaction ,Red Dot  is gone .

Monday, 25 April 2016

Overdelivery of line is 100,00 percent, but the allowed overdelivery is only 0 percent.

We had the same problem with one of our client. The reason behind was, there were some orphans purchParmSubLine records lying in the table, which led to add up the remain del note qty and attempting to post Delivery note again. We suspected, the reasons these records were left in the table, when posting failed for any reason or client session crashed when posting was being done. Anyways, simple way to resolve it by creating a simple job to clean up those records and Hallelujah! the problem is gone!
static void tecDeleteOrphanParmRecords(Args _args)
{
   PurchParmTable purchParmTable;
   PurchParmLine  purchParmLine;
   ;
   ttsbegin;
   while select forupdate purchParmTable
       join forupdate purchParmLine
       where purchParmLine.ParmId == purchParmTable.ParmId
       && purchParmLine.TableRefId    == purchParmTable.TableRefId
       && purchParmTable.PurchId  == "Your PO number"
       && purchParmTable.ParmJobStatus == ParmJobStatus::Waiting
       && purchParmTable.Ordering == DocumentStatus::Invoice
   if(purchParmTable.RecId || purchParmLine.RecId)
   {
       purchParmTable.delete();
       purchParmLine.delete();
   }
   ttscommit;
}
Cleaning up PurchParmTable and Line will also clean up related tables (Sub tables) by itself.
Try posting again.  Everything should work smoothly.
Cheers!
PG

Monday, 15 February 2016

Send email using X++ code

SysMailer   mailer = new SysMailer();
        SysEmailParameters parameters = SysEmailParameters::find();
        ;

        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('hesham.elgabarty@augpharma.com');
        mailer.tos().appendAddress('hesham.elgabarty@augpharma.com');
        mailer.htmlBody('AZZZ');
        mailer.subject('Comunicazione AX');

        mailer.sendMail();
        info('Done');

Tuesday, 26 January 2016

Can not post a purchase invoice

We have come across some scenarios where it was not possible to complete purchase invoicing, for example:
  • There is pending invoice in AX that is not visible in invoicepool. It can be seen only from purchase order side. It blocks many orders.
  • A Pending Invoice is not appearing in PL>common>Pending Supplier Invoices however when you go to the PO and look at the invoice tab, the Pending Invoice is still highlighted and when you select this you can see the detail of the pending invoice but we cannot do anything with it
  • When trying to post a purchase invoice you get an error message that says: Invoice %1 could not post because it contained matching errors which must be approved.
  • While selecting Pending vendor invoice gets an error as “One or more pending invoices cannot be displayed because they are in use” and the invoice is not displayed.
It may happen that if AOS gets stopped suddenly or the client loses connection with the AOS, some records stay in specific tables that causes these kind of situations. In other cases we or Partners could not find repro steps to get those scenarios.
I found a list of the SQL tables where the ‘pending’ record may exist. If the record is found in any of the following tables, the recommendation is to remove it when you have no users accessing AOS (and take normal precautions first of backing up the data). Also test the procedures in a test/development environment before applying it to a live enviroment. Then, check to see if you are able to properly invoice update the PO.
PurchParmTable
PurchParmLine
PurchParmSubTable
PurchParmSubLine
PurchParmUpdate
VendInvoiceInfoTable
VendInvoiceInfoLine
VendInvoiceInfoSubTable
VendInvoiceInfoSubLine
Of course, you can also delete these records going through Forms, these are the ones I used (ensure no users besides you are working in the application):
1. Firstly checking PurchParm tables when looking History forms (Account Payable/ Inquiries/ History/ Purchase orders), and delete those records where the status is “Waiting”.
2. The next step is to check VendInvoiceInfo tables where you found the wrong records, You can access those records in the list page: Accounts payable module > Places > Pending Purchase Order Invoices. Here you can delete it as well. Note: pending invoice of your case will be in this list page.
Hope it’s helpful

VendTmpInvoiceInfoTable

Friday, 15 January 2016

Unreserved "Physical Reserved" Qty in Ax 2009 thru x++

To remove a reservation (just reverse the sign on the qty):
In the code below, ‘inventTransParent’ is the inventTransId of the record that has the reservation (e.g. salesline.inventTransId)
You probably will want to modify the ‘where’ clause a bit to make sure you get the reservation records only, but this is just an example.
//Remove any existing reservations
InventTrans            inventTransReserve    ;
InventMovement         inventMovement        ;
InventUpd_Reservation  inventUpd_Reservation ;
;
while select inventTransReserve where inventTransReserve.InventTransId == inventTransParent
{
   Inventmovement = inventTransReserve.inventmovement(true);
   inventUpd_Reservation = InventUpd_Reservation::newInventDim(inventmovement,inventTransReserve.inventDim(), -1 * inventTransReserve.Qty ,false);    inventUpd_Reservation.updatenow();
}

Wednesday, 24 June 2015

Simple Lookup Form

 SysTableLookup _SysTableLookup = SysTableLookup::newParameters(tablenum(carTable),this) ;
     _SysTableLookup.addLookupfield(fieldnum(carTable,carID));
     _SysTableLookup.addLookupfield(fieldnum(carTable,carName));
     _SysTableLookup.performFormLookup();

Monday, 23 March 2015

Simple Steps To Create Number Sequence In Ax2012

Number Sequence Creation:
Here I want to design a form named FirstForm with DataSource FirstTable
I want to create sequence  like "AX00001---------AX99999".

Step 1
Create an EDT - String Type
So, I created an EDT named "AXSeqEDT" with label "AX Seq"
Drag into Table(FirstTable)àFields

Step 2
Now create a new Number Sequence
Path for creating num Sequence is
"Module:: Organization administration.......Common.........Number sequences......Number sequences"
Click on New(Number Sequence)
Now number Sequence form will be opened----That contains 4 sections.
Section 1.Identification.....Specify the NumberSeqCode and Name
Section 2.Scope Parameters... Select the Scope from the Dropdown
Section 3.Segments.... Add the constant and alphanumeric (by clicking the add button and selecting from drop down)
Section 4 .General.....Checkmark for continous and Specify the "smallest and largest and Next" Fields
Now Save Ur Settings

Step 3
Now add the Respective manual-code to class - NumberSeqModuleURMODULE
And Table - URMODULEParameters.
So I am creating number sequence based on HRM Module.....So iam usingclassNumberSeqModuleHRM and TableHRMParameters
Now go to AOT---Classes-NumberSeqModuleHRM---loadModule()
Add the code here...
Note::Here we can add the code seeing the existing implementation
The Added Code is::
/* setup discussion number sequence - it is global */
    datatype.parmDatatypeId(extendedtypenum(AXSeqEDT));
    datatype.parmReferenceHelp(literalstr("@SYS32633"));
    datatype.parmWizardIsContinuous(true);
    datatype.parmWizardIsManual(NoYes::No);
    datatype.parmWizardIsChangeDownAllowed(NoYes::No);
    datatype.parmWizardIsChangeUpAllowed(NoYes::No);
    datatype.parmWizardHighest(99999);
    datatype.parmSortField(12);
    this.create(datatype);
Now Goto AOT---Tables---HRMParameters---methods-----click on new method

Add the code In the New method
Note::Here we can add the code seeing the existing implementation

The Added Code is
static client server NumberSequenceReference numRefAXSeqEDT()
{
returnNumberSeqReference::findReference(extendedTypeNum(AXSeqEDT));
}


Step 4
In order to add our newly created number sequence reference to our Module write the following Job and Execute it
Below job is important to run because without it your new number sequence will not be available to number sequence form under Parameters. This is the change in behavior from AX 2009 where all new number sequence loads while restarting the Dynamic AX. In AX 2012 all the number sequence created to system while installation, so restarting the AOS wont effect in loading the new number sequence, that is why it is important to run the job to load new number sequences.
The Code added in The Job is
static void jobName(Args _args)
{
    NumberSeqModuleHRM  NumberSeqModuleHRM = newNumberSeqModuleHRM();
    ;
    NumberSeqModuleHRm.load();
}


Step 5
Organization Administration >> CommonForms >> Numbersequences>>Numbersequences>> Generate >> run the wizard.

Step 6
Now we have to check the number sequence  is correctly working  for that write a job:

static void number(Args _args)
{
    NumberSeq  numberSeq;
    CarId num;
    ;
    numberSeq = NumberSeq::newGetNum(ProjParameters::numRefcarId());
    num = numberSeq.num();
    info(num);
}


Step 7
Now add the Code in Create method of Forms Datasource methods
Goto-AOT-Forms-FirstForm-Datasources-FirstTable-Methods-Override method(Create)
public void create(boolean _append = false)
{
    ;
super(_append);
    FirstTable.AXSeqEDT = NumberSeq::newGetNum(HRMParameters::numRefAXSeqEDT(),true).num();
}


Step 8
Now save all your settings.....Now Open our form-FirstForm


Another tutorial