> For the complete documentation index, see [llms.txt](https://docs.editran.onesait.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.editran.onesait.com/documentacion-editran/ibm-editran-v5.3-comun-z-os-en/interfaz-generica-de-aplicacion/anexo-c.-macroficheros/detalle-del-proceso-de-macroficheros.md).

# Macrofile process details

## Generalities. <a href="#toc149819092" id="toc149819092"></a>

It was previously mentioned that a macrofile contains data that can be loaded in different presentation sessions depending on an identifier, present in all records, by which the specific session to which they are associated is determined.

To define this identifier, the "Parameters" field has been added to the Application and Presentation Session profiles. This field, with a maximum of 60 characters, consists of the following data:

* Separator value: 1 character.
* Start of the identifier field: 1 to 6 digits.
* Separator: 1 character.
* Length of the identifier field: 1 to 2 digits.
* Separator: 1 character.
* Identifier field value: 0 to 48 characters.
* Separator: 1 character.
* Start of the data field to be loaded: 1 to 6 digits.
* Separator: 1 character.
* Length of the data field to be loaded: 1 to 6 digits.
* Separator: 1 character.

It can be seen that, if the maximum lengths are used for all data, they would not fit within the 60 characters of "Parameters"; however, it is understood that it is highly unlikely for this to occur in practice.

An example can conveniently illustrate these concepts:

```
*7*12*XXX/INVOICES*54*162*
```

According to this value, the records selected for loading in the presentation session whose profile specifies it would be positions 54 to 215 (162) of the records that have XXX/INVOICES in positions 7 to 18 (12). The identifier field may be embedded in the data field to be loaded.

The macrofile process is carried out by procedure ZTBGPMCR in installation, which invokes program ZTBGBMCR, and which contains all the DDs of the usual Editran procedures plus those of ZTBGFMAC, macrofile to be processed, ZTBGFSES, list of sessions to be loaded, and ZTBGFERR, list of sessions not loaded or in error. It can receive a PARM with Xnn....... where nn=01 or 51 only for loading and 03 or 53 for emission, which would normally include the associated loading. With 01 and 03 the application file will be deleted after loading, while with 51 or 53 it will be retained.

It is possible to carry out the loading and/or the emission of one or several presentation sessions, as will be seen later. In any case, for a specific session, the records corresponding to it are selected from the macrofile according to the "Parameters" field and written to the emission application file specified in the session profile, which must be unique. From here, the macrofile process invokes Editran's standard pre-emission process.

The sequential emission application file is automatically reserved before selecting the records from the macrofile and, if option 01 or 03 was selected, it is deleted after the loading has been performed, or, in other words, after the standard Editran pre-emission process has finished and control has been returned to the macrofile process.

The macrofile process can be used in any Editran operating mode. It is not allowed with cumulative loads.

## Process for only one presentation session. <a href="#toc149819093" id="toc149819093"></a>

It can be carried out in the following ways:

* From Editran, for which the procedure ZTBGPMCR must be specified as pre-emission in the transmission session profile.
* From the Editran operator, interactive or batch, for which the procedure ZTBGPMCR must be specified in the presentation session profile and a load (01) or an emission (03) must be requested.
* From JCL ZTBGJMCR that invokes procedure ZTBGPMCR by setting the PARM "Annlllllllllrrrrrrrrraaaaaa" where nn=01 or 51 (load) or 03 or 53 (emission) and lllllllllrrrrrrrrraaaaaa the presentation session. In this case the ZTBGFSES file of session list is not used.

The process is carried out as follows:

* Through the transmission or presentation session, as applicable, the profile of the latter is accessed and the "Parameters" and "Emission application file" fields, which must be unique, are taken and validated.
* The process of one presentation session is carried out
  * If the session is in a state compatible with loading, that is, it is finished or not loaded, the macrofile is scanned until a record is found that matches the identifier contained in "Parameters" and whose data portion to be loaded is written to the emission application file. The same will be done with subsequent records until one is found that does not match it. If no record is found, an empty file is generated.
  * If the session could not be loaded because it was in an incompatible state (e.g., it is emitting), this will be reported with the corresponding result code.
  * If emission was requested or loading was requested and it could be carried out, the main Editran pre-emission program is invoked, which performs the conventional loading and/or emission process. Upon completion, control is returned to the macrofile process, which deletes or catalogs the emission application file according to the chosen option.
  * If loading was requested and it was not carried out, the pre-program is not invoked.
* If an error occurs, the JCL will end with the corresponding code. If there is no error, but the session was not loaded, it will end with code 04.

## Process for several presentation sessions. <a href="#toc149819094" id="toc149819094"></a>

It can only be carried out from JCL ZTBGJMCR, which invokes procedure ZTBGPMCR by setting the PARM "Ann " where nn=01 or 51 (load) or 03 or 53 (emission) followed by 24 blanks.

The sessions to be loaded and/or emitted are taken from the ZTBGFSES file, with a record length of 80, so it can be created with an editor, which contains in the first 24 positions of each record a presentation session to be processed. The list of presentation sessions must be in the same order as the different associated data portions are found in the macrofile. The data of a session must form a single group of contiguous records. If the data were in a different order from that of the sessions, it is not guaranteed that all sessions will be loaded, since the macrofile is scanned sequentially and according to the order of the list. If for any session it is known that no data exist in the macrofile, it is recommended to remove it from the session list to avoid reading the entire file.

The process is carried out as follows:

* A presentation session is taken from the ZTBGFSES file and its profile is accessed, and the "Parameters" and "Emission application file" fields, which must be unique, are taken and validated.
* The process of a presentation session described above is carried out. If the session could not be loaded or an error occurred during its process, in addition to notifying it, it will be included in the ZTBGFERR error session list.
* A new presentation session is taken from ZTBGFSES and the treatment is repeated until the session list is exhausted. Note that the macrofile is not scanned from the beginning for each session looking for the corresponding records; rather, it is read only once sequentially, hence the importance of having the records associated with each session arranged in the macrofile in the same order as the sessions in ZTBGFSES, as already mentioned.
* The macrofile process is not interrupted if an error occurs during the treatment of any session. If more than one error occurs, the first one found takes precedence and the JCL ends with that code. If no error occurs, but some session was not loaded, it ends with code 04. The ZTBGFERR file will contain the sessions with errors or not loaded.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.editran.onesait.com/documentacion-editran/ibm-editran-v5.3-comun-z-os-en/interfaz-generica-de-aplicacion/anexo-c.-macroficheros/detalle-del-proceso-de-macroficheros.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
