writeblock
The writeblock function writes the data contains in the argument of a string variable to the output file.
The readblock and writeblock functions are used in conjunction with each other to pass a block of data from the input file to the output file without compliance checking or testing for proper EDI syntax. Together these functions provide a more efficient alternative of using "wildcard" segments, which are typically implemented in build and break maps.
The readblock and writeblock functions are also used in conjunction with the Document Extraction service, to specify the beginning and end of each document in a batch of documents, so that each document can be extracted individually.
The readblock, writeblock, and unreadblock functions are supported only for positional and EDI files.
See the "XML Build and Break Maps" appendix in the IBM® Sterling Gentran:Server® for Microsoft Windows XML User Guide for special considerations when using this function with XML data.
Common use
The writeblock function is primarily used for document extraction maps as well as build and break maps.
Syntax
writeblock(string_variable);Examples
Example 1
String[1024] buffer;
readblock(buffer);
writeblock(buffer);
while readblock(buffer) do
begin
if left(buffer,3) = "HDR" then
begin
unreadblock();
break;
end
writeblock(buffer);
end
//Read a block from the input file and place it in buffer. Look for
//a "HDR" record tag. If found, reset the file pointer to where it was
//before the "HDR" record was found. Write contents of the buffer to
//the output file.Example 1
string[250] buffer;
string[3] match;
integer match_len;
// set these next two variables
match = "SUM"; // the tag of the last record in the document
match_len = 3; // the length of the tag
// read the block we're on and write it
readblock(buffer);
writeblock(buffer);
// keep reading and writing records until the end of the document
while readblock(buffer) do
begin
writeblock(buffer);
if left(buffer, match_len) = match then
begin
break;
end
end