Usina BRAdvPL Guide
Sign in
← All topics
AUTOMATIC ROUTINEPublished

MATA261 — ExecAuto for warehouse transfer

MATA261 via MsExecAuto · estrutura posicional de aLinha

Reference guide for developing the MATA261 ExecAuto call in AdvPL, with attention to the positional aLinha structure.

MATA261MsExecAutoExecAutoAutomatic routineArraysAdvPL
01 · OVERVIEW

Overview

This page documents routine MATA261 from an AdvPL development perspective: how to prepare the structure sent to MsExecAuto, which positions compose aLinha and which cautions matter when validating the automatic routine contract. In versions later than the historical 11.8 sample, aLinha is positional: every value must remain in the exact position expected by the routine, including empty positions. The goal is to serve as a programming reference guide; functional Protheus process explanations may be linked from a dedicated site in the future.

02 · SYNTAX

Syntax

MATA261 via MsExecAuto · estrutura posicional de aLinha

Parameters

1 · D3_COD
CaractereRequired

Source product. SB1->B1_COD in the example.

2 · D3_DESCRI
CaractereRequired

Source product description.

3 · D3_UM
CaractereRequired

Source unit of measure.

4 · D3_LOCAL
CaractereRequired

Source warehouse. 07 in the example.

5 · D3_LOCALIZ
CaractereOptional

Source location. Keep the position even when empty.

6 · D3_COD
CaractereRequired

Destination product. The same code as the source in the example.

7 · D3_DESCRI
CaractereRequired

Destination product description.

8 · D3_UM
CaractereRequired

Destination unit of measure.

9 · D3_LOCAL
CaractereRequired

Destination warehouse. 11 in the example.

10 · D3_LOCALIZ
CaractereOptional

Destination location. Keep the position even when empty.

11 · D3_NUMSERI
CaractereOptional

Serial number when applicable.

12 · D3_LOTECTL
CaractereOptional

Source control lot.

13 · D3_NUMLOTE
CaractereOptional

Source lot/sub-lot according to the control used.

14 · D3_DTVALID
DataOptional

Source expiration date. Use CTOD("") when not applicable.

15 · D3_POTENCI
NuméricoOptional

Potency. Zero in the example.

16 · D3_QUANT
NuméricoRequired

Transferred quantity. aDados[nX][2] in the example.

17 · D3_QTSEGUM
NuméricoOptional

Second-unit quantity. Zero in the example.

18 · D3_ESTORNO
CaractereOptional

Reversal indicator/information.

19 · D3_NUMSEQ
CaractereOptional

Sequence number related to the movement.

20 · D3_LOTECTL
CaractereOptional

Control lot in the destination section. This repeated position is intentional.

21 · D3_DTVALID
DataOptional

Expiration date in the destination section. Use CTOD("") when not applicable.

22 · D3_ITEMGRD
CaractereOptional

Grid item when applicable.

23 · D3_OBSERVA
CaractereOptional

Movement note. OVHL in the example.

Return value

This page documents the item-row structure; return values and error handling depend on the MsExecAuto flow used by the caller.

03 · PRACTICAL EXAMPLE

Positional structure for later versions

Local aLine := {}

AAdd(aLine, SB1->B1_COD)       // D3_COD - source
AAdd(aLine, SB1->B1_DESC)      // D3_DESCRI - source
AAdd(aLine, SB1->B1_UM)        // D3_UM - source
AAdd(aLine, "07")              // D3_LOCAL - source
AAdd(aLine, "")                // D3_LOCALIZ - source
AAdd(aLine, SB1->B1_COD)       // D3_COD - destination
AAdd(aLine, SB1->B1_DESC)      // D3_DESCRI - destination
AAdd(aLine, SB1->B1_UM)        // D3_UM - destination
AAdd(aLine, "11")              // D3_LOCAL - destination
AAdd(aLine, "")                // D3_LOCALIZ - destination
AAdd(aLine, "")                // D3_NUMSERI
AAdd(aLine, "")                // D3_LOTECTL - source
AAdd(aLine, "")                // D3_NUMLOTE - source
AAdd(aLine, CTOD(""))          // D3_DTVALID - source
AAdd(aLine, 0)                 // D3_POTENCI
AAdd(aLine, aData[nX][2])      // D3_QUANT
AAdd(aLine, 0)                 // D3_QTSEGUM
AAdd(aLine, "")                // D3_ESTORNO
AAdd(aLine, "")                // D3_NUMSEQ
AAdd(aLine, "")                // D3_LOTECTL - destination
AAdd(aLine, CTOD(""))          // D3_DTVALID - destination
AAdd(aLine, "")                // D3_ITEMGRD
AAdd(aLine, "OVHL")            // D3_OBSERVA
Expected result

The row contains 23 positions and transfers the product from warehouse 07 to 11.

04 · PRACTICAL EXAMPLE

Why the 11.8 sample should not be copied literally

// Referência histórica: estrutura identificada por campo
// { "D3_COD", <valor>, Nil }
//
// Versões posteriores deste guia: estrutura posicional
// AAdd(aLinha, <valor-da-posicao-1>)
// AAdd(aLinha, <valor-da-posicao-2>)
// ...
Expected result

The legacy field-identified format and the later positional format are different contracts.

BEST PRACTICES
  • The TOTVS Support Center reference cited here is historical and targets Protheus 11.8; use it as a conceptual basis and validate the automatic routine contract in the release being used.
  • In the later versions covered by this example, aLinha is positional. Do not remove a position because its field is empty.
  • Keep the expected type in empty positions: empty strings for character fields, CTOD("") for dates and zero for numeric fields.
  • Positions 1–5 represent the source product/warehouse and positions 6–10 represent the destination product/warehouse.
  • D3_LOTECTL and D3_DTVALID appear again at positions 20 and 21; do not collapse these positions.
  • Revalidate the array after release, patch or related package updates.
COMMON PITFALLS
  • Mixing the 11.8 format with the later positional format can cause execution errors or incorrect values.
  • Moving one value shifts the interpretation of every following position.
  • Field names in comments do not replace the positional contract.
  • Scenarios with lot, serial, location or second-unit control require their corresponding positions to be filled according to the environment configuration and the routine contract.

Related content

REFERENCES
  1. TOTVS. Cross Segmento - Backoffice Linha Protheus - ADVPL - Exemplo execauto MATA261. TOTVS Support Center. Historical reference identified for Protheus 11.8. Accessed Aug. 25, 2026.
Status
Published
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha