Click here to Skip to main content
15,899,313 members
Articles / Programming Languages / C#

Browse Control for ISO SDK App – Part 1

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
29 Dec 2016CPOL2 min read 4.1K   1  
Browse Control for ISO SDK App – Part 1

Background

In a conventional M3 Program, data in some fields can be searched by pressing the F4 key or Browse function.

image

Using MAK (M3 Adaptation Kit – the framework to develop M3 programs), it is just a matter of overriding PxPMT() to enable this Browse feature. However, in SDK development, we don’t have that option. Neither a function to override nor control to re-use.

Instead, using WPF & C#, we have to create it from scratch. I did this for my current SDK project and I am going to share it with the SDK development community.

There is an article in Potato IT blog (https://potatoit.kiwi/2013/09/19/smart-office-sdk-first-project-part-6-the-browse-control/). This was a good starting point for me. However, since I have MAK background, I wanted to implement it in a similar way that PxPMT() method does (below is an excerpt of M3 Browse).

C#
if (IN62) {
   if (DSP.hasFocus("W1TOOL")) {
      this.PXFILE.moveLeft("CSYTAB00");
      this.PXMBR.clear();
      this.PXOPT = '1';
      this.PXKVA1.moveLeft(LDAZD.CONO, 3);
      this.PXKTY1.move("EQ");
      this.PXKTY2.move("EQ");
      this.PXKVA3.moveLeft("TOOT");
      this.PXKTY3.move("EQ");
      this.PXKVA4.moveLeft(DSP.W2TOOT);
      this.PXFLD1.moveLeftPad("CTSTKY");
      this.PXFLD2.moveLeftPad("CTTX15");
      this.PXF11 = '1';
      COMF04();
....

That is, the client (developer) should not worry about the data binding, extraction logic, etc. Instead, only specify Logical file, it’s keys with values, columns to be displayed, etc.

In a similar way, my SDK app should be called without any data extraction logic, etc. (like the below code).

C#
if (e.Key == Key.F4)
{
    IInstanceHost child = theHost.CreateDialog();

    BrowseControl bc = new BrowseControl(child);
    bc.Field = "BANO";
    bc.AlternativeField = "";
    bc.BrowseVariant = "";
    bc.KeyFields = new String[] { "LMCONO","LMITNO","LMBANO" };
    bc.KeyValues = new String[] { "0", "" };
    bc.SearchText = txtUser.Text;
    //child.HostContent = bc;
    if (bc.ShowDialog().Value)
    {
        txtUser.Text = bc.SearchText;
    }
}

Solution

image

In my solution, I’ve used CRS990MI program and its transactions to encapsulate data extraction from the developer. This MI Program will work based on defined browse definitions in MNS185 program.

The Transactions InitBrowse & LstBrowse are actually doing the work. You will understand this when we talk about the C#/WPF code. But for now, for your quick information, I summarized it as below.

  1. InitBrowse – Returns the browse definition of the search field with the columns headings. As in the above code, if you are going to search BANO (lot number), first we want to know what are the keys, key positions in order to get the BANO value. That is CONO (company) & ITNO (Item Number). Likewise, InitBrowse API provides us these metadata.
  2. LstBrowse – Gets data for the given search field (BANO) along with meta information from InitBrowse API.

In the next post (Part 2), I’m going to explain the C#/WPF code.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Brandix Lanka Pvt Ltd.
Sri Lanka Sri Lanka
I’ve started my career in 2001 with Microsoft .net ver 1.0. I’m a MCSD for .net.

Currently, I’m working for Sri Lanka’s largest apparel exporter as a Software Engineer. All projects in .net, MS Sql Server, Biztalk Server, WCF and WPF. And also, I’m developing components to the ERP. In addition to that, I’ve involved to create architecture of ERP integration.

Comments and Discussions

 
-- There are no messages in this forum --