Using Intersystem Communication Function Files - IBM-ILE

An Intersystem Communications Function (ICF) file defines the layout of the data sent and received between two programs on different systems and links you to the configuration objects that are used to communicate with a remote system. The ICF Programming manual contains information about ICF files.

I/O Considerations for Intersystem Communication Function Files

  • An ILE C/C++ program can process ICF files as program described files or as externally described files (the system file QSYS/QICDMF contains a system-supplied record format).
  • The concept of clearing or opening a file using append mode does not apply to ICF files. If you open an ICF file using append mode (ar+ or ab+), the file is opened for input and output.
  • If you want to write a variable length of data, you must use the keyword VARLEN in the DDS.
  • ICF locale mode can be disabled at the application level by setting the maximum program devices number to 2 or greater for all ICF files on the CRTICFF command.

Opening ICF Files as Binary Stream Files

To open an iSeries ICF file as a binary stream file for record-at-a-time processing, use the fopen() function with one of the following modes:

•rb •wb and ab •ab+

Note: The only way to create an ICF file is to use the CRTICFF command. If you use the fopen() function and the ICF file does not exist, a physical database file is created.

The valid keyword parameters are:

•type •indicators

I/O Considerations for Binary Stream ICF Files

The fwrite() function returns the number of elements that are successfully written. When you use PDATA, the value returned by the fwrite() function does not take PDATA into consideration. When using PDATA, errno is set to ETRUNC even though all the data was successfully written.

Program Devices for Binary Stream ICF Files

The program device that is associated with ICF files is a communications session. You establish the default device by implicitly acquiring it using the fopen() function.

Binary Stream Functions for ICF Files

Use the following binary stream functions to process ICF files:

  • fclose()
  • fopen()
  • fread()
  • freopen()
  • fwrite()

Opening ICF Files as Record Files

To open an iSeries ICF file as a record file, use the _Ropen() function with one of the following modes:

•rr •rr+ and wr+ ar+ •wr and ar

The valid keyword parameters are:

•indicators •riofb •secure

I/O Considerations for Record ICF Files

The _Rwrite() function returns the number of characters that are successfully transferred across a communication line. When you use PDATA, unlike the _fwrite() function, the value that is returned by the _Rwrite() function (num_bytes) includes PDATA.

Program Devices for Record ICF Files
The program device that is associated with ICF files is a communications session. You establish the default device by implicitly acquiring it using the _Ropen() function. The implicitly acquired program device is determined by the ACQPGMDEV parameter on the CRTICFF, OVRICFF, or CHGICFF commands. If the program device name is specified on the ACQPGMDEV parameter the program device must be defined to the device file before it is opened. This is done by specifying the name on the PGMDEV parameter of the ADDICFDEVE or OVRICFDEVE commands.

If *NONE is specified for the ACQPGMDEV parameter of the CRTICFF, OVRICFF, or CHGICFF commands, you must explicitly acquire the program device using the _Racquire() function.

You can change the default program device in the following ways:

  • Use the _Racquire() function to explicitly acquire another program device. The device that is just acquired becomes the current program device.
  • Use the _Rpgmdev() function to change the current program device associated with a file to a previously-acquired device. This program device can be used for subsequent input and output operations to the file.
  • The actual program device read becomes the default device if you read from an invited device using the _Rreadindv() function.
  • Use the _Rrelease() function to release a device from the file. When you release the device, it is no longer available for I/O operations.

To release a program device, use the _Rrelease() function (the program device must have been previously acquired). This detaches the device from an open file; I/O operations can no longer be performed for this device. If you wish to use the device after releasing it, it must be acquired again.

All program devices are implicitly released when you close the file. If the device file has a shared open data path, the last close operation releases the program device.

Record Functions for ICF Files

Use the following record functions to process ICF files:

Record Functions for ICF Files

Example

The following example gets a user ID and password from a source program and sends it to a target program. The target program checks the user ID and password for errors and sends a response to the source program.

Note:To run this example the target program T1520TGT must exist on a remote system. A communications line between the source system with program T1520ICF and the target system with program T1520TGT must be active.You also need Advanced Program to Program Communications (APPC).

  1. To create the physical file T1520DDA, type:
  2. CRTPF FILE(MYLIB/T1520DDA) SRCFILE(QCLE/QADDSSRC)

    T1520DDA — DDS Source for Password and User ID

    DDS Source for Password and User ID

  3. To create the ICF file T1520DDB using the DDS source shown below type:
  4. CRTICFF FILE(MYLIB/T1520DDB) SRCFILE(QCLE/QADDSSRC)
    ACQPGMDEV(CAPPC2)

    T1520DDB — DDS Source to Send Password and User ID

    DDS Source to Send Password and User ID

  5. To create the ICF file T1520DDC using the DDS source shown below, type:
  6. CRTICFF FILE(MYLIB/T1520DDC) SRCFILE(QCLE/QADDSSRC) ACQPGMDEV(CAPPC1)

    T1520DDC — DDS Source to Receive Password and Userid

    DDS Source to Receive Password and Userid

  7. Create an intrasystem device INTRAC. Type:
  8. CRTDEVINTR DEVD(INTRAC) RMTLOCNAME(INTRAC) ONLINE(*NO)
  9. Vary on the intrasystem device INTRAC. Type:
  10. VRYCFG CFGOBJ(INTRAC) CFGTYPE(*DEV) STATUS(*ON) RANGE(*OBJ)
  11. To add a program device entry for ICF file T1520DDB, type:
  12. ADDICFDEVE FILE(MYLIB/T1520DDB) PGMDEV(CAPPC2) RMTLOCNAME( CAPPC1)
    MODE(CAPPCMOD)
  13. To add a program device entry for ICF file T1520DDC, type:
  14. ADDICFDEVE FILE(MYLIB/T1520DDC) PGMDEV(CAPPC1) RMTLOCNAME(*REQUESTER)
    MODE(CAPPCMOD)
  15. To create the program T1520ICF using the source shown below, type:
  16. CRTBNDC PGM(MYLIB/T1520ICF) SRCFILE(QCLE/QACSRC)

    T1520ICF — ILE C Source to Send and Receive Data

     ILE C Source to Send and Receive Data

     ILE C Source to Send and Receive Data

     ILE C Source to Send and Receive Data

    The _Ropen() function opens the record file T1520DDB. The _Rformat() function accesses the record format EVOKPGM in the file T1520DDB. The EVOKE statement in T1520DDB calls the target program T1520TGT. The _Rformat() function accesses the record format SNDPASS in the file T1520DDB. The user ID and password is sent to the target program T1520TGT. The _Rformat() function accesses the record format CHKPASS in the file T1520DDB. The received password and user ID is then verified.

  17. To create the program T1520TGT using the following source, type:
  18. CRTBNDC PGM(MYLIB/T1520TGT) SRCFILE(QCLE/QACSRC)

    T1520TGT — ILE C Source to Check Data is Sent and Returned

    ILE C Source to Check Data is Sent and Returned

    ILE C Source to Check Data is Sent and Returned

    The _Ropen() function opens the file T1520DDC. The _Ropen() function opens the password file T1520DDA. The _Rformat() function accesses the record format RCVPASS in the file T1520DDC. The _Rreadn() function reads the password and user ID from the source program T1520ICF. Errors are checked, and a response is sent to the source program T1520ICF.

  19. To run the program T1520ICF, type:
  20. CALL PGM(MYLIB/T1520ICF)

    The output is as follows:

     output

    After calling the program, you may enter a user ID and password. If the password is correct, ″Password valid″ appears on the display; if it is incorrect, ″Password invalid″ appears.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

IBM-ILE Topics