How to execute "New Button"

SUGGESTED

Hi,

i need to call from my 4gl script the "New Button" that is on the right bar of window.

Is it possible? Can anyone help me?

Thanks a lot!

  • FormerMember
    0 FormerMember

    Hello,

    I have the same need !

    I want to call from code the click on the "New Button" (then fill the fields on the screen with some values).

    Anyone can help please ?

    I tried "Gosub NOUVEAU From GOBJSUB" but i have some errors.

    Thank you

  • 0

    Hi guys, 

    You can use ACTION 'APRES_CRE' to do some script. Follow is a script that we created when button "New" in PIH were pressed.

    $ACTION
    Case ACTION
    When "APRES_CRE","APRES_MOD" : Gosub AJUSTE_ELEMENTOS
    Endcase
    Return

     

    $AJUSTE_ELEMENTOS
    Local decimal YIPI : YIPI=0
    Local decimal YICMS : YICMS=0
    Local Integer YELEMENTOS(1..8)

    If !clalev ([F:YPVF]) : Local File PVCRFOOT [YPVF] : Endif
    If !clalev ([F:YPVF2]) : Local File PVCRFOOT [YPVF2] : Endif
    If !clalev ([F:YIMP]) : Local File XQPINVOICE [YIMP] : Endif
    If !clalev ([F:YEL]) : Local File PFOOTINV [YEL] : Endif

    CALL OUVRE_TRACE("") FROM LECFIC

    YELEMENTOS(1)=6
    YELEMENTOS(2)=5

    #infbox [M:PIH0]NUM
    Filter [F:YIMP]
    For [F:YIMP] where [F:YIMP]NUM=[M:PIH0]NUM
    YIPI+=[F:YIMP]TTIPI
    YICMS+=[F:YIMP]TOTICMSFCPST+[F:YIMP]TTICMSST
    Next

    Link [F:YPVF] With [F:YEL]PFI0=[F:YPVF]INVDTA as [LNK]
    Columns [LNK] ([F:YPVF]VCRNUM,[F:YPVF]VCRTYP,[F:YPVF]IND,[F:YEL]XQELEFAT)

    For [LNK] where find([F:YEL]XQELEFAT, YELEMENTOS) and [F:YPVF]VCRNUM=[M:PIH0]NUM
    CALL ECR_TRACE([F:YPVF]VCRNUM-num$([F:YPVF]VCRTYP)-num$([F:YPVF]IND)-num$([F:YEL]XQELEFAT)-'YIPI'-NUM$(YIPI) , 0) FROM GESECRAN
    Filter [F:YPVF2]
    Read [F:YPVF2]PVF0=[F:YPVF]VCRNUM;[F:YPVF]VCRTYP;[F:YPVF]IND
    if !fstat
    CALL ECR_TRACE('ENTROU NO FSTAT' , 0) FROM GESECRAN
    Case [F:YEL]XQELEFAT
    When 6
    [F:YPVF2]INVORDAMT=YIPI
    [F:YPVF2]RCPCPLAMT=YIPI
    When 5
    [F:YPVF2]INVORDAMT=YICMS
    [F:YPVF2]RCPCPLAMT=YICMS
    endcase
    ReWrite [F:YPVF2]
    endif
    next

    For I=0 To [M:PIH4]NBFAC
    Affzo [M:PIH4]INVDTAAMT(I)
    Affzo [M:PIH4]INVORDAMT(I)
    Affzo [M:PIH4]RCPCPLAMT(I)
    Next I

    #CALL FERME_TRACE FROM LECFIC
    #CALL LEC_TRACE FROM LECFIC

    RETURN

  • 0
    SUGGESTED

    Use the below code snippet

    $AVANT_ACT

    Case BOUT

      When "N"

          #You can write code here

    Endcase

    Return

    Thank you,

    Shereef N

  • 0 in reply to FormerMember

    I think is better NEVER invoke GOBJSUB. 

    Well I think what you want is that User never click new? Rigth? Because any previous answer is for that. Please could you confirm? Maybe we have a possible solution. 

    Regards,