リレーション・ハンドラーのサンプル

Visual LANSA

リレーション・ハンドラーのサンプル


* =======================================================

* Component :DF_PROC/DFREL01

* Type :Function

* Disclaimer :The following material is supplied as

* sample material only.No warranty concerning this

* material or its use in any way whatsoever is

* expressed or implied

* =======================================================

FUNCTION OPTIONS(*DIRECT *LIGHTUSAGE *MLOPTIMIZE) RCV_LIST(#VIS_LIST #PID_LIST #COL1_LIST #COL2_LIST #COL3_LIST #COL4_LIST #COL5_LIST #COL6_LIST #COL7_LIST #COL8_LIST #COL9_LIST #COLA_LIST)

INCLUDE PROCESS(*DIRECT) FUNCTION(VFREL1)

* The Employee group

GROUP_BY NAME(#EMPLOYEE) FIELDS(#EMPNO #GIVENAME #SURNAME #PHONEBUS #ADDRESS1 #ADDRESS2 #ADDRESS3 #POSTCODE #PHONEHME #DEPTMENT #SECTION)

* Clear all keys and additional columns

EXECUTE SUBROUTINE(CLEARKEYS)

EXECUTE SUBROUTINE(CLEARCOLS)

* Field #SRC_TYPE (Source Business Object Type) is

* the source object of the relationship so switch

* on that initially .....

CASE OF_FIELD(#SRC_TYPE)

* Expand Sections in a Department/Organization

WHEN VALUE_IS('= DEM_ORG')

EXECUTE SUBROUTINE(ORGSEC)

* Expand Employees in a Department/Section

WHEN VALUE_IS('= DEM_ORG_SEC')

EXECUTE SUBROUTINE(SECEMP)

OTHERWISE

ABORT MSGTXT('Unknown source business object type encountered by function DFREL01')

ENDCASE

* Finished ... always use a return command

RETURN

* Return the sections in a department/organization

SUBROUTINE NAME(ORGSEC)

CHANGE FIELD(#DEPTMENT) TO(#SRC_AK1)

* We can now read all the EMPLOYEES in the specified

* department/section and add them to the instance list

SELECT FIELDS(*ALL) FROM_FILE(SECTAB) WITH_KEY(#DEPTMENT)

EXECUTE SUBROUTINE(SETAKEY) WITH_PARMS(1 #DEPTMENT)

EXECUTE SUBROUTINE(SETAKEY) WITH_PARMS(2 #SECTION)

EXECUTE SUBROUTINE(SETNCOL) WITH_PARMS(1 #SECPCODE)

EXECUTE SUBROUTINE(SETACOL) WITH_PARMS(1 #SECADDR1)

EXECUTE SUBROUTINE(SETACOL) WITH_PARMS(2 #SECADDR2)

EXECUTE SUBROUTINE(SETACOL) WITH_PARMS(3 #SECADDR3)

EXECUTE SUBROUTINE(SETACOL) WITH_PARMS(4 #SECPHBUS)

EXECUTE SUBROUTINE(ADDTOLIST) WITH_PARMS('DEM_ORG_SEC' #SECDESC #SECTION)

ENDSELECT

* Finished

ENDROUTINE

SUBROUTINE NAME(SECEMP)

CHANGE FIELD(#DEPTMENT) TO(#SRC_AK1)

CHANGE FIELD(#SECTION) TO(#SRC_AK2)

SELECT FIELDS(#EMPLOYEE) FROM_FILE(PSLMST1) WITH_KEY(#DEPTMENT #SECTION)

EXECUTE SUBROUTINE(SETAKEY) WITH_PARMS(1 #DEPTMENT)

EXECUTE SUBROUTINE(SETAKEY) WITH_PARMS(2 #SECTION)

EXECUTE SUBROUTINE(SETAKEY) WITH_PARMS(3 #EMPNO)

EXECUTE SUBROUTINE(SETNCOL) WITH_PARMS(1 #POSTCODE)

EXECUTE SUBROUTINE(SETACOL) WITH_PARMS(1 #ADDRESS1)

EXECUTE SUBROUTINE(SETACOL) WITH_PARMS(2 #ADDRESS2)

EXECUTE SUBROUTINE(SETACOL) WITH_PARMS(3 #ADDRESS3)

EXECUTE SUBROUTINE(SETACOL) WITH_PARMS(4 #PHONEBUS)

EXECUTE SUBROUTINE(SETACOL) WITH_PARMS(5 #PHONEHME)

EXECUTE SUBROUTINE(SETACOL) WITH_PARMS(6 #DEPTMENT)

EXECUTE SUBROUTINE(SETACOL) WITH_PARMS(7 #SECTION)

USE BUILTIN(TCONCAT) WITH_ARGS(#SURNAME ',' #GIVENAME) TO_GET(#FULLNAME)

EXECUTE SUBROUTINE(ADDTOLIST) WITH_PARMS('DEM_ORG_SEC_EMP' #FULLNAME #EMPNO)

ENDSELECT

* Finished

ENDROUTINE

* =======================================================

INCLUDE PROCESS(*DIRECT) FUNCTION(VFREL2)

注意: 追加カラム日時の値を加えるには、SETACOLサブルーチンで英数字の追加カラムを加える時と同様の方法で、SETDCOLサブルーチンを使います。

日時のフィールド値をISO形式に変換する(追加カラム日時では必須)際の詳細は「追加カラム(日時)のプログラミング例」を参照してください。