7.8.2 BROWSE Examples

Example 1: Browse all lines of a given order allowing selection of an individual order line:

GROUP_BY   NAME(#BRWLIN) FIELDS(#ORDLIN #PRODUCT #QUANTITY)

REQUEST    FIELDS(#ORDNUM)

BROWSE     FIELDS(#BRWLIN) FROM_FILE(ORDLIN) WITH_KEY(#ORDNUM) RETURN_RRN(#RRNFLD)

This is functionally similar to:

DEF_LIST   NAME(#BRWLIN) FIELDS((#SELECTOR *SELECT) #ORDLIN #PRODUCT #QUANTITY #RRNFLD)

REQUEST    FIELDS(#ORDNUM)

CLR_LIST   NAMED(#BRWLIN)

SELECT     FIELDS(#BRWLIN) FROM_FILE(ORDLIN) WITH_KEY(#ORDNUM) RETURN_RRN(#RRNFLD)

ADD_ENTRY  TO_LIST(#BRWLIN)

ENDSELECT

DISPLAY    BROWSELIST(#BRWLIN)

SELECTLIST NAMED(#BRWLIN) GET_ENTRYS(*SELECT)

FETCH      FIELDS(#BRWLIN) FROM_FILE(ORDLIN) WITH_RRN(#RRNFLD)

ENDSELECT

Example 2: Generically browse customers by name that are in state NSW with a credit limit of $100,000:

BROWSE     FIELDS(#NAME #ADD1 #ADD2 #POSTCD #CRDLIM) FROM_FILE(CUSTMAS) WHERE('(#POSTCD > 1999) *AND (#POSTCD < 3000) *AND (#CRDLIM = 100000)') WITH_KEY(#NAME) GENERIC(*YES)

Example 3: Expand on example 2 by automatically selecting the record if it is the only record in the browse:

BROWSE     FIELDS(#NAME #ADD1 #ADD2 #POSTCD #CRDLIM) FROM_FILE(CUSTMAS) WHERE('(#POSTCD > 1999) *AND (#POSTCD < 3000) *AND (#CRDLIM = 100000)') WITH_KEY(#NAME) GENERIC(*YES) ONE_FOUND(*SELECT)

Example 4: Use browse to provide for a customer master file inquiry with update and delete facilities. The browse is to support generic searching for the customer name:

    GROUP_BY   NAME(#BRWLIN) FIELDS(#NAME #ADD1 #ADD2 #ADD3 #POSTCD)

    BEGIN_LOOP

L1: REQUEST    FIELDS(#NAME)

    SET_MODE   TO(*DISPLAY)

    BROWSE     FIELDS(#BRWLIN) FROM_FILE(CUSTMAS) WITH_KEY(#NAME) GENERIC(*YES) NO_SELECT(L1) RETURN_RRN(#FILRRN) CHANGE_KEY(*YES) DELETE_KEY(*YES)

    DISPLAY    FIELDS(#BRWLIN)

    IF_MODE    IS(*CHANGE)

    UPDATE     FIELDS(#BRWLIN) IN_FILE(CUSTMAS) WITH_RRN(#FILRRN)

    ENDIF

    IF_MODE    IS(*DELETE)

    DELETE     FROM_FILE(CUSTMAS) WITH_RRN(#FILRRN)

    ENDIF

    END_LOOP