ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

What am I missing??

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

  • What am I missing??

    I'm trying to format a value with a Procedure. Final desired result would be:

    INSTRING: '388447389 '
    OUTSTRING: '0000000000388447389'

    The Call:

    EJMCC# = Proc01( Field : 'Desc' : 19 );

    Header Info:

    Code:
         p Proc01          b
         D Proc01          pi           500A
         D  pVal                               Value Like( FIELDTEXT )
         D  pField                       10A   Value
         D  pLen                          2S 0 Value
       ...
    Code:
    Code:
                  @Val      = %Dec( pVal : pLen : 0 );
                  ISDStrLen = pLen;
                  ISDETEXT  = %EditC( @Val : 'X' );
    But, I get the message:

    "Second parameter for %DEC or %DECH is not valid

    What am I missing??

  • #2
    Re: What am I missing??

    Hi,

    the second and third parameter in %DEC or %DecH must be known at compile time. Using a variable as second or third parameter is not allowed.

    Instead of converting a character string into a numeric value and reconvert into a character string, you may work with EVALR and %Subst.

    Something like this (not tested and perhaps there are better solutions):
    PHP Code:
    D RtnValue        S                   500A   Varying

     
    /Free
       
    %Len(RtnValue) = pLen;
       
    RtnValue = %Xlate(' ''0'RtnValue);
       %
    Subst(RtnValuepLen - %Len(%Trim(pVal))) = %Trim(PVal); 
    Birgitta

    Comment


    • #3
      Re: What am I missing??

      OK then, does anyone have a Masking Procedure for Credit Card data? Where I can pass it up to 19 bytes and it replaces all but the first 4 and last 4 digits with an '*'?? It's variable length, and I'm doing this in /FREE. But, I'm trying to allow the function to encrypt and mask any passed value greater than 5 bytes (up to 20 bytes).

      Comment


      • #4
        Re: What am I missing??

        will this work okay so its backwards but the idea might work
        the encrypt function can be found in the forum under tools.

        Code:
        d ###@@X          pr                                        
        d  infield                      18                          
                                                                    
        d ###@@X          pi                                        
        d  infield                      18                          
         *                                                          
        d length          s              3  0                       
         *                                                          
                                                                    
         /free                                                      
                                                                    
                length = %len(%trim(infield));                      
                infield = '****' + %subst(infield:5:length-4);      
                %subst(infield:length-3:4) = '****';                
                                                                    
                dsply infield ' ';
        the other way
        Code:
        d ###@@X          pr                                                
        d  infield                      18                                  
                                                                            
        d ###@@X          pi                                                
        d  infield                      18                                  
         *                                                                  
        d length          s              3  0                               
        d thefront        s              4                                  
        d theback         s              4                                  
        d filler          s             18     inz('******************')    
         *                                                                  
         /free                                                              
                length = %len(%trim(infield));                              
                if length > 8;                                              
                 thefront = %subst(infield:1:4);                            
                 theback = %subst(infield:length-3:4);                      
                 infield = thefront +                                       
                            %subst(filler:1:length-8) +                     
                            theback;                                        
                 dsply infield ' ';                
                endif;                             
                                                   
                                                   
                                                   
              *inlr = *on;                         
         /end-free
        All my answers were extracted from the "Big Dummy's Guide to the As400"
        and I take no responsibility for any of them.

        www.code400.com

        Comment


        • #5
          Re: What am I missing??

          Damm that jamie is fast

          Code:
          dinstring         s             15    inz('3884473898765  ')         
          doutstring        s             19                                   
          dL                s              5i 0                                
           /free                                                               
             // all but the first 4 and last 4 are * outstring = 3884*****8765 
              L=%len(%trim(instring));                                         
              outstring=instring;                                              
             %subst(outstring:5:L-8)='****************';                       
             // just the first 4 and last 4 are * outstring = ****47389****    
              outstring=instring;                                              
             %subst(outstring:1:4)='****';                                     
             %subst(outstring:L-3:4)='****';                                   
                *inlr = *on;                                                   
           /end-free
          Best of Luck
          GLS
          Last edited by GLS400; July 24, 2008, 01:59 PM. Reason: changed l to L
          The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

          Comment


          • #6
            Re: What am I missing??

            it just sounded fun I think im gonna add the encrypt part on this later!
            All my answers were extracted from the "Big Dummy's Guide to the As400"
            and I take no responsibility for any of them.

            www.code400.com

            Comment


            • #7
              Re: What am I missing??

              okay here is a small example of a procedure.......
              that uses the encrypting API (Qc3EncryptData)

              okay create a source file called SOURCE

              PHP Code:
              crtsrcpf mylib/source  rcdlen(112
              then put the three source members I gave you in there.

              first use (F15) on the module ==> ENCRYPT

              and for pete's sake in my example I use "MYLIB" change it
              to a real library on your own systemi
              Code:
              CRTRPGMOD MODULE(MYLIB/ENCRYPT) SRCFILE(MYLIB/SOURCE)
              do the same for the testing program
              Code:
              CRTRPGMOD MODULE(MYLIB/ENCRYPTTST) SRCFILE(MYLIB/SOURCE)
              but then do this
              Code:
              crtpgm mylib/encrypttst module(encrypttst encrypt)

              now just start debug on ENCRYPTTST and watch the PFM..
              that would be "Pure EFIN Magic"
              Attached Files
              All my answers were extracted from the "Big Dummy's Guide to the As400"
              and I take no responsibility for any of them.

              www.code400.com

              Comment

              Working...
              X