Dataport does not fill form, but fills table????

nvermanverma Member Posts: 396
I created a dataport to bring in some data from a csv file. The dataport seems to work( it goes to 100%), it bring in all the data i want. I can see the data I brought in the FA Journal Line Table. But its not showing up in the FA Journal Line form. Any ideas why it might be doing that?

I thought the form is used to show the data that is presented in the table. I have no idea why its not coming in the form.

Answers

  • SavatageSavatage Member Posts: 7,142
    edited 2012-04-25
    Did you view the keys of table FA Journal Line (5621)?

    Did you fill Journal Template Name & Journal Batch Name or did you think those were unnecessary?

    Again.....
    You can enter a line in the journal & export it using your dataport to see how the data should look.
    & import 1 line & manually enter 1 line and compare them. If you dataport fills in all the fields that the manual entry does then your on the right track. It they don't match then your dataport is not ready to use!
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Verify if the fields "Journal Template Name" and "Journal Batch Name" in table "FA Journal Line" have the same values as your FA Journal form filters.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • nvermanverma Member Posts: 396
    This is the code I wrote for the Dataport and It should answer all your questions.
    [b]FA Journal Line- OnPreDateItem()[/b]
    IF CurrDataport.IMPORT THEN BEGIN
      REPEAT
        CurrFile.READ(cha);
      UNTIL cha = 10; // of course in case the RecordSeparator is "<<NewLine>>"
    END; 
    
    FAJournalLine.SETRANGE("Journal Template Name", FAJournalBatch."Journal Template Name");
    FAJournalLine.SETRANGE("Journal Batch Name", FAJournalBatch.Name);
    //FAJournalLine.SETFILTER("Journal Template Name", 'ASSETS');
    //FAJournalLine.SETFILTER("Journal Batch Name", 'DEFAULT');
    
    // If the payment journal currently contains lines, then get the last line no., and start inserting
    // payment journal lines from that point forward.
    IF FAJournalLine.FIND('+') = TRUE THEN
      LastLineNo := FAJournalLine."Line No."
    
    // Otherwise, start the line no. at zero
    ELSE
      LastLineNo := 0;
    
    [b]FA Journal Line - OnBeforeImportRecord()[/b]// OMODNV01 - ADD Start
    // Clear variables so that values are not replicating across multiple import lines
    CLEAR(FAPostingDate);
    CLEAR(DocumentNo);
    CLEAR(FANo);
    CLEAR(DepreciationBookCode);
    CLEAR(FAPostingType);
    CLEAR(Description);
    CLEAR(Amount);
    CLEAR(CostCenterCode);
    CLEAR(FundNo);
    CLEAR(ControlFundNo);
    // OMODNV01 - ADD End
    
    [b]FA Journal Line - OnAfterImportRecord()[/b]// OMODNV01 - ADD Start
    // Initialize the template and batch names
    FAJournalLine.INIT;
    
    FAJournalLine.SETRANGE("Journal Template Name", FAJournalBatch."Journal Template Name");
    FAJournalLine.SETRANGE("Journal Batch Name", FAJournalBatch.Name);
    
    //FAJournalLine.SETFILTER("Journal Template Name", 'ASSETS');
    //FAJournalLine.SETFILTER("Journal Batch Name", 'DEFAULT');
    
    LastLineNo += 10000;
    FAJournalLine."Line No." := LastLineNo;
    
    FAJournalLine."FA Posting Date" := FAPostingDate;
    FAJournalLine."Document No." := DocumentNo;
    FAJournalLine."FA No." := FANo;
    FAJournalLine."Depreciation Book Code" := DepreciationBookCode;
    
    CASE FAPostingType OF
      'Acquisition Cost':
        FAJournalLine."FA Posting Type" := FAJournalLine."FA Posting Type"::"Acquisition Cost";
      'Depreciation':
        FAJournalLine."FA Posting Type" := FAJournalLine."FA Posting Type"::Depreciation;
      'Write-Down':
        FAJournalLine."FA Posting Type" := FAJournalLine."FA Posting Type"::"Write-Down";
      'Appreciation':
        FAJournalLine."FA Posting Type" := FAJournalLine."FA Posting Type"::Appreciation;
      'Custom 1':
        FAJournalLine."FA Posting Type" := FAJournalLine."FA Posting Type"::"Custom 1";
      'Custom 2':
        FAJournalLine."FA Posting Type" := FAJournalLine."FA Posting Type"::"Custom 2";
      'Disposal':
        FAJournalLine."FA Posting Type" := FAJournalLine."FA Posting Type"::Disposal;
      'Maintenance':
        FAJournalLine."FA Posting Type" := FAJournalLine."FA Posting Type"::Maintenance;
    ELSE
        FAJournalLine."FA Posting Type" := FAJournalLine."FA Posting Type"::"Salvage Value";
        
    END;
    
    FAJournalLine.Description := Description;
    FAJournalLine.Amount := Amount;
    
    // Get the cost center and fund data from the dataport line
    FAJournalLine.VALIDATE("Cost Center Code", CostCenterCode);
    FAJournalLine."Control Fund No." := 'OPER';
    FAJournalLine.INSERT;
    
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    See my previous posting. I have nothing to add.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • nvermanverma Member Posts: 396
    I am looking at the data it imported to FA Journal Table and I noticed that the Journal Template Name and Journal Batch name are left blank.

    I think that might be reason its not showing up in the FA Journal Line form.

    Any Idea why it might be doing that.

    Originally I had this:
    FAJournalLine.SETFILTER("Journal Template Name", 'ASSETS');

    Shoudlnt it set the Journal Template Name to ASSETS automatically? This might seem like a stupid question
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    SETFILTER or SETRANGE are used to filter your records, not to assign fieldvalues. You should assign the proper values to all key fields yourself.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • nvermanverma Member Posts: 396
    hmmm...that is so strange....I manually assigned the Journal Template Name and Journal Batch Name and it worked.

    FAJournalLine."Journal Template Name" := 'ASSETS';
    FAJournalLine."Journal Batch Name" := 'DEFAULT';

    hmmm....OK. I guess that makes sense...Thanks.. I learned something new today.
  • vijay_gvijay_g Member Posts: 884
    edited 2012-05-03
    If you would have used insert(true),you could have found that the template and batch are inserting or not.
    anyway now it has been solved.

    Congrats Harry for reaching his fantastic figure(6666). =D>
  • DenSterDenSter Member Posts: 8,307
    vijay_g wrote:
    If you would have used insert(true),you could have found that the template and batch are inserting or not.
    I don't think that has anything to do with it. The lines imported so there was no question whether they were inserted, they were just imported without a template and batch number. The OnInsert checks for valid templates and batches, and they could have been there with blank values.
  • vijay_gvijay_g Member Posts: 884
    You are right that the record can be inserted without template or batch having only line no. incremental but this is the line that would stop to insert record.
    FAJnlTemplate.GET("Journal Template Name");
    
  • DenSterDenSter Member Posts: 8,307
    If there is a template with a blank Name it would not stop the insert, and it is quite common to have those.
  • vijay_gvijay_g Member Posts: 884
    Yes it would not stop to insert but where do we need to have those....?
    DenSter wrote:
    and it is quite common to have those.
  • DenSterDenSter Member Posts: 8,307
    The point is, your advice that INSERT(TRUE) would catch them is not correct.
  • SavatageSavatage Member Posts: 7,142
    Savatage wrote:
    Did you fill Journal Template Name & Journal Batch Name or did you think those were unnecessary?
    nverma wrote:
    I am looking at the data it imported to FA Journal Table and I noticed that the Journal Template Name and Journal Batch name are left blank.
    SETFILTER or SETRANGE are used to filter your records, not to assign fieldvalues. You should assign the proper values to all key fields yourself.
    nverma wrote:
    hmmm...that is so strange....I manually assigned the Journal Template Name and Journal Batch Name and it worked.
    sums it up. :thumbsup:
  • vijay_gvijay_g Member Posts: 884
    This should have stopped here as we suppose that there can not be a blank template as standard nav says anyway.
    Thanks a lot Harry.. :)
    vijay_g wrote:
    You are right that the record can be inserted without template or batch having only line no. incremental but this is
    the line that would stop to insert record.
    FAJnlTemplate.GET("Journal Template Name");
    
  • DenSterDenSter Member Posts: 8,307
    vijay_g wrote:
    we suppose that there can not be a blank template
    Which is the assumption that makes your advice wrong. Sorry to keep hammering at this, but you just cannot make assumptions like that.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    vijay_g wrote:
    This should have stopped here as we suppose that there can not be a blank template as standard nav says anyway.

    Vijay if I am driving my car, and I need to stop, I can drive into a brick wall. Most definitely this WILL stop the car. But would you say this is the proper way to stop a car?
    David Singleton
  • vijay_gvijay_g Member Posts: 884
    DenSter wrote:
    Which is the assumption that makes your advice wrong. Sorry to keep hammering at this, but you just cannot make assumptions like that.

    sorry for this if i was wrong but just want to know how can a db have blank template? i have never seen this anywhere(i can insert forcefully but this is not the right way that a user can do even).
  • DenSterDenSter Member Posts: 8,307
    vijay_g wrote:
    how can a db have blank template? i have never seen this anywhere
    There are a bunch of different ways that this can happen, but it is quite common to have blank templates and batches. I'm not saying it is right, but it DOES happen. The fact that you have not seen this shows your level of experience.

    Don't get me wrong, I like the way you are thinking, and it was quite clever, but just not thought through all the way. It was too complicated when the simple answer (set the template and batch names properly) was a much better solution. You need to start thinking through what you're saying a little bit more, and take a few steps beyond what you are used to. Just because 'practically' something is 'not supposed' to happen does not mean that you can safely assume that it never does. As a result you are making assumptions that can completely screw up your work.
Sign In or Register to comment.