Automatic Validation of LOTN

johndanter

johndanter

Legendary Poster
Hi folks

I've been asked to look at a way of ensuring values entered to LOTN are always numeric....without modifying JDE E1 objects
So they must have values 0 - 9.

The reason I've been asked is there are some weird LOTNs on our system that contain special chars, like # ~ { etc.
We think they came from an import during copy and paste.

I am playing with DD items, using the following in the Edit Rule tab

Range 0 -9 - fails if left blank so I may need to add ' ' and doesn't always work anyway

Value, but this only works Y N 1 0. I'd love to know how to change this, seems to look at F9201.FROER1

My own BSFN but I am at a loss to see how the values are passed like AN8 calls IsColumnInAddressBook. this works magically wherever you have an AN8, so is something I want to replicate.
Seems to use this BF szBEHAVIOR_EDIT_STRING [BHVREDTST]

Any ideas please? Other than modding the input screen

Thanks

John
 
Last edited:
LOTN is one of the few Pristine DD items we modified to specify our own custom DD Edit Rule BSFN for this very reason. In our case users, when pasting, often put in leading spaces.

The DS for DD item Edit Rules are always identical for the first 3 params, the 4th param is simply the DD item itself. Parameter names do not matter, only the DD of the param.

BHVRERRID
BHVREDTST
DL01
[DD Item]

Note that on some tools releases the value was not passed in the DD item in some cases but was passed in szBhvrEditString. I think this was an Xe thing and I don't believe it happens anymore, but as a precaution I always check for empty string, or zero, null date, etc. on the DD item param and if it is I parse from szBhvrEditString - again, I think on modern TR this is no longer needed but I still do it.

If you want to return a description, return a value in szDescription001. This will show up when you associate a description with a DD item in APPLs. If you throw an error, throw it on the [DD Item] param. Be sure and specify the correct ID param number using the #define from the typedef. Standard BSFN error handling type stuff.

Here is our custom LOTN Edit Rule BSFN.

Code:
/*****************************************
 * TYPEDEF for Data Structure
 *    Template Name: DD Edit Rule - LOTN                                         
 *    Template ID:   D5641014A
 *    Generated:     Wed Jan 20 10:55:37 2010
 *
 * DO NOT EDIT THE FOLLOWING TYPEDEF
 *    To make modifications, use the OneWorld Data Structure
 *    Tool to Generate a revised version, and paste from
 *    the clipboard.
 *
 **************************************/

#ifndef DATASTRUCTURE_D5641014A
#define DATASTRUCTURE_D5641014A

typedef struct tagDSD5641014A
{
  ID                idBhvrErrorId;                       
  JCHAR             szBhvrEditString[51];                
  JCHAR             szDescription001[31];                
  JCHAR             szLot[31];                           
} DSD5641014A, *LPDSD5641014A;
 
#define IDERRidBhvrErrorId_1                    1L
#define IDERRszBhvrEditString_2             2L
#define IDERRszDescription001_3                   3L
#define IDERRszLot_4                              4L

#endif

Code:
/************************************************************************** 
 *  Business Function:  AcmeDDEditRuleLOTN 
 * 
 *        Description:  AcmeDDEditRuleLOTN 
 * 
 *         Parameters: 
 *           LPBHVRCOM           lpBhvrCom    Business Function Communications 
 *           LPVOID              lpVoid       Void Parameter - DO NOT USE! 
 *           LPDSD5641           lpDS         Parameter Data Structure Pointer   
 * 
 *************************************************************************/ 
 
JDEBFRTN (ID) JDEBFWINAPI AcmeDDEditRuleLOTN (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD5641014A lpDS)  
 
{ 
   /************************************************************************ 
    *  Variable declarations 
    ************************************************************************/ 
 
   /************************************************************************ 
    * Check for NULL pointers 
    ************************************************************************/ 
   if ((lpBhvrCom == (LPBHVRCOM) NULL) || 
       (lpVoid    == (LPVOID)    NULL) || 
       (lpDS      == (LPDSD5641014A)	NULL)) 
   { 
     jdeErrorSet (lpBhvrCom, lpVoid, (ID) 0, _J("4363"), (LPVOID) NULL); 
     return ER_ERROR; 
   } 
 
   /************************************************************************ 
    * Main Processing 
    ************************************************************************/ 
	if(IsStringBlank(lpDS->szLot))
		jdeStrncpy(lpDS->szLot, lpDS->szBEHAVIOR_EDIT_STRING, DIM(lpDS->szLot)-1);

	/* if the string is NOT blank and the first char is a space, throw an error */
	if(!IsStringBlank(lpDS->szLot) && jdeIsspace(lpDS->szLot[0]))
	{
		jdeErrorSet (lpBhvrCom, lpVoid, (ID)IDERRszLot_4, _J("50041LOTN1"), (LPVOID)NULL); 
		return ER_ERROR;
	}
	
	return ER_SUCCESS; 
}
 
Last edited:
Absolute legend, thanks.

I was looking at cloning N76B020 and only allowing 0 - 9 but then couldn't figure out to get the LOTN value in automatically. Until I spotted the common aliases you've also listed in loads of other DD BSFNS.
I want it work same way as B0000095 Format Company I guess. No matter what they type in, illegal chard disappear.

I'll play around, thanks :)

N31B0260 seems to use those 3 aliases too, so I'll see if I can do it in NER first
 
Last edited:
I think if you want to "scrub" the input data you would do so by returning in szBhvrEditString as well as [DD item].
 
Sadly I'm always getting error 4077 no matter what. Even when blank and I just tab out

NER: RRDScrubLOTN
Event GUID: ABC7F0BA-835B-49EB-A721-1B6C1FED88F6
Data Structure: D55LOTNS - RRD Scrub LOTN DSTR
BF idBHVR_ERROR_ID [BHVRERRID]
BF szBEHAVIOR_EDIT_STRING [BHVREDTST]
BF lotn [DL01]
BF szLot [LOTN]
----------------------------------------
Event Level Variables
----------------------------------------
evt_cCharToProcess [CHAR]
evt_iCount [INTEGER]
evt_iLength [INTEGER]
evt_OutputDescriptionLine1 [DSC1]
----------------------------------------
00001 // Object Creation: John Danter 27/04/2020
00002 // Scrub all srtrings and illegal chars out of the LOTN. Only allow 0-9
00003 BF szLot [LOTN] = BF szBEHAVIOR_EDIT_STRING [BHVREDTST]
00004 -If BF szLot [LOTN] is not equal to <Blank>
And BF szLot [LOTN] is not equal to <NULL>
00005 | VA evt_iCount [INTEGER] = "0"
00006 | VA evt_iLength [INTEGER] = length([BF szLot [LOTN]])
00007 | VA evt_OutputDescriptionLine1 [DSC1] = <NULL>
00008 | -While VA evt_iCount [INTEGER] is less than or equal to VA evt_iLength [INTEGER]
00009 | | VA evt_cCharToProcess [CHAR] = substr([BF szLot [LOTN]], [VA evt_iCount [INTEGER]], "1")
00010 | | //
00011 | | -If VA evt_cCharToProcess [CHAR] is equal to (<Blank>,"0","1","2","3","4","5","6","7","8","9")
00012 | | | VA evt_OutputDescriptionLine1 [DSC1] = concat([VA evt_OutputDescriptionLine1 [DSC1]], [VA evt_cCharToProcess [CHAR]])
00013 | | -Else
00014 | | | Set NER Error("4077", BF szLot)
00015 | | End If
00016 | | //
00017 | | VA evt_iCount [INTEGER] = [VA evt_iCount [INTEGER]]+1
00018 | End While
00019 | BF szLot [LOTN] = VA evt_OutputDescriptionLine1 [DSC1]
00020 End If
 
Thanks to you both, I got this working fine now. I removed the error and just parsed the text instead.

I moved this BF szLot [LOTN] = BF szBEHAVIOR_EDIT_STRING [BHVREDTST] as in debug that field seemed full of Chinese chars :) ????

I added this BSFN as a Display Rule BSFN and it magically removes all chars apart from 0 - 9

Here's the code

NER: RRDScrubLOTN
Event GUID: ABC7F0BA-835B-49EB-A721-1B6C1FED88F6
Data Structure: D55LOTNS - RRD Scrub LOTN DSTR
BF idBHVR_ERROR_ID [BHVRERRID]
BF szBEHAVIOR_EDIT_STRING [BHVREDTST]
BF lotn [DL01]
BF szLot [LOTN]

----------------------------------------
Event Level Variables
----------------------------------------
evt_cCharToProcess [CHAR]
evt_iCount [INTEGER]
evt_iLength [INTEGER]
evt_OutputDescriptionLine1 [DSC1]
----------------------------------------
00001 // Object Creation: John Danter 27/04/2020
00002 // Scrub all srtrings and illegal chars out of the LOTN. Only allow 0-9
00003 //
00004 -If BF szLot [LOTN] is greater than <Blank>
00005 | VA evt_iCount [INTEGER] = "0"
00006 | VA evt_iLength [INTEGER] = length([BF szLot [LOTN]])
00007 | VA evt_OutputDescriptionLine1 [DSC1] = <NULL>
00008 | //
00009 | -While VA evt_iCount [INTEGER] is less than VA evt_iLength [INTEGER]
00010 | | VA evt_cCharToProcess [CHAR] = substr([BF szLot [LOTN]], [VA evt_iCount [INTEGER]], "1")
00011 | | //
00012 | | -If VA evt_cCharToProcess [CHAR] is equal to ("0","1","2","3","4","5","6","7","8","9")
00013 | | | VA evt_OutputDescriptionLine1 [DSC1] = concat([VA evt_OutputDescriptionLine1 [DSC1]], [VA evt_cCharToProcess [CHAR]])
00014 | | -Else
00015 | | | ! Set NER Error("4077", BF szLot)
00016 | | End If
00017 | | //
00018 | | VA evt_iCount [INTEGER] = [VA evt_iCount [INTEGER]]+1
00019 | End While
00020 | BF szLot [LOTN] = VA evt_OutputDescriptionLine1 [DSC1]
00021 | BF szBEHAVIOR_EDIT_STRING [BHVREDTST] = VA evt_OutputDescriptionLine1 [DSC1]
00022 End If
 
Last edited:
Does a Display Rule BSFN prevent the undesirable characters getting into the database?
 
I don't think a display rule will, you will want to use an Edit Rule on the DD item and throw an error.
 
It does work as is.

It only allows 0-9 anything else is removed by the BSFN and fed back in.
So it's removed before it gets to the DB

If someone tried this via a CSV upload using a UBE, then it wouldn't work no
 
Back
Top