SVFileServiceの例
この簡単なフォームにより、個別の変数ファイルからのデータの読み込みや、そのファイルへの書き込みを行うことができます。
* Uses Integrator Services: SVFileService
* This forms connects to the local JSM Server and allows SV files to be read, with the resulting information displayed in a list,
* or written, based on the information currently in the list.
*
* The browse and working list definitions are defined with 5 columns to support the definition of an order.
* The following field must be defined in your repository:
* jsmstring string 1000
*
jsmsts alpha 20
* jsmmsg alpha 255
* jsmhdle char 4
* jsmcmd alpha
4
function options(*DIRECT)
begin_com role(*EXTENDS #PRIM_FORM) clientheight(573) clientwidth(692) framestyle(Dialog) height(607) left(441) top(129) width(700)
define_com class(#PRIM_PHBN) name(#Connect) caption('Connect') displayposition(1) left(5) parent(#PANL_2) tabposition(1) top(5) width(120)
define_com class(#PRIM_PHBN) name(#Read) caption('Read') displayposition(2) enabled(False) left(135) parent(#PANL_2) tabposition(2) top(5) width(120)
define_com class(#PRIM_PHBN) name(#Disconnect) caption('Disconnect') displayposition(5) enabled(False) left(525) parent(#PANL_2) tabposition(5) top(5) width(120)
define_com class(#PRIM_PHBN) name(#Write) caption('Write') displayposition(3) enabled(False) left(265) parent(#PANL_2) tabposition(3) top(5) width(120)
define_com class(#PRIM_PHBN) name(#Clear) caption('Clear') displayposition(4) enabled(False) left(395) parent(#PANL_2) tabposition(4) top(5) width(120)
define_com class(#PRIM_STBR) name(#stbr_1) displayposition(1) height(24) left(0) messageposition(1) parent(#PANL_1) tabposition(1) tabstop(False) top(77) width(692)
define_com class(#PRIM_PANL) name(#PANL_1) displayposition(2) height(101) left(0) parent(#COM_OWNER) tabposition(2) tabstop(False) top(472) width(692)
define_com class(#PRIM_PANL) name(#PANL_2) displayposition(2) height(34) left(5) parent(#PANL_1) tabposition(2) tabstop(False) top(34) width(692)
define_com class(#PRIM_grid) name(#detaillst) columnbuttonheight(15) componentversion(1) displayposition(1) height(366) left(0) parent(#COM_OWNER) selectionstyle(Multiple) tabposition(1) top(94) width(692)
define_com class(#PRIM_gdcl) name(#linenum) caption('Line') captiontype(Caption) displayposition(1) parent(#detaillst) readonly(False) source(#STD_NUM) width(15)
define_com class(#PRIM_gdCL) name(#partnum) caption('Part') captiontype(Caption) displayposition(2) parent(#detaillst) readonly(False) source(#STD_OBJ) width(14)
define_com class(#PRIM_gdCL) name(#partdsc) caption('Description') captiontype(Caption) displayposition(3) parent(#detaillst) readonly(False) source(#STD_DESC) width(30)
define_com class(#PRIM_gdCL) name(#partamt) caption('Unit Amount') captiontype(Caption) displayposition(4) parent(#detaillst) readonly(False) source(#STD_AMNT)
define_com class(#PRIM_gdCL) name(#partqty) caption('Quantity') captiontype(Caption) displayposition(5) parent(#detaillst) readonly(False) source(#STD_QTY) widthtype(Remainder)
define_com class(#JSMSTRING.Visual) name(#jsmfile) caption('Path and File Name') displayposition(3) height(19) labeltype(Caption) left(10) marginleft(100) parent(#COM_OWNER) tabposition(3) top(16) usepicklist(False) width(594)
define_com class(#PRIM_GPBX) name(#GPBX_1) caption('SV type') displayposition(4) height(45) left(8) parent(#COM_OWNER) tabposition(4) tabstop(False) top(40) width(281)
define_com class(#PRIM_RDBN) name(#CSV) buttonchecked(True) caption('CSV') displayposition(1) height(21) left(16) parent(#GPBX_1) tabposition(1) top(16) width(50)
define_com class(#PRIM_RDBN) name(#TSV) caption('TSV') displayposition(3) left(88) parent(#GPBX_1) tabposition(3) top(16) width(50)
define_com class(#PRIM_RDBN) name(#SV) caption('Other') displayposition(2) left(152) parent(#GPBX_1) tabposition(2) top(16) width(50)
define_com class(#STD_descs.Visual) name(#separator) displayposition(4) height(19) labeltype(Caption) left(200) marginleft(2) parent(#GPBX_1) tabposition(4) top(16) usepicklist(False) width(70)
def_list name(#valueslst) fields(#std_num #std_obj #std_desc #std_amnt #std_qty) counter(#listcount) type(*working)
evtroutine handling(#com_owner.Initialize)
#jsmhdle := *default
#com_owner.clearlists
#com_owner.setlist
endroutine
evtroutine handling(#Connect.Click)
#com_owner.Connect
endroutine
evtroutine handling(#Read.Click)
#com_owner.ReadSVFile
endroutine
evtroutine handling(#Disconnect.Click)
#com_owner.DisConnect
endroutine
evtroutine handling(#Write.Click)
#com_owner.WriteSVFile
endroutine
evtroutine handling(#Clear.Click)
#com_owner.ClearLists
#com_owner.SetList
endroutine
mthroutine name(Connect)
if (#jsmhdle.IsNull)
* connect the JSMX client to the Java Service Manager and start a thread for the service
* Start JSM Server on IBM
i
* use builtin(jsmx_open) with_args('ISERIES01:9990') to_get(#jsmsts #jsmmsg #jsmhdle)
* Start default JSM server
use builtin(jsmx_open) to_get(#jsmsts #jsmmsg #jsmhdle)
#com_owner.check( #jsmsts #jsmmsg )
* Load the service
#jsmcmd := 'service_load service(svfileservice)'
use builtin(jsmx_command) with_args(#jsmhdle #jsmcmd) to_get(#jsmsts #jsmmsg)
#com_owner.check( #jsmsts #jsmmsg )
#connect.enabled := false
#read.enabled := true
#write.enabled := true
#clear.enabled := true
#disconnect.enabled := true
endif
endroutine
mthroutine name(ReadSVFile)
* add variables for any additional keywords you need to modify
#jsmcmd := 'read file(' + #jsmfile + ')'
if (#csv.buttonchecked)
#jsmcmd := #jsmcmd + ' content(*csv)'
endif
if (#tsv.buttonchecked)
#jsmcmd := #jsmcmd + ' content(*tsv)'
endif
if (#sv.buttonchecked)
if (#com_owner.checksv = false)
return
endif
#jsmcmd := #jsmcmd + ' content(*sv) separator(' + #separator + ')'
endif
#com_owner.ClearLists
use builtin(jsmx_command) with_args(#jsmhdle #jsmcmd) to_get(#jsmsts #jsmmsg #valueslst)
#com_owner.check( #jsmsts #jsmmsg )
selectlist named(#valueslst)
add_entry to_list(#detaillst)
endselect
* add some blank entries to allow for additions to the file
#std_obj #std_desc #std_amnt #std_qty := *null
#std_num := #listcount
begin_loop using(#std_count) to(20)
#std_num := #std_num + 1
add_entry to_list(#detaillst)
end_loop
endroutine
mthroutine name(WriteSVFile)
clr_list named(#valueslst)
selectlist named(#detaillst)
if (#std_obj <> *blank)
add_entry to_list(#valueslst)
endif
endselect
* add variables for any additional keywords you need to modify
#jsmcmd := 'write file(' + #jsmfile + ')'
if (#csv.buttonchecked)
#jsmcmd := #jsmcmd + ' content(*csv)'
endif
if (#tsv.buttonchecked)
#jsmcmd := #jsmcmd + ' content(*tsv)'
endif
if (#sv.buttonchecked)
if (#com_owner.checksv = false)
return
endif
#jsmcmd := #jsmcmd + ' content(*sv) separator(' + #separator + ')'
endif
use builtin(jsmx_command) with_args(#jsmhdle #jsmcmd) to_get(#jsmsts #jsmmsg #valueslst)
#com_owner.check( #jsmsts #jsmmsg )
endroutine
mthroutine name(ClearLists)
clr_list named(#valueslst)
clr_list named(#detaillst)
endroutine
mthroutine name(SetList)
#std_obj #std_desc #std_amnt #std_qty := *null
begin_loop using(#std_num) to(20)
add_entry to_list(#detaillst)
end_loop
endroutine
mthroutine name(DisConnect)
if (#jsmhdle <> *blank)
* disconnect from IBM
i host
use builtin(jsmx_command) with_args(#jsmhdle disconnect) to_get(#jsmsts #jsmmsg)
#com_owner.check( #jsmsts #jsmmsg )
* unload the service
use builtin(jsmx_command) with_args(#jsmhdle service_unload) to_get(#jsmsts #jsmmsg)
#com_owner.check( #jsmsts #jsmmsg )
* Close the thread
use builtin(jsmx_close) with_args(#jsmhdle) to_get(#jsmsts #jsmmsg)
#jsmhdle := *null
#connect.enabled := true
#read.enabled := false
#write.enabled := false
#clear.enabled := false
#disconnect.enabled := false
endif
endroutine
* check the JSM return status
mthroutine name(check)
define_map for(*input) class(#jsmsts) name(#i_status)
define_map for(*input) class(#jsmmsg) name(#i_message)
message msgtxt(#i_status + ' :' +
#i_message)
endroutine
mthroutine name(checkSV)
define_map for(*result) class(#std_bool) name(#i_state) mandatory('true')
if (#separator *EQ *blank)
use builtin(message_box_show) with_args(ok ok ERROR ERROR 'Character used as separator must be entered')
#i_state := false
endif
endroutine
end_com