How To Get The Values Of Temp-table Browser

PrJlndni

Member
Hello,

Good day Masters!

I really need help regarding my ongoing project.

My task is to create a browser that can search something then will display its information on the same browser. at first, the browser should be empty, then the searched account numbers and it's info will be stored in the temp table and displayed in the browser accordingly.

What I currently did is that, I made a temp-table where I can store all the data that's being searched. Using the browser, I enabled one of its fields and use it as my searching area.

My problem is how to get the inputted value in the browser so that I could start searching. Below is my work. It's really a mess. Please Help. Thank you very much :(
Code:
DEFINE VARIABLE t_AcctNo  AS CHARACTER LABEL " Account No" FORMAT "XX-XXXXXX-X".
DEFINE VARIABLE t_OldFTaxFlagValue AS CHARACTER FORMAT "X".
DEFINE VARIABLE t_FTaxFlagChangeValue AS LOGICAL FORMAT "YES/NO" INIT NO.
DEFINE VARIABLE t_NewFTaxFlagValue AS CHARACTER FORMAT "X".
DEFINE VARIABLE t_exit    AS LOGICAL INIT TRUE.
DEFINE VARIABLE l_maint01 AS LOGICAL INIT YES.
DEFINE VARIABLE t_ChkRowID AS ROWID.
DEFINE VAR t_new              AS LOGICAL.
DEFINE VAR t_sort             AS INTEGER INIT 0.
DEFINE VAR t_ChkRecID AS RECID.
DEFINE VAR temp_recaddrs AS CHARACTER.

DEFINE TEMP-TABLE temp-Customer
    FIELD t_sort AS INTEGER
    FIELD recaddrs AS CHARACTER
    FIELD NAME AS CHARACTER FORMAT "X(20)"
    FIELD Address AS CHARACTER  FORMAT "X(20)"
    FIELD FTaxFlag    AS INT
    FIELD Changes AS LOGICAL INIT NO
    INDEX t_sort t_sort.

/*DEFINE TEMP-TABLE temp-Customer2 LIKE CustService.Customer.*/


DEFINE QUERY t_ChkBrw00 FOR temp-Customer SCROLLING.
DEFINE BROWSE t_ChkBrw00 QUERY t_ChkBrw00 NO-LOCK
    DISP temp-Customer.recaddrs   FORMAT "XX-XXXXXX-X"
         temp-Customer.NAME      FORMAT "X(20)"
         temp-Customer.Address    FORMAT "X(20)"
         IF temp-Customer.FTaxFlag = 1 THEN "Enrolled" ELSE "NOT Enrolled"  FORMAT "X(12)"
    ENABLE
          temp-Customer.recaddrs
   
          WITH SIZE 98 BY 08 CENTERED NO-BOX NO-LABELS.

DEFINE FRAME f_MainProc WITH KEEP-TAB-ORDER.
DEFINE FRAME f_ChkBrw00
    "  Account No. Name                 Address              Status       Change " VIEW-AS TEXT AT ROW 1 COL 1
    "  ----------- -------------------- -------------------- ------------ ------ " VIEW-AS TEXT AT ROW 2 COL 1
    t_ChkBrw00  AT ROW 3 COL 01 HELP " [F7] To CHECK Account No."
        WITH VIEW-AS DIALOG-BOX OVERLAY NO-LABELS NO-UNDERLINE SCROLLABLE ROW 05 CENTERED TITLE "[ Franchise Browser ]".

FIND FIRST temp-Customer NO-ERROR.
IF NOT AVAILABLE (temp-Customer) THEN do:
    CREATE temp-Customer.
    ASSIGN temp-Customer.t_sort = 0 temp-Customer.NAME = "-" temp-Customer.Address = "-" t_ChkRowID = ROWID(temp-Customer).
END.
DISPLAY t_HeadTitle01 WITH FRAME f_MainProc.
HIDE b_Proceed b_Cancel FRAME f_MainProc.

RUN StartProc. 

PROCEDURE StartProc.
    DISP t_AcctNo AT ROW 3 COL 3   WITH FRAME f_ChkBrw00.
DO WHILE l_maint01.
    ON END-ERROR, PF4 OF  FRAME f_ChkBrw00 DO:
        ASSIGN l_maint01 = FALSE.
        HIDE FRAME f_ChkBrw00.
        HIDE FRAME f_MainProc.
    END.
      
    ON VALUE-CHANGED OF t_AcctNo IN FRAME f_ChkBrw00 DO:
      
    END.

    ON RETURN OF t_ChkBrw00 OR RETURN OF t_AcctNo IN FRAME f_ChkBrw00 DO:
        MESSAGE t_AcctNo.
        FIND FIRST CustService.Customer WHERE CustService.Customer.recaddrs = SUBSTRING(t_AcctNo,3,6) NO-ERROR.
        IF AVAIL(CustService.Customer) THEN do:
            MESSAGE CustService.Customer.recaddrs VIEW-AS ALERT-BOX.
            CREATE temp-Customer.
            BUFFER-COPY CustService.Customer TO temp-Customer.
            ASSIGN t_ChkRowID = ROWID(temp-Customer).
            OPEN QUERY t_ChkBrw00 FOR EACH temp-Customer WHERE temp-Customer.recaddrs = Customer.recaddrs.
            REPOSITION t_ChkBrw00 TO ROWID t_ChkRowID.
            IF Customer.FTaxFlag = 0 THEN DO:
                ASSIGN temp-Customer.FTaxFlag = 1.
            END.
            ELSE IF t_FTaxFlagChangeValue = YES AND temp-Customer.FTaxFlag = 1 THEN DO:
                ASSIGN temp-Customer.FTaxFlag = 0.
            END.
          
        END.
        ELSE do:
            MESSAGE "NOT found" VIEW-AS ALERT-BOX.
        END.
      
        OPEN QUERY t_ChkBrw00 FOR EACH temp-Customer.
        WAIT-FOR RETURN OF t_AcctNo  or RETURN , PF4, F7 OF t_ChkBrw00 IN FRAME f_ChkBrw00 FOCUS t_ChkBrw00.
    END.

    ENABLE t_AcctNo WITH FRAME f_ChkBrw00.
    OPEN QUERY t_ChkBrw00 FOR EACH temp-Customer.
    WAIT-FOR PF4, RETURN OF /*t_ChkBrw00*/ t_AcctNo IN FRAME f_ChkBrw00 FOCUS t_ChkBrw00.
  
   END. 
  
END.
 
Last edited by a moderator:

ForEachInvoiceDelete

Active Member
What version of progress are you using? Looks version 9 from the code, and CHUI.

This might help but not sure if it works in a character enviroment. Would definitely work in GUI.

(Returns the value of "InputColumnHeader" in the selected row of the browser).


DEFINE VARIABLE hquery AS HANDLE NO-UNDO.
DEFINE VARIABLE hBuffer AS HANDLE NO-UNDO.
DEFINE VARIABLE hSearchCol AS HANDLE NO-UNDO.
DEFINE VARIABLE iCount AS INT NO-UNDO.

do with frame fr_order: /* Frame your browsers on */

ASSIGN hquery = br_Order:QUERY /* Replace br_Order with your browse */
hbuffer = hquery:GET-BUFFER-HANDLE(1)
hSearchCol = hBuffer:BUFFER-FIELD("InputColumnHeader").


DO iCount = 1 TO br_Order:NUM-SELECTED-ROWS: /* Replace br_Order with your browse */
br_Order:FETCH-SELECTED-ROW(icount).

message hSearchCol:BUFFER-VALUE view-as alert-box.
end.

end.
 
Last edited:

ForEachInvoiceDelete

Active Member
The above should work.

What i think you want to do is edit an internal cell of a browser, and when you hit a key it uses the value you inputted to create a temp-table and refresh the browse query?
 

ForEachInvoiceDelete

Active Member
I did similar using bits of the above code. Just put it in a browse trigger.

Example on 'Return', get the value of the selected row/ column as per above code.

then do your populate temp-table code to create the data (Make sure you dont over-write the fake temp-table record thats acting as your searchable area). Then run

{&OPEN-BROWSERS-IN-QUERY-f_ChkBrw00}.

You should also do some editable checking to ensure the user can only edit your first row.
 

PrJlndni

Member
Hi Sir,

Thank you for your informative response.
I bet {&OPEN-BROWSERS-IN-QUERY-f_ChkBrw00} is from AppBuilder.
I've been using hard coding this time. All I want to do is to have my browser enabled.
I enabled two columns, but when I run the program only one column is enabled.
I don't know how come the second column is not enabled since I already commanded it to be enabled.
I tried using the tab key hoping that it will hop to the next column that's enabled.
Unfortunately, it does not move a bit. Please help :(
 

ForEachInvoiceDelete

Active Member
No, you can stick that anywhere. It will just force all browsers in the frame to refresh.

I am using appbuilder but this should apply just the same.

In the display statement put

enable table1.field1 table1.field2

heres my example that displays 7 fields in the browse and enables two of them for editing.

In my display trigger of the browse.

ttValidating.Scrap
ttValidating.FabTrimCode FORMAT "X(15)":U
ttValidating.udg1 FORMAT "X(8)":U
ttValidating.udg2 FORMAT "X(8)":U
ttValidating.udg3 FORMAT "X(8)":U
ttValidating.udg4 FORMAT "X(8)":U
ttValidating.udg5 FORMAT "X(8)":U
enable ttValidating.Scrap ttValidating.fabtrimcode
 

Osborne

Active Member
As ForEachInvoiceDelete posted, providing you enable the column in the DISPLAY statement it should be enabled. Is there anywhere lurking in your program something like this:
Code:
temp-Customer.recaddrs:READ-ONLY IN BROWSE t_ChkBrw00 = TRUE.
If there is then this would prevent the column being enabled even though it is set as enabled in the DEFINE BROWSE section.
 

PrJlndni

Member
Good day Masters!

@ForEachInvoiceDelete: Sir, I'm already using that method but it seems not working for me. I tried the appbuilder, its codes alone, works well if I just run it the normal way. But when I compiled it in our main program, only one column will work. The rest are disabled.
In fact, I used the codes below right now. Please help me check. I might have done something why it won't work.

@Osborne: Hi Sir, I am not using read-only attributes. Just plain frames. Please help me check my codes below.

Thank you very much Masters. :)
 

PrJlndni

Member
Code:
DEFINE VARIABLE t_RecAddrs              AS CHARACTER LABEL " Account No" FORMAT "XX-XXXXXX-X".
DEFINE VARIABLE t_OldFTaxFlagValue      AS CHARACTER FORMAT "X".
DEFINE VARIABLE temp_recaddrs           AS CHARACTER.
DEFINE VARIABLE t_NewFTaxFlagValue      AS CHARACTER FORMAT "X".
DEFINE VARIABLE t_FTaxFlagChangeValue   AS LOGICAL FORMAT "YES/NO" INIT NO.
DEFINE VARIABLE t_exit                  AS LOGICAL INIT TRUE.
DEFINE VARIABLE l_maint01               AS LOGICAL INIT YES.
DEFINE VARIABLE t_new                   AS LOGICAL INIT FALSE.
DEFINE VARIABLE t_loop                  AS LOGICAL INIT FALSE.
DEFINE VARIABLE t_existing              AS LOGICAL INIT FALSE.
DEFINE VARIABLE t_ChkRowID              AS ROWID.
DEFINE VARIABLE t_sorting               AS INTEGER INIT 1.
DEFINE VARIABLE t_exit01                AS LOGICAL INIT TRUE.
DEFINE VARIABLE t_edit                  AS LOGICAL INIT FALSE.

DEFINE TEMP-TABLE temp-Customer
    FIELD t_sort    AS INTEGER
    FIELD recaddrs  AS CHARACTER FORMAT "XX-XXXXXX-X"
    FIELD NAME      AS CHARACTER FORMAT "X(20)"
    FIELD Address   AS CHARACTER  FORMAT "X(20)"
    FIELD FTaxFlag  AS INTEGER
    FIELD Changes   AS LOGICAL INIT NO
    INDEX t_sort t_sort.

FIND FIRST temp-Customer NO-ERROR.
IF NOT AVAILABLE (temp-Customer) THEN do:
    CREATE temp-Customer.
    ASSIGN temp-Customer.t_sort = 1.
END.
DEFINE QUERY t_ChkBrw00 FOR temp-Customer SCROLLING.
DEFINE BROWSE t_ChkBrw00 QUERY t_ChkBrw00  NO-LOCK
    DISPLAY
         temp-Customer.recaddrs 
         temp-Customer.NAME      FORMAT "X(20)"
         temp-Customer.Address   FORMAT "X(20)"
         IF temp-Customer.FTaxFlag = 1 THEN "Enrolled" ELSE "NOT Enrolled"  FORMAT "X(12)"
         temp-Customer.FTaxFlag   
         temp-Customer.changes   
    ENABLE       
          temp-Customer.recaddrs
          temp-Customer.changes
          WITH SIZE 71 BY 15 CENTERED NO-ROW-MARKERS NO-BOX NO-LABELS.
/*temp-Customer.recaddrs:READ-ONLY IN BROWSE t_ChkBrw00 = TRUE.
temp-Customer.changes:READ-ONLY IN BROWSE t_ChkBrw00 = TRUE.*/
DEFINE FRAME f_MainProc WITH KEEP-TAB-ORDER.
DEFINE FRAME f_ChkBrw00
    "  Account No. Name                 Address              Status       Change " VIEW-AS TEXT AT ROW 1 COL 1
    "  ----------- -------------------- -------------------- ------------ ------ " VIEW-AS TEXT AT ROW 2 COL 1
    t_ChkBrw00  AT ROW 3 COL 01 HELP " [F7] To CHECK Account No."
        WITH VIEW-AS DIALOG-BOX OVERLAY NO-LABELS NO-UNDERLINE SCROLLABLE ROW 05 CENTERED TITLE "[ Franchise Browser ]" KEEP-TAB-ORDER.

/*FIND FIRST temp-Customer NO-ERROR.
IF NOT AVAILABLE (temp-Customer) THEN do:
    CREATE temp-Customer.
    ASSIGN temp-Customer.t_sort = 1.
END.*/

DO WHILE t_exit01.                                                                                                                                             /*LOOP PROCESS FOR A BETTER FLOW OF THE PROGRAM*/
      VIEW FRAME f_MainProc.
      DISPLAY t_HeadTitle01 WITH FRAME f_MainProc.
      HIDE b_Proceed b_Cancel.
      RUN StartProc.                                                                                                                                       /*PROCEDURE TO START THE SYSTEM PROCESS*/
      t_exit01 = TRUE.                                                                                                                                             /*LOOP PROCESS FOR A PROPER EXIT FLOW OF THE PROGRAM*/
      RETURN.                                                                                                                                                        /**RETURN TO START PROCEDURE**/
END.

PROCEDURE StartProc.
  
    ENABLE t_ChkBrw00 WITH FRAME f_ChkBrw00.
    DO WHILE l_maint01.
        ON tab OF FRAME f_ChkBrw00 DO:
            MESSAGE "1" VIEW-AS ALERT-BOX.
        END.
        ON END-ERROR, PF4 OF FRAME f_ChkBrw00 DO:
            ASSIGN l_maint01 = FALSE t_new = FALSE t_exit01 = FALSE t_loop = FALSE.
            HIDE FRAME f_ChkBrw00.
            HIDE FRAME f_MainProc.
        END.
        ON RETURN OF FRAME f_ChkBrw00 DO:
            MESSAGE "returning" VIEW-AS ALERT-BOX.
        END.
        ON F7 OF t_ChkBrw00 IN FRAME f_ChkBrw00 DO:
            MESSAGE "FALSE" VIEW-AS ALERT-BOX.
            ASSIGN t_exit = FALSE t_new = TRUE.
            FIND LAST temp-Customer NO-ERROR.
            IF AVAIL(temp-Customer) THEN ASSIGN t_ChkRowID = ROWID(temp-Customer).
            OPEN QUERY t_ChkBrw00 FOR EACH temp-Customer NO-LOCK.
            /*REPOSITION t_ChkBrw00 TO ROWID t_ChkRowID.*/
            WAIT-FOR end-error, PF4, RETURN OF FRAME f_ChkBrw00 FOCUS t_ChkBrw00.
        END.
        /*ON VALUE-CHANGED OF t_ChkBrw00 IN FRAME f_ChkBrw00 DO:
            ASSIGN t_ChkRowID = ROWID(temp-Customer).
            ASSIGN t_edit = TRUE.
        END.*/
        IF t_exit THEN DO:
            MESSAGE "IN" VIEW-AS ALERT-BOX.
            WAIT-FOR end-error, PF4, F7 OF t_ChkBrw00 IN FRAME f_ChkBrw00 /*FOCUS t_ChkBrw00*/.
        END.
        ELSE do:
            IF t_new THEN DO:
                MESSAGE "NEW record" VIEW-AS ALERT-BOX.
                FIND temp-Customer WHERE rowid(temp-Customer) = t_ChkRowID NO-ERROR.
                IF AVAIL(temp-Customer) THEN do:
                    FIND FIRST CustService.Customer WHERE CustService.Customer.recaddrs = substring(temp-Customer.recaddrs,3,6).
                    IF AVAIL(CustService.Customer) THEN DO:
                        t_RecAddrs = substring(GetCustAcctNo(CustService.Customer.recaddrs),1,2) + CustService.Customer.recaddrs + substring(GetCustAcctNo(CustService.Customer.recaddrs),11,1).
                        FIND temp-Customer WHERE temp-Customer.recaddrs = t_RecAddrs NO-ERROR.
                        IF AVAIL(temp-Customer) THEN do:
                            ASSIGN t_new = FALSE t_edit = TRUE.
                            MESSAGE SKIP "Account already exist." VIEW-AS ALERT-BOX ERROR.
                        END.
                        ELSE DO:
                            FIND LAST temp-Customer NO-ERROR.
                            IF AVAIL(temp-Customer) THEN do:
                                ASSIGN t_new = FALSE t_edit = FALSE.
                                /*t_loop = TRUE.
                                t_existing = TRUE.*/
                                MESSAGE "saving PROCESS..." t_RecAddrs " " t_sorting VIEW-AS ALERT-BOX.
                                IF temp-Customer.t_sort = t_sorting THEN ASSIGN temp-Customer.recaddrs = t_RecAddrs temp-Customer.NAME = CustService.Customer.NAME temp-Customer.Address = CustService.Customer.Address temp-Customer.FTaxFlag = CustService.Customer.FTaxFlag temp-Customer.Changes = NO.
                                /*ELSE DO:   
                                    ASSIGN t_sorting = /*t_sorting + 1*/ 3.
                                    CREATE temp-Customer.
                                    ASSIGN temp-Customer.t_sort = t_sorting temp-Customer.recaddrs = t_RecAddrs temp-Customer.NAME = CustService.Customer.NAME temp-Customer.Address = CustService.Customer.Address temp-Customer.FTaxFlag = CustService.Customer.FTaxFlag temp-Customer.Changes = NO.
                                    /*t_loop = FALSE.*/
                                END.*/
                                /*CREATE temp-Customer.
                                ASSIGN temp-Customer.t_sort = 2.*/
                            END.
                        END.
                    END.
                END.
                MESSAGE "out" VIEW-AS ALERT-BOX.
            END.
            ELSE DO:
                IF NOT t_edit THEN do:
                    MESSAGE "EDITING" VIEW-AS ALERT-BOX.
                    t_edit = TRUE.
                    /*t_new = TRUE.*/
                    t_existing = TRUE.
                    /*FIND LAST temp-Customer NO-ERROR.
                    IF AVAIL(temp-Customer) THEN ASSIGN t_ChkRowID = ROWID(temp-Customer).*/
                    OPEN QUERY t_ChkBrw00 FOR EACH temp-Customer /*WHERE temp-Customer.recaddrs = t_RecAddrs*/ .
                    REPOSITION t_ChkBrw00 TO ROW t_sorting.
                    WAIT-FOR end-error, PF4, RETURN OF /*t_ChkBrw00 IN*/ FRAME f_ChkBrw00 /*FOCUS t_ChkBrw00*/ .
                END.
                ELSE DO:
                    MESSAGE "VIEW edited record, NEXT LINE" VIEW-AS ALERT-BOX.
                    t_new = TRUE.
                    /*t_existing = TRUE.*/
                    FIND LAST temp-Customer NO-ERROR.
                    IF AVAIL(temp-Customer) THEN ASSIGN t_ChkRowID = ROWID(temp-Customer).
                    OPEN QUERY t_ChkBrw00 FOR EACH temp-Customer /*WHERE temp-Customer.recaddrs = t_RecAddrs*/ .
                    REPOSITION t_ChkBrw00 TO ROWID t_ChkRowID.
                    WAIT-FOR end-error, PF4, RETURN OF /*t_ChkBrw00 IN*/ FRAME f_ChkBrw00 /*FOCUS t_ChkBrw00*/ .
                END.
            END.
            IF t_existing THEN DO:
                /*t_edit = TRUE.*/
                ASSIGN t_new = FALSE t_edit = TRUE t_existing = FALSE.
                MESSAGE "existing FIELD" VIEW-AS ALERT-BOX.
                t_sorting = t_sorting + 1.
                CREATE temp-Customer.
                ASSIGN temp-Customer.t_sort = t_sorting.
                /*FIND temp-Customer WHERE rowid(temp-Customer) = t_ChkRowID NO-ERROR.
                IF AVAIL(temp-Customer) THEN do:
                    ASSIGN temp_recaddrs = temp-Customer.recaddrs.
                    FIND FIRST temp-Customer WHERE temp-Customer.recaddrs = temp_recaddrs AND temp-Customer.FTaxFlag = t_OldFTaxFlagValue.
                    IF AVAIL(temp-Customer) THEN DO:
                        ASSIGN temp-Customer.FTaxFlag = CustService.Customer.FTaxFlag temp-Customer.Changes = NO.*/
              
            END.
          
        END.
        END.
END PROCEDURE.

Edit: Code tags added. For future reference please enclose code in [code][/code] tags.
 
Last edited by a moderator:

PrJlndni

Member
It will work if we normally run it in the procedure editor, But the moment I compile it to our programs and run to a putty, only the first column will work. :(
 

Osborne

Active Member
I am finding the same, but it is not easy to see what the exact problem is from your code. One possible problem is this line in the F7 trigger:

Code:
WAIT-FOR end-error, PF4, RETURN OF FRAME f_ChkBrw00 FOCUS t_ChkBrw00.

It seems as though when the browse is enabled for data to be entered you have a WAIT-FOR which is not a good idea. Your program needs to be more event driven and have a single WAIT-FOR to close the program/frame as opposed to the four WAIT-FOR's you currently have in different sections. Ideally the main parts you should have are something along there lines:

Code:
ON F7 OF t_ChkBrw00 IN FRAME f_ChkBrw00 DO:
   ASSIGN t_exit = FALSE t_new = TRUE.
   FIND LAST temp-Customer NO-ERROR.
   IF AVAIL(temp-Customer) THEN ASSIGN t_ChkRowID = ROWID(temp-Customer).
   OPEN QUERY t_ChkBrw00 FOR EACH temp-Customer NO-LOCK.
   /*REPOSITION t_ChkBrw00 TO ROWID t_ChkRowID.*/
   APPLY "ENTRY" TO temp-Customer.recaddrs IN BROWSE t_ChkBrw00.
END.

ON END-ERROR OF t_ChkBrw00 IN FRAME f_ChkBrw00 DO:
   /* Actions to either set the browse to default or exit the program/frame */
   IF t_exit THEN
      APPLY "END-ERROR" TO FRAME f_ChkBrw00.
   ELSE
      ...
   RETURN NO-APPLY.
END.

ON ROW-LEAVE OF t_ChkBrw00 IN FRAME f_ChkBrw00 DO:
   /* Check what is entered, create a new record and set the screen to be ready for the next time the user presses F7 */
   IF LAST-EVENT:FUNCTION <> "END-ERROR" THEN DO:
      ...
      t_exit = TRUE.
   END.
END.

ENABLE t_ChkBrw00 WITH FRAME f_ChkBrw00.

WAIT-FOR end-error, PF4, RETURN OF FRAME f_ChkBrw00 FOCUS t_ChkBrw00.
 
Last edited:

PrJlndni

Member
Hi Master Osborne,

I have been trying your suggestions.
Then I came up with this. My problem is that I cannot enable temp-Customer.changes no matter how I tried to enable it.
Code:
DEFINE VARIABLE t_RecAddrs              AS CHARACTER LABEL " Account No" FORMAT "XX-XXXXXX-X".
DEFINE VARIABLE t_OldFTaxFlagValue      AS CHARACTER FORMAT "X".
DEFINE VARIABLE temp_recaddrs           AS CHARACTER.
DEFINE VARIABLE t_NewFTaxFlagValue      AS CHARACTER FORMAT "X".
DEFINE VARIABLE t_FTaxFlagChangeValue   AS LOGICAL FORMAT "YES/NO" INIT NO.
DEFINE VARIABLE t_exit                  AS LOGICAL INIT TRUE.
DEFINE VARIABLE l_maint01               AS LOGICAL INIT YES.
DEFINE VARIABLE t_new                   AS LOGICAL INIT FALSE.
DEFINE VARIABLE t_NewLine               AS LOGICAL INIT FALSE.
DEFINE VARIABLE t_existing              AS LOGICAL INIT FALSE.
DEFINE VARIABLE t_ChkRowID              AS ROWID.
DEFINE VARIABLE t_sorting               AS INTEGER INIT 1.
DEFINE VARIABLE t_exit01                AS LOGICAL INIT TRUE.
DEFINE VARIABLE t_forChanges            AS LOGICAL INIT FALSE.

FUNCTION GetCustAcctNo RETURNS CHARACTER (INPUT f_recaddrs LIKE CustService.Customer.RecAddrs):
  FIND FIRST CustService.Customer WHERE CustService.Customer.RecAddrs = f_recaddrs NO-ERROR.
  IF AVAIL CustService.Customer THEN RETURN STRING(CustService.Customer.Zone-Num,"99") + "-" + CustService.Customer.RecAddrs + "-" + STRING(CustService.Customer.CkDigit,"9").
  ELSE RETURN "UnUpdated".
END FUNCTION.

DEFINE TEMP-TABLE temp-Customer
    FIELD t_sort    AS INTEGER
    FIELD recaddrs  AS CHARACTER FORMAT "XX-XXXXXX-X"
    FIELD NAME      AS CHARACTER FORMAT "X(20)"
    FIELD Address   AS CHARACTER  FORMAT "X(20)"
    FIELD FTaxFlag  AS INTEGER
    FIELD Changes   AS LOGICAL INIT NO
    INDEX t_sort t_sort.

FIND FIRST temp-Customer NO-ERROR.
IF NOT AVAILABLE (temp-Customer) THEN do:
    CREATE temp-Customer.
    ASSIGN temp-Customer.t_sort = 1.
END.
DEFINE QUERY t_ChkBrw00 FOR temp-Customer SCROLLING.
DEFINE BROWSE t_ChkBrw00 QUERY t_ChkBrw00  NO-LOCK
    DISPLAY
         temp-Customer.recaddrs 
         temp-Customer.NAME      FORMAT "X(20)"
         temp-Customer.Address   FORMAT "X(20)"
         IF temp-Customer.FTaxFlag = 1 THEN "Enrolled" ELSE "NOT Enrolled"  FORMAT "X(12)"
         temp-Customer.changes   
    ENABLE       
          temp-Customer.recaddrs
          temp-Customer.changes
          WITH SIZE 71 BY 15 CENTERED NO-ROW-MARKERS NO-BOX NO-LABELS.

DEFINE FRAME f_MainProc WITH KEEP-TAB-ORDER.
DEFINE FRAME f_ChkBrw00
    "  Account No. Name                 Address              Status       Change " VIEW-AS TEXT AT ROW 1 COL 1
    "  ----------- -------------------- -------------------- ------------ ------ " VIEW-AS TEXT AT ROW 2 COL 1
    t_ChkBrw00  AT ROW 3 COL 01 HELP " [F7] To CHECK Account No."
        WITH VIEW-AS DIALOG-BOX OVERLAY NO-LABELS NO-UNDERLINE SCROLLABLE ROW 05 CENTERED TITLE "[ Franchise Browser ]" KEEP-TAB-ORDER.

DO WHILE t_exit01.                                                                                                                                     /*      VIEW FRAME f_MainProc.
      DISPLAY t_HeadTitle01 WITH FRAME f_MainProc.
      HIDE b_Proceed b_Cancel.*/
      RUN StartProc.                                                                                                                                             t_exit01 = TRUE.                                                                                                                                        RETURN.                                                                                                                                             
END.

PROCEDURE StartProc.
    DO WHILE l_maint01.
        ON END-ERROR, PF4 OF FRAME f_ChkBrw00 DO:
            ASSIGN l_maint01 = FALSE t_new = FALSE t_exit01 = FALSE .
            HIDE FRAME f_ChkBrw00.
            HIDE FRAME f_MainProc.
        END.
        ON TAB OF temp-Customer.recaddrs IN BROWSE t_ChkBrw00 DO:
            MESSAGE "here" VIEW-AS ALERT-BOX.
            ASSIGN temp-Customer.changes:READ-ONLY IN BROWSE t_ChkBrw00 = FALSE.
            ASSIGN temp-Customer.changes:COLUMN-READ-ONLY IN BROWSE t_ChkBrw00 = FALSE.
            ASSIGN temp-Customer.recaddrs:READ-ONLY IN BROWSE t_ChkBrw00 = TRUE.
            ASSIGN temp-Customer.recaddrs:COLUMN-READ-ONLY IN BROWSE t_ChkBrw00 = TRUE.
        END.
        ON RETURN OF temp-Customer.recaddrs IN BROWSE t_ChkBrw00 DO:
            MESSAGE "RETURN" VIEW-AS ALERT-BOX.
            IF t_new THEN DO:
                FIND temp-Customer WHERE rowid(temp-Customer) = t_ChkRowID NO-ERROR.
                IF AVAIL(temp-Customer) THEN do:
                    FIND FIRST CustService.Customer WHERE CustService.Customer.recaddrs = substring(temp-Customer.recaddrs,3,6).
                    IF AVAIL(CustService.Customer) THEN DO:
                        t_RecAddrs = substring(GetCustAcctNo(CustService.Customer.recaddrs),1,2) + CustService.Customer.recaddrs + substring(GetCustAcctNo(CustService.Customer.recaddrs),11,1).
                        FIND temp-Customer WHERE temp-Customer.recaddrs = t_RecAddrs NO-ERROR.
                        IF AVAIL(temp-Customer) THEN do:
                            ASSIGN t_new = FALSE t_existing = TRUE.
                            MESSAGE "Account already exist." VIEW-AS ALERT-BOX ERROR.
                        END.
                        ELSE DO:
                            FIND LAST temp-Customer NO-ERROR.
                            IF AVAIL(temp-Customer) THEN do:
                                ASSIGN t_new = FALSE t_forChanges = TRUE t_existing = FALSE.
                                IF temp-Customer.t_sort = t_sorting THEN ASSIGN temp-Customer.recaddrs = t_RecAddrs temp-Customer.NAME = CustService.Customer.NAME temp-Customer.Address = CustService.Customer.Address temp-Customer.FTaxFlag = CustService.Customer.FTaxFlag temp-Customer.Changes = NO.
                            END.
                        END.
                    END.
                END.
            END.
            ELSE ASSIGN t_new = FALSE t_forChanges = FALSE t_existing = FALSE t_NewLine = TRUE.
            OPEN QUERY t_ChkBrw00 FOR EACH temp-Customer.
            REPOSITION t_ChkBrw00 TO ROW t_sorting.
        END.
        ON RETURN OF temp-Customer.changes IN BROWSE t_ChkBrw00 DO:
            FIND FIRST temp-Customer WHERE temp-Customer.recaddrs = t_RecAddrs NO-ERROR.
            IF AVAIL(temp-Customer) THEN DO:
                IF temp-Customer.FTaxFlag = 1 THEN
                    IF temp-Customer.Changes = YES  THEN ASSIGN temp-Customer.FTaxFlag = 0.
                    ELSE ASSIGN temp-Customer.FTaxFlag = 1.
                ELSE DO:
                    IF temp-Customer.Changes = YES THEN ASSIGN temp-Customer.FTaxFlag = 1.
                    ELSE ASSIGN temp-Customer.FTaxFlag = 0.
                END.
            END.
        END.
        ON F7 OF t_ChkBrw00 IN FRAME f_ChkBrw00 DO:
            MESSAGE "NEW record" VIEW-AS ALERT-BOX.
            ASSIGN t_new = TRUE.
            FIND LAST temp-Customer NO-ERROR.
            IF AVAIL(temp-Customer) THEN ASSIGN t_ChkRowID = ROWID(temp-Customer).
            OPEN QUERY t_ChkBrw00 FOR EACH temp-Customer NO-LOCK.
            REPOSITION t_ChkBrw00 TO ROWID t_ChkRowID.
            ASSIGN temp-Customer.recaddrs:READ-ONLY IN BROWSE t_ChkBrw00 = FALSE.
            ASSIGN temp-Customer.recaddrs:COLUMN-READ-ONLY IN BROWSE t_ChkBrw00 = FALSE.
            ASSIGN temp-Customer.changes:READ-ONLY IN BROWSE t_ChkBrw00 = FALSE.
            ASSIGN temp-Customer.changes:COLUMN-READ-ONLY IN BROWSE t_ChkBrw00 = FALSE.
        END.

        IF t_forChanges THEN do:
            t_forChanges = FALSE.
            OPEN QUERY t_ChkBrw00 FOR EACH temp-Customer.
            REPOSITION t_ChkBrw00 TO ROW t_sorting.
            ASSIGN temp-Customer.recaddrs:READ-ONLY IN BROWSE t_ChkBrw00 = TRUE.
            ASSIGN temp-Customer.recaddrs:COLUMN-READ-ONLY IN BROWSE t_ChkBrw00 = TRUE.
            ASSIGN temp-Customer.changes:READ-ONLY IN BROWSE t_ChkBrw00 = FALSE.
            ASSIGN temp-Customer.changes:COLUMN-READ-ONLY IN BROWSE t_ChkBrw00 = FALSE.
        END.
        IF t_existing THEN DO:
            ASSIGN t_new = TRUE.
            FIND LAST temp-Customer NO-ERROR.
            IF AVAIL(temp-Customer) THEN ASSIGN t_ChkRowID = ROWID(temp-Customer).
            OPEN QUERY t_ChkBrw00 FOR EACH temp-Customer NO-LOCK.
            REPOSITION t_ChkBrw00 TO ROWID t_ChkRowID.
            /*ASSIGN temp-Customer.recaddrs:READ-ONLY IN BROWSE t_ChkBrw00 = FALSE.
            ASSIGN temp-Customer.recaddrs:COLUMN-READ-ONLY IN BROWSE t_ChkBrw00 = FALSE.
            ASSIGN temp-Customer.changes:READ-ONLY IN BROWSE t_ChkBrw00 = TRUE.
            ASSIGN temp-Customer.changes:COLUMN-READ-ONLY IN BROWSE t_ChkBrw00 = TRUE.*/
        END.
        IF t_NewLine THEN DO:
            t_NewLine = FALSE.
            MESSAGE "NEW LINE" VIEW-AS ALERT-BOX.
            ASSIGN temp-Customer.recaddrs:READ-ONLY IN BROWSE t_ChkBrw00 = TRUE.
            ASSIGN temp-Customer.recaddrs:COLUMN-READ-ONLY IN BROWSE t_ChkBrw00 = TRUE.
            ASSIGN temp-Customer.changes:READ-ONLY IN BROWSE t_ChkBrw00 = TRUE.
            ASSIGN temp-Customer.changes:COLUMN-READ-ONLY IN BROWSE t_ChkBrw00 = TRUE.
            t_sorting = t_sorting + 1.
            CREATE temp-Customer.
            ASSIGN temp-Customer.t_sort = t_sorting.
        END.
        ENABLE t_ChkBrw00 WITH FRAME f_ChkBrw00.
        WAIT-FOR end-error, PF4, F7, RETURN OF t_ChkBrw00 IN FRAME f_ChkBrw00 OR RETURN OF BROWSE t_ChkBrw00 FOCUS t_ChkBrw00.
    END.
END PROCEDURE.
 
Last edited by a moderator:

Cringer

ProgressTalk.com Moderator
Staff member
Please, please, please add [code][/code] tags around your source code.
 

Osborne

Active Member
One thing that instantly stands out is that the triggers are being defined in the internal procedure - once the internal procedure goes out of scope so will they.

Because of the way the program is put together it is not easy to see why the one field is not enabled. The best thing to do is go back to basics to start with a working version then build up. The following is one of the Progress examples they provide that runs against Sports2000, with the difference being the introduction of the StartProc internal procedure to match what you are trying to achieve. Change the Customer table references to your table and confirm that all the fields are correctly enabled. Then start adding sections checking each time, and as soon as it stops working correctly it will hopefully highlight the problem.
Code:
DEFINE VARIABLE method-return AS LOGICAL NO-UNDO.

DEFINE TEMP-TABLE ttCustomer NO-UNDO LIKE Customer.

DEFINE QUERY q1 FOR ttCustomer SCROLLING.

DEFINE BROWSE b1 QUERY q1
  DISPLAY ttCustomer.CustNum ttCustomer.Name ttCustomer.Phone
  ENABLE ttCustomer.Name ttCustomer.Phone
  WITH 15 DOWN NO-ASSIGN SEPARATORS.

DEFINE BUTTON button1 LABEL "New Row".

DEFINE FRAME f1
  SKIP(1) SPACE(8) b1 SKIP(1) SPACE(8) button1
  WITH NO-BOX.

ON ROW-LEAVE OF b1 IN FRAME f1 DO: /* No-Assign Browser */
  /* If new row, create record and assign values in browse. */
  IF b1:NEW-ROW THEN DO:
     CREATE ttCustomer.
     ASSIGN INPUT BROWSE b1 ttCustomer.Name ttCustomer.Phone.
     DISPLAY ttCustomer.CustNum WITH BROWSE b1.
     method-return = b1:CREATE-RESULT-LIST-ENTRY().
     RETURN.
  END.
  /* If record exists and was changed in browse, update it. */
  IF BROWSE b1:CURRENT-ROW-MODIFIED THEN DO:
     GET CURRENT q1.
     ASSIGN INPUT BROWSE b1 ttCustomer.Name ttCustomer.Phone.
  END.
END.

ON f7 OF b1 IN FRAME f1 DO:
  APPLY "CHOOSE" TO button1.
END.

ON CHOOSE OF button1 IN FRAME f1 DO: /* Insert */
  method-return = b1:INSERT-ROW("AFTER").
END.

RUN StartProc.

PROCEDURE StartProc:
  FOR EACH Customer NO-LOCK:
     CREATE ttCustomer.
     BUFFER-COPY Customer TO ttCustomer.
  END.
  OPEN QUERY q1 FOR EACH ttCustomer NO-LOCK.
  ENABLE ALL WITH FRAME f1.
  WAIT-FOR END-ERROR, PF4, WINDOW-CLOSE OF CURRENT-WINDOW.
END PROCEDURE.
 

PrJlndni

Member
Master Osborne,

I tried your codes in my procedure editor. It was successful but then when I run it in our character-based program, the ttCustomer.Phone column is disabled. That's my main problem, whatever I do that's running good in our procedure editor is not the same with our character-based procedure editor. :(
 

Osborne

Active Member
This is weird as I tried the example in character mode and on pressing the TAB key it moved a row down thus giving the impression the column is not enabled when it is. I do not know if this is a bug or is supposed to be this way, but it explains why you are having the problems you are. BACK-TAB works but not TAB. To solve you need to have the following:
Code:
ON TAB OF temp-Customer.recaddrs IN BROWSE t_ChkBrw00 DO:
   APPLY "ENTRY" TO temp-Customer.changes IN BROWSE t_ChkBrw00.
   RETURN NO-APPLY.
END.
 
Top