You are on page 1of 10

Negotiated limits The following examples depict how the mode controlling

commands (STRMOD, ENDMOD, and CHGSSNMAX)


Total
change the affected modes. The DSPMODSTS command is
Current maximum number of sessions allowed for
used throughout this example to show the transitions that are
this device.
taking place for the modes affected by these commands.
Local This example shows the mode controlling commands being
Current minimum number of locally controlled ses- run at system NEWYORK as they relate to the connection
sions on this device. with location LOSANGEL.
Remote
To show the following display, type
Current minimum number of remotely controlled
sessions on this device. DSPMODSTS DEV(LOSANGEL) MODE(\ALL)
Number for device and press F11 (Display sessions) to display information
about the sessions:
Total
Current active number of sessions on this device.
Local
à ð
Display Mode Status
Current active number of locally controlled ses- Device . . . . . . . . . : LOSANGEL
System: SYSNAMðð

sions on this device. Device status . . . . . . : ACTIVE

Type options, press Enter.


Number for location 5=Display details

Mode --Sessions--
Opt Mode Status Total Local
Total BLANK Started 1 1
#BATCH Started 1 1
Current active number of sessions running for this SNASVCMG Started 1 1
location.
Local the modes after the connection between NEWYORK and
Current active number of locally controlled ses- LOSANGEL has been established. The display shows that
sions for this location. the reserved mode SNASVCMG and that the modes
#BATCH and BLANK have been started. The SNASVCMG
To display all modes for a device, you can type
mode is used by the system for negotiating SNA sessions
DSPMODSTS DEV(LOSANGEL) MODE(\ALL) between two locations as well as alerts between network
and then press the Enter key to obtain the following display: nodes. (In SNA, an alert is a record sent to a focal point to
identify a problem or an impending problem.)

à ð The following display shows what happens when the local


Display Mode Status
System: SYSNAMðð system has started an application that acquires a session.
Device . . . . . . . . . : LOSANGEL
Device status . . . . . . : ACTIVE The mode specified on the DSPMODSTS command is
Type options, press Enter. #BATCH (Note that this is one of the modes specified on the
5=Display details
CRTDEVAPPC command when NEWYORK and LOSANGEL
Mode ---------Conversations---------
Opt Mode
BLANK
Status
Started
Total Source Target Detached
ð ð ð ð
were configured. Refer to Appendix D for details).
#BATCH Started ð ð ð ð
SNASVCMG Started ð ð ð ð

à ð
Display Mode Status
If you then press F11 (Display sessions), the following Device . . . . . . . . . : LOSANGEL
System: SYSNAMðð

display is shown: Device status . . . . . . : ACTIVE

Type options, press Enter.


5=Display details

à ð Opt Mode
Mode
Status
---------Conversations---------
Total Source Target Detached
Display Mode Status BLANK Started ð ð ð ð
System: SYSNAMðð #BATCH Started 1 1 ð ð
Device . . . . . . . . . : LOSANGEL SNASVCMG Started ð ð ð ð
Device status . . . . . . : ACTIVE

Type options, press Enter.


5=Display details
Pressing F11 (Display sessions) gives the previous display
Mode --Sessions--
Opt Mode
BLANK
Status
Started
Total Local
ð ð
showing display mode status for sessions. The displays also
#BATCH
SNASVCMG
Started
Started
ð
ð
ð
ð
show that there is one session that has been established and
one conversation currently in progress between NEWYORK
and LOSANGEL using the mode #BATCH.
These displays show the device name and status. Current
values are also shown for conversations and sessions. From Because all modes for APPN(*NO) start automatically when
these displays you may also select option 5 (Display details) the device description is varied on, you must first end a
for a selected mode. mode using the ENDMOD command before you can issue a
STRMOD command to start a mode. You can then start an

Chapter 4. Running APPC 4-7


IBM-supplied mode BLANK to the remote location Use Option 5 to display the details of the mode status for the
LOSANGEL by issuing the STRMOD command: mode BLANK:
STRMOD RMTLOCNAME(LOSANGEL) MODE(BLANK)
Then press the Enter key to start the mode. (Note that the à ð
Display Details of Mode Status
mode BLANK is the other mode specified on the System: SYSNAMðð
Mode/status . . . . . . . . . . . . . . : BLANK Started
CRTDEVAPPC command during configuration). Device/status . . . . . . .
Local location/network ID .
.
.
.
.
.
.
.
.
.
.
.
.
:
:
LOSANGEL
NEWYORK
ACTIVE
APPC
Remote location/network ID . . . . . . : LOSANGEL APPC

By next issuing the DSPMODSTS command Conversations: Total Source Target Detached
Configured maximum . . . . . . . : 8
Number for device . . . . . . . . : ð ð ð ð
DSPMODSTS DEV(LOSANGEL) MODE(BLANK) Number for location . . . . . . . : ð ð ð ð

Sessions: Total Local Remote


you will see that the mode BLANK has been started, and Configured limits . . . . . . . . : 8 4
Local maximum . . . . . . . . . . : 6
also the session limits that have been negotiated between Negotiated limits . . . . . . . . : 6 3 3
Number for device . . . . . . . . : ð ð
NEWYORK and LOSANGEL. Because the DSPMODSTS Number for location . . . . . . . : ð ð

command was started by supplying the mode name, the Press Enter to continue.
Bottom

display that is shown is the one that shows the details of the F3=Exit F5=Refresh F12=Cancel F14=Display previous mode
mode status:
á ñ
à ð As this display shows, the configured limits for the mode are
Display Details of Mode Status

Mode/status . . . . . . . . . . . . . . : BLANK
System:
Started
SYSNAMðð not affected by the CHGSSNMAX command. What has
Device/status . . . . . . .
Local location/network ID .
.
.
.
.
.
.
.
.
.
.
.
.
:
:
LOSANGEL
NEWYORK
ACTIVE
APPC
changed are the negotiated limits between NEWYORK and
Remote location/network ID . . . . . . : LOSANGEL APPC
LOSANGEL using mode BLANK.
Conversations: Total Source Target Detached
Configured maximum . . . . . . . : 8
Number for device . . . . . . . . :
Number for location . . . . . . . :
ð
ð
ð
ð
ð
ð
ð
ð
To end all of the user modes between NEWYORK and
Sessions: Total Local Remote LOSANGEL, you can use the ENDMOD command. Once this
Configured limits . . . . . . . . : 8 4
Local maximum . . . . . . . . . . : 8 command has been run, no new sessions can be started
Negotiated limits . . . . . . . . : 8 4 4
Number for device . . . . . . . . : ð ð between the two locations on modes BLANK and #BATCH
Number for location . . . . . . . : ð ð
until another explicit STRMOD command is run. Type
Bottom
Press Enter to continue.
ENDMOD RMTLOCNAME(LOSANGEL) MODE(\ALL)
F3=Exit F5=Refresh F12=Cancel F14=Display previous mode
To display the mode status, type
á ñ
DSPMODSTS DEV(LOSANGEL)
To change the maximum number of sessions allowed
between locations NEWYORK and LOSANGEL, you can use à ð
the CHGSSNMAX command. If you want to change the Display Mode Status
System: SYSNAMðð
maximum number of sessions specified for the mode BLANK Device . . . . . . . . . :
Device status . . . . . . :
LOSANGEL
ACTIVE
from 8 to 6, for example, type Type options, press Enter.
5=Display details
CHGSSNMAX RMTLOCNAME(LOSANGEL) MODE(BLANK) Mode ---------Conversations---------
MAXSSN(6) Opt Mode Status Total Source Target Detached
BLANK Ended ð ð ð ð
5 #BATCH Ended 1 1 ð ð
To show the mode status, type SNASVCMG Started ð ð ð ð

DSPMODSTS DEV(LOSANGEL) MODE(\ALL)


Note: Only the user modes #BATCH and BLANK are
affected by the ENDMOD command. The reserved
à ð mode SNASVCMG is not affected by the ENDMOD
Display Mode Status
System: SYSNAMðð
Device . . . . . . . . . : LOSANGEL command.
Device status . . . . . . : ACTIVE

Type options, press Enter.


5=Display details Use Option 5 to display the details of the mode status for the
Mode ---------Conversations--------- mode #BATCH:
Opt Mode Status Total Source Target Detached
5 BLANK Started ð ð ð ð
#BATCH Started 1 1 ð ð
SNASVCMG Started ð ð ð ð

4-8 OS/400 APPC Programming V4R1


and one active conversation between NEWYORK and
à ð LOSANGEL using mode #BATCH.
Display Details of Mode Status
System: SYSNAMðð
Mode/status . . . . . . . . . . . . . . : #BATCH Ended
Device/status . . . . . . . . . . . . . : LOSANGEL ACTIVE To display the mode status, type
Local location/network ID . . . . . . . : NEWYORK APPC
Remote location/network ID . . . . . . : LOSANGEL APPC
DSPMODSTS DEV(LOSANGEL)
Conversations: Total Source Target Detached
Configured maximum . . . . . . . : 8
Number for device . . . . . . . . : 1 1 ð ð The DSPMODSTS command shown here occurred after the
Number for location . . . . . . . : 1 1 ð ð
application that had acquired a session using mode #BATCH
Sessions: Total Local Remote
Configured limits . . . . . . . . : 8 4 has ended. This caused the session and conversation
Local maximum . . . . . . . . . . : ð
Negotiated limits .
Number for device .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
:
:
ð
1
ð
1
ð counts to go to zero.
Number for location . . . . . . . : 1 1

Bottom
Press Enter to continue. à ð
F3=Exit F5=Refresh F12=Cancel F14=Display previous mode Display Mode Status
System: SYSNAMðð
Device . . . . . . . . . : LOSANGEL
á ñ Device status . . . . . . : ACTIVE

Type options, press Enter.


5=Display details
The ENDMOD command causes the mode #BATCH to end, Mode ---------Conversations---------
Opt Mode Status Total Source Target Detached
but it does not affect sessions that have already been acti- BLANK Ended ð ð ð ð
#BATCH Ended ð ð ð ð
vated. This is the reason that there is still one active session SNASVCMG Started ð ð ð ð

Chapter 4. Running APPC 4-9


4-10 OS/400 APPC Programming V4R1
Chapter 5. Writing ICF APPC Application Programs
This chapter describes how an application program uses the
AS/400 system, intersystem communications function (ICF)
Intersystem Communications Function File
file, and APPC to communicate with a remote system. The
An intersystem communications function (ICF) file must be
program can be coded using any of the high-level languages
created before your application can use APPC. For more
that support ICF, such as ILE C/400, ILE COBOL/400,
information about the ICF file, see the ICF Programming
FORTRAN/400, and ILE RPG/400. These languages allow
book.
an application program to do the following:
Ÿ Start a session by opening a file and acquiring a The ICF file is a system object of type *FILE with a specific
program device either explicitly or implicitly. set of commands and operations. The commands allow you
to manage the attributes of the file and the operations allow
Ÿ Send or receive information by writing to or reading from
a program to use the file. Commands allow you to create,
a program device.
delete, change and display the file description.
Ÿ End a session by releasing the program device and
closing the file. The following commands are valid for APPC applications.
Note: FORTRAN/400 supports only the following CRTICFF
operations: Create ICF file and file level attributes. This command
allows you to create an ICF file.
Ÿ Open with acquire
CHGICFF
Ÿ Close
Change ICF file. This command allows you to change
Ÿ Read the file attributes of the ICF file.
Ÿ Write OVRICFF
Override ICF file. This command allows you to tempo-
For more information about the languages, refer to the rarily change the file attributes of the ICF file at run
appropriate language reference manual. Chapter 7 contains time. These changes are only in effect for the duration
additional information about writing applications that use of the job and do not affect other users of the file.
APPC.
DLTF
This chapter also contains the following information: Delete file. This command allows you to delete a file
from the system.
Ÿ A description of the read and write operations that
specify a record format, which contains specific commu- DSPFD
nications functions. You can define record formats using Display file description. This command displays the file
data description specifications (DDS) keywords, or you description of any file on the system. The information
can use system-supplied formats. may be printed or displayed.
Ÿ Information about using return codes. After an ICF oper- DSPFFD
ation completes, a return code (and a high-level lan- Display file field description. This command displays
guage file status) is returned to your application. The the description of the fields in any file on the system.
return code indicates whether the operation completed This information may be printed or displayed.
successfully or unsuccessfully. Along with the return ADDICFDEVE
code, exception messages may also be issued. Refer to Add ICF device entry. This command allows you to
Appendix B, Sense Data and Return Codes for more permanently add a program device entry that contains
information about return codes and to the appropriate a program device name, remote location information,
language reference manuals for more information about and session level attributes.
the high-level language file status.
CHGICFDEVE
Ÿ A mapping of the LU type 6.2 architected verbs and Change ICF device entry. This command allows you to
parameters to the corresponding ICF operation or func- permanently change the program device attributes pre-
tion. This information is useful if you are writing applica- viously added with the ADDICFDEVE command.
tion programs that are used for communications between
an AS/400 system and another system, such as a OVRICFDEVE
System/370 or personal computer, that supports APPC. Override ICF device entry. This command allows you
to:
Ÿ Temporarily add the program device entry, the
remote location information, and the session level
attributes to the ICF file.

 Copyright IBM Corp. 1997 5-1


Ÿ Override a program device entry with the specified minor error return code is returned when an attempt is
remote location information and session level attri- made to acquire the program device.
butes for an ICF file.
*LOC: Specifies that the local location name is to be
RMVICFDEVE determined by the system.
Remove ICF device entry. This command allows you
*NETATR: Specifies that the local location name speci-
to permanently remove the program device entry previ-
fied in the system network attributes is used.
ously added with the ADDICFDEVE command or
changed with the CHGICFDEVE command. local-location name: Specify the name of your location.
MODE
Specifies the mode to be used.
Specifying the Program Device Entry
*NETATR: Specifies that the mode specified in the
Commands system network attributes is used.
The following describes the parameters for the BLANK: The mode name, consisting of 8 blank charac-
ADDICFDEVE, CHGICFDEVE, and OVRICFDEVE com- ters, is used.
mands and lists the values for each parameter for APPC. For mode-name: Specify a mode name for the remote
more information about how the system processes the location. If the mode is not valid for any combination of
location parameters (RMTLOCNAME, DEV, LCLLOCNAME, remote location device, local location, and remote
RMTNETID, and MODE), refer to “Using the Location network ID, a major and minor error return code is
Parameters” on page 3-3. returned when an attempt is made to acquire the
PGMDEV program device.
Specifies the program device name that is defined in the RMTNETID
ICF file and specified in the application. The total Specifies that the remote network ID used with the
number of devices that may be acquired to an ICF file is remote location.
determined by the MAXPGMDEV parameter on the
CRTICFF or CHGICFF command. *LOC: Specifies that the remote network ID for the
remote location should be used. If several remote
pgm-device name: Enter the name by which the user network IDs are associated with the remote location, the
program refers to this communications session. system automatically selects the remote network ID.
RMTLOCNAME *NETATR: Specifies the remote network ID specified in
Specifies the remote location name with which your the network attributes is used.
program communicates. A remote location must be
*NONE: The remote network has no name.
specified using the ADDICFDEVE, CHGICFDEVE, or
OVRICFDEVE command. If a remote location name is remote-network id: Specify a remote network ID.
not specified, a major and minor error return code is
FMTSLT
returned when an attempt is made to acquire the
Specifies the type of record selection used for input
program device.
operations.
*REQUESTER: The name used to refer to the communi-
*PGM: The program determines what record formats are
cations device through which the program was remotely
selected.
started.
*RECID: The RECID keywords specified in the DDS for
location-name: Enter the name of the remote location
the ICF file are used to select records.
that should be associated with the program device.
*RMTFMT: The remote format name received from the
DEV sending system is used to select records.
Specifies the name of the device description used for the
remote location. If the device is not valid for the remote CNVTYPE
location, a major and minor error return code is returned Specifies the conversation type for which the application
when an attempt is made to acquire the program device. program is designed. For additional information, refer to
“APPC Sessions and Conversations” on page 3-1.
*LOC: Specifies that the device is to be determined by *SYS: Specifies that the system gives the length and
the system. general data stream identifier values that go before each
section of user data in APPC communications. The
device-name: Specify the name of the device that is
application gives the data portion of the general data
associated with the remote location.
stream on output operations and receives only the data
LCLLOCNAME portion of the general data stream on input operations.
Specifies the name of your location. If the local location For the LU type 6.2 architecture, this is the mapped con-
name is not valid for the remote location, a major and versation support.

5-2 OS/400 APPC Programming V4R1


*USER: Specifies that the application program gives the Ÿ The send buffer is full.
length and general data stream identifier values that go
Ÿ The program does an operation using an ALWWRT,
before each section of user data. The application gives
CONFIRM, DETACH, FRCDTA, INVITE, or PRPCMT
the length and general data stream values in the first
keyword.
4 bytes of output data and receives the length and
general data stream values in the first 4 bytes of input Ÿ The program does a commit or rollback operation.
data. For the LU type 6.2 architecture, this is the basic The DFREVOKE keyword is useful for specialized applica-
conversation support. tions in which data must be sent at the same time as the
*SRCPGM: Specifies that the target program accepts program start request.
the conversation type specified by the source program. Note: If you have an APPC device configured with the
single session location as *YES (that is,
OVRFLWDTA
SNGSSN(*YES)), you can only have one active
Specifies whether overflow data is discarded or kept.
session and one active transaction at any given time.
Overflow data is the excess data that occurs when your
However, if your program acquires a session, uses
print buffer is not able to receive all of a lengthy input
an evoke function to start a program on that session,
operation.
and then sends or receives a detach function, your
*DISCARD: Specifies that overflow data is truncated. program is no longer connected to the session it pre-
*RETAIN: Specifies that overflow data is kept and can viously acquired. A program running in a different job
be obtained on the next input operation. can then acquire your old session, provided a conver-
sation is available on the mode associated with that
session. If your program attempts another evoke
function to start a program on the old session, it will
Communications Operations and
fail.
Functions
With the evoke function your program can specify the fol-
This section gives a brief description of the operations and lowing information:
functions you can code into a program that uses the APPC
support to communicate with another system. Ÿ Remote program name
Ÿ Remote library name (optional)
Common functions such as RECID are not described in this
publication. You should refer to the ICF Programming book Ÿ User-defined program initialization parameters (optional)
or the DDS Reference for additional information. Ÿ Synchronization level (optional)
Ÿ Security information (optional)
Starting a Session Using the Open and
If your program uses the EVOKE, SECURITY, and SYNLVL
Acquire Operations
keywords, you can specify all of the above information. If
A communications session is a logical connection between your program is using one of the evoke system-supplied
two systems through which a local program can communi- formats, you can specify all of the above except synchroniza-
cate with a program at a remote location. Your application tion level. In this case the default for the synchronization
program uses the open and acquire operation to establish a level is always *NONE.
session, which is controlled by your system (locally con-
For information on how to code the evoke function refer to
trolled) or by the remote system (remotely controlled).
the ICF Programming book and the DDS Reference.

Starting a Transaction Using the Evoke Notes:


Function 1. If a program start request is received on the AS/400
system with an unqualified program name, (that is, it has
A transaction is a logical connection between two programs, no library name) the system uses the library list specified
and is equivalent to establishing a conversation between the on the QUSRLIBL system value at the time the sub-
two programs. Your program uses the evoke function to start system that is handling the program start request was
a program on the remote system after a session is started. started.
The evoke function causes a program start request (an
APPC FMH5) to be sent. It is only valid when your program 2. If a program start request is received on the AS/400
is not already communicating with another program on the system with a qualified program name, the program
same session. name can be in the form 'program.library' or in the form
'library/program'.
You can use the defer evoke (DFREVOKE) keyword with 3. Program names and library names on the AS/400
the EVOKE keyword to delay the evoke function until one of system are limited to 10 characters each.
the following conditions is met.

Chapter 5. Writing ICF APPC Application Programs 5-3


Program Initialization Parameters 3. The DFREVOKE keyword is not supported by system-
supplied formats.
When using EVOKE DDS keyword
If your program is using DDS keywords, it may send These notes pertain to both the DDS keyword and the
up to 255 user-defined parameters to the remote system-supplied formats for specifying program initialization
system. The number and format of the parameters is parameters.
defined by the target program. If the remote system is
another AS/400 system, the parameters are passed to Synchronization Level: When using DDS keywords,
the target program as if they were passed from a call you specify the synchronization level by using the SYNLVL
to a program (CALL) command. For a prestart job keyword. The SYNLVL keyword supports the following
program, the parameters are retrieved from a data values:
area using the Retrieve Data Area (RTVDTAARA)
command or the appropriate high-level language oper- Ÿ *NONE: Specifies that confirm or two-phase commit
ation (such as the COBOL ACCEPT statement). processing is not allowed on this transaction. This is the
default value.
If the remote system is an AS/400 system, a maximum
of 40 parameters may be passed. The total length of Ÿ *CONFIRM: Specifies that the sending program can
the user-defined parameters cannot exceed 32,767 request the receiving program to acknowledge receipt of
characters. For a prestart job, the length of the user- the data. The receiving program can send a positive
defined parameters cannot exceed 2000 bytes. To acknowledgement, or the receiving program or system
determine the total length of the data to be sent, use can send a negative acknowledgement. Two-phase
the following formula: commit processing is not allowed on
SYNLVL(*CONFIRM) transactions. Refer to “Confirm
4 + (4 + length(parm1) + 4 + Considerations” on page 7-3 for more information about
length(parm2) + ... + 4 + length(parmn)) confirm processing. Also, refer to the descriptions of the
The constant 4 must be included to allow for system CONFIRM, RSPCONFIRM, and RCVCONFIRM
overhead. keywords for more information on confirm processing.
When using evoke system-supplied formats Ÿ *COMMIT: Allows the programs to operate as described
If your program is using one of the evoke system- for the *CONFIRM value. Moreover, *COMMIT requires
supplied formats, you specify the parameters in the programs to use two-phase commit processing to protect
user buffer. Because this does not allow you to specify their resources. Two-phase commit processing allows
individual parameters, you can only pass one param- programs to synchronize updates to protected resources
eter or you must know how the remote system sepa- (such as databases). If necessary, updates can be rolled
rates program initialization parameters and use that back, so that the resources remain synchronized. Refer
separator to code the parameters in the user buffer. to the descriptions of the PRPCMT, RCVROLLB, and
For example, a System/36 separates parameters with RCVTKCMT keywords for more information on two-
a comma. If you want the program initialization param- phase commit processing. The Backup and Recovery
eter data to be treated as individual parameters by a book has information about commitment control and the
System/36, you should code your user buffer with each commit and rollback operations, which are an essential
parameter separated by a comma. part of two-phase commit processing.

Notes: Notes:
1. When sending program parameters as part of the evoke 1. Your program cannot specify a synchronization level
data stream, ensure each parameter sent is the same when using one of the evoke system-supplied formats.
length as the respective parameter in the target In this case the synchronization level always defaults to
program. If it is longer than the respective target *NONE.
program parameter, truncation occurs. If it is shorter, 2. Simply specifying SYNLVL(*CONFIRM) does not cause
unpredictable results may occur. confirm processing to occur; it only means that confirm
2. For program start requests received on an AS/400 processing will be allowed. To perform confirm proc-
system, commas embedded within parameters cause essing, you must specify the CONFIRM keyword or the
what would otherwise be a single parameter to be con- TNSSYNLVL keyword.
sidered multiple parameters. For example: 3. The TNSSYNLVL keyword can be used with all synchro-
Parm 1="A" nization levels. For more information about the
Parm 2="B,C" TNSSYNLVL keyword, see “Transaction-
Parm 3="D,E" Synchronization-Level Function” on page 5-6.
Instead of being three parameters, this example is con-
sidered five separate parameters.

5-4 OS/400 APPC Programming V4R1


Security: If your program is using DDS keywords, security determine the synchronization level established by
information for the evoke function is provided with the SECU- the source program by using the get-attributes opera-
RITY keyword. If your program is using one of the evoke tion. Refer to “Get-Attributes Operation” on page 5-9
system-supplied formats, security information is provided in for more information.
the evoke parameter list coded in your program. The default
value is to send no security information with the evoke func- The confirm function causes any data currently held in the
tion. Refer to “APPC Security Considerations” on page 3-12 buffer to be sent, including any data on a write operation that
for information about APPC security. specified the confirm function. Refer to “Confirm
Considerations” on page 7-3 for additional information.

Sending Data Prepare-for-Commit Function


You can send data during a transaction using the write oper- Your program uses the prepare-for-commit (PRPCMT)
ation. APPC also supports various functions that are dis- function to request one of its partners to prepare to commit
cussed below. These functions may be issued by your its protected resources. The partner can respond with a
program to another program with or without data. commit, a rollback, or a FAIL operation. If the partner
responds with a FAIL operation, the partner program is in
Note: These functions can be used only when your program
control and can attempt to correct any errors that it detected.
is in send state. For more information about sending
and receiving data, see “Conversations” on page 3-1. The PRPCMT function contrasts with the commit operation in
the following ways:
Control-Data Function Ÿ PRPCMT only works with one conversation at a time.
The commit operation attempts to commit all protected
Your program uses the control-data (CTLDTA) keyword at
resources in the two-phase commit transaction program
the file or record level to inform the remote program that
network.
control data is being sent. The CTLDTA keyword signals
program-specific data that is not considered normal data Ÿ PRPCMT only prepares the remote protected resources
flow. to be committed. In other words, the remote resources
have been locked and cannot be changed. They are in a
The CTLDTA keyword has no additional affect when the state in which they can either be committed or rolled
EOS, RSPCONFIRM, or RQSWRT keywords are in effect. backed. Eventually, the remote resources are com-
mitted or rolled back depending on whether the rest of
the two-phase commit transaction program network
Force-Data Function commits or rolls back its protected resources.
Your program uses the force-data (FRCDTA) function to The commit operation ends only after all remote pro-
immediately send communications data currently held in the tected resources in the two-phase commit transaction
buffer without waiting for the buffer to become full. Your program network have either been committed or rolled
program can continue to send data without waiting for confir- back.
mation to be returned, but your program must be in send
Ÿ PRPCMT allows the application program to attempt error
state.
recovery without rolling back the protected logical unit of
The FRCDTA keyword has no additional effect when the work (LUW). When the application program issues a
keywords ALWWRT, CONFIRM, DETACH, EVOKE, INVITE, PRPCMT and the partner responds with a fail function,
or FAIL are also selected. the PRPCMT function completes. The application
program can then attempt error recovery, and issue the
PRPCMT function again. The fail function is described in
Confirm Function “Notifying the Remote Program of Problems by Using
the Fail Function” on page 5-8.
Your program uses the confirm function to indicate the end
of a user-defined group of data and requests that the remote Note: The remote program is in send state after
program acknowledge that it has accepted the data. An oper- responding with the fail function. The local appli-
ation that includes the confirm function does not complete cation program cannot issue the PRPCMT func-
until the remote program responds with a positive or negative tion again until the conversation states change.
acknowledgment. When the application program issues a commit operation
Note: The confirm function only applies when and the partner responds with a fail function, the logical
SYNLVL(*CONFIRM) or SYNLVL(*COMMIT) is speci- unit of work is rolled back.
fied in the EVOKE DDS record format used by the An operation that includes the prepare-for-commit function
source program, or when the program start request does not complete until the remote program responds with a
received by a target program establishes a synchroni- commit or rollback operation or a FAIL or EOS function.
zation level of confirm. An AS/400 target program can

Chapter 5. Writing ICF APPC Application Programs 5-5


After the PRPCMT function completes successfully, your program. This function should also only be used if the remote
program can do any one of the following. system is able to receive the APPC architected map name
GDS ID variable. For example, the AS/400 system and
Ÿ Use the commit operation to commit protected
System/38 support receipt of map names; System/36 does
resources.
not.
Ÿ Use the rollback operation to roll back the protected
logical unit of work (LUW). When sending and receiving format names between AS/400
systems, you should specify FMTSLT(*RMTFMT) on the
Ÿ Use the end-of-session function to end the attachment of
ADDICFDEVE, CHGICFDEVE, or OVRICFDEVE commands.
the program to a session and roll back the protected
LUW.
Note: The prepare-for-commit function only applies when Variable-Buffer-Management Function
SYNLVL(*COMMIT) is specified in the EVOKE DDS
If you want to send multiple or partial records using one write
record format used by the source program, or when
operation, then your program can use the variable-buffer-
the program start request received by a target
management (VARBUFMGT) function.
program establishes a synchronization level of
commit. An AS/400 target program can determine the Using the VARBUFMGT keyword allows you to specify the
synchronization level established by the source length of data independently of the data itself. A program
program by using the get-attributes operation. Refer uses the data length specified as the value passed in the
to “Get-Attributes Operation” on page 5-9 for more variable length (VARLEN) DDS keyword, or if VARLEN is not
information. used, the length of the record format specified on the write
operation is used. Note that the length specified on the
The prepare-for-commit function causes any data currently
VARLEN keyword must be greater than zero if it is used.
held in the buffer to be sent, including any data on a write
operation that specified the prepare-for-commit function. Note: The variable-buffer-management function can only be
Refer to “Two-Phase Commit Considerations” on page 7-4 used with basic conversations (that is, with
for additional information. CNVTYPE (*USER) on the ADDICFDEVE,
CHGICFDEVE, or OVRICFDEVE commands for the
source program, or with CNVTYPE (*USER) or
Transaction-Synchronization-Level CNVTYPE (*SRCPGM) for the target program).
Function Figure 5-1This example shows only one of many
ways to perform this task. You can also write a
Your program uses the transaction-synchronization-level
program that will send multiple variable-length
(TNSSYNLVL) function to specify that synchronization for this
records. In addition, other programming languages
transaction should be done at the level that the SYNLVL
may be used.
keyword specified on the evoke.

The TNSSYNLVL keyword can only be used if specified with R EXAMPLE1 VARBUFMGT
one of the following keywords. REC1 3ð

Ÿ ALWWRT R EXAMPLE2 VARBUFMGT


Ÿ DETACH VARLEN(&VLEN);
REC2 3ð
Ÿ INVITE VLEN 5S P
The following topics have more information about the Figure 5-1. DDS Used for Variable-Buffer-Management Example
transaction-synchronization-level function. Program

Ÿ “Allow-Write Function” on page 5-9


ð1 VARBUF1.
Ÿ “Ending a Transaction Using the Detach Function” on ð5 ARRAY OCCURS 3 TIMES.
page 5-9 1ð RECORD-LENGTH PIC 99 COMP-4.
1ð RECORD-DATA PIC X(8).
Ÿ “Invite Function” on page 5-7

Figure 5-2 (Part 1 of 3). COBOL/400 Example Program for


Format-Name Function Sending Multiple Fixed-Length Records

Your program uses the format-name (FMTNAME) function


to send the record format name, along with any data speci-
fied, to the remote system. The format name can only be
used with mapped conversations (conversations in which
CNVTYPE (*SYS) is specified on the ADDICFDEVE,
CHGICFDEVE, and OVRICFDEVE commands for the source

5-6 OS/400 APPC Programming V4R1

You might also like