A problem with ax is that many functions are bound to the form at the presentation layer. Code To directly implement a function, you need to see how the code in the form is processed and stripped out.
For example, the collection and registration functions are encapsulated in the forms inventtranspick and inventtransregister. Although they are also implemented through the inventtranswms class, inventtranswms_pick and inventtranswms_register classes, but if you want to directly implement the pick and register functions through code, you need to take a look at their processing logic and modify it.
1. Add the movement method to inventtranswms_pick and inventtranswms_register respectively. The code can be pasted from the corresponding form:
Inventtranswms_pick: Static Inventmovement Movement (Common _ record)
{
Inventmovement movement;
Inventquarantineorder;
;
If (_ Record. tableid = Tablenum (inventquarantineorder ))
{
Inventquarantineorder = _ Record;
If (Inventquarantineorder. Status = Inventquarantinestatus: created)
{
Movement=Inventmovement: Construct (inventquarantineorder, inventmovsubtype: transferreceept );
}
}
If ( ! Movement)
{
Movement=Inventmovement: Construct (_ record );
}
Return Movement;
}
Inventtranswms_resigter: Static Inventmovement Movement (Common _ record)
{
Inventmovement movement;
Inventquarantineorder;
If (_ Record. tableid = Tablenum (inventquarantineorder ))
{
Inventquarantineorder = _ Record;
If (Inventquarantineorder. Status = Inventquarantinestatus: created)
{
Movement=Inventmovement: Construct (inventquarantineorder, inventmovsubtype: none );
}
Else
{
Movement=Inventmovement: Construct (inventquarantineorder, inventmovsubtype: transferreceept );
}
}
Else
{
Movement=Inventmovement: Construct (_ record );
}
If (Movement. newmovement_transferreceept ())
{< br> movement = movement. newmovement_transferreceept ();
movement = movement. newmovement_transferissuereceive () ? movement. newmovement_transferissuereceive (): movement;
movement = movement. newmovement_transferreceept () ? movement. newmovement_transferreceipt (): movement;
}
Return Movement;
}
2. Add the pick and registe methods to the two classes:
Inventtranswms_pick: Static Void Pick (Common _ cursor, tmpinventtranswms _ tmpinventtranswms)
{
Inventtranswms_pick= NewInventtranswms_pick (inventtranswms_pick: Movement (_ cursor), _ tmpinventtranswms );
;
Inventtranswms_pick: updateinvent (inventtranswms_pick, _ tmpinventtranswms );
}
Inventtranswms_register: Static Void Register (Common _ cursor, tmpinventtranswms _ tmpinventtranswms)
{
Inventtranswms_register= NewInventtranswms_register (inventtranswms_register: Movement (_ cursor), _ tmpinventtranswms );
;
Inventtranswms_register: updateinvent (inventtranswms_register, _ tmpinventtranswms );
}
3. Call example:
Collect details of a line transfer ticket
Inventdim. inventlocationid = ' GW ' ;
Tmpinventtranswms. inventqty = 1 ;
Tmpinventtranswms. inventdimid = Inventdim: findorcreate (inventdim). inventdimid;
Tmpinventtranswms. insert ();
Inventdim. inventlocationid = ' GW ' ;
Tmpinventtranswms. inventqty = 1 ;
Tmpinventtranswms. inventdimid = Inventdim: findorcreate (inventdim). inventdimid;
Tmpinventtranswms. insert ();
Inventtranswms_pick: Pick (inventtransferline, tmpinventtranswms );
Register the details of a purchase order: Tmpinventtranswms. inventqty = 1 ;
Inventdim. inventlocationid = ' MW ' ;
Inventdim. inventbatchid = ' 001 ' ;
Tmpinventtranswms. inventdimid = Inventdim: findorcreate (inventdim). inventdimid;
Tmpinventtranswms. insert ();
Tmpinventtranswms. inventqty = 1 ;
Inventdim. inventlocationid = ' MW ' ;
Inventdim. inventbatchid = ' 002 ' ;
Tmpinventtranswms. inventdimid = Inventdim: findorcreate (inventdim). inventdimid;
Tmpinventtranswms. insert ();
// Insert end
Inventtranswms_register: Register (purchline, tmpinventtranswms );