IBM i Global

IBM i 

A space for professionals working with IBM’s integrated OS for Power systems to exchange ideas, ask questions, and share expertise on topics like RPG and COBOL development, application modernization, open source integration, system administration, and business continuity.


#Power


#IBMi
#Power
 View Only
  • 1.  Displaying a message

    Posted Mon October 02, 2023 01:32 PM

    Hi,

    One of the subroutine in my program checks whether case/pallet entered is valid or not and accordingly it displays message on the screen.

    Currently it accepts case id and displays it on the screen as per program's flow but  i just want to add a message on the screen that when any case id is entered that 'you entered case not pallet' and after this it should proceed like earlier i mean after overriding this message program's flow should be continued like earlier so i just wanted to introduce this warning kind of message only which should be overriden(soft warning).

    my subroutine to validate pallet and case id is like below , kindly advise suitable changes in this subroutine to get this soft warning introduced in it.

    [code]

          **************************************************************************
          * Subroutine VLDT1 - To validate scanned LPNs                        *
          **************************************************************************
         C     Vldt1         BegSr
          *
          /Free
                Wrk_Paid = *Blanks;
                ItemClas = *Blanks;
    em01        FlgProcess2 = 'N';

                If  WSCASN = *Blanks;
                      WsMsg = 'Scan Palet/Case';
                      Flg_Error = 'Y' ;
                      LeaveSr;
                EndIf;

               // Invalid case/Pallet scanned
                Chain(N)  WSCASN  IDCASE00;                //Single Case
                IF  Not %Found(IDCASE00);
                Chain(N) (LdWhse:' ':WSCASN) IDCASE10;
                  If  Not %Found(IDCASE10);
                      WsMsg = 'Not Valid Cs/Pl';
                      Flg_Error = 'Y' ;
                      LeaveSr;
                  Else ;
                    if PltOrCase = ' ' ;
                      PltOrCase = 'P' ;
    em22            elseif PltOrCase = 'X' and idpaid <> *blanks;
     |                exec sql
     |                  select count(*) into :count from idcasez3
     |                  where idwhse = :ldwhse and idzone = :w_zone and
     |                    idaisl = :w_aisl and idbay = :w_bay and
     |                    idlevl = :w_levl and idposn = :w_posn and
     |                    idpaid = ' ';
     |                if count > *zero;
     |                  WsMsg = 'Scan ONLY Cases';
     |                  Flg_Error = 'Y' ;
     |                  LeaveSr;
     |                else;
     |                  Exec Sql
     |                   Select count(*) into :count from idcase36
     |                     where idpaid = :idpaid;
     |                  if count = stptqt or count = stnum5;
     |                    WsMsg = 'Partial Pallet Only';
     |                    Flg_Error = 'Y' ;
     |                    LeaveSr;
     |                  endif;
    em22              endif;
                    else;
                      if PltOrCase = 'C' ;
                         WsMsg = 'Scan ONLY Cases';
                         Flg_Error = 'Y' ;
                         LeaveSr;
                      endif;
                    endif;
                  EndIf;
                ELSE;
                    If PltOrCase = ' ' ;
                       PltOrCase = 'C' ;
                    Else;
                      if PltOrCase = 'P' ;
                         WsMsg = 'Scan ONLY Pallet';
                         Flg_Error = 'Y' ;
                         LeaveSr;
                      endif;
                    EndIf;
                EndIf;

    em22        // If called from TOM Back Order, check GTOBKORP
     |          if l00_inpln <> *blanks;
     |            chain(n) (l00_inlocn:l00_inpln:wscasn) gtobkorp;
     |            if not %found (gtobkorp);
     |              wsmsg = 'Invalid Pallet/Case';
     |              Flg_Error = 'Y';
     |              LeaveSr;
     |            else;
     |              if boflag = '1';
     |                wsmsg = 'Invalid Pallet/Case';
     |                Flg_Error = 'Y';
     |                LeaveSr;
     |              endif;
     |            endif;
    em22        endif;

               //Case or cases on pallet can NOT be locked with 'QH' lock
                Chain(N)  WSCASN  IDCASE00;                //Single Case
                IF  %Found(IDCASE00);

    ra02          //if IdLkcd = 'QH' OR IdLkc2 = 'QH' OR IdLkc3 = 'QH' OR
    ra02          //   IdLkc4 = 'QH' OR IdLkc5 = 'QH' ;
    ra02          //Lock code logic
    ra02          exSr @getLockCodes;
    ra02          If lockCodeErr;
                        WsMsg = 'No Locked Cases';
                        Flg_Error = 'Y' ;
                        LeaveSr;
                  endif;

               //can NOT have SDC & SD2 Items. They belong to SDC/SD2
    em01         Exsr Read_BNK012P;
     |         //GSITEM = %trim(IdStyl) + %trim(IdSsfx);
     |         //Chain  GSITEM  GSDCXREFP;
     |         //If  %found(GSDCXREFP);
     |         //   if (IDCASN < GSLOW  OR  IDCASN > GSHIGH  OR
     |         //         IDSC1 = GSREVS);
     |         //       WsMsg = 'No SDC/SD2 units';
     |         //       Flg_Error = 'Y' ;
     |         //       LeaveSr;
     |         //   endif;
    em01       //EndIf;

                ELSE;

                  SetLL (LdWhse:' ':WSCASN) IDCASE10;   //Pallet is scanned
                  ReadE(N) (LdWhse:' ':WSCASN) IDCASE10;
                  DoW  Not %Eof(IDCASE10);
                        Wrk_Paid = 'Y' ;

                  //Case or cases on pallet can NOT be locked with 'QH' lock
    ra02             //if IdLkcd = 'QH' OR IdLkc2 = 'QH' OR IdLkc3 = 'QH' OR
    ra02             //   IdLkc4 = 'QH' OR IdLkc5 = 'QH' ;
    ra02             //Lock code logic
    ra02             exSr @getLockCodes;
    ra02             If lockCodeErr;
                           WsMsg = 'No Locked Cases';
                           Flg_Error = 'Y' ;
                           LeaveSr;
                     endif;

                  //can NOT have SDC & SD2 Items. They belong to SDC/SD2
    em01            Exsr Read_BNK012P;
     |            //GSITEM = %trim(IdStyl) + %trim(IdSsfx);
     |            //Chain  GSITEM  GSDCXREFP;
     |            //If  %found(GSDCXREFP);
     |            //   if (IDCASN < GSLOW  OR  IDCASN > GSHIGH  OR
     |            //         IDSC1 = GSREVS);
     |            //       WsMsg = 'No SDC/SD2 units';
     |            //       Flg_Error = 'Y' ;
     |            //       LeaveSr;
     |            //   endif;
    em01          //EndIf;

                  ReadE(N) (LdWhse:' ':WSCASN) IDCASE10;
                  EndDo;

                ENDIF;

               //save item first time when you scanned
                  IF  W_Styl = *Blanks;
                      W_Whse = IdWhse;
                      W_Co   = IdCo  ;
                      W_Div  = IdDiv ;
                      W_Zone = IdZone;
                      W_Aisl = IdAisl;
                      W_Bay  = IdBay ;
                      W_Levl = IdLevl;
                      W_Posn = IdPosn;
                      W_Styl = IdStyl;
                      W_Ssfx = IdSsfx;
                      W_Item = %trim(W_Styl) + %trim(W_Ssfx);
                  ELSE;
               //can NOT have mixed SKU
                     If W_Styl <> IdStyl OR W_Ssfx <> IdSsfx ;
                         WsMsg = 'No Mixed SKUs';
                         Flg_Error = 'Y' ;
                         LeaveSr;
                     EndIf;
                  ENDIF;

    em04    // Make sure full and partial pallet not being mixed
     |      PartialPalt = 'N';
    em05    // Check if equipment
     ||     itnbr = %trim(W_Styl) + %trim(W_Ssfx);
     ||     Chain ('003':itnbr) itmrevl1;
    em05    If %found (itmrevl1) and opegrp = 'EQ';
     |      Chain ('GOODMAN':'MFG':' ':' ':W_Styl:W_Ssfx) STSTYL00;
     |      If PltOrCase = 'C';
     |        If stptqt > 1 or stnum5 > 1;
     |          PartialPalt = 'Y';
     |        EndIf;
     |      Else;
     |        If PltOrCase = 'P';
     |          Exec Sql
     |            Select count(*) into :count from idcase36
     |              where idpaid = :idpaid;
     |          If count <> stptqt and count <> stnum5;
     |            PartialPalt = 'Y';
     |          EndIf;
     |        Else;
     |          If PltOrCase = 'X';
    em22          if idpaid = *blanks;
     ||             PartialPalt = 'N';
     ||           else;
     ||             PartialPalt = 'Y';
    em22          endif;
     |          EndIf;
     |        EndIf;
     |      EndIf;
     |
     |      // Loop thru cases in Printer location/Pallet#/Case#
     |      // to check if it contains partial pallets
     |      Setll (LdWhse:' ':W_FlLocn) IDCASE10;
     |      Reade (LdWhse:' ':W_FlLocn) IDCASE10;
     |      If %eof (IDCASE10);
     |            P_Zone  = %Subst(W_FLLOCN:1:2);
     |            P_Aisl  = %Subst(W_FLLOCN:3:2);
     |            P_Bay   = %Subst(W_FLLOCN:5:2);
     |            P_Levl  = %Subst(W_FLLOCN:7:2);
     |            P_Posn  = %Subst(W_FLLOCN:9:2);
     |        Setll (LdWhse:P_Zone:P_Aisl:P_Bay:P_Levl:P_Posn) IDCASEZ3;
     |        Reade(n) (LdWhse:P_Zone:P_Aisl:P_Bay:P_Levl:P_Posn) IDCASEZ3;
     |      EndIf;
     |      If not %eof (IDCASE10) or not %eof (IDCASEZ3);
     |        If IdPaid = *blanks;
     |        // Carton
     |          If stptqt > 1 or stnum5 > 1;
     |            PltOrCase = 'X';
     |          EndIf;
     |        Else;
     |          // Pallet
     |          Exec Sql
     |            Select count(*) into :count from idcase36
     |              where idpaid = :idpaid;
     |          If count <> stptqt and count <> stnum5;
     |            PltOrCase = 'X';
     |          EndIf;
     |        EndIf;
     |
     |        // Set error if partial pallet in printer location
     |        // and non-partial pallet is being loaded
     |        If PltOrCase = 'X' and PartialPalt <> 'Y';
     |          WsMsg = 'Partial Pallet Only';
     |          Flg_Error = 'Y' ;
     |          LeaveSr;
     |        Else;
     |          If PltOrCase = 'C' and PartialPalt = 'Y';
     |            WsMsg = 'Scan ONLY Cases';
     |            Flg_Error = 'Y' ;
     |            LeaveSr;
     |          Else;
     |            If PltOrCase = 'P' and PartialPalt = 'Y';
     |              WsMsg = 'Scan ONLY Full Palt';
     |              Flg_Error = 'Y' ;
     |              LeaveSr;
     |            EndIf;
     |          EndIf;
     |        EndIf;
     |
     |      EndIf;
    em04
    em05    EndIf;
    kc01
     |      stprgr = *blanks;
     |      Chain ('GOODMAN':'MFG':' ':' ':W_Styl:W_Ssfx) STSTYL00;
     |      if stprgr = *blanks;
     |        Flg_Error = 'Y' ;
     |        wssku = W_Styl + W_Ssfx;
     |        WsMsg = 'New item - See Sup';
     |        LeaveSr;
    kc01    endif;

          /End-Free
          *
          * No Error ? then move units from EOL locn into Forklift locn
          * Move scanned Pallet(s)/Case(s) from EOL locn into Forklift printer locn
         C                   Exsr      MvEOL2Prt
          *
          /Free
                 Chain(N)  ISZ3Key1  ISLOCNZ3;
                 if  %Found(ISLOCNZ3);
                    WsSKU  = %trim(IsStyl) + %trim(IsSsfx);
                    W_Item = %trim(IsStyl) + %trim(IsSsfx);
                    WsInvu = IsInvu;

            //find Item Class
                    chain (W_Item:'DDC') ITEMBL;
                    if %found(ITEMBL);
                       ItemClas = I_ITCLS;  //ISSYR exist both in ITEMBL & ISLOCN files
                    endif;

                 endif;
          /End-Free
         C                   EndSr
          **************************************************************************

    [/code]



    ------------------------------
    Kevin Steve
    ------------------------------


  • 2.  RE: Displaying a message

    Posted Mon October 02, 2023 01:45 PM

    I tried below changes in this subroutine but it just seems to be stopping it's previous flow and seems kind of hard warning because it's not getting overridden because prior to introducing this warning message program displayed details as per the enetred Case ID' but now though i can see this warning message but after pressing the enter key it remains on te same screen i mean not getting overridden (which normally happens in a soft warning kind of messages):-

    below is my updated code for this desired soft warning :-

    [code]

          ENDIF;                                              
            ENDIF;                                            
     //     Else;                                             
          Chain(N)  (LdWhse: ' ':WSCASN) IDCASE10;            
            IF NOT  %FOUND(IDCASE10);                         
                WsMsg = 'you scanned Case instead of pallet'; 
                Flg_Error = 'Y' ;                             
                LeaveSr;                                      
     //     ENDIF;                                            

    [/code]

    Kindly advise what's wrong in it and please share updated code which should throw that soft warning but should be overridden.

    Thanks



    ------------------------------
    Kevin Steve
    ------------------------------



  • 3.  RE: Displaying a message

    Posted Mon October 02, 2023 01:53 PM

    Hi,

    Just for better clarity i changed my last code( 2nd post)  after the below statements in this subroutine (post 1-Subroutine VLDT1 - To validate scanned LPNs ) which displays this warning message but we can't override it so i want it to be overridden and continue the flow of orginal subroutine later on after bypassing this soft warning message.

    [code]

     // Invalid case/Pallet scanned
                Chain(N)  WSCASN  IDCASE00;                //Single Case
                IF  Not %Found(IDCASE00);
                Chain(N) (LdWhse:' ':WSCASN) IDCASE10;
                  If  Not %Found(IDCASE10);
                      WsMsg = 'Not Valid Cs/Pl';
                      Flg_Error = 'Y' ;
             

            LeaveSr;

     [/code]

    So Kindly advise the desired changes here.

    Thanks 



    ------------------------------
    Kevin Steve
    ------------------------------



  • 4.  RE: Displaying a message

    Posted Tue October 03, 2023 04:50 AM

    Hi, 

    Anyone has any idea on this please  ? 

    Thanks



    ------------------------------
    Kevin Steve
    ------------------------------



  • 5.  RE: Displaying a message

    Posted Wed October 04, 2023 11:48 AM

    Hi,

    To display that soft warning which needs to be overridden changes need to be done inside this VLDT1 subroutine.

    Here in this Subroutine 'VLDT1 - To validate scanned LPNs'

    How can we make below changes :-

    when they enter Pallet and it does NOT exist in IDCASE10 then hard stop error.

     -->If they enter case# (that does NOT start with letter 'L')
     and it does NOT exist in IDCASE00 file, then hard stop error.  

    -->If they enter valid case# (ie., it exists in IDCASE00 but NOT in IDCASE10) 
    then "warning soft error". With the use of SELECT and ENDSL statements combining with LeaveSR ?

    If any one has expertise in SQLRPGLE then could someone please advise here ?

    Thanks



    ------------------------------
    Kevin Steve
    ------------------------------



  • 6.  RE: Displaying a message

    Posted Thu October 05, 2023 09:25 AM

    Kevin,

    Not sure anyone can reasonably help given that we don't have the entire program, or at least the code that executes the subroutine, and the display file DDS.

    What is the result of executing the subroutine? Are the fields Flg_Error and WsMsg being set as expected?

    If so, what logic in the mainline code is used to EXFMT the display file format? Upon return from the subroutine your mainline code would need to re-display the screen to show the message. Is that happening and the message just doesn't display?

    I'm not confident I understand what you desire to happen versus what is actually happening.

     As for the use of SELECT and ENDSL you should be able to read about those op-codes in the RPG Reference Manual. Pretty much operates like any other language.



    ------------------------------
    Gary Keith
    ------------------------------



  • 7.  RE: Displaying a message

    Posted Thu October 05, 2023 12:56 PM

    Not sure if this is what you are looking for but here is some sample code based on your description. Underlined text is from your post.

     -->If they enter case# (that does NOT start with letter 'L')  and it does NOT exist in IDCASE00 file, then hard stop error.  is the first part ("if" to "else") of this block of code.
    -->If they enter valid case# (ie., it exists in IDCASE00 but NOT in IDCASE10) ... starts at the "else" of this block.

    if not %found(IDCASE00);  // does not exist in IDCASE00
      if %substr(WSCASN:1:1) <> 'L';
        // set field values for hard stop error
        leavesr;
      endif;
    else;  // does exist in IDCASE00
      if not %found(IDCASE10);
        // set field values for warning soft error
        leavesr;
      endif;
    endif;

    Note that I am assuming this code is AFTER a CHAIN to those two files. Also, I don't know what the remainder of the logic for the screen looks like so I don't know what fields need to be set to what values to signal an error or hard vs. soft error.



    ------------------------------
    Gary Keith
    ------------------------------