Plex 2E

  • 1.  Condition - compare long text constant

    Posted Mar 25, 2015 08:56 AM

    Please, I need to test field if it's contains, quite long text string and I need to test it in condition

    Text constant for test is: 'BONUS SOBRE COMPRAS CLUBE PEÇA E GANHE'

    So whole it don't fit into condition field as you can see on attached screen:

    text_compare.png

    So is there any possibility how to compare such long string? Or only thing I can do is *CONCAT it to some work variable and than compare it?

    Thanks.



  • 2.  Re: Condition - compare long text constant
    Best Answer

    Posted Mar 25, 2015 10:46 AM

    You are correct,

     

    in PGM initialise

    LCL.Text Teststring =  Concat ''BONUS SOBRE COMPRAS'  with  'CLUBE PEÇA E GANHE' *one space

     

    then

     

    if RCD.DFM Descritivo Documento  EQ  LCL.Text Teststring

       do something

     

     

     

    You need to be sure that the document description will always be exactly as tested of course, else you wil be in to having to uppercase the field, remove blanks, find a likeness to some degree of similarity. 

     

     

    and you could always place all this into an INTFUN - pass in the field, and get back a stsus '*same' or *differs' - and use the INTFUN everywhere you need to do this.  When the value finally alters, you only have to update the one INTFUN which tests for different versions/spelling mistakes.

    Or to take abstraction further, use an extfun, or build it as a procedure in a SRVPGM, then you don't have to recompile everywhere that uses it. 

     

    R

     

     

     

     



  • 3.  Re: Condition - compare long text constant

    Posted Mar 26, 2015 09:17 AM

    Hi there,

     

    I just wanted to add, that in my experience, using *Messages for literals will benefit in the long run, especially with i18N...

     

    So, LCL.Text Teststring = Rtvmsg('Literal that can be translated externally without recompiling stuff')

     

    Crispin.



  • 4.  Re: Condition - compare long text constant

    Posted Mar 26, 2015 12:49 PM

    Hi,

     

      I store them in a file. I am lost with RTVMSG! There is no function by that name, I that a USER SOURCE function ?

     

     

     

    John



  • 5.  Re: Condition - compare long text constant

    Posted Mar 27, 2015 06:06 AM

    Crispin is right of course, especially in a multi lingual environment, but also for normal use.

    Whereas my suggestion would use a CND (never a CON if yiou can avoid it, expressly so that you can locate where a given value is in use,)

     

    To try Crispins method is simple enough

    if you create a msg of type RTV, thus

     

    Field name. . . . . . . . : Object attribute status

    List name . . . . . . . . : Message types          

                                                        

    ?  Value                Description                

      CMP                  Completion message        

      ERR                  Error message              

      EXC                  Execution message          

      INF                  Information message        

    X  RTV                  Retrieval message          

      STS                  Status message            

                                                      

    and then ion an action diagram, use 'insert message' to get the contaent back to a LCL field you can use in the compare.

     

    Function file : *Messages                 Default context . . . . : LCL

    Function. . . : rtvmsgtest                                            

                                                                                                              Obj                                 

    IOB Parameter                 Use Typ   Ctx Object Name               

      O  *MSG                      VRY FLD   LCL Text50

                                                                          

     

     

    This neatly externalises the literal value so that it can be altered instantly, across all functions, by editing the message description.

     

    Appropriate security/authority for changes and so on is then another issue of course, for the program object is no longer completely self contained and is liable to failures brought on by a faulty message file change...

     

    all depends on the circumstances and your requirements.

     

     

    R



  • 6.  Re: Condition - compare long text constant

    Posted Mar 27, 2015 10:11 AM

    Learned something new...

     

    Thanks

         John Slanina



  • 7.  Re: Condition - compare long text constant

    Posted Mar 27, 2015 01:11 PM

    One neat use of RTV messages is to concatenate text by passing parameters to the message. For example if you want to create some text "Please find attached invoice for 12 items from 12/03/15 to 17/03/15", you can use a RTV message and pass in the value and dates. The dates are formatted automatically and leading zeros removed and decimal points added to numeric values (same as with error messages). But you are limited to 132 characters maximum returned from each message.

     

    - Bob