How to create a custom field (UDF)

SOLVED

Hi Sage City neighbours!

I’m still learning here so please be patient. I would like to add a custom field to the BPC4 screen; BPs – Customer – Ship-to customer tab. The purpose of this field is only to store a 10 alphanumeric account number. This field has no logic behind it, programing or references anywhere else in EM. Ideally, I would like to place it beside field XBPDNAM0 – Company name 1.

How do I go at this?

Thanks a million! Rest assured, this newbie is learning fast!

  • +1
    verified answer

    Hello Martin,

    The thing about screen BPC4 is that it has a grid  in block 1 (with all fields but field BPAADD set to hidden) which holds all the information on the right hand of the screen, every time you click on a line in the grid it refreshing things like the Company Name, work days, misc. tax rule, ect in the remaining blocks on the screen.

    So you will need to add two fields in theory to the screen:

    1. First one on the grid (set as hidden) in block 1

    2. Second field will be the custom field in block 2.

    You will need two field actions on the fields you have added:

    1. First field action (Before line) will be on the field NBDLV (the grid line indicator) which copies the field value from the grid to the custom field in the right.

    2. The other field action (After modification) will be on the second new field you added (not the one on the grid, which populates the value in the grid.

    It is not very difficult to do, but that is how you would go about it.

    Hope it helps.

  • +1 in reply to RegardHulsbos
    verified answer

    Hello Martin,

    Agree with @Regard Hulsbos, with some additional information

    1. Instead of adding Before Line on NBDLV to copy value from Grid to Custom Field, you can use Entry point $REMP_ADRBPA from TRTBPA

    If dim([M]XFIELD)>0
    [M]XXFIELD = [M]XFIELD(NOL)
    Endif

    Both solution seems correct.

    2. In the After Modificacion field action to populate value from XXFIELD to XFIELD(on grid), you will also need to call 

    [M]FLMOD([M]XNUMLIG) = 1
    Gosub INIT_FLMODFONC From SUBBPA

    Based on standard field action.

    Regards,

  • 0 in reply to Julien BARGETTO

    Hello!  I am also trying to add a custom field to BPC4 (and table BPDLVCUST).  I do not have a strong X3 coding skill set so I need a little help.  Currently my new field will not "save" data.  No errors - just not writing to the table.  I think the issue is I do not understand the comment Julien made in point #2 - "you will also need to call".  So I think my question is - what exactly do I need to do with:

    "[M]FLMOD([M]XNUMLIG) = 1
    Gosub INIT_FLMODFONC From SUBBPA"

  • 0 in reply to Julien BARGETTO
    SUGGESTED

    I tried using both the entry point $REMP_ADRBPA from TRTBPA and the before line action on NBDLV, neither would populate the field when first displayed.  I ended up using the Initialization action on the field along with the Before line action on NBDLV.   

    Subprog D_XXFIELD(VALEUR)
    Variable Char VALEUR()
      [M:BPC4]XXFIELD = [M:BPC4]XFIELD([M]XNUMLIG) : Affzo [M:BPC4]XXFIELD
    End