SmartBusinessEntityAdapter Issue
 
Forums / SmartComponent Library - Developer Forum / SmartBusinessEntityAdapter Issue

SmartBusinessEntityAdapter Issue

10 posts, 0 answered
  1. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    04 Feb 2019
    Link to this post
    I have a pretty simple maintenance form. It has a toolbar, smartbusinessentityadapter and a smartviewer.

    The smartviewer is setup with a barcode scanner for quick retrieval of a record from the server. I am using the method below to retrieve the one record from the backend. This code works just fine as I can scan (or key enter) and retrieve the item just fine. However, as soon as I update a record or create a new record the RetrieveData no longer works. The property THIS-OBJECT:PoLineAdapter:Available = false even though in the BE:ReceiveData I can see the values of the TT just fine. 

    Do I need to RESET something on the frontend?

    Any help would be appreciated...


    METHOD PRIVATE VOID FetchPoLine(  ):
      
      DEFINE VARIABLE cWhereString AS CHARACTER       NO-UNDO. 
      DEFINE VARIABLE oRequest   AS Consultingwerk.OERA.FetchDataRequest NO-UNDO.
      DEFINE VARIABLE lOkay   AS LOGICAL         NO-UNDO.
      
      cWhereString = "WHERE ePoLine.OrderNum = " + STRING (THIS-OBJECT:OrderNum) + " AND ePoLine.SeqNum = " + STRING (THIS-OBJECT:SeqNum) + " AND ePoLine.ItemNum = " + QUOTER (cCurrentItemNum) + " AND ePoLine.PackNum = " + STRING (iCurrentPackNum).
      
    // Tried adding this to solve the issue with retrieving after updating a record
      THIS-OBJECT:PoLineAdapter:ClearPreviousQueryString(TRUE).
      
      THIS-OBJECT:PoLineAdapter:EmptyDatasetOnRetrieveData = TRUE.
      THIS-OBJECT:PoLineAdapter:BatchSize = 1.  // only want one record
      THIS-OBJECT:PoLineAdapter:QueryString = "FOR EACH ePoLine " + cWhereString. 
      THIS-OBJECT:PoLineAdapter:RetrieveData().
      
      IF NOT THIS-OBJECT:PoLineAdapter:Available THEN
      DO:
       THIS-OBJECT:AddRecord().
      END.
      
      ELSE
      DO:
       THIS-OBJECT:EnableFields(EnableFieldsEnum:Update).
        END.
      
      RETURN.
     END METHOD.
  2. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    06 Feb 2019 in reply to Roger Blanchard
    Link to this post
    Just that I understand this ... the FetchPoLine method is called whenever a bar code is scanned? And THIS-OBJECT:OrderNum, THIS-OBJECT:SeqNum, cCurrentItemNum and iCurrnetPackNum are values resulting from scanning the bar code? 

    I doubt that this is relevant for this case - but I would try to avoid using global variables for that purpose. I'd pass actual parameters to the method. But that's another story.

    There is nothing required to reset the SmartBusinessEntityAdapter. So you're sure that on the second run, you're producing a valid query string? Did you verify the value of

      THIS-OBJECT:PoLineAdapter:QueryString 

    After calling the 

     THIS-OBJECT:PoLineAdapter:RetrieveData().

    can you try to

    MESSAGE
        BufferHelper:NumRecords (THIS-OBJECT:PoLineAdapter:QueryHandle:GET-BUFFER-HANDLE (1)) SKIP 
        THIS-OBJECT:PoLineAdapter:BindingSource:Count
    VIEW AS ALERT-BOX

  3. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    06 Feb 2019 in reply to Mike Fechner
    Link to this post
    "the FetchPoLine method is called whenever a bar code is scanned"

    The sequence is;
    1. We need to validate the barcode that was just scanned. We do this by using InvokeMethod on our ItemBusinessEntity and pass the scanned barcode. The GetItem method on the BE will return back our unique ItemNum. 

    oItemParameter = NEW Osprey.Pos.Item.ItemParameter ().
         
    oItemParameter:UpcNum  = cUpcNum. // this is the barcode that was scanned 
    oItemParameter:PackNum = iPackNum.
        
    FrameworkSettings:ServiceAdapter:InvokeMethod ("Default",
                                                                               "Osprey.Pos.Item.ItemBusinessEntity",
                                                                               "GetItem",
                                                                               INPUT-OUTPUT DATASET-HANDLE hDSet,
                                                                                oItemParameter).

    2. If we get a valid ItemNum returned we then use the RetrieveData of the Adapter.

    cWhereString = "WHERE eBatchItem.BatchId = " + STRING (THIS-OBJECT:BatchId) + " AND eBatchItem.ItemNum = " + QUOTER (cCurrentItemNum) + " AND eBatchItem.PackNum = " + STRING (iCurrentPackNum).
      
      THIS-OBJECT:BatchItemAdapter:EmptyDatasetOnRetrieveData = TRUE.
      THIS-OBJECT:BatchItemAdapter:BatchSize = 1.  // only want one record
      THIS-OBJECT:BatchItemAdapter:QueryString = "FOR EACH eBatchItem " + cWhereString. 
      THIS-OBJECT:BatchItemAdapter:RetrieveData().

    I did check the QueryString and it looked correct. As I said if I add logic to RetrieveData in the BE to display the TT record it is correct.

    I will try the following;

    MESSAGE
        BufferHelper:NumRecords (THIS-OBJECT:PoLineAdapter:QueryHandle:GET-BUFFER-HANDLE (1)) SKIP 
        THIS-OBJECT:PoLineAdapter:BindingSource:Count
    VIEW AS ALERT-BOX
  4. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    06 Feb 2019 in reply to Mike Fechner
    Link to this post
    The results were;

    BufferHelper:NumRecords (THIS-OBJECT:PoLineAdapter:QueryHandle:GET-BUFFER-HANDLE (1)) = 1
    THIS-OBJECT:PoLineAdapter:BindingSource:Count = 0
  5. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    06 Feb 2019 in reply to Roger Blanchard
    Link to this post
    I tried adding 

    THIS-OBJECT:PoLineAdapter:BindingSource:RefreshAll().

    made no difference.
  6. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    06 Feb 2019 in reply to Roger Blanchard
    Link to this post
    Then you should invoke the ....:QueryHandle:QUERY-OPEN() method.

    But I don't see why that should be required. Is there an error thrown somewhere? Maybe in the default-window of the ABL session? Or anything in the AppServer log?
  7. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    06 Feb 2019 in reply to Mike Fechner
    Link to this post
    I will check again but I did not see any errors.

    Let me try what you suggest to see if it solves the issues and then will look at logs.
  8. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    07 Feb 2019 in reply to Mike Fechner
    Link to this post
    Adding the QUERY-OPEN on the Adapter:QueryHandle did not help.

    No errors on Appserver logs just a warning. It looks like it found the record just fine.

    I also looked at client logs and no errors. 

    [19/02/06@19:06:04.639-0500] P-004560 T-014020 1 AS-4 APPL           --------------------------------------------------------------------------------------------------------
    [19/02/06@19:06:04.639-0500] P-004560 T-014020 1 AS-4 APPL           ########################################################################################################
    [19/02/06@19:06:07.565-0500] P-004560 T-014020 1 AS-4 DataAccess     Client-Query: FOR EACH eBatchItem WHERE eBatchItem.BatchId = 62002 AND eBatchItem.ItemNum = "          60" AND eBatchItem.PackNum = 1 AND  eBatchItem.BatchId = "62002"
    [19/02/06@19:06:07.565-0500] P-004560 T-014020 1 AS-4 DataAccess     Default-Query: FOR EACH BatchItem, FIRST Mix OF BatchItem OUTER-JOIN, FIRST LikeItem OF BatchItem OUTER-JOIN, FIRST Item OF BatchItem OUTER-JOIN INDEXED-REPOSITION
    [19/02/06@19:06:07.569-0500] P-004560 T-014020 1 AS-4 -- (Procedure: 'BufferWhereClause Consultingwerk.Util.QueryHelper' Line:577) WARNING: -mmax exceeded. Automatically increasing from 4089 to 4136. (5409)
    [19/02/06@19:06:07.572-0500] P-004560 T-014020 1 AS-4 DataAccess     Prepare-Query: FOR EACH BatchItem WHERE BatchItem.BatchId = 62002 AND BatchItem.ItemNum = "          60" AND BatchItem.PackNum = 1 AND BatchItem.BatchId = "62002", FIRST Mix OF BatchItem OUTER-JOIN, FIRST LikeItem OF BatchItem OUTER-JOIN, FIRST Item OF BatchItem OUTER-JOIN INDEXED-REPOSITION
    [19/02/06@19:06:07.572-0500] P-004560 T-014020 1 AS-4 DataAccess     Index Information on Buffer BatchItem: upBatchItem
    [19/02/06@19:06:07.572-0500] P-004560 T-014020 1 AS-4 DataAccess     Index Information on Buffer Mix: upMixCode
    [19/02/06@19:06:07.572-0500] P-004560 T-014020 1 AS-4 DataAccess     Index Information on Buffer LikeItem: upLikeCode
    [19/02/06@19:06:07.572-0500] P-004560 T-014020 1 AS-4 DataAccess     Index Information on Buffer Item: upItem
    [19/02/06@19:06:07.572-0500] P-004560 T-014020 1 AS-4 DataAccess     Restart-Rowid for Table eBatchItem: ?
    [19/02/06@19:06:07.573-0500] P-004560 T-014020 1 AS-4 DataAccess     Next-Rowid for Table eBatchItem: ?
    [19/02/06@19:06:07.573-0500] P-004560 T-014020 1 AS-4 DataAccess     Last-Batch for Table eBatchItem: yes
    [19/02/06@19:06:07.594-0500] P-004560 T-014020 1 AS-4 APPL           ########################################################################################################
    [19/02/06@19:06:07.594-0500] P-004560 T-014020 1 AS-4 APPL           Table Name                                  Record Reads         Updates         Creates         Deletes
    [19/02/06@19:06:07.594-0500] P-004560 T-014020 1 AS-4 APPL           --------------------------------------------------------------------------------------------------------
    [19/02/06@19:06:07.594-0500] P-004560 T-014020 1 AS-4 APPL           pos.BatchItem                                          1               0               0               0
    [19/02/06@19:06:07.594-0500] P-004560 T-014020 1 AS-4 APPL           --------------------------------------------------------------------------------------------------------
    [19/02/06@19:06:07.594-0500] P-004560 T-014020 1 AS-4 APPL           Index Name                                   Index Reads                         Creates         Deletes
    [19/02/06@19:06:07.594-0500] P-004560 T-014020 1 AS-4 APPL           --------------------------------------------------------------------------------------------------------
    [19/02/06@19:06:07.594-0500] P-004560 T-014020 1 AS-4 APPL           pos._Field._File/Field                                11                               0               0
  9. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    07 Feb 2019 in reply to Roger Blanchard
    Link to this post
    I forgot to mention I have this issue on all my forms that are setup this way.

  10. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    07 Feb 2019 in reply to Roger Blanchard
    Link to this post
    We'll continue to investigate this in the support desk ticket created for the case.

    We may have to create a repro for this.
10 posts, 0 answered