Hi Adrian and Wayne,
I try to answer your questions briefly.
1.) The main UBE and the TC UBE is mapped to run locally in OCM.
2.) The TC UBE is called through Report Interconnect from the main UBE.
3.) The main UBE wait for the TC UBE to finish because the "Asynchronously" check box is unmarked in the in the Report Interconnect call.
4.) Communication between the main and TC UBE:
The TC UBE has a Report Interconnect data structure:
INPUT parameters are the values of the "groupping fields"
OUTPUT parameters are: mnCountOfFormatFetched, mnCountOfRowInserted, cEndingCode.
I initialize my counters in the Process Begin event.
I increment mnCountOfFormatFetched each time when Format Fetched event called. I don't use the "Issue a write for this event" feature instead of I issue a Table I/O Insert and detect the success with "If FileIO_Status is EQ CO_Success" and increment mnCountOfRowInserted when it was successful. You can not use TableI/O in B7321 only UserInsert, further you can not detect the success of Insert with "If FileIO_Status is EQ CO_Success". This possibility started with B733x.
I map the "Grouping Fields" into the index field and I run an other counter TXTI map this also into the according index field to preserve the original order of rows. Further I map the whole row into a large text field based on NFLF data item. Further I extract the Transaction number part of the input row and map this value into a separate field in the output.
5.) I calculate the value of cEndingCode output parameter based on the counters in the Process End event.
6.) The Main UBE:
* Its primary section (called Control Section) is a hidden one without BSVW. Almost all of my logic is reside in the Do Section event of this section.
* There is a standard Page Header section extended with the current version of the main UBE.
* Ther is a conditional section , named "Processing Options" where I print all of the PO values in a readable format (e.g. interpreting blank, 0 and 1 as No and Yes)
* There is an other conditional section, named "Print Error" which containes all of the necessary identification informations like the order number of the input text row (generated by the TC), User ID, Batch Number (in Final mode only), Transaction Number (extracted in TC), Line Number inside the Transaction (generated in the beginning of the Control Section) and a long text variable for the description of the detected error.
There is a last UNconditional section, named "Print Results" which designate, that was it a Proof or Final run, prints the counters (e.g. ForamtFetched, Row Inserted into work table,Numbers of Transactions, Count of Data errors, Count of Rows with error, Count of inserted F0911Z1 rows, Count of F0911Z1 insert failed and finally a long ending status message which can be vary (I have approx 20 different) depending on the processing option settings (Final/Proof, Forcing the insert the rows with error, Forcing to keep the batch with error, etc.) and the detected errors if there was any.
7.) The Control Section:
* Initialize the variables like counter, constants (for Table I/O Insert F0911Z1 field), etc.
* Determines the values of "Grouping Fields"
* retrieve audit informations.
* Call the Proc Op conditional section.
* Delete the worktable records if any based on the grouping fields. Detects errer when it fails.
* Call the TC UBE.
* Detect errors when the "CountOfFormatFetched" counter is null or not equal with the CounOfRowInserted for the work table returned by the TC UBE.
* Loops through the records in the work table and determines the Line Number inside the separate Transactions using the appropriate index of the worktable. Detect ererors on the Update Table IO statement.
* Determine the Batch Number in Final mode using X0010 - Get Next Number BSFN call, and converts the numeric value to string (EDBT is a string type field).
Loops through the records again and:
* extracts the fields for F0911Z1 from the large text fields
* converts the values from string to the appropriate numeric or date type where it is necessary. Detects error when the conversion fails.
* Retrieves ANI Based on MCU, OBJ, SUB. Detects error when it fails.
*... makes some other action, convertion, and validations.
* Calls the Print Error conditional section on all detected errors with the appropriate error description.
* Insert F0911Z1 record based on PO settings and error status of the current row. Detects error when it fails.
AFTER the While Loop:
Delete the Batch (inserted records into F0911Z1 depending on PO settings, error status, Proff/Final mode). Detects error when it fails.
* Delete the worktable records if any based on the grouping fields.
* Determines the "Ending Status Message" for the "Print Results" section.
8.) When the primary and hidden control section finished the the undconditional "Print Results" section automaticaly printed on the end of the report output.
It was my answer briefly
Hope could help.
Let me know if you have further question or I wasn't enough clear (you know, my English).
Good Luck,
Zoltán
B7332 SP11, ESU 4116422, Intel NT4, SQL 7 SP1
(working with B7321, B7331, XE too)