ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Window push button return to previous screen

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Window push button return to previous screen

    Hello there,

    I am a newbie in RPGLE and I started working 2 months ago in a company which is training us for AS400 and RPGLE. I switched from Robotics Engineering to programming and I'm kinda having a hard time for the moment because I don't have the mindset of a programmer yet but I am trying my best. I can read the code easily but when it's about writing in code my ideas then sometimes I am having a hard time like now.


    I created a Window with push buttons YES and NO, . When I press YES everything goes by the plan and updates the record. When I press NO i would like to quit my Window and get me back to my main program display but everytime it gets me out of the program because i have RETURN, even If I would use ExFmt MainDisplay the program will still continue after de display is executed and not going back to the starting point. I am trying to find a solution to a solution so that when I press NO i am sent back to my display.
    In the code the ''problem'' Starts from F3 and at F7 is the moment when I press NO (Push =2) and ExFmt GLCACCD1 is executed and after it is executed I would like to start again from DoW Not *InKC but the program keeps going forward.

    Sorry if my explantion is not that good, i noted some things too on the code to be easier to understand.



    Code:
    hDFTACTGRP(*No)
    hActGrp('CAAC')
    hOption(*NoDebugIO)
    hBndDir('BNDDIR1021')
    fGLCACCD0 CF E WORKSTN
    fGLCACCL0 UF A E K DISK ExtFile(wOvrDBF)
    f UsrOpn
    fXXGNCDL0 IF E K DISK
    ddsLDA ds DtaAra(*LDA)
    d #Acct 7S 0 inz
    d #Sts 1
    
    ddsPSDS sds
    d #ProgName 1 10A
    d #ProgLib 81 90
    
    dwErr s N
    dwCommand s 512
    ddsCACCD1Ext1 e ds ExtName(GLCACCD0:GLCACCD1)
    d Inz
    ddsCACCD1Ext2 e ds ExtName(GLCACCD0:GLCACCD1)
    d Prefix('CA':2)
    ddsCACCD1Ext3 e ds ExtName(GLCACCD0:GLCACCD1)
    d Qualified
    d Inz
    ddsCACCD1Ext4 e ds ExtName(GLCACCD0:GLCACCD1)
    d Qualified
    d Inz
    * Prototypes
    d$IsInvalid pr N
    d******************
    d$SendMessage pr ExtProc('$SENDMESSAGE')
    d pMessageID 7 Const
    d pMsgData 1024 Const
    d Options(*NoPass)
    d*
    dwOvrDBF s 21
    d******************
    d$QCMDEXC pr ExtPgm('QCMDEXC')
    d pCommand 512 Const
    d pLength 15p 5 Const
    d*
    d$ClearMessages pr ExtProc('$CLEARMESSAGES')
    d******************
    dGLCAIQR0 pr ExtPgm('GLCAIQR0')
    d pAcct 7s 0
    
    d Acc#Inc S 7s 0
    d #Found S N
    d #DF7 S 2s 0
    d Executer S 30s 0
    d* Push s 1s 0
    d$DSP1File2 pr
    d******************
    d$File2DSP1 pr
    
    
    /Free
    // Reset #Sts;
    // $SettingUp();
    // $PrepareScreen();
    Monitor;
    wCommand ='CRTDUPOBJ +
    OBJ(GLCACCP0) +
    FROMLIB(TEST_OCT21) +
    OBJTYPE(*FILE) +
    TOLIB(QTEMP) +
    DATA(*YES)';
    $QCMDEXC(%Trim(wCommand):%Len(%Trim(wCommand)));
    wCommand ='CRTDUPOBJ +
    OBJ(GLCACCL0) +
    FROMLIB(TEST_OCT21) +
    OBJTYPE(*FILE) +
    TOLIB(QTEMP) +
    DATA(*YES)';
    $QCMDEXC(%Trim(wCommand):%Len(%Trim(wCommand)));
    wCommand ='CRTDUPOBJ +
    OBJ(GLCACCL1) +
    FROMLIB(TEST_OCT21) +
    OBJTYPE(*FILE) +
    TOLIB(QTEMP) +
    DATA(*YES)';
    $QCMDEXC(%Trim(wCommand):%Len(%Trim(wCommand)));
    On-Error;
    EndMon;
    #dPgmN = #ProgName;
    @DPGMQ = #ProgName;
    wOvrDBF='GLCACCL0';
    $ClearMessages();
    OPEN GLCACCL0;
    // Display;
    Write GLCACCH1;
    Write GLCACCF1;
    Write XXERRMH1;
    ExFmt GLCACCD1;
    
    
    [B][U]DoW Not *InKC;[/U]                              [SIZE=16px]  //F3= Exit[/SIZE]
    [U]Clear #DF7;[/U][/B]
    Select;
    When *InKD;                                     //F4= Record List
    Select;
    When @FLD = '@DACCT';
    #Sts = 'A';
    Out dsLDA;
    GLCAIQR0(@DACCT);
    In dsLDA;
    Chain (@DACCT) GLCACCL0;
    // Acc#Inc = @DACCT;
    If %Found();
    $DSP1File2(); //dsCACCD1Ext1 = dsCACCD1Ext2;
    dsCACCD1Ext4 = dsCACCD1Ext2;
    #Found = *On;
    else;
    Reset GLCACCD1;
    @DACCT = Acc#Inc;
    ENDIF;
    ENDSl;
    
    
    When *InKE;                                    //F5 = Refresh
    Reset GLCACCD1;
    $ClearMessages();
    
    
    When *InKG;                                    [SIZE=16px][B]//F7 = Post[/B][/SIZE]
    //$IsInvalid();
    [U][B]#DF7 =#DF7 + 1;
    ExFmt Dialog;
    Select;
    When Push=1;
    #DF7 +=1;
    When Push =2;
    ExFmt GLCACCD1;
    EndSl;[/B][/U]
    If Not $IsInvalid();
    SetLL (@DACCT) GLCACCL0;
    If not %Equal ; //#Found
    $File2DSP1(); //dsCACCD1Ext2 = dsCACCD1Ext1;
    Write GLCACCP1;
    $SendMessage('GL00000':%Char(CAACCT)); //Account succesfully created
    //RESET GLCACCD1;
    Else;
    Chain @DACCT GLCACCL0;
    If %Found() AND dsCACCD1Ext2= dsCACCD1Ext4;
    $File2DSP1();//dsCACCD1Ext2=dsCACCD1Ext1;
    
    //dsCACCD1Ext4= dsCACCD1Ext2;
    // If dsCACCD1Ext2 <> dsCACCD1Ext4;
    // $SendMessage('GL00026':%Char(CAACCT));
    // Else;
    Update GLCACCP1;
    RESET GLCACCD1;
    $SendMessage('GL00024':%Char(CAACCT)); //Account Updated
    Else;
    $ClearMessages();
    $SendMessage('GL00027':%Char(CAACCT)); //Account modified, press F7 to update
    // ExFmt Dialog;
    // Select;
    // When Push=1;
    // #DF7 =1;
    // When Push =2;
    // Return;
    // Endsl;
    dsCACCD1Ext2=dsCACCD1Ext4;
    If #DF7 = 2;
    $ClearMessages();
    $SendMessage('GL00033':%Char(CAACCT));//Account Updated again
    $File2DSP1();//dsCACCD1Ext2=dsCACCD1Ext1;
    Update GLCACCP1;
    Reset GLCACCD1;
    Reset #DF7;
    
    ENDIF;
    
    ENDIF;
    
    //RESET GLCACCD1;
    Endif;
    EndIf;
    // EndIf;
    
    
    When *InKH; //F8 = Insert Record;
    Acc#Inc = @DACCT;
    Chain(n) (@DACCT) GLCACCL0;
    If %Found();
    #Found =*On;
    $DSP1File2(); //dsCACCD1Ext1 = dsCACCD1Ext2;
    dsCACCD1Ext4 = dsCACCD1Ext2;
    Else;
    dsCACCD1Ext3= dsCACCD1Ext1; //1
    Reset GLCACCD1;
    dsCACCD1Ext1 = dsCACCD1Ext3;
    Clear dsCACCD1Ext3;
    EndIf;
    dsCACCD1Ext3.@RCD = @RCD;
    dsCACCD1Ext3.@FLD = @FLD;
    IF dsCACCD1Ext1 <> dsCACCD1Ext3;
    $IsInvalid ();
    
    ENDIF;
    
    
    When *InKK; //F11 = Delete;
    Chain @DACCT GLCACCL0;
    If %Found();
    Delete GLCACCP1;
    $SendMessage('GL00025':%CHar(CAACCT)); //Account deleted
    Elseif not %Found();
    $SendMessage('GL00029':%Char(CAACCT));
    Endif;
    
    
    Other; //ENTER
    $IsInvalid();
    // Select;
    // When Push = 1;
    // #DF7 += 1;
    // When Push = 2;
    // #DF7 = 0;
    
    // ENDSL;
    ENDSL;
    // $Validate();
    //EndSl;
    //Write GLCACCH1;
    //Write GLCACCF1;
    Write XXERRMH1;
    ExFmt GLCACCD1;
    ////// If #DF7 = 2;
    ////// ExFmt Dialog;
    ////// else;
    ////// ExFmt GLCACCD1;
    ////// ENDIF;
    // If #DF7 =2;
    // ExFmt Dialog;
    // Return;
    // ExFmt GLCACCD1;
    // Clear #DF7;
    // Else;
    // ExFmt Dialog;
    // ENDIF;
    EndDo;
    If *InLR;
    *InLR = *Off;
    Else;
    *InLR = *On;
    ENDIF;
    /End-Free
    p $DSP1File2 b
    d $DSP1File2 pi
    d*dsCACCD1Ext1 = dsCACCD1Ext2;
    /Free
    
    @DACCT = CAACCT;
    @DDESC = CADESC;
    @DDELN = CADELN;
    @DACTP = CAACTP;
    @DFATP = CAFATP;
    @DVTTP = CAVTTP;
    @DCTTP = CACTTP;
    @DVTPC = CAVTPC;
    @DCNTP = CACNTP;
    @DOPIN = CAOPIN;
    @DREF1 = CAREF1;
    @DREF2 = CAREF2;
    @DUSD1 = CAUSD1;
    @DUSD2 = CAUSD2;
    @DUSD3 = CAUSD3;
    @DUSD4 = CAUSD4;
    @DUSD5 = CAUSD5;
    @DACST = CAACST;
    @DEFDT = CAEFDT;
    @DIADT = CAIADT;
    /End-Free
    p $DSP1File2 e
    p*
    p*
    p $File2DSP1 b
    d $File2DSP1 pi
    d*dsCACCD1Ext2 = dsCACCD1Ext1;
    /Free
    CAACCT = @DACCT;
    CADESC = @DDESC;
    CADELN = @DDELN;
    CAACTP = @DACTP;
    CAFATP = @DFATP;
    CACTTP = @DCTTP;
    CAVTTP = @DVTTP;
    CAVTPC = @DVTPC;
    CACNTP = @DCNTP;
    CAOPIN = @DOPIN;
    CAREF1 = @DREF1;
    CAREF2 = @DREF2;
    CAUSD1 = @DUSD1;
    CAUSD2 = @DUSD2;
    CAUSD3 = @DUSD3;
    CAUSD4 = @DUSD4;
    CAUSD5 = @DUSD5;
    CAACST = @DACST;
    CAEFDT = @DEFDT;
    CAIADT = @DIADT;
    /End-Free
    p $File2DSP1 e
    
    p$IsInvalid b
    d$IsInvalid pi 1N
    d wErr s 1N
    d wValues s 1024
    /Free
    $ClearMessages();
    %SubArr(*In:31:17) = *Off;
    if @DACCT <= 0;
    *In31 = *On;
    wErr = *On;
    $SendMessage('GL00001':*Blank);
    EndIf;
    if @DDESC = *Blank;
    *In32 = *On;
    wErr = *On;
    $SendMessage('GL00002');
    @DDELN = *Blank;
    *In33 = *On;
    wErr = *On;
    else;
    @DDELN = @DDESC;
    //$SendMessage('GL00003');
    EndIf;
    If @DACTP = *Blank;
    *In35 = *On;
    wErr = *On;
    $SendMessage('GL00004');
    Else;
    SetLL ('ACTP':@DACTP) XXGNCDL0;
    If not %Equal();
    *In35 = *On;
    wErr = *On;
    wValues= *Blank;
    SetLL 'ACTP' XXGNCDL0;
    ReadE 'ACTP' XXGNCDL0;
    Dow Not %Eof();
    wValues = %Trim(wValues) + '/'+ %Trim(GCCODE);
    ReadE 'ACTP' XXGNCDL0;
    ENDDO;
    wValues = %Trim(wValues: '/');
    $SendMessage('GL00019':%Trim(wValues));
    ENDIF;
    EndIf;
    //if @DDELN = *Blank;
    // @DDELN = @DDESC;
    // *In33 = *On;
    // wErr = *On;
    // $SendMessage('GL00003');
    // ENDIF;
    if @DFATP = *Blank;
    *In42 = *On;
    wErr = *On;
    $SendMessage('GL00005');
    Endif;
    if @DCTTP = *Blank;
    *In34= *On;
    wErr = *On;
    $SendMessage('GL00006');
    Endif;
    if @DCNTP = *Blank;
    *In36= *On;
    wErr = *On;
    $SendMessage('GL00009':'Y/N');
    Endif;
    If @DCNTP <> 'Y'
    AND @DCNTP <> 'N';
    *In36 = *On;
    wErr = *On;
    $SendMessage('GL00009':'Y/N');
    EndIf;
    If @DOPIN <>'Y'
    And @DOPIN <>'N';
    *In38 = *On;
    wErr = *On;
    $SendMessage('GL00010':'Y/N');
    EndIf;
    If @DREF1 <> 'N'
    AND @DREF1 <> 'Y';
    *In39 = *On;
    wErr = *On;
    $SendMessage('GL00011':'Y/N');
    EndIf;
    If @DREF2 <> 'N'
    AND @DREF2 <> 'Y';
    *In46 = *On;
    wErr = *On;
    $SendMessage('GL00012''Y/N');
    Endif;
    If @DUSD1 = *Blank;
    *In40 = *On;
    wErr = *On;
    $SendMessage('GL00013');
    ENDIF;
    If @DUSD2 = *Blank;
    *In41= *On;
    wErr = *On;
    $SendMessage('GL00014');
    ENDIF;
    If @DUSD3 = *Blank;
    *In43= *On;
    wErr = *On;
    $SendMessage('GL00015');
    ENDIF;
    If @DUSD4 = *Blank;
    *In45 =*On;
    wErr = *On;
    $SendMessage('GL00016');
    ENDIF;
    If @DUSD5= *Blank;
    *In47 = *On;
    wErr = *On;
    $SendMessage('GL00017');
    ENDIF;
    Return wErr;
    /End-Free
    p$IsInvalid e
Working...
X