Wednesday, 8 August 2012

If a report attached to a form ,how can the report display the values of the selected one in form?

suppose i put my report on the  CustPackingSlipJour  form then i selected on e record,i want to display the information of that particular record only in my report then the following code helps    

public class ReportRun extends ObjectRun
{
    CustPackingSlipJour     externalCustPackingSlipJour;
}

public void init()
{
    element.initFromArgs(element.args());
    super();
}

void initFromArgs(Args args)
{
    if (args && args.dataset())
    {
        switch(args.dataset())
        {
               case tablenum(CustPackingSlipJour) :
                                        externalCustPackingSlipJour  =   args.record();        
        }
     } 
}

How to filter the data based on combo selection ?

DataDic-->Tables--->MedicineTable-->Fields

ItemId(string)
ItemExpired(enum)
ExpiryDate(date)

Medicine-->BaseEnums-->ItemExpired
ItemExpired :: Yes
                      No
                      All

MedicineInfoForm-->Methods-->classDeclaration

public class FormRun extends ObjectRun
{
    QueryBuildRange qbr;
}

 MedicineInfoForm -->DataSources--> MedicineTable -->Methods-->init()

public void init()
{
;
    super();
    qbr =    MedicineTable_ds.query().dataSourceTable(tablenum( MedicineTable )).addRange(fieldnum( MedicineTable ,ItemExpired));
    qbr.value(queryValue(ComboBox.selection()));
}

MedicineInfoForm-->Design--->Design-->Group : ItemExpired--->ComboBox:combobox-->Methods-->
modified()

public boolean modified()
{
    boolean ret;

    ret = super();

    if(combobox.selection()== ItemExpired::All)
    {
    qbr.value('');
    }
    else
    {
    qbr.value(queryValue(ComboBox.selection()));
    }

     MedicineTable_ds .executeQuery();

    return ret;
}

Explation on field fixed and related field fixed in table

Lets say you have ClothesTable and ClothesOrders.
ClothesTable has the following fields: ClotheId, Name and CollectionTypeId
MenClothesOrder has the following fields: OrderId, ClotheId, Qty  OrderId could be a number sequence and Qty entered manually bby the user.
CollectionTypeId has the following elements:
0 - Men
1 - Women
2 - Children
Example 1: Related Fixed Field
On MenClothesOrder we create a new relation to ClothesTable and specify the follwing two:
1. Normal = ClotheId to ClotheId (Best practice to specify this on the EDT) and
2. Related Fixed Field 0 = ClothesTable.CollecTionTypeId.
This shows that the lookup to the clothes table should show only clothes with the same ClotheId (point 1) AND clothes that are of type Men (point 2) because the our table deals with order for mens' clothes. We use 0 because Menis element 0 in the Enum.
Example 2: Fixed Field
This kinda works the other way round:
Imagine you have a ClothesOrders table (generic) and you have seperate tables for MenClothesTable, WomenClothesTable and ChildrenClothesTable. Fixed field says that the specified normal relation (on ClotheId) to MenClothesTable only works if the CollectionTypeId of the current record is set to 0 (Men) else the relation is disabled.

Learners blog

http://www.axaptapedia.com/Display_methodhttp://parimalajyothijp.blogspot.in/2012_01_01_archive.html
http://gotdax.blogspot.in/2009/12/batch-renaming-primary-key.html
http://dax-world.blogspot.com

















Tuesday, 7 August 2012

displaymethod to get employee countryregionid

display AddressCountryRegionId SARdisplayEmployeeCountryRegion()
{
    DirPartyAddressRelationship         partyAddressRelationship;
    DirPartyAddressRelationshipMapping  addressRelationshipMapping;
    Address                             address;
    AddressCountryRegionId              ret;
    ;
    select  addressRelationshipMapping
    join partyAddressRelationship
    where partyAddressRelationship.PartyId == this.PartyId && partyAddressRelationship.IsPrimary &&
    partyAddressRelationship.RecId == addressRelationshipMapping.PartyAddressRelationshipRecId
    join address
    where address.RecId        == addressRelationshipMapping.AddressRecId &&
    address.DataAreaId   == addressRelationshipMapping.RefCompanyId;

    if(address)
    ret = address.CountryRegionId;
    else
    ret = '';
    return ret ;
}

A Fetch Method Override for A Date Range Data Retrival from Cust TRans Table as on ...

// #. A Fetch Method Override for A Date Range Data Retrival from Cust TRans Table as on ...
public boolean fetch()
{
    // 0. Declare Variables
    QueryRun qr;
    QueryBuildDatasource QueryBuildDatasource1;
    QueryBuildRange rangeTransDate;
    Boolean ret;
    CustTable custTable;
    CustTrans custTrans;

    // 1. A QueryRun object called qr is initialized with the active query of the report,
    qr = new QueryRun(element);

    // 2. Get DAtaSource from current element query
    QueryBuildDatasource1 = element.query().dataSourceTable(tablenum(CustTrans));

    // 3. A range for the customer transaction date field is added to Datasource
    rangeTransDate = QueryBuildDatasource1.addRange(fieldnum(CustTrans, transDate));

    // 4. Actusl Date Range Value is added to qr
    rangeTransDate.value(queryRange(systemdateGet() - daysBack, systemDateGet()));

    // 5. The range is locked, so the user cannot change it.
    rangeTransDate.status(RangeStatus::LOCKED);

    // 6. The transaction date range is added to the caption of the report.
    element.design().caption(strfmt("%1, %2", element.design().caption(), rangeTransDate.value()));

    // 7. At this point, the query is looped. The standard loop of the query and the printout of the
    // record is what the super() call in fetch() handles. Before the query is looped, there is a
    // check to see whether the dialogs for the query and the report are called.These are the two dialogs which are wrapped by RunBaseReportStd
    if (qr.prompt() && element.prompt())
    {
        // 8. query is looped
        while (qr.next())
        {
            // 9. Within each loop, the tables CustTable and CustTrans are initialized.
            // If no records are found, the loop breaks and the report ends.
            // If a data source has changed, a new record is found
            // and the record is printed using the send() method.
            custTable = qr.get(tableNum(CustTable));
            custTrans = qr.get(tableNum(CustTrans));

            if (!custTable)
            {
                ret = false;
                break;
            }
            // 10. Note the second parameter in the send() method.
            // The second parameter defines the level of the record. CustTable is on the first level of the query and
            // CustTrans is on the second level. This is important since, if it is not set correctly,
            // auto sums will not be printed.
            if (qr.changed(tableNum(custTable)))
            {
                 element.send(custTable, 1);
            }
            if (qr.changed(tableNum(custTrans)))
            {
                 element.send(custTrans, 2);
            }
        }
    ret = true;
    }
    else
        ret = false;
    return ret;
}
// 11.     ------Tactics of reports---
// In the fetch example, the query of the report was looped. The case could also be looping
// a WHILE statement, SELECT statement, or a combination of both. For each record
// looped in the query, you might want to select a record from a table which is not part of
// the query, or even build a temporary table to be printed. For each record to be printed,
// all you have to do is call the send() method
thnks

Monday, 6 August 2012