Once%the%Java%object%has%been%instantiated,%we%can%convert%it%into%a%byte%array%using%the%
getByteBuffer()%method.%This%returns%a%serialized%version%of%the%structured%record%defined%in%the%
original%copybook.%
Now%that%we%have%the%data%ready,%we%can%use%this%to%link%to%the%target%program .%
We%create%a%new%instance%of%the%Program%class,%and%specify%the%name%of%the%target%program%that%we%
wish%to%LINK%to%using%the%setName()%method.%%
We%then%invoke%the%link%method%on%our%program%object%-%this%time%passing%the%StockPart%byte%array%%
On%successful%return%from%the%target%program,%any%updates%to%the%commarea%will%be%reflected%in%the%
byte%array.%%
Here,%we%take%the%updated%byte%array%and%construct%a%new%StockPart%object%to%represent%the%
returned%data .%Sub se qu en t%cod e%m a y%the n%rea d%va lue s%from %this%ne w ly-constructed%object%using%the%
accessor%methods.%
A%commarea%is%a%bidirectional%transfer%mechanism,%and%programs%can%use%this%area%to%send%any%
format%of%data %in%eith er%dire ction .%O ur%pre vio us %example%sent%a%record %in%the %Sto ckP art%format,%and%
received%a%record%in%the%same%format.%
%With%a%large%enough%data%area,%any%record%format%can%be%returned.%
In%this%ex a m p le ,%we%use%a%S to c kP a rt %o b jec t%t o %co n s tr u ct %a%b y te %a rra y %th a t%will%be%pas se d %to %a %ta rg e t%
program.%When%called,%that%program%will%look%up%the%sup plier%record%and%pop ulate%the%com ma rea%
with%a%record%format%detailing%the%supplier%of%that%part.%
Having%previously%created%a%suitable%JZOS%class%to%map%the%record%for%a%supplier%-%when%the%link%
method%completes%-%we%can%generate%a%new%instance%of%the%supplier%object%from%the%returned%byte%
array.%The%resulting%object%can%be%queried%for%the%supplier%information.%
CICS%offers%an%optimization%on%a%link%command%by%specifying%the%size%of%the%data%to%the%target%
program%-%a%benefit%also%available%from%the%JCICS%API.%%
As%an%example,%a%part%lookup%routine%may%only%need%a%8-byte%part%number%as%input,%but%will%require%
an%80-byte%commarea%to%return%the%data.%Specifying%the%optional%int%parameter%after%the%byte%array%
allows%the%caller%to%specify%the%data%length%used%on%the%send.%
In%this%ex a m p le ,%a %b yt e%a rr ay %o f%le n g th %8 0 %is %cre a te d %b y %th e %ca llin g %p ro g ra m,%but%the%datalength%is%
specified%as%8.%When%CICS%passes%control%to%the%target%program,%only%the%first%8%bytes%are%
transmitted.%Th e%remainder%of%the%80 -byte%commarea%is%padded%with%zeroes.%When%the%target%
program%returns,%all%80-bytes%are%sent%back%to%the%calling%program.%
This%optimization%can%be%used%to%reduce%CPU%and%response%times,%especially%where%large%commareas%
are%required%for%return%values%or%where%links%flow%between%CICS%systems.%
Recall%that%the%other%method%of%passing%data%from%one%program%to%another%is%by%Channels%and%
Containers.%A%channel%is%a%conduit%between%programs,%it%typically%holds%one%or%more%containers%to%be%
passed%between%the%programs.%A%container%is%a%named%block%of%data.%
Channels%and%containers%offer%the%advantage%that%more%than%32%KB%of%data%can%be%passed.%By%
contrast,%commareas%are%confined%to%a%32%KB%limit.%