Fill FILL-IN with Browser data

Asked

Viewed 610 times

0

I’m trying to create a kind of simple CRUD I got to this point but still have half failed my code, to using the window type Appbuilder I have a screen with "New" "Change" "Delete" "Save" but when I click on Rowse and try to change the selection I cannot fill the fields Fill-in anyone can help me ?

the code I have is

&ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 GUI
&ANALYZE-RESUME
/* Connected Databases 
*/
&Scoped-define WINDOW-NAME C-Win
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS C-Win 
/*------------------------------------------------------------------------

  File: 

  Description: 

  Input Parameters:
      <none>

  Output Parameters:
      <none>

  Author: 

  Created: 

------------------------------------------------------------------------*/
/*          This .W file was created with the Progress AppBuilder.      */
/*----------------------------------------------------------------------*/

/* Create an unnamed pool to store all the widgets created 
     by this procedure. This is a good default which assures
     that this procedure's triggers and internal procedures 
     will execute in this procedure's storage, and that proper
     cleanup will occur on deletion of the procedure. */

CREATE WIDGET-POOL.

/* ***************************  Definitions  ************************** */

/* Parameters Definitions ---                                           */

/* Local Variable Definitions ---                                       */

DEFINE TEMP-TABLE tt-usuario
    FIELD nome AS CHAR
    FIELD sobrenome AS CHAR
    FIELD cpf AS CHAR.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK 

/* ********************  Preprocessor Definitions  ******************** */

&Scoped-define PROCEDURE-TYPE Window
&Scoped-define DB-AWARE no

/* Name of designated FRAME-NAME and/or first browse and/or first query */
&Scoped-define FRAME-NAME DEFAULT-FRAME
&Scoped-define BROWSE-NAME br-usuario

/* Internal Tables (found by Frame, Query & Browse Queries)             */
&Scoped-define INTERNAL-TABLES tt-usuario

/* Definitions for BROWSE br-usuario                                    */
&Scoped-define FIELDS-IN-QUERY-br-usuario tt-usuario.nome tt-usuario.sobrenome tt-usuario.cpf   
&Scoped-define ENABLED-FIELDS-IN-QUERY-br-usuario   
&Scoped-define SELF-NAME br-usuario
&Scoped-define QUERY-STRING-br-usuario FOR EACH tt-usuario
&Scoped-define OPEN-QUERY-br-usuario OPEN QUERY {&SELF-NAME} FOR EACH tt-usuario.
&Scoped-define TABLES-IN-QUERY-br-usuario tt-usuario
&Scoped-define FIRST-TABLE-IN-QUERY-br-usuario tt-usuario


/* Definitions for FRAME DEFAULT-FRAME                                  */
&Scoped-define OPEN-BROWSERS-IN-QUERY-DEFAULT-FRAME ~
    ~{&OPEN-QUERY-br-usuario}

/* Standard List Definitions                                            */
&Scoped-Define ENABLED-OBJECTS fi-nome fi-sobnome fi-cpf bt-save bt-criar ~
bt-alterar bt-del br-usuario 
&Scoped-Define DISPLAYED-OBJECTS fi-nome fi-sobnome fi-cpf 

/* Custom List Definitions                                              */
/* List-1,List-2,List-3,List-4,List-5,List-6                            */

/* _UIB-PREPROCESSOR-BLOCK-END */
&ANALYZE-RESUME



/* ***********************  Control Definitions  ********************** */

/* Define the widget handle for the window                              */
DEFINE VAR C-Win AS WIDGET-HANDLE NO-UNDO.

/* Definitions of the field level widgets                               */
DEFINE BUTTON bt-alterar 
     LABEL "Alterar" 
     SIZE 15 BY 1.13.

DEFINE BUTTON bt-criar 
     LABEL "Novo" 
     SIZE 15 BY 1.13.

DEFINE BUTTON bt-del 
     LABEL "Deletar" 
     SIZE 15 BY 1.13.

DEFINE BUTTON bt-save 
     LABEL "Salvar" 
     SIZE 15 BY 1.13.

DEFINE VARIABLE fi-cpf AS CHARACTER FORMAT "x(3).x(3).x(3)-x(2)":U 
     LABEL "CPF" 
     VIEW-AS FILL-IN 
     SIZE 30 BY 1 NO-UNDO.

DEFINE VARIABLE fi-nome AS CHARACTER FORMAT "X(10)":U 
     LABEL "Nome" 
     VIEW-AS FILL-IN 
     SIZE 30 BY 1 NO-UNDO.

DEFINE VARIABLE fi-sobnome AS CHARACTER FORMAT "X(256)":U 
     LABEL "Sobrenome" 
     VIEW-AS FILL-IN 
     SIZE 30 BY 1 NO-UNDO.

/* Query definitions                                                    */
&ANALYZE-SUSPEND
DEFINE QUERY br-usuario FOR 
      tt-usuario SCROLLING.
&ANALYZE-RESUME

/* Browse definitions                                                   */
DEFINE BROWSE br-usuario
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _DISPLAY-FIELDS br-usuario C-Win _FREEFORM
  QUERY br-usuario DISPLAY
      tt-usuario.nome COLUMN-LABEL "Nome" FORMAT "x(10)"
    tt-usuario.sobrenome COLUMN-LABEL "Sobrenome" FORMAT "x(30)"
    tt-usuario.cpf COLUMN-LABEL "CPF" FORMAT "x(14)"
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
    WITH NO-ROW-MARKERS SEPARATORS SIZE 60 BY 6 FIT-LAST-COLUMN.


/* ************************  Frame Definitions  *********************** */

DEFINE FRAME DEFAULT-FRAME
     fi-nome AT ROW 2 COL 39 COLON-ALIGNED WIDGET-ID 12
     fi-sobnome AT ROW 4 COL 39 COLON-ALIGNED WIDGET-ID 14
     fi-cpf AT ROW 6 COL 39 COLON-ALIGNED WIDGET-ID 16
     bt-save AT ROW 8 COL 50 WIDGET-ID 10
     bt-criar AT ROW 2 COL 11 WIDGET-ID 2
     bt-alterar AT ROW 4 COL 11 WIDGET-ID 4
     bt-del AT ROW 6 COL 11 WIDGET-ID 6
     br-usuario AT ROW 10 COL 11 WIDGET-ID 200
    WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY 
         SIDE-LABELS NO-UNDERLINE THREE-D 
         AT COL 1 ROW 1
         SIZE 80 BY 16 WIDGET-ID 100.


/* *********************** Procedure Settings ************************ */

&ANALYZE-SUSPEND _PROCEDURE-SETTINGS
/* Settings for THIS-PROCEDURE
   Type: Window
   Allow: Basic,Browse,DB-Fields,Window,Query
   Other Settings: COMPILE
 */
&ANALYZE-RESUME _END-PROCEDURE-SETTINGS

/* *************************  Create Window  ************************** */

&ANALYZE-SUSPEND _CREATE-WINDOW
IF SESSION:DISPLAY-TYPE = "GUI":U THEN
  CREATE WINDOW C-Win ASSIGN
         HIDDEN             = YES
         TITLE              = "<insert window title>"
         HEIGHT             = 16
         WIDTH              = 80
         MAX-HEIGHT         = 16
         MAX-WIDTH          = 80
         VIRTUAL-HEIGHT     = 16
         VIRTUAL-WIDTH      = 80
         RESIZE             = yes
         SCROLL-BARS        = no
         STATUS-AREA        = no
         BGCOLOR            = ?
         FGCOLOR            = ?
         KEEP-FRAME-Z-ORDER = yes
         THREE-D            = yes
         MESSAGE-AREA       = no
         SENSITIVE          = yes.
ELSE {&WINDOW-NAME} = CURRENT-WINDOW.
/* END WINDOW DEFINITION                                                */
&ANALYZE-RESUME



/* ***********  Runtime Attributes and AppBuilder Settings  *********** */

&ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
/* SETTINGS FOR WINDOW C-Win
  VISIBLE,,RUN-PERSISTENT                                               */
/* SETTINGS FOR FRAME DEFAULT-FRAME
   FRAME-NAME Custom                                                    */
/* BROWSE-TAB br-usuario bt-del DEFAULT-FRAME */
IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(C-Win)
THEN C-Win:HIDDEN = no.

/* _RUN-TIME-ATTRIBUTES-END */
&ANALYZE-RESUME


/* Setting information for Queries and Browse Widgets fields            */

&ANALYZE-SUSPEND _QUERY-BLOCK BROWSE br-usuario
/* Query rebuild information for BROWSE br-usuario
     _START_FREEFORM
OPEN QUERY {&SELF-NAME} FOR EACH tt-usuario.
     _END_FREEFORM
     _Query            is OPENED
*/  /* BROWSE br-usuario */
&ANALYZE-RESUME





/* ************************  Control Triggers  ************************ */

&Scoped-define SELF-NAME C-Win
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL C-Win C-Win
ON END-ERROR OF C-Win /* <insert window title> */
OR ENDKEY OF {&WINDOW-NAME} ANYWHERE DO:
  /* This case occurs when the user presses the "Esc" key.
     In a persistently run window, just ignore this.  If we did not, the
     application would exit. */
  IF THIS-PROCEDURE:PERSISTENT THEN RETURN NO-APPLY.
END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL C-Win C-Win
ON WINDOW-CLOSE OF C-Win /* <insert window title> */
DO:
  /* This event will close the window and terminate the procedure.  */
  APPLY "CLOSE":U TO THIS-PROCEDURE.
  RETURN NO-APPLY.
END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME bt-alterar
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL bt-alterar C-Win
ON CHOOSE OF bt-alterar IN FRAME DEFAULT-FRAME /* Alterar */
DO:
    MESSAGE 'Tem Certeza que deseja alterar o registro?'
        VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO UPDATE lResp AS LOGICAL.
    IF lResp THEN DO:
    UPDATE tt-usuario.nome = fi-nome:SCREEN-VALUE IN FRAME {&FRAME-NAME}
         tt-usuario.sobrenome = fi-sobnome:SCREEN-VALUE IN FRAME {&FRAME-NAME}
         tt-usuario.cpf = fi-cpf:SCREEN-VALUE IN FRAME {&FRAME-NAME}. 
      {&OPEN-QUERY-{&BROWSE-NAME}}
    END.
END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME bt-criar
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL bt-criar C-Win
ON CHOOSE OF bt-criar IN FRAME DEFAULT-FRAME /* Novo */
DO:
  CLEAR FRAME {&FRAME-NAME}.
END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME bt-del
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL bt-del C-Win
ON CHOOSE OF bt-del IN FRAME DEFAULT-FRAME /* Deletar */
DO:
  MESSAGE 'Tem Certeza que deseja deletar?'
        VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO UPDATE lResp AS LOGICAL.
    IF lResp THEN DO:
    DELETE tt-usuario.
   {&OPEN-QUERY-{&BROWSE-NAME}}
    END.
END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME bt-save
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL bt-save C-Win
ON CHOOSE OF bt-save IN FRAME DEFAULT-FRAME /* Salvar */
DO:
    CREATE tt-usuario. 

    ASSIGN tt-usuario.nome = fi-nome:SCREEN-VALUE IN FRAME {&FRAME-NAME}
           tt-usuario.sobrenome = fi-sobnome:SCREEN-VALUE IN FRAME {&FRAME-NAME}
           tt-usuario.cpf = fi-cpf:SCREEN-VALUE IN FRAME {&FRAME-NAME}. 
      {&OPEN-QUERY-{&BROWSE-NAME}}

END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define BROWSE-NAME br-usuario
&UNDEFINE SELF-NAME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK C-Win 


/* ***************************  Main Block  *************************** */

/* Set CURRENT-WINDOW: this will parent dialog-boxes and frames.        */
ASSIGN CURRENT-WINDOW                = {&WINDOW-NAME} 
       THIS-PROCEDURE:CURRENT-WINDOW = {&WINDOW-NAME}.

/* The CLOSE event can be used from inside or outside the procedure to  */
/* terminate it.                                                        */
ON CLOSE OF THIS-PROCEDURE 
   RUN disable_UI.

/* Best default for GUI applications is...                              */
PAUSE 0 BEFORE-HIDE.

/* Now enable the interface and wait for the exit condition.            */
/* (NOTE: handle ERROR and END-KEY so cleanup code will always fire.    */
MAIN-BLOCK:
DO ON ERROR   UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK
   ON END-KEY UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK:
  RUN enable_UI.
  IF NOT THIS-PROCEDURE:PERSISTENT THEN
    WAIT-FOR CLOSE OF THIS-PROCEDURE.
END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


/* **********************  Internal Procedures  *********************** */

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI C-Win  _DEFAULT-DISABLE
PROCEDURE disable_UI :
/*------------------------------------------------------------------------------
  Purpose:     DISABLE the User Interface
  Parameters:  <none>
  Notes:       Here we clean-up the user-interface by deleting
               dynamic widgets we have created and/or hide 
               frames.  This procedure is usually called when
               we are ready to "clean-up" after running.
------------------------------------------------------------------------------*/
  /* Delete the WINDOW we created */
  IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(C-Win)
  THEN DELETE WIDGET C-Win.
  IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable_UI C-Win  _DEFAULT-ENABLE
PROCEDURE enable_UI :
/*------------------------------------------------------------------------------
  Purpose:     ENABLE the User Interface
  Parameters:  <none>
  Notes:       Here we display/view/enable the widgets in the
               user-interface.  In addition, OPEN all queries
               associated with each FRAME and BROWSE.
               These statements here are based on the "Other 
               Settings" section of the widget Property Sheets.
------------------------------------------------------------------------------*/
  DISPLAY fi-nome fi-sobnome fi-cpf 
      WITH FRAME DEFAULT-FRAME IN WINDOW C-Win.
  ENABLE fi-nome fi-sobnome fi-cpf bt-save bt-criar bt-alterar bt-del 
         br-usuario 
      WITH FRAME DEFAULT-FRAME IN WINDOW C-Win.
  {&OPEN-BROWSERS-IN-QUERY-DEFAULT-FRAME}
  VIEW C-Win.
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

If anyone can help and try to explain how you did it would help me a lot.

1 answer

0


Speak, Alef,

I put this code in the value-changed event of the user:

IF AVAILABLE tt-usuario THEN
   ASSIGN fi-nome    = tt-usuario.nome
          fi-sobnome = tt-usuario.sobrenome
          fi-cpf     = tt-usuario.cpf.
DISPLAY fi-nome fi-sobnome fi-cpf WITH FRAME {&FRAME-NAME}.

See that every browser has, behind you, a query. This query is constantly manipulated by Browse navigation. Every time I click on a Browse record, selecting a line, the query is positioned in that record. So I don’t need to give find. See that I test direct if available tt-user (because Browse may be empty, and then error). There I put the value of name, surname and Cpf in the internal memory value of Fill-ins. Finally, I show these values. I could have put the DIRECT value on the screen using

assign fi-nome:screen-value in frame {&frame-name} = tt-usuario.nome.

But then you’d have to codify it a little differently when it comes to saving it. In Progress you have collections of attributes and properties for widgets on screen, hence the screen-value there.

  • Cool my boss had taught me the direct way, the one using the IF is better, so how I use the Appbuild he taught me so, I select the Rowse, then I go in to display code, and I put in the ON: MOUSE-SELECT-CLICK name... , but cool if one

  • have any suggestions of program I can do to train, concludes this crud I ended up doing otherwise simpler than the one you sent

  • The mouse-select-click is redundant because any click triggers the Trigger. value-changed only comes into action when the selected value of Browse changes. It decreases overhead a little, in my opinion.

  • In fact, there are N ways, even better, to make this screen that you wanted. But in the real lack someone to train you... I do not know what to suggest to you to do, has to see the need of your company. It is Totvs that you use?

  • Uhum Totvs Datasul

  • If you have ddk, try to create a simple register, then a complex, a query, a report, so... Then you learn in practice and already understand a little more the structure of tables, suddenly.

  • I found the DDK to looking for on the net, my boss is helping me with some tips but I really don’t like the Progress kkk learning by need kkk

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.