Wednesday, December 18, 2024

ax - How to find type used for specified Number Sequence ?

Searching for the data type for the sequence Time_6:
select datatypeid from NUMBERSEQUENCEDATATYPE
where
recid = 
  (
    select NUMBERSEQUENCEDATATYPE from NumberSequenceReference
    where
    NUMBERSEQUENCEID =
    (
      select recid from NumberSequencetable
      where
      NUMBERSEQUENCE = 'Time_6'
    )
)
Output:
datatypeid
-----------
8374
Then job in AX:
static void Job8(Args _args)
{
    info( extendedTypeId2name( 8374 ) );
}
Output:

Thursday, August 8, 2024

SSRS - How to add stripline to chart

The stripline is in this example defined on X axis.



 














Remember: the value for StartWith is order of the axis value, not exact value (StartWidth):
=DatePart("ww", today(), FirstDayOfWeek.Monday, FirstWeekOfYear.System ) 
  -min(Fields!skp.Value)).



















PS: Better variant is to use SSRS function CountDistinct() - solves problem with gaps in axis values:
=CountDistinct( IIF(Fields!skp.Value <= DatePart("ww", today(), 
FirstDayOfWeek.Monday, FirstWeekOfYear.System ), Fields!skp.Value, nothing) )

Thursday, July 18, 2024

ax - How to get ItemId by ExternalItemId for specified customer

CustVendExternalItem custVendExternalItem;
ItemId itemId;
...
itemId = "";
custVendExternalItem = CustVendExternalItem::findExternalItemId( 
  ModuleInventPurchSalesVendCustGroup::Cust, "COMPANYID", sExternalItemId );
if ( custVendExternalItem != null ) itemId = custVendExternalItem.ItemId;

Friday, June 21, 2024

SSRS - How to get first and last day in month

These are useful functions, for example for parameter filling:

First and last day of this month:
=dateadd("m",0,dateserial(year(Today),month(Today),1))
=dateadd("m",1,dateserial(year(Today),month(Today),0))
First and last day of last month:
=dateadd("m",-1,dateserial(year(Today),month(Today),1))
=dateadd("m",0,dateserial(year(Today),month(Today),0))
First and last day of next month:
=dateadd("m",1,dateserial(year(Today),month(Today),1))
=dateadd("m",2,dateserial(year(Today),month(Today),0))

Monday, June 17, 2024

c - How to solve error UNRESOLVED EXTERNAL SYMBOL for static class field

.h
class OverloadedOperator {
public:
	
	string name;
	float price;
 
	static int n;
};
The problem could be in missing static field initialization in .cpp file. Should be:

.cpp
#include "OverloadedOperator.h"

int OverloadedOperator::n = 0;

Thursday, May 2, 2024

sql server - How to check used count of decimal places in the field

select prodid, remaininventphysical,
len(replace( rtrim( replace( 
  convert( varchar, remaininventphysical), '0', ' ' ) ), ' ', '0' ) ) - 
charindex( '.', replace( rtrim( replace( 
  convert( varchar, remaininventphysical ), '0', ' ' ) ), ' ', '0' ) )
as nonzerodecimalplacesused
from PRODBOM
order by prodid;
Output:
prodid               remaininventphysical                    nonzerodecimalplacesused
-------------------- --------------------------------------- ------------------------
24-015377            0.0600060006000600                      14
24-015376            0.0800000000000000                      2
24-014563            0.0450045004500450                      15
24-013446            0.0450045004500450                      15
24-013445            0.0000000000000000                      0
24-011934            0.0000000000000000                      0
24-008828            0.0000000000000000                      0
24-008602            0.0000000000000000                      0
24-006598            0.0000000000000000                      0
23-039521            0.0000000000000000                      0

Thursday, March 21, 2024

c_c++ - How to check DLL architecture (x86 vs x64)

From VS terminal run this command:
dumpbin /headers clib.dll
Output:
Dump of file clib.dll

PE signature found

File Type: DLL

FILE HEADER VALUES
            8664 machine (x64)
               A number of sections
        65FA9AE8 time date stamp Wed Mar 20 09:14:32 2024
               0 file pointer to symbol table
               0 number of symbols
              F0 size of optional header
            2022 characteristics
                   Executable
                   Application can handle large (>2GB) addresses
                   DLL

c_c++ - How to check entry points of the DLL

From VS terminal run this command:
dumpbin /exports clib.dll
Output, you can see two entry points:
Dump of file clib.dll

File Type: DLL

  Section contains the following exports for CLib.dll

    00000000 characteristics
    FFFFFFFF time date stamp
        0.00 version
           1 ordinal base
           2 number of functions
           2 number of names

    ordinal hint RVA      name

          1    0 00011249 add = @ILT+580(add)
          2    1 000110BE subtract = @ILT+185(subtract)

  Summary

        1000 .00cfg
        1000 .data
        1000 .idata
        1000 .msvcjmc
        3000 .pdata
        3000 .rdata
        1000 .reloc
        1000 .rsrc
        8000 .text
       10000 .textbss

Tuesday, January 16, 2024

c# - How to use LINQ aggregate() function

This calling performs SUM on Population (with starting value = 0.)
    
public List<Country> Countries = new();
...
this.Countries.Add( new Country( "Czech", Country.ContinentEnum.EUROPE, 10 ) );
this.Countries.Add( new Country( "Poland", Country.ContinentEnum.EUROPE, 40 ) );
this.Countries.Add( new Country( "China", Country.ContinentEnum.ASIA, 1100 ) );
this.Countries.Add( new Country( "USA", Country.ContinentEnum.AMERICA, 340 ) );
...
int total = this.Countries.Aggregate( 0, (total,b) => total + b.Population );

MessageBox.Show( total.ToString() );  // -> 1490