error in dataport while importing

vikasvikas Member Posts: 46
edited 2004-05-21 in Navision Attain
i am importing a text file such that data in first line is stored in sales header and 2nd data in sales line.but the problem is that it gives error in
"if not gvsalesheader.get();" line saying-- the expression code cannot be type converted to a option-value.
and how to convert a code datatype into decimal. because quantity and unit price in sales are in decimal and my three gobal variables are in code.
help me in this regard
IF NOT gvImportCounter = 1 THEN BEGIN 
gvsalesno := gvImportField1;
IF gvsalesheader.GET(gvImportField2) THEN BEGIN 
gvsalesheader.INIT;
gvsalesheader."Document Type" :=gvsalesheader."Document Type"::Order;
gvsalesheader."No." := COPYSTR(gvImportField2, 1, 20);
gvsalesheader.VALIDATE("Sell-to Customer No.", COPYSTR(gvImportField3, 1, 30));
gvsalesheader.INSERT;
END; 
gvImportCounter += 1; 
END 
ELSE IF gvImportCounter = 2 THEN BEGIN 
gvsalesline.RESET;
//gvItem.SETRANGE(gvItem."Sales Type"::Customer);
//gvItem.SETRANGE(gvItem."Sales Code", gvImportCustNo);
gvsalesline.SETRANGE(gvsalesline."No.", gvImportField1);
 
IF NOT gvsalesline.FIND('-') THEN BEGIN //Insert item Price
gvsalesline.INIT;
gvsalesline."No." := COPYSTR(gvImportField1, 1, 20);
//gvsalesline.Quantity := gvImportField2;
//gvsalesline."Unit Price" :=gvImportField3;
gvsalesline.INSERT;
END; 
gvImportCounter := 1;
 END;

Comments

  • WarfoxWarfox Member Posts: 53
    Have you tried it with the Evaluate command?
  • RobertMoRobertMo Member Posts: 484
    "if not gvsalesheader.get();" line saying-- the expression code cannot be type converted to a option-value.

    read the help for GET. GET requires (but not strictly) parms for Primary key fields. If you are using GET without parms, or less then fields in PK, it actaully tries to get the record with empty primary key fields.

    In your case table is T36 with PK: "Document type" (option) and "No." (code20) so you must call GET with both parms, not just second one.
    call it like
    gvsalesheader.get(gvsalesheader."Document Type"::Order,vImportField2)
    
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • lakshmivallurulakshmivalluru Member Posts: 168
    Hi Vikas,

    u did not assign the document type for the salesline.and see that the structure of the text file matches the structure of the dataport fields.
    you can use format function to modify the decimal into text. Also the code length should be the max length of the decimal value.

    let us knwo whether u managed to sort the problem or not
    LR
Sign In or Register to comment.