Infor M3 #10 -- FieldSelection in MAK

Field Selection in MAK


We always take burden on creating views/indexes for DB instances to retrieve the data with a set of  desired inputs. Which would add one more custom object into our fixes list ๐Ÿ˜•

To avoid the modifications on DB instances/tables we have API's in Infor M3 Java i.e., Field Selections, by using this class we can easily retrieve data based on any keys/columns from the table irrespective of primary keys.

In this post we would be discussing about two main classes
  • FieldSelection
  • Expression

Field Selection 

Using this class system defines on which table and index data needs to be fetched.

Syntax:

FieldSelection fieldSelection_object = new FieldSelection(String mdb, String lf)

mdb refers to the table's name on which this selection has to be made
lf refers to the table's index on which this selection has to be made

fieldSelection_object just defines the table and index from which data needs to be fetched. Conditions are defined using another class i.e., Expression.

Expression

We can use expressions to create a where clause of an SQL query, we have different types of expressions in M3
  • EQ (Equals)
  • NE (NotEquals)
  • GT (GreaterThan)
  • GE (GreaterthanorEquals)
  • LT (LessThan)
  • LE (LessthanorEquals)
  • BT (Between)
  • IN (In)
  • LK (Like)
  • GEU (GreaterthanorEqualsUnique)
  • LEU (LessthanorEqualsUnique)
  • LKU (LikebutUnique)
  • GTU (GreaterthanUnique)
  • LTU (LessthanUnique)
  • NEU (NotEqualsUnique)
Each expression performs their own task as the name suggests. Let us see how to use them in program.

Syntax:

Expression.createEQ(String table, String field, String value)
Expression.createNE(String table, String field, String value)
Expression.createGT(String table, String field, String value)
Expression.createGE(String table, String field, String value)
Expression.createLT(String table, String field, String value)
Expression.createLE(String table, String field, String value)
Expression.createGEU(String table, String field, String value)
Expression.createLEU(String table, String field, String value)
Expression.createGTU(String table, String field, String value)
Expression.createLTU(String table, String field, String value)
Expression.createNEU(String table, String field, String value)

All of the above methods have same parameters, table is the name of the table on which you have created FieldSelection in the above section, field is the column name from the table which should include column's prefix and the value is the input to the column.

Expression.createBT(String table, String field, String fromValue, String toValue)

This expression is used for retrieving data between two values of a column.

Expression.createIN(String table, String field, String[] values)

This expression is used for retrieving data based on a column's data on multiple values.

Expression.createLK(String table, String field, String value)
Expression.createLKU(String table, String field, String value)

This expression is used to retrieve the data using a wild card entry, wild card entry is *. Whenever system finds * in the given value system treats it as wildcard and fetches the data matching the pattern just like LIKE ' ' in SQL.

We can use multiple expressions using AND, OR methods available in Expression class.

Let us take an example, let's fetch customer orders created between the date range and the customers who's number starts with CIND.

Create FieldSelection object on customer order master table. i.e., OOHEAD

FieldSelection OOHEAD_FS = new FieldSelection("OOHEAD", "00");

Create expressions based on the requirement, in our example we need to fetch data based on date range and a wild card entry.

Expression dataRangeExpression = Expression.createBT("OOHEAD","OARGDT","20190901","20190924");

Expression customerWildCardExpression = Expression.createLK("OOHEAD","OACUNO","CIND*");


OOHEAD_FS.setExpression(dataRangeExpression.AND(customerWildCardExpression));

OHEAD.SETLL("00", OHEAD.getKey("00",1));

while(OHEAD.READE("00", OHEAD.getKey("00",1),OOHEAD_FS ))

{

//here you get only records which are in the date range and customer starting with CIND

}




Note : This can't be used for prompting data in F4 functionality




That's it, come back here and tell us about the before-and-after. I bet you'll have something to say!

Please let me know your thoughts in the comment section below!

If you enjoyed this post, I'd be very grateful if you'd help it spread by emailing it to a friend, or sharing it on Twitter or LinkedIn.

In our next post let us see in about Virtual fields in Infor M3


Thanks for reading!

--Saiteja Saadi











Comments

  1. ๐Ÿ‘๐Ÿ‘great stuff Sai!!

    ReplyDelete
  2. Excellent Bro....

    ReplyDelete
  3. Nice Post,

    Marriage Registration in India, any ceremonial Hindu Marriage, Arya Samaj Mandir Marriage, Muslim Marriage, Christian Marriage in India would now have to be registered by people of all religions and by the Supreme Court in all states.

    Thank You

    ReplyDelete

Post a Comment