Count Imported Records - Dataport

SavatageSavatage Member Posts: 7,142
edited 2005-11-30 in Navision Attain
Ok the topic was closed so I had to create a new one.

delete txt file after import
RE: viewtopic.php?t=4449

Answers:
Put the following Code in the OnPost Dataport Trigger
CurrFile.CLOSE;
IF Confirm(Text000, true) then
ERASE(CurrDataport.FILENAME);
Where Text000 = 'Would you like to delete the file?'


OR

CurrFile.CLOSE;
IF Confirm(Text000, true) then
WHILE EXISTS(CurrDataport.FILENAME)
DO ERASE(CurrDataport.FILENAME);


What I would like to do Now is for the Message after the import to say

XXX Orders Imported
Would you like to delete the file?


XXX being the number of records imported

So basically the only change would to get a count on the records?
I'm thinking the count should go on the
OnAfterImportRecord() of the Sales Header Dataitem. Help. Thanks.

Answers

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Wow, the topic was closed :shock:

    Guess we should not have highjacked it :mrgreen:

    I think best thing to do indeed is to keep somekind of counter in the OnAfterImport trigger

    RecCounter := RecCounter + 1;

    Another thing you can do is if all imported records have a similar ID or fieldvalue you can filter on this and do a COUNT on the table.
  • SavatageSavatage Member Posts: 7,142
    This thing I know is simple but I just can't get it. Even if the # of records imported poped-up in it's own box ie/ Orders Imported: XX with an OK button then the "Would you like to delete the file" POP-Up next then that would be fine

    ](*,)
    OBJECT Dataport 50011 Internet Sales Order w Address
    {
      OBJECT-PROPERTIES
      {
        Date=11/30/05;
        Time=[ 2:52:00 PM];
        Modified=Yes;
        Version List=HRBiLO,Need;
      }
      PROPERTIES
      {
        TransactionType=Update;
        FileFormat=Variable;
        FieldStartDelimiter=";
        FieldEndDelimiter=";
        FieldSeparator=~;
        OnPostDataport=BEGIN
                         CurrFile.CLOSE;
                         IF CONFIRM(Text0001,TRUE) THEN
                         ERASE(CurrDataport.FILENAME);
                       END;
    
      }
      DATAITEMS
      {
        { PROPERTIES
          {
            DataItemTable=Table36;
            ReqFilterFields=Document Type,No.;
            OnAfterImportRecord=BEGIN
                                  "Sales Header".VALIDATE("Sell-to Customer No.");
                                  // Internet Begin
                                      "Internet Order" := TRUE;
                                  // Internet End
    
                                  "Sales Header"."Document Date" := "Order Date";
                                  "Sales Header"."Posting Date" := "Order Date";
                                  "Sales Header"."Shipment Date" := WORKDATE;
                                  "Sales Header"."Ship-to Name" := Internet_Cust_Name;
                                  "Sales Header"."Ship-to Address" := Internet_Cust_Address1;
                                  "Sales Header"."Ship-to Address 2" := Internet_Cust_Address2;
                                  "Sales Header"."Ship-to City" := Internet_Cust_City;
                                  "Sales Header"."Ship-to State" := Internet_Cust_State;
                                  "Sales Header"."Ship-to ZIP Code" := Internet_Cust_Zip;
                                  "Sales Header"."Residential Delivery" := Internet_Cust_Residential;
                                  "Sales Header"."Internet Order" := TRUE;
                                  "Sales Header"."Posting No." := "No.";
                                  "Sales Header"."Shipping No." := "No.";
                                END;
    
          }
          FIELDS
          {
            {      ;     ;"Document Type"      }
            {      ;     ;"No."                }
            {      ;     ;"Sell-to Customer No." }
            {      ;     ;"Customer PO Number" }
            {      ;     ;"Order Date"         }
            {      ;     ;"Shipping Agent Code" }
            {      ;     ;"E-Ship Agent Service" }
            {      ;     ;Internet_Cust_Residential }
            {      ;     ;Internet_Cust_Name   }
            {      ;     ;Internet_Cust_Address1 }
            {      ;     ;Internet_Cust_Address2 }
            {      ;     ;Internet_Cust_City   }
            {      ;     ;Internet_Cust_State  }
            {      ;     ;Internet_Cust_Zip    }
          }
           }
        { PROPERTIES
          {
            DataItemTable=Table37;
            OnAfterImportRecord=BEGIN
                                  "Sales Line".VALIDATE("No.");
                                  "Sales Line"."Qty. Ordered" := Internet_Cust_Qty;
                                  "Sales Line".Quantity := Internet_Cust_Qty;
                                  "Sales Line".VALIDATE("Qty. Ordered");
                                  "Sales Line"."EDI Unit Price" := Internet_Price;
                                END;
    
          }
          FIELDS
          {
            {      ;     ;"Document Type"      }
            {      ;     ;"Document No."       }
            {      ;     ;Type                 }
            {      ;     ;"Line No."           }
            {      ;     ;"No."               ;OnAfterFormatField=BEGIN
                                                                    VALIDATE("No.");
                                                                  END;
                                                                   }
            {      ;     ;Internet_Cust_Qty    }
            {      ;     ;Internet_Price       }
          }
           }
      }
      REQUESTFORM
      {
        PROPERTIES
        {
          Width=9020;
          Height=3410;
        }
        CONTROLS
        {
        }
      }
      CODE
      {
        VAR
          SalesHeader@1000000007 : Record 36;
          Internet_Cust_Name@1000000000 : Text[30];
          Internet_Cust_Address1@1000000001 : Text[30];
          Internet_Cust_Address2@1000000002 : Text[30];
          Internet_Cust_City@1000000003 : Text[30];
          Internet_Cust_State@1000000004 : Text[30];
          Internet_Cust_Zip@1000000005 : Code[20];
          SalesLine@1000000006 : Record 37;
          Internet_Cust_Qty@1000000008 : Decimal;
          Internet_Cust_Residential@1000000009 : Boolean;
          Internet_Price@1000000010 : Decimal;
          Text0001@1102606000 : TextConst 'ENU=Would You Like To Delete The File?';
          OrderCount@1000000011 : Integer;
    
        BEGIN
        END.
      }
    }
    
    
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    edited 2005-11-30
    OBJECT Dataport 50011 Internet Sales Order w Address 
    { 
      OBJECT-PROPERTIES 
      { 
        Date=11/30/05; 
        Time=[ 2:52:00 PM]; 
        Modified=Yes; 
        Version List=HRBiLO,Need; 
      } 
      PROPERTIES 
      { 
        TransactionType=Update; 
        FileFormat=Variable; 
        FieldStartDelimiter="; 
        FieldEndDelimiter="; 
        FieldSeparator=~; 
        OnPostDataport=BEGIN 
                         CurrFile.CLOSE; 
                         IF CONFIRM(Text0001,TRUE,OrderCount) THEN 
                         ERASE(CurrDataport.FILENAME); 
                       END; 
    
      } 
      DATAITEMS 
      { 
        { PROPERTIES 
          { 
            DataItemTable=Table36; 
            ReqFilterFields=Document Type,No.; 
            OnAfterImportRecord=BEGIN 
                                  "Sales Header".VALIDATE("Sell-to Customer No."); 
                                  // Internet Begin 
                                      "Internet Order" := TRUE; 
                                  // Internet End 
    
                                  "Sales Header"."Document Date" := "Order Date"; 
                                  "Sales Header"."Posting Date" := "Order Date"; 
                                  "Sales Header"."Shipment Date" := WORKDATE; 
                                  "Sales Header"."Ship-to Name" := Internet_Cust_Name; 
                                  "Sales Header"."Ship-to Address" := Internet_Cust_Address1; 
                                  "Sales Header"."Ship-to Address 2" := Internet_Cust_Address2; 
                                  "Sales Header"."Ship-to City" := Internet_Cust_City; 
                                  "Sales Header"."Ship-to State" := Internet_Cust_State; 
                                  "Sales Header"."Ship-to ZIP Code" := Internet_Cust_Zip; 
                                  "Sales Header"."Residential Delivery" := Internet_Cust_Residential; 
                                  "Sales Header"."Internet Order" := TRUE; 
                                  "Sales Header"."Posting No." := "No."; 
                                  "Sales Header"."Shipping No." := "No."; 
    
                                  OrderCount := OrderCount + 1;
    
                                END; 
    
          } 
          FIELDS 
          { 
            {      ;     ;"Document Type"      } 
            {      ;     ;"No."                } 
            {      ;     ;"Sell-to Customer No." } 
            {      ;     ;"Customer PO Number" } 
            {      ;     ;"Order Date"         } 
            {      ;     ;"Shipping Agent Code" } 
            {      ;     ;"E-Ship Agent Service" } 
            {      ;     ;Internet_Cust_Residential } 
            {      ;     ;Internet_Cust_Name   } 
            {      ;     ;Internet_Cust_Address1 } 
            {      ;     ;Internet_Cust_Address2 } 
            {      ;     ;Internet_Cust_City   } 
            {      ;     ;Internet_Cust_State  } 
            {      ;     ;Internet_Cust_Zip    } 
          } 
           } 
        { PROPERTIES 
          { 
            DataItemTable=Table37; 
            OnAfterImportRecord=BEGIN 
                                  "Sales Line".VALIDATE("No."); 
                                  "Sales Line"."Qty. Ordered" := Internet_Cust_Qty; 
                                  "Sales Line".Quantity := Internet_Cust_Qty; 
                                  "Sales Line".VALIDATE("Qty. Ordered"); 
                                  "Sales Line"."EDI Unit Price" := Internet_Price; 
                                END; 
    
          } 
          FIELDS 
          { 
            {      ;     ;"Document Type"      } 
            {      ;     ;"Document No."       } 
            {      ;     ;Type                 } 
            {      ;     ;"Line No."           } 
            {      ;     ;"No."               ;OnAfterFormatField=BEGIN 
                                                                    VALIDATE("No."); 
                                                                  END; 
                                                                   } 
            {      ;     ;Internet_Cust_Qty    } 
            {      ;     ;Internet_Price       } 
          } 
           } 
      } 
      REQUESTFORM 
      { 
        PROPERTIES 
        { 
          Width=9020; 
          Height=3410; 
        } 
        CONTROLS 
        { 
        } 
      } 
      CODE 
      { 
        VAR 
          SalesHeader@1000000007 : Record 36; 
          Internet_Cust_Name@1000000000 : Text[30]; 
          Internet_Cust_Address1@1000000001 : Text[30]; 
          Internet_Cust_Address2@1000000002 : Text[30]; 
          Internet_Cust_City@1000000003 : Text[30]; 
          Internet_Cust_State@1000000004 : Text[30]; 
          Internet_Cust_Zip@1000000005 : Code[20]; 
          SalesLine@1000000006 : Record 37; 
          Internet_Cust_Qty@1000000008 : Decimal; 
          Internet_Cust_Residential@1000000009 : Boolean; 
          Internet_Price@1000000010 : Decimal; 
          Text0001@1102606000 : TextConst 'ENU=Would You Like To Delete The File?'; 
          OrderCount@1000000011 : Integer; 
    
        BEGIN 
        END. 
      } 
    }
    

    Making a Internet Interface Harry :mrgreen:

    I've made 2 changes in your object

    And I think you should Initialise the ordercount to 0 in the predataport trigger.

    Change your textconstant to

    %1 Orders are imported\Would You Like To Delete The File?

    Maybe this helps
  • SavatageSavatage Member Posts: 7,142
    I'll give it a go.. i tried all this but I didn't Put OrderCount After TRUE. I think that's where I messed up
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    I hope it works! I did not tested it [-o<

    :mrgreen:
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Savatage wrote:
    Ok the topic was closed so I had to create a new one.

    delete txt file after import
    RE: http://www.mibuso.com/forum/viewtopic.php?t=4449

    [...]

    I don't see a "Locked" icon next to that thread, so why do you think it's closed?
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • SavatageSavatage Member Posts: 7,142
    Savatage wrote:
    Ok the topic was closed so I had to create a new one.

    delete txt file after import
    RE: http://www.mibuso.com/forum/viewtopic.php?t=4449

    [...]

    I don't see a "Locked" icon next to that thread, so why do you think it's closed?

    I tried a few times to add to the post and it just kept kicking me out of it. So I assumed that adding anymore replies to the post was closed especially since it was SOLVED.
  • SavatageSavatage Member Posts: 7,142
    I hope it works! I did not tested it [-o<

    :mrgreen:

    Perfection! \:D/
Sign In or Register to comment.