Putting an integer in a code variable

sarmigsarmig Member Posts: 89
Hi.

I'm having a big problem with a probably small thing...

How do I put an integer (like 1) in a field of type code?

Comments

  • mohana_cse06mohana_cse06 Member Posts: 5,504
  • sarmigsarmig Member Posts: 89
    It's not working. My objective is that when I open a form (the Routing Line form), the operation number appears. The operation number, since there's only one entry per item, is always 1. This is what I have from the processing report from yesterday (in the item data item):
    RecRoutingLine.RESET;
    RecRoutingLine.SETRANGE("Routing No.","No.");
    
    IF RecRoutingLine.FINDSET THEN BEGIN
      IF "Tempo Fabrico Machos" > 0 THEN BEGIN
      RecRoutingLine."Run Time" := "Tempo Fabrico Machos";
      RecRoutingLine.MODIFY;
      MESSAGE('%1', RecRoutingLine."Run Time");
      END
    END
    
    ELSE BEGIN
        RecRoutingHeader.RESET; 
        RecRoutingHeader.SETRANGE("No.","No.");
    
        RecRoutingHeader."No." := "No."; //Nº da tabela item
        RecRoutingHeader.Description := Description;
        RecRoutingHeader.INSERT;
        RecRoutingHeader.Status := RecRoutingHeader.Status::Certified;
        RecRoutingHeader.MODIFY;
    
        RecRoutingLine.RESET; 
        RecRoutingLine.SETRANGE("Routing No.","No.");
    
        RecRoutingLine."Routing No." := "No.";  //Nº da tabela item
        RecRoutingLine."Work Center No." := "Work Center No.";
        RecRoutingLine."Work Center Group Code" := "Work Center Group Code";
        RecRoutingLine."Operation No." := FORMAT(1);
        RecRoutingLine."Run Time" := "Tempo Fabrico Machos";
        RecRoutingLine.INSERT;
    
        IF "Tempo Fabrico Machos" > 0 THEN BEGIN
          RecRoutingLine."Run Time" := "Tempo Fabrico Machos";
          RecRoutingLine.MODIFY;
        END
     END
    
  • raveendran.sraveendran.s Member Posts: 119
    edited 2011-07-13
    Removed by myself as it is not good solution
    --
    Regards,
    Raveendran.BS
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    sarmig wrote:
    It's not working.

    What are you expecting from Not Working?
    your question is to insert integer in Code..
    FORMAT works perfectly for that..
    if it is not working in your scenario means you have identify the mistake in your code..
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    This code worked for me..
    RecRoutingLine.RESET;
    RecRoutingLine.SETRANGE("Routing No.","No.");
    
    IF RecRoutingLine.FINDSET THEN BEGIN
      IF "Tempo Fabrico Machos" > 0 THEN BEGIN
      RecRoutingLine."Run Time" := "Tempo Fabrico Machos";
      RecRoutingLine.MODIFY;
      MESSAGE('%1', RecRoutingLine."Run Time");
      END
    END
    ELSE BEGIN
        RecRoutingHeader.RESET;
        //RecRoutingHeader.SETRANGE("No.","No.");
    
        RecRoutingHeader."No." := "No."; //Nº da tabela item
        RecRoutingHeader.Description := Description;
        RecRoutingHeader.INSERT;
        RecRoutingHeader.Status := RecRoutingHeader.Status::Certified;
        RecRoutingHeader.MODIFY;
    
        RecRoutingLine.RESET; 
        //RecRoutingLine.SETRANGE("Routing No.","No.");
    
        RecRoutingLine."Routing No." := "No.";  //Nº da tabela item
        RecRoutingLine."Work Center No." := "Work Center No.";
        RecRoutingLine."Work Center Group Code" := "Work Center Group Code";
        RecRoutingLine."Operation No." := FORMAT(1);
        RecRoutingLine."Run Time" := "Tempo Fabrico Machos";
        RecRoutingLine.INSERT;
    
        IF "Tempo Fabrico Machos" > 0 THEN BEGIN
          RecRoutingLine."Run Time" := "Tempo Fabrico Machos";
          RecRoutingLine.MODIFY;
        END;
    END;
    
  • sarmigsarmig Member Posts: 89
    The problem is that the field Operation No. in the Routing Line form has nothing, and I want '1' to appear there.
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    sarmig wrote:
    The problem is that the field Operation No. in the Routing Line form has nothing, and I want '1' to appear there.

    With the above code, if I didnt get routing lines with item then it will create header and lines with operation No 1..
    and it is working..

    you have to identify why these solutions are not working for you..
  • sarmigsarmig Member Posts: 89
    I'm having no idea...
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Did you try with the code which i have given? (I have modified some code of yours)
  • sarmigsarmig Member Posts: 89
    I did. I noticed you eliminated some setranges...
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    are you sure you dont have Routing Header and Lines for the Item which you are runnig?

    create a new item and try..
  • sarmigsarmig Member Posts: 89
    You were right. The item I was testing with already had a Routing Line and Header, although I really don't know how it was created (my supervisor told me these were not created automatically). I got it. Sorry for bothering. Thank you for helping me!
  • sarmigsarmig Member Posts: 89
    By the way, where should I add another
    RecRoutingLine."Operation No." := FORMAT(1);
    
    so that I can insert an operating number to the items that already have a Routing Line and Header. I tried to do it here:
    IF RecRoutingLine.FINDSET THEN BEGIN
      IF "Tempo Fabrico Machos" > 0 THEN BEGIN
      RecRoutingLine."Run Time" := "Tempo Fabrico Machos";
      RecRoutingLine."Operation No." := FORMAT(1);
      RecRoutingLine.MODIFY;
    

    but it's not working.
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Operation No. is part of primary key..so we cannot do it like this..
    we have to delete the line and insert again
Sign In or Register to comment.