Update different tables with data stocked in another table

SuperSage77SuperSage77 Member Posts: 101
hello!
I shall want use a table (A) which would contain a table ID + a field ID and a value for this field for use to filter the table (B).
And a field ID and a new value for this field for modify the record in the table (B).
ex: I stock in the table (A) the ID 27 for Item and field 1 for "No. " and value "No." : ART-001, and for modify field 3 'Description' with value 'upgrade the 2/08/2012'.
Then i launch a codeunit wich read the table (A) and open the table (B) wich ID is ythe corresponding value of ID Table in table(A) and after filter on this table with the value ART-001 and after modify the field 3 with the value of Table (A).
The second record in Table(A) can be another table ex: 36 'sales header' etc...
I try to use RecordRef but I do'nt filter after the Recordref is open ???
Which syntax allows to filter a Recordref.
Must me use another means than a Recordref ?

Thanks for answer!
Rudy

Answers

  • ufukufuk Member Posts: 514
    I recommend storing recordid value in that table. This way you can directly access to the recordref. If this is not possible here are the possibilities:

    You can filter RecordRef by Gettable, Get or Setview properties.
    GETTABLE requires a filtered record and this is not your case.
    SETVIEW requires a formatted string. (I can help you to code this but not recommend a method like that)
    GET requires a pk. an example for this:
    recref.open(TableID);
    EVALUATE(RecID,RecRef.NAME + ':' + FORMAT(KeyFieldValue));
    RecRef.GET(RecID);
    FldRef := RecRef.FIELD(NoOfFieldToBeUpdated);
    FldRef.VALUE := ValueToAssign;
    RecRef.MODIFY;
    
    Ufuk Asci
    Pargesoft
  • SuperSage77SuperSage77 Member Posts: 101
    Hello ufuk!
    Thanks! it's good way.
    I'have just a little pb : The ValueToAssign isa text in my Table A, but when I want update in my Table (B) I must EVALUATE in case of field type in Table (B).
    For Text-Code, or nteger ==> no pb but if is decimal type I do'nt now convert Text in Decimal ;
    Can you help me ?
    Thanks.

    Rudy.
  • ufukufuk Member Posts: 514
    You're welcome. You can use EVALUATE for decimals too. What's the problem?
    You can also use EvaluateValue function of Migration Management codeunit. It has useful controls.
    Ufuk Asci
    Pargesoft
Sign In or Register to comment.