Products Downloads


French version


 

 

To create a JavaBean to perform the display, create, modify and delete operations:

 

Build a new Visual Adelia Batch program. This program will have to handle all the display, creation, deletion and modification options.

  • Begin by declaring all the necessary variables for the above operations. These must be placed in the program's [DECL PGM] part.

DECL PGM

 

 

BOOL

OK

 

ALPHA(8)

ACTION_CODE

 

REF(CU_CUST_CODE)

PCUS_CODE

 

LIST

LST_CUST

*REF_LDM(CUSTOMERS)

 

PARAM OK ACTION_CODE PCUS_CODE LST_CUST

 

  • Then, in the [INIT PGM] part, enter the code that will perform all the required operations.

 

OK = *FALSE

 

* Display the Customer Detail

IF ACTION_CODE = 'DETAIL'

     LOAD_SQL_LST LST_CUST CUSTOMERS *COND(CU_CUS_CODE = :PCUS_CODE)

     IF *SQLCODE=*NORMAL

         OK=*TRUE

     END

ELSE

 

Code for retrieving a record's details.

 

 

* Create a new customer

IF ACTION_CODE = 'CREATE'

      CHAIN_SQL CUSTOMERS *COND(CU_CUS_CODE = :PCUS_CODE) 

      IF *SQLCODE=*NORMAL

           OK=*FALSE

      ELSE

           READ_LST LST_CUST

              CREATE_SQL CUSTOMERS

              IF *SQLCODE=*NORMAL

                    OK=*TRUE

              ELSE

                    OK=*FALSE

              END

           END_READ_LST

      END

ELSE 

 

Code for creating a new record.

 

 

 

* Delete a customer

IF ACTION_CODE = 'DELETE'

         DELETE_SQL CUSTOMERS *COND(CU_CUS_CODE = :PCUS_CODE)

         IF *SQLCODE=*NORMAL

              OK=*TRUE

         END

ELSE

 

Code for deleting a record.

 

 

* Modification of a customer

IF ACTION_CODE = 'MODIFY'

       READ_LST LST_CUST

           UPD_SQL CUSTOMERS CU_CUS_NAME= :CU_CUS_NAME, -

                   CU_CUS_ZIP = :CU_CUS_ZIP, -

                   CU_CUS_CITY = :CU_CUS_CITY, -

                   CU_CUS_ADDR1 = :CU_CUS_ADDR1, -

                   CU_CUS_ACCOUNT = :CU_CUS_ACCOUNT, -

                   CU_CUS_BANK = :CU_CUS_BANK, -

                   *COND(CU_CUS_CODE = :PCUS_CODE)

           IF *SQLCODE=*NORMAL

                   OK=*TRUE

           END

      END_READ_LST

END

 

Code for modifying a record.

 

 

↑ Top of page

  • Aucune étiquette