Dataport not bring any data???

nvermanverma Member Posts: 396
Hey guyz,

I created a dataport to import some information from a csv file.

It creates a No. for the record but it doesnt import any of the information. All the fields are left blank.

I tried debugging it, it doesnt seem to read any of the information from the excel file. All the fields from the excel file are blank in the debugging mode.

I have created all the variables in the C/AL Global, and Dataport fields. I have set import to yes, FileFormat to variable, FieldSeperator to , ,Record and dataitem seperator to NewLine. I have set AutoSave, AutoUpdate, and AutoPrelace to YES.

I dont know what else I could be missing. All the code I have written is in OnAfterImportRecord.

Any idea why it might be doing wrong since it doesnt seem to read the csv file???
CLEAR("Fixed Asset");
"Fixed Asset".INIT;
"Fixed Asset"."No." := "No.";
"Fixed Asset".Description1 := Description1;
"Fixed Asset"."Description 2" := Description2;
"Fixed Asset"."Serial No." := "Serial No.";
"Fixed Asset"."Office No." := "Office No.";
"Fixed Asset"."Make/Brand Name" := "Make/Brand Name";
"Fixed Asset"."Model No." := "Model No.";
"Fixed Asset"."Responsible Employee" := "Responsible Employee";
"Fixed Asset"."FA Class Code" := "FA Class Code";
"Fixed Asset"."Cost Center Code" := "Cost Center Code";
"Fixed Asset"."Shortcut Dimension 7 Code" := "Shortcut Dimension 7 Code";
"Fixed Asset".INSERT(TRUE);

Comments

  • SavatageSavatage Member Posts: 7,142
    Is importing one line or no lines just to clarify. What trigger of the data port do you have that code on. Check the keys of the table your importing to so you know your covering all the "main" fields /ie "line no."
  • SavatageSavatage Member Posts: 7,142
    I also see in your code your simply assigning an imported value to nav fields without using VALIDATE to fill in the values.
  • nvermanverma Member Posts: 396
    The csv file has alot of line. Each line in the csv file is one record.

    Trigger - OnAfterImportRecord()

    The Table key is "No." field. What would I have to with the key field of the table??

    I have to validate the values...i didnt know that. The last dataport I created, i never validated all the values and the dataport worked fine.
  • SavatageSavatage Member Posts: 7,142
    When I create a dataport I import all fields into variables and map them back to nav fields.
    I import them in the order you would naturally manually enter them. Validating where needed. You can always throw a message on the code , say after you get the " no." fields throw MESSAgE('%1',"no.");
    To see if it's even picking up the value. Then that helps you find the problem. It will either be while importing or after importing. Then you can narrow you focus.
  • SavatageSavatage Member Posts: 7,142
    You also say you don't validate, even in the past. The best check I can do to find out if a data port is working 100% is to import 1 line. Then manually enter one line. View the table for those two lines , they should one on top of another. If the data port is filling all the fields just like the manual entry then you can start feling good about the port.
  • nvermanverma Member Posts: 396
    Thats the thing, the dataport is not picking up the values from the csv file. It leave all the fields blank. Even when I try to debug the code, all the variables are blank even when its is in the OnAfterImport trigger.

    I am not sure why they are blank.

    I took out all the other lines from the CSV file except one and its still empty. It creates a Job No. for that line. But the rest of the line is blank. None of the information gets imported.
  • SavatageSavatage Member Posts: 7,142
    Try losing the insert( true).
    Since I can't See i have ask if you've filled in the data port fields.
    You also say it finds nothing then you said it imported just the "no."
    Please be specific on exactly what's happening
  • SavatageSavatage Member Posts: 7,142
    Are you importing into your own global variables and mapping back?
  • nvermanverma Member Posts: 396
    I got rid of the True, and still nothing.

    No. field is increment using a No. Series. Before a record gets inserted into the database, it has its own unique No.

    Each line in the CSV file will have a unique No. field (this will help us differentiate between different records).

    After the unique No. has been created using the No. Series, information from the CSV file is suppose to be assigned to different variables in that table.

    I have created global variables and I am mapping back to them.
  • SavatageSavatage Member Posts: 7,142
    Are you sure your getting the number series properly? Search the forum for " dataport number series" for examples.
    Also, make sure your trigger you are using is correct and nothing on the others
  • nvermanverma Member Posts: 396
    The No. series is working fine. Its creating a new (unique No.) for each line in the csv file. Its just not copy the information from the file and inserting it in the table.
  • SavatageSavatage Member Posts: 7,142
    Try changing
    "Fixed Asset"."No." := "no.";
    To "Fixed Asset".validate(No.",yourNOvariable);
    Do you get a message?

    Also in your code I see nothing about getting a number series? Why?
  • SavatageSavatage Member Posts: 7,142
    I'm not at a computer right now so it's hard to visualize the fixed assets table.
    You said you've made data ports before, with what I told you you should be able to figure out the problem.
    [-o<
  • SavatageSavatage Member Posts: 7,142
    nverma wrote:

    The Table key is "No." field. What would I have to with the key field of the table??
    .
    I don't understand what you are asking here. You do realize when importing into a table filling the key fields is a big deal. You need to validate more. Check the application designers guide that comes with the product. It has a section on dataports.
  • lvanvugtlvanvugt Member Posts: 774
    I guess the DataItem this code is on is linked to the Fixed Asset table. What's the name of the DataItem? Is it "Fixed Asset"?

    If so your code is clearing the record you are importing and mapping each fields on it's own as code in the OnAfterImportRecord is having an implicit WITh DO on the DataItem variable "Fixed Asset". So actually your could as saying:
    CLEAR("Fixed Asset");
    "Fixed Asset".INIT;
    "Fixed Asset"."No." := "Fixed Asset"."No.";
    "Fixed Asset".Description := "Fixed Asset".Description;
    ...
    "Fixed Asset".INSERT(TRUE);
    
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • SavatageSavatage Member Posts: 7,142
    edited 2012-03-29
    You say you are importing into globals & mapping back but your first post shows code where the variables are the same name as the fields.

    so if your using the lookup to fill in the dataport fields then your bypassing the variables.

    change your variable name's to ImportedNo, ImportedDesc1,ImportedDesc2, etc.
    manually type in these names into the dataport fields.

    then change your code..
    "Fixed Asset"."No." := ImportedNo;
    "Fixed Asset".Description := IMportedDesc1;
    etc.
    etc.

    also the final check I can mention is to add a "No." manually into the csv file.
    if it works with a solid number in the csv file then you know using your number series isn't working properly.

    you can also add a line to the table in questions & use your dataport to export the info to a csv to see if it's in the same format as the csv file you are using.

    all the solutions mentions should help you find where it's going wrong.
  • SavatageSavatage Member Posts: 7,142
    Another point.
    If you look at the code on the table you will see..

    Description - OnValidate()
    IF ("Search Description" = UPPERCASE(xRec.Description)) OR ("Search Description" = '') THEN
    "Search Description" := Description;

    So if you aren't validating how are you going to fill the Search Description field?

    that's where 1 manual entry line compared to 1 dataport import line can show you what's missing.
    nverma wrote:
    The last dataport I created, i never validated all the values and the dataport worked fine.
    I would also go back to the "other" dataport you created and do a comparision and fix it if needed, remember it doesn't necessarily mean validate ALL the values, just the right ones.
    nverma wrote:
    It creates a Job No. for that line. But the rest of the line is blank. None of the information gets imported.
    Fixed Asset table doesn't have a "Job No." field are you referring to the "No." field?
    nverma wrote:
    No. field is increment using a No. Series. Before a record gets inserted into the database, it has its own unique No.
    The fixed assets table has a "No." field & A "No. Series" field. are you sure your not confusing these?

    this shouldn't be a hard dataport to create.
  • Yashojit_PandhareYashojit_Pandhare Member Posts: 38
    I might sound silly but just on the other side to ensure....
    Check if Dataport FieldSeparator is <,> as you are using a CSV file

    :thumbsup:
Sign In or Register to comment.