Árvore de páginas

How to create a form directly in ECM.

  1. Create an HTML file with the fields with the same name used in Microsiga Protheus.
  2. Add the HTML file as a New Card Index in the Documents of ECM and check the Code that was generated. This code will be used in the creation of the future Process.

 

* For more information about form customizations in ECM, see the ECM documentation. The Objective of this documentation is to provide the care we must take to build a form for integration with Microsiga Protheus.

Sample form.

<HTML>

<HEAD>

  <TITLE> Example - Customer </TITLE>

  <LINK REL=STYLESHEET HREF="/webdesk203/wdk/global.css">

</HEAD>

<BODY scroll=yes>

<span class="NumSecao">

<strong> Registration</strong></span>

<HR>

<br>

<form>

<table>

  <tr>

    <td align="right" width="150" class="Labels"><b>Code:</b></td>

    <td class="Normal"><strong><input type="text" size="6" name="A1_COD"></strong></td>

  </tr>

  <tr>

    <td align="right" width="150" class="Labels"><b>Loja:</b></td>

    <td class="Normal"><strong><input type="text" size="2" name="A1_LOJA"></strong></td>

  </tr>

  <tr>

    <td align="right" width="150" class="Labels"><b>Física/Jurídica:</b></td>

    <td class="Normal"><strong>

        <select name="A1_PESSOA">

            <option value="F">Física</option>

            <option value="J">Jurídica</option>

        </select>

       </strong></td>

  </tr>

  <tr>

    <td align="right" width="150" class="Labels"><b>Name:</b></td>

    <td class="Normal"><strong><input type="text" size="40" name="A1_NOME"></strong></td>

  </tr>

  <tr>

    <td align="right" width="150" class="Labels"><b>Trade Name:</b></td>

    <td class="Normal"><strong><input type="text" size="20" name="A1_NREDUZ"></strong></td>

  </tr>

  <tr>

    <td align="right" width="150" class="Labels"><b>Address:</b></td>

    <td class="Normal"><strong><input type="text" size="40" name="A1_END"></strong></td>

  </tr>

  <tr>

    <td align="right" width="150" class="Labels"><b>Type:</b></td>

    <td class="Normal"><strong>

        <select name="A1_TIPO">

            < option value = "F" > Cons. End </option>

            <option value="L">Rural Producer</option>

            <option value="R">Reseller</option>

            <option value="S">Solidary</option>

            <option value="X">Export</option>

        </select>

    </strong></td>

  </tr>

  <tr>

    <td align="right" width="150" class="Labels"><b>City:</b></td>

    <td class="Normal"><strong><input type="text" size="60" name="A1_MUN"></strong></td>

  </tr>

  <tr>

    <td align="right" width="150" class="Labels"><b>State:</b></td>

    <td class="Normal"><strong><input type="text" size="2" name="A1_EST"></strong></td>

  </tr>

 </table>

</form>

</BODY>

</HTML>

Building forms for automatic routines.

  1. Configure the integration for GED between Protheus and ECM in the Configurator, in the Environment > Totvs ECM > GED Wizard option.
  2. Use the FWECMPutCard function to send the form to the ECM according to the example below (the card index will be created in the ERP_MP \ <empresas> \ MP_CARDS folder in ECM):

Example of source code.

#include "totvs.ch".

User Function FormCliente().

Local cProcessId := "CLIENTE" // if provided, it updates the form related to the process, otherwise, creates a new one.

Local cDescription := "Customer file form".

Local cCardDescription := "".

Local aHTML := Array(1,2) // form files.

Local aEvents := Array(1,2) // events that will not be customized for the form.

Local nFormId

Local aError

 

aHTML[1][1] := "cliente.html" // file name

aHTML[1][2] := '<HTML>'+; // file content

'<HEAD>'+;

'  <TITLE>Example - Customer</TITLE>'+;

'  <LINK REL=STYLESHEET HREF="/webdesk203/wdk/global.css">'+;

'</HEAD>'+;

'<BODY scroll=yes>'+;

'<span class="NumSecao">'+;

'<strong> Registration</strong></span>'+;

'<HR>'+;

'<br>'+;

'<form>'+;

'<table>'+;

'  <tr> '+;

'    <td align="right" width="150" class="Labels"><b>Code:</b></td>'+;

'    <td class="Normal"><strong><input type="text" size="6" name="A1_COD"></strong></td>'+;

'  </tr>'+;

'  <tr> '+;

'    <td align="right" width="150" class="Labels"><b>Store:</b></td>'+;

'    <td class="Normal"><strong><input type="text" size="2" name="A1_LOJA"></strong></td>'+;

'  </tr>'+;

'  <tr> '+;

'    <td align="right" width="150" class="Labels"><b>Individual/Legal Entity:</b></td>'+;

'    <td class="Normal"><strong>'+;

'        <select name="A1_PESSOA">'+;

'            <option value="I">Individual</option>'+;

'            <option value="E">Legal Entity</option>'+;

'        </select>'+;

'    </strong></td>'+;

'  </tr>'+;

'  <tr> '+;

'    <td align="right" width="150" class="Labels"><b>Name:</b></td>'+;

'    <td class="Normal"><strong><input type="text" size="40" name="A1_NOME"></strong></td>'+;

'  </tr>'+;

'  <tr> '+;

'    <td align="right" width="150" class="Labels"><b>Trade Name:</b></td>'+;

'    <td class="Normal"><strong><input type="text" size="20" name="A1_NREDUZ"></strong></td>'+;

'  </tr>'+;

'  <tr> '+;

'    <td align="right" width="150" class="Labels"><b>Address:</b></td>'+;

'    <td class="Normal"><strong><input type="text" size="40" name="A1_END"></strong></td>'+;

'  </tr>'+;

'  <tr> '+;

'    <td align="right" width="150" class="Labels"><b>Type:</b></td>'+;

'    <td class="Normal"><strong>'+;

'        <select name="A1_TIPO">'+;

'            <option value="F">Cons. Final</option>'+;

'            <option value="L">Rural Producer</option>'+;

'            <option value="R">Reseller</option>'+;

'            <option value="S">Solidary</option>'+;

'            <option value="X">Export</option>'+;

'            </select>'+;

'       </strong></td>'+;

'  </tr>'+;

'  <tr> '+;

'    <td align="right" width="150" class="Labels"><b>City:</b></td>'+;

'    <td class="Normal"><strong><input type="text" size="60" name="A1_MUN"></strong></td>'+;

'  </tr>'+;

'  <tr> '+;

'    <td align="right" width="150" class="Labels"><b>State:</b></td>'+;

'    <td class="Normal"><strong><input type="text" size="2" name="A1_EST"></strong></td>'+;

'  </tr>'+;

' </table>'+;

'</form>'+;

'</BODY>'+;

'</HTML>'

 

aEvents[1][1] := "setEnable" // name of the event

aEvents[1][2] := 'function setEnable() {'+; // JavaScript language script

'log.info("Function call test");'+;

'}'

 

nFormId := FWECMPutCard(cProcessId,cDescription,cCardDescription,aHTML,aEvents) // returns the ECM card index code

If FWWFIsError()

   aError := FWWFGetError()

   MsgStop(aError[2])

Else

   MsgInfo("Card index updated successfully")

EndIf

Return

Building forms for MVC routines.

  1. Configure the integration for GED between Protheus and ECM in the Configurator, in the Environment > Totvs ECM > GED Wizard option.
  2. Use the GetXMLLayout method of the View to generate the HTML.
    1. Only the Fields and Grid components will be converted into HTML.
    2. Only the forms of the CRUD and Master/Detail type can be exported to ECM, since you cannot simulate all the events from the other types of Microsiga Protheus forms.
    3. This method is just a demonstration of how the mechanism is in Microsiga Protheus. MVC forms have an automatic way of generating a process with form in ECM, in the routine 'Related Actions'.

#include "totvs.ch".

User Function FormView()

Local oView := FWLoadView("MATA030_MVC")

Local cProcessId := "CLIENTE" // if provided, it updates the form related to the process, otherwise, creates a new one.

Local cDescription := "Customer file form".

Local cCardDescription := "".

Local aEvents := Array(1,2) // events that will not be customized for the form.

Local nFormId

Local aError

Local aFiles

Local lHtm := .T.

Local lEmbedded := .F.

Local lDocType := .T.

 

oView:setOperation(3)

 

aFiles := oView:GetXMLLayOut(lHtm,lEmbedded,lDocType)

 

aEvents[1][1] := "setEnable" // name of the event

aEvents[1][2] := 'function setEnable() {'+; // JavaScript language script

'log.info("Function call test");'+;

'}'

 

nFormId := FWECMPutCard(cProcessId,cDescription,cCardDescription,aFiles,aEvents) // returns the card index code in ECM

If FWWFIsError()

   aError := FWWFGetError()

   MsgStop(aError[2])

Else

   MsgInfo("Card index updated successfully")

EndIf

Return

Using MVC Model 1 forms

For automatic routines of the Model 1 (CRUD) type that use only Data Dictionary fields, you can use MVC to simplify the form customization process, as follows:

#include "totvs.ch".

User Function FormTable()

Local cTable := "SA1"

Local cProcessId := "MATA030"

Local cDescription := "Customer (automatic routine)"

Local oView

Local aEvents := Array(1,2) // events that will not be customized for the form.

Local nFormId

Local aError

Local aFiles

Local lHtm := .T.

Local lEmbedded := .F.

Local lDocType := .T.

 

FwAliasMVC(cTable,cProcessId,cDescription)

 

oView := FwLoadView("PROTHEUSMVC")

oView:setOperation(3)

 

aFiles := oView:GetXMLLayOut(lHtm,lEmbedded,lDocType)

aEvents[1][1] := "setEnable" // name of the event

aEvents[1][2] := 'function setEnable() {'+; // JavaScript language script

'log.info("Function call test");'+;

'}'

 

nFormId := FWECMPutCard(cProcessId,cDescription,cCardDescription,aFiles,aEvents) // returns the card index code in ECM

If FWWFIsError()

   aError := FWWFGetError()

   MsgStop(aError[2])

Else

   MsgInfo("Card index updated successfully")

EndIf

Return

 

 

 



 

  • Sem rótulos