Save Collection Data in Aggregate UDF Help me to solve

Discussion in 'Tally Developer' started by Naitesh, Sep 6, 2018.

    
  1. Naitesh

    Naitesh Member


    Please help me to save collection into Aggregate UDF
    I wrote this code but something wrong
    Help me to solve


    [System: UDF]
    MyUdfStkMasterTBL : Aggregate : 20010
    MyUdfStkItemName : String : 20011

    [#Menu: Accounts Info.]
    Add: Item :Before :mad:@locQuit:Stock Item Master:Alter:Stock Detail Master
    Add: Item :Before :mad:@locQuit:Import Stock Item Master:Call : TestFunction123

    [Report:Stock Detail Master]
    Form: STForm
    Title: "Stock Detail Master"
    Object:company

    [Form: STForm]
    Width: 100% Screen
    Height: 100% Screen
    Background: FormClr
    Part:STPart

    [Part:STPart ]
    Line: STLineTitle,STLine
    Repeat:STLine:MyUdfStkMasterTBL
    Break on : $$IsEmpty:$MyUdfStkItemName
    Scroll: Vertical

    [Line:STLineTitle]
    Fields : TLSTSrNoFld, TLSTNameFld
    Local : Field : Default : Delete : Border

    [Line:STLine]
    Fields : Multi SNo, STNameFld
    Local : Field : Default : Delete : Border

    [Field: TLSTSrNoFld]
    Use: Name Field
    Set as: "Sr"
    Width: 4
    Align: Center
    Color: BLUE

    [Field: TLSTNameFld]
    Use: Name Field
    Set as: "Stock Name"
    Width: 30
    Align: Left
    Color: BLUE

    [Field: STNameFld]
    Use : Name Field
    Storage : MyUdfStkItemName
    Unique : Yes
    Width: 30

    [Collection : CollMaster123]
    Type : Vouchers : Stock Item
    Child Of : $$BaseOwner:#VchStockItem

    [Collection : CollDetails123]
    Source Collection : CollMaster123
    Walk : Inventory Entries
    By : StockItemName : $StockItemName
    Fetch :StockItemName

    [Function : TestFunction123]
    10 : WALK COLLECTION : CollDetails123
    20 : INSERT COLLECTION OBJECT : MyUdfStkMasterTBL
    30 : Set Target : MyUdfStkMasterTBL
    40 : Set Value : MyUdfStkItemName : $$String:$StockItemName
    60 : SET TARGET : ..
    70 : END Walk
    80 : Accept Create
    90 : Return
    100: MSGBOX : "Status" : "Stock Item-Type Imported"
     

    Attached Files:



  2. sivam

    sivam Active Member


    Check with this file
     

    Attached Files:

    vinoth and Jaya like this.


  3. NSA

    NSA Member


    The below coding is a model for creating a master with object as company. Further It can be used to update the UDF Aggregate . The code is just a model. So anyone can define their own Aggregate UDF and associated Field UDF to modify for their own purpose.

    This group has helped me a lot to learn coding. Thanks to all people who has supported me . Especially Amit Sir. I am presenting this as to acknowledge the gratitude to him.
    Once again thanking you all, have a nice day

    [Report: DelvryLocMaster]
    Form : DelvryLocMaster
    Object: Company : ##svcurrentcompany
    [Form: DelvryLocMaster]
    Use: Master Accounting Form
    Delete: Parts
    Add: Parts: DelvryLocMaster
    Output: NewUniqueRCPLocationName
    On: Form Accept: Yes: Form Accept
    On: Form Accept: Yes: Call:LocationCreationFunction
    [Part: DelvryLocMaster]
    Lines: DelvryLocMaster, DelvryLocMasterR, DelvryLocMasterBPL, DelvryLocMasterKM
    [Line: DelvryLocMaster]
    Fields:Simple Prompt, DelvryLocMaster
    Local:Field:Simple Prompt: Set as: "Name of the Location"
    [Field: DelvryLocMaster]
    Use:Short Name Field
    Modifies: UniqueRCPLocationNameVar

    [Line: DelvryLocMasterR]
    Space Top: 3
    Fields:Simple Prompt, DelvryLocMasterR
    Local:Field:Simple Prompt: Set as: "Region:"
    [Field: DelvryLocMasterR]
    Use: Short Name Field
    Table: Region Master
    Show Table:Always
    Modifies: RCPRegionVar
    [Line: DelvryLocMasterBPL]
    Space Top: 3
    Fields: Simple Prompt, DelvryLocMasterBPL
    Local: Field: Simple Prompt: Set as: "Base Price Level:"
    [Field: DelvryLocMasterBPL]
    Use: Short Name Field
    Table: Price Levels
    Show Table:Always
    Modifies: RCPPriceLevelBasetoLocationvar
    [Line: DelvryLocMasterKM]
    Space Top: 3
    Fields: Simple Prompt, DelvryLocMasterKM
    Local: Field: Simple Prompt: Set as: "Km?:"
    [Field: DelvryLocMasterKM]
    Use : Amount Field
    Modifies: RCPKMvar
    [Function: LocationCreationFunction]
    00: Insert Collection Object: LocationMaster
    10: Set Target: LocationMaster
    20: Set Value : UniqueRCPLocationName: $$String:##UniqueRCPLocationNameVar
    30: Set Value : RCPRegion: $$String:##RCPRegionVar
    40: Set Value : RCPPriceLevelBasetoLocation: $$String:##RCPPriceLevelBasetoLocationvar
    50: Set Value : RCPKM: $$String:##RCPKMvar
    60: Set Target:..
    70: Accept Create
    80: Accept Object
    90: Set Value: UniqueRCPLocationNameVar: $$String:""
    100: Return


    [Variable: UniqueRCPLocationNameVar]
    Type: String

    [Variable: RCPRegionVar]
    Type: String

    [Variable: RCPPriceLevelBasetoLocationvar]
    Type: String

    [Variable: RCPKMvar]
    Type: Amount

    [System: Variable]
    UniqueRCPLocationNameVar: ""
    RCPRegionVar: ""
    RCPPriceLevelBasetoLocationvar: ""
    RCPKMvar: ""
     
    Amit Kamdar likes this.


  4. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    Very Good efforts.......keep coding. :)
     


  5. NSA

    NSA Member


    Thank You Sir
     




  6. this is for saving data to aggr udf but how to alter this aggr udf
     


  7. NSA

    NSA Member


    I
    Depends on the primary object where you saved your UDF aggregate.

    At the end, to ALTER the UDF in AGGREGATE use a function and Modify object..
     


  8. NSA

    NSA Member


    ;;Example for Altering UDF Aggregate Collection
    ;;1) General Form- for Alteration
    [Report:General UDF Aggre Alter Report]
    Form: General UDF Aggre Alter Form
    Object: Company : ##Svcurrentcompany
    Variable:RCPGUALRepTitleVAR;;Variable to be Set Report Tittle of the Report of Actual Alteration Form
    Variable:RCPGUALFunctionVAR;; Variable to be Set Function in the Report of Actual Alteration Form
    Variable:RCPCollectionforFunction;;Variable to set Collection Name in the Report of Actual Alteration Form
    [Form:General UDF Aggre Alter Form]
    Use: Master Accounting Form
    Delete: Parts
    Add: Parts: General UDF Aggre Alter Part
    Add : On : At End : Form Accept : Yes :Call: RCPGUALFunction

    [Part:General UDF Aggre Alter Part]
    Line:General UDF Aggre Alter Line
    [Line:General UDF Aggre Alter Line]
    Fields:Simple Prompt
    Local:Field:Simple Prompt:Set as:$$String:##RCPGUALRepTitleVAR
    ;;------------------VAriable Declaration--------------
    ;;------------------------Global Variable----------------
    [Variable:RCPCollectionforFunction]
    Type:String
    [Variable:RCPGUALFunctionVAR]
    Type:String
    [Variable:RCPGUALRepTitleVAR]
    Type:String
    [Variable:RCPCountColl]
    Type:String
    [Variable:ColIndxNo]
    Type:String
    [System:Variable]
    RCPGUALFunctionVAR:""
    RCPGUALRepTitleVAR:""
    RCPCollectionforFunction:""
    RCPCountColl:""

    ;;------------------------General Function----------------
    [Function:RCPGUALFunction]
    IF01:if:Not $$Isempty:##RCPGUALFunctionVAR
    IF02:If:Not $$IsEmpty:##RCPCollectionforFunction
    010:Set:RCPCountColl:($$NumItems:($$sTRING:##RCPCollectionforFunction))
    Action:A01:Do If:##RCPCountColl>0:Set:ColIndxNo:##RCPCountColl+1
    Action:A02:Do If:##RCPCountColl<=0:Set:ColIndxNo:1
    Action:A03:Call:##RCPGUALFunctionVAR
    020:End if
    025:End If
    030:Return

    ;;2) A Sepcific Form for Altertation of UDF

    [Report:Specific UDF Aggre Alter Report]
    Use:General UDF Aggre Alter Report
    Variable:XYZVar;;Depends on Number of Fields in the orginal Aggregate UDF Report, Here only 2 (A and B) for example
    Variable:pQRVar;;Depends on Number of Fields in the orginal Aggregate UDF Report, Here only 2 (A and B) for example
    Set:RCPGUALFunctionVAR:$$String:"Specific UDF Aggre Function";; Should be same as function name
    Set:RCPGUALRepTitleVAR:$$LocaleString:"Specific UDF Aggre Alter Form" ;; can give any desired name
    Set:RCPCollectionforFunction:$$String:"SpecificUDFAggreOrginalCollection";; Here we need to put the orginal collection name, make sure than collection fetch all required data
    Local:Form:General UDF Aggre Alter Form:Add:parts:After:General UDF Aggre Alter Part:Specific UDF Aggre Alter Part

    [Part:Specific UDF Aggre Alter Part]
    Lines:Specific UDF Aggre Alter Line1, Specific UDF Aggre Alter Line2
    [Line:Specific UDF Aggre Alter Line1]
    Fields:Simple Prompt, Short Name field
    Local:Field:Simple Prompt:Info:"Specific UDF Aggre Fld 1"
    Local:Field:Short Name field:Modifies:XYZVar:Yes

    [Line:Specific UDF Aggre Alter Line2]
    Fields:Simple Prompt, Short Name field
    Local:Field:Simple Prompt:Info:"Specific UDF Aggre Fld 2"
    Local:Field:Short Name field:Modifies:pQRVar:Yes

    [Function:Specific UDF Aggre Function]
    000:Modify Object:(Company,##SVCurrentCompany).SpecificUDFAggreOrginalCollection[##ColIndxNo].XYZ[1].XYZ:##XYZVar
    010:Modify Object:(Company,##SVCurrentCompany).SpecificUDFAggreOrginalCollection[##ColIndxNo].PQR[1].PQR:##PQRVar

    [Collection:SpecificUDFAggreOrginalCollection]
    Type:SpecificUDFAggreOrginal:Company
    Child Of:##SVCUrrentCompany
    Fetch:XYZ,PQR
     


Share This Page