Menampilkan data pada Ax dengan SysTableLookup

Berikut ini saya mau menulis mengenai pengalaman yang saya dapat untuk menampilkan data pada tabel tertentu dengan kriteria tertentu menggunakan Kelas SysTableLookup:

Asumsi saya mempunyai tabel :
1. VendTable dengan field : AccountNum,Name dan VendGroup.
2. ParameterUmum dengan field : VendGroupId dan Description.

Kasus :
Tampilakan data AccountName dan Name yang VendGroup terdaftar atau ada didalam ParameterUmum.

Penyelesaian :

public void lookupVendor(FormControl control)
{
    Query                   query = new Query();
    QueryBuildDataSource    queryBuildDataSource;
    QueryBuildRange         queryBuildRange;
    SysTableLookup          sysTableLookup;
    ;

    sysTableLookup = SysTableLookup::newParameters(tablenum(VendTable), control);

    sysTableLookup.addLookupfield(fieldnum(VendTable, AccountNum), true);
    sysTableLookup.addLookupfield(fieldnum(VendTable, Name), false);

    queryBuildDataSource = query.addDataSource(tablenum(VendTable));
    queryBuildRange = queryBuildDataSource.addRange(fieldnum(VendTable, VendGroup));
    queryBuildRange.value(ParameterUmum::find().VendorGroupId);

    sysTableLookup.parmQuery(query);

    sysTableLookup.performFormLookup();
}

Fungsi newParameters pada objek sysTableLookup digunakan untuk menandakan kalo akan dilakukan lookup ke tabel VendTable. Sedangkan fungsi addLookupField digunakan untuk mengambil kolom yang diinginkan. Setelah dilakukan langkah menentukan tabel dan kolom yang mau dilookup maka selanjutnya gunakan kelas QueryBuildDataSource. Sesuai dari namanya maka kelas ini untuk menangani DataSource. Setelah itu kita buat range untuk memfilter data. Kemudian eksekusi fungsi performFormLookup untuk melakukan lookup berdasarkan langkah-langkah sebelumnya.

Terima Kasih.

Advertisements

2 Responses to Menampilkan data pada Ax dengan SysTableLookup

  1. Dian says:

    Salam,
    Saya dian, Boleh tanya bagaimana menampilkan data daripada purchline.purchprice seperti fecth di bawah ini.
    Saya ada 2 section group di Report, Section Grp Salestable saya call method

    display PurchPrice purchprice()
    {
    ;
    return purchline.PurchPrice;
    }

    Section Salesline saya call method

    display PurchPrice purchprice1()
    {
    ;
    return _purchline.PurchPrice;
    }

    public boolean fetch()
    {
    QueryBuildDataSource datasource, datasource2;
    QueryRun _queryRun, _queryRun1;
    boolean _bfirst = true;
    boolean _exist = false;
    SalesTable _salestable;

    ;
    datasource = this.query().dataSourceTable(tablenum(SalesTable));
    datasource.addRange(fieldnum(SalesTable,ShippingDateRequested)).value(queryRange(fromDate, toDate));
    datasource.addGroupByField(fieldnum(SalesTable,CustAccount));

    _queryRun = new QueryRun(this.query());

    while(_queryRun.next())
    {
    _salestable = _queryRun.get(tablenum(SalesTable));
    if(_salestable.isFarmer())
    {
    if(!_bfirst && _salestable.isDirectDelivered())
    {
    element.newPage();
    }
    custAccount = _salestable.CustAccount;

    _queryRun1 = this.buildQuery();
    while(_queryRun1.next())
    {
    salestable = _queryRun1.get(tablenum(SalesTable));
    purchtable = _queryRun1.get(tablenum(PurchTable));

    if(supplier != purchtable.OrderAccount)
    {
    if(_exist)
    {
    element.execute(1001);
    _subtotal = 0;
    }
    _bflag = true;
    _exist = true;
    }

    else
    {
    _bflag = false;
    }

    select _salesline order by ItemId where _salesline.SalesId == salestable.SalesId &&
    (_salesline.SalesStatus == SalesStatus::Delivered || _salesline.SalesStatus==SalesStatus::Invoiced || _salesline.SalesStatus==SalesStatus::None);

    this.send(salestable);

    _totalQty += _salesline.SalesQty;
    _subtotal += _salesline.SalesQty;

    while select salesline order by ItemId where salesline.InventTransId != _salesline.InventTransId &&
    salesline.SalesId == salestable.SalesId &&
    (salesline.SalesStatus == SalesStatus::Delivered || salesline.SalesStatus==SalesStatus::Invoiced || salesline.SalesStatus==SalesStatus::None)

    {
    //info(strfmt(“salesline.InventTransId= %1, salestable.SalesId= %2”, salesline.InventTransId, salestable.SalesId));
    _totalQty += salesline.SalesQty;
    _subtotal += salesline.SalesQty;

    this.send(salesline);
    }

    select purchline order by ItemId where purchtable.PurchId == salestable.interCompanyOriginalPurchTable().PurchId &&
    purchtable.PurchId == purchline.PurchId &&
    (purchline.PurchStatus == purchstatus::Received || purchline.PurchStatus==purchstatus::Invoiced || purchline.PurchStatus==purchstatus::None) &&
    purchline.InventRefId == _salesLine.SalesId &&
    purchline.InventRefTransId == _salesLine.InventTransId;

    this.send(purchline);
    //Info(strfmt(“purchline.Name= %1, purchline.PurchPrice= %2”, purchline.Name, purchline.PurchPrice));

    while select _purchline order by itemid where _purchline.InventTransId != purchline.InventTransId &&
    purchtable.PurchId == _purchline.PurchId &&
    (_purchline.PurchStatus == purchstatus::Received || _purchline.PurchStatus==purchstatus::Invoiced || _purchline.PurchStatus==purchstatus::None) &&
    _purchline.InventRefId == salesLine.SalesId &&
    _purchline.InventRefTransId == salesLine.InventTransId

    {
    this.send(_purchline);
    //Info(strfmt(“purchline.Name= %1, _purchline.PurchPrice= %2”, _purchline.Name, _purchline.PurchPrice));
    }

    supplier = purchtable.OrderAccount;
    }

    if(_exist)
    {
    element.execute(1001);
    element.execute(1002);
    _subtotal = 0;_totalQty = 0;
    _bfirst = false;_bflag = true;_exist = false;
    supplier = “”;
    }
    }

    }
    return true;
    }

    Terima kasih banyak banyak

  2. Pingback: Menampilkan data pada 2 datasource yang berbeda dengan kelas SysMultiTableLookUp « Vyor’s Weblog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: