2008-11-25

Tutorial Membuat Sub File di AS400

Sebelumny kita harus mengetahui, apa itu sub file. Sub File digunakan untuk menampilkan data banyak
berbentuk table. berikut contoh gambar Sub File :

X SCRNO CSNO NAMA ACNO STATUS
X 0000000001 0000000 YADI 0000000000 0
0000000011 0000000 DENI 0000000000 0
X 0000000007 0000000 Salemet 0000000000 0


untuk membuat Sub File ada beberapa File yang harus di siapkan, diantaranya adalah :
1. Buat File *.pf <-- sebagai data base yang akan di akses 2. Buat File *.dspf <-- yang akan menangani masalah tampilan. 3. Buat File *.rpg/rpgle <-- sebagai program utama 1. File DSPF
0000.10 A*%%TS SD 20081114 144536 MULYADI REL-V5R3M0 5722-WDS
0000.20 A* 90/05/03 12:22:01 SYSTEK REL-R02M00 5728-PW1
0000.30 A*%%EC
0000.40 A DSPSIZ(24 80 *DS3)
0000.50 A REF(*LIBL/TRLBTOT)
0000.60 A CHGINPDFT(CS)
0000.70 A PRINT(*LIBL/QSYSPRT)
0000.80 A R SFLREC SFL
0000.90 A*%%TS SD 20081114 144536 MULYADI REL-V5R3M0 5722-WDS
0001.00 A TEXT('SUB FILE FORMAT KEYWORD')
0001.10 A CRDLIM 15S 0H
0001.20 A PILIH 1A I 8 9VALUES('X' ' ')
0001.30 A NAME R O 8 14REFFLD(SUBFIL/NAME LIBY/CUSMSTL)
0001.40 A ADDR R O 8 26REFFLD(SUBFIL/ADDR LIBY/CUSMSTL)
0001.50 A CUST R O 8 37REFFLD(SUBFIL/CUST LIBY/CUSMSTL)
0001.60 A R SFLCTL SFLCTL(SFLREC)
0001.70 A*%%TS SD 20081114 143714 MULYADI REL-V5R3M0 5722-WDS
0001.80 A SFLSIZ(0100)
0001.90 A SFLPAG(0010)
0002.00 A CA03(03 'EXIT_PROGRAM')
0002.10 A OVERLAY
0002.20 A 20N40 SFLDSP
0002.30 A N40 SFLDSPCTL
0002.40 A 40 SFLCLR
0002.50 A N39 SFLEND
0002.60 A RECNUM 1S 0H
0002.70 A 20 6 4' PILIH NAMA -
0002.80 A ALAMAT '
0002.90 A COLOR(WHT)
0003.00 A CTR 1S 0H
0003.10 A 5 3'==================================-
0003.20 A ======================='
0003.30 A 7 3'==================================-
0003.40 A ======================='
0003.50 A 4 3'MASUKAN NAMA'
0003.60 A SNAMA 10A I 4 19
0003.70 A 1 3'PROGRAM LATIHAN YADI'
0003.80 A R FUNCKY
0003.90 A*%%TS SD 20081103 164843 MULYADI REL-V5R3M0 5722-WDS
0004.00 A 21 4'F3-EXIT'
0004.10 A 20 4'==================================-
0004.20 A ====================== '
0004.30 A 20 21 44'pageup/pagedown'
0004.40 A COLOR(RED)
0004.50 A R NEWPAGE
0004.60 A*%%TS SD 20081103 165309 MULYADI REL-V5R3M0 5722-WDS
0004.70 A 4 7'NAMA TERPILIH :'
0004.80 A 5 7'ALAMAT TERPILIH :'
0004.90 A NAMAMU 10A O 4 29
0005.00 A CITYMU 10A O 5 29
0005.10 A 3 3'|'
0005.20 A 4 3'|'
0005.30 A 5 3'|'
0005.40 A 6 3'|'
0005.50 A 7 4'-----------------------------------
0005.60 A ---'
0005.70 A 3 41'|'
0005.80 A 4 41'|'
0005.90 A 5 41'|'
0006.00 A 6 41'|'
0006.10 A 2 4'-----------------------------------
0006.20 A ---'
****************** End of data ******************************************************

2. File *.pf
*************** Beginning of data **************************************************
0001.00 A R EMPLTES
0003.00 A DNAME 30A
0004.00 A DKATEGORI 1A
0005.00 A DLOCATION 28A
0006.00 A DUSRID 13A
0007.00 A DAGE 2S
****************** End of data *****************************************************

3. File rpgle
0000.01 F**************************************************************************
0000.02 F* VALIDASI DATA NASABAH U SWASYS
0000.03 F* YADI MULYADI
0000.04 F**************************************************************************
0000.05 F*
0001.03 FCUSMSTL IF E K DISK
0001.04 FCLDUSRC CF E WORKSTN
0001.05 F RECNUMKSFILE SFLREC
0001.06 C*
0001.07 C* DECLARE KEY FOR SEARCHING
0001.08 C NMKEY KLIST
0001.09 C KFLD SNAMA
0001.12 C*
0001.13 C *IN03 DOWEQ'0'
0001.14 C* SNAMA DSPLY
0001.15 C* *IN30 DSPLY
0001.16 C* *IN20 DSPLY
0001.17 C WRITEFUNCKY
0001.19 C EXFMTSFLCTL
0001.20 C *IN03 IFEQ '0'
0001.21 C *IN20 IFEQ '0'
0001.24 C EXSR SFLFIL
0001.25 C ELSE
0001.26 C *IN30 IFEQ '1'
0001.27 C SNAMA ANDNE*BLANK
0001.30 C 'NKEY' DSPLY
0001.31 C ELSE
0001.32 C EXSR CEK
0001.34 C ENDIF
0001.35 C ENDIF
0001.36 C ENDIF
0001.37 C ENDDO
0001.38 C SNAMA DSPLY
0001.39 C *IN03 DSPLY
0001.40 C *IN20 DSPLY
0001.41 C *IN30 DSPLY
0001.42 C SETON LR
0001.43 C*-------------------------------------------------------------------------
0001.44 C* SUB FILE SFLFIL
0001.45 C*-------------------------------------------------------------------------
0001.46 C SFLFIL BEGSR
0001.47 C NMKEY SETLLSUBFIL
0001.48 C *IN21 DOWEQ'0'
0001.49 C READ SUBFIL 71
0001.50 C *IN71 IFEQ '1'
0001.51 C MOVE '1' *IN21
0001.52 C ELSE
0001.53 C ADD 1 RECNUM
0001.54 C WRITESFLREC
0001.55 C END
0001.56 C ENDDO
0001.57 C RECNUM IFGT 0
0001.58 C SETON 20
0001.59 C ENDIF
0001.60 C ENDSR
0001.61 C*-------------------------------------------------------------------------
0001.62 C* SUB FILE SFLCLR
0001.63 C*-------------------------------------------------------------------------
0001.64 C SFLCLR BEGSR
0001.65 C MOVE '1' *IN40
0001.66 C WRITESFLCTL
0001.67 C MOVE '0' *IN40
0001.68 C MOVE '0' *IN20
0001.69 C MOVE '0' *IN21
0001.70 C Z-ADD*ZERO RECNUM
0001.71 C ENDSR
0001.61 C*-------------------------------------------------------------------------
0001.62 C* SUB FILE SFLCLR
0001.63 C*-------------------------------------------------------------------------
0001.64 C SFLCLR BEGSR
0001.65 C MOVE '1' *IN40
0001.66 C WRITESFLCTL
0001.67 C MOVE '0' *IN40
0001.68 C MOVE '0' *IN20
0001.69 C MOVE '0' *IN21
0001.70 C Z-ADD*ZERO RECNUM
0001.71 C ENDSR
0001.72 C*-------------------------------------------------------------------------
0002.00 C* SUB FILE CEK
0003.00 C*------------------------------------------------------------------------
0004.00 C CEK BEGSR
0004.01 C* Z-ADDRECNUM SAVRRN
0004.02 C READCSFLREC 30
0004.07 C*
0004.12 C *IN30 DOWNE'1'
0004.17 C PILIH IFEQ 'X'
0004.18 C MOVE NAME NAMAMU
0004.19 C MOVE CITY CITYMU
0004.20 C EXFMTNEWPAGE
0004.21 C UPDATSFLREC
0004.22 C ENDIF
0004.23 C READCSFLREC 30
0004.24 C ENDDO
0004.25 C SNAMA IFEQ *BLANK
0004.26 C 'NKEY' DSPLY
0004.27 C ENDIF
0004.28 C EXSR SFLCLR
0005.00 C ENDSR
0006.00 C*------------------------------------------------------------------------
****************** End of data ************************************************

jalankan dengan memasukan perintah sebagai berikut :
call namaLibrary/namaprogram
misal
Call ciamis/yadiProgram

No comments: