I got this transaction ZENSY0470M to insert data and this web panel to insert (or update) information into the above transaction
I'm having trouble validating the date when trying to update a record For example If a record has the same key ZENSY0470M_SalOutCd7Plc = 1, ZENSY0470M_BseCd =1 and ZENSY0470M_EvntCd = 1
- I pick the date range (ZENSY0470M_AplyPrdFrm ~ ZENSY0470M_AplyPrdTo) is 1/10 to 5/10
- The next record which has the same key ZENSY0470M_SalOutCd7Plc = 1, ZENSY0470M_BseCd =1 and ZENSY0470M_EvntCd = 1 CANNOT have a date in the 1/10 to 5/10 range (1/10, 2/10, ... 5/10), for ex, 30/0 ~ 2/10 would be wrong) But when I update a record using the web panel, I need to change the date range from 1/10 ~ 5/10 to 2/10 ~ 6/10, it will trigger the validation, how can I avoid this (I still want to validate the date range, but it needs to exclude the record that I'm updating and compare to other records. Thank you!
CodePudding user response:
Maybe you should add in the 'ChkRegister' subroutine the part of the key (ZENSY0470M_TmpltId) that's missing to exclude from the search the record you're updating:
For each ZENSY0470M
where ZENSY0470M_SalOutCd7Plc = &ZENSY0470M_SalOutCd7Plc
where ZENSY0470M_BseCd = &ZENSY0470M_BseCd
where ZENSY0470M_EvntCd = &ZENSY0470M_EvntCd
where ZENSY0470M_TmpltId <> &ZENSY0470M_TmpltId //Add this line
If ZENSY0470M_AplyPrdFrm <= &ZENSY0470M_AplyPrdFrm and &ZENSY0470M_AplyPrdTo >= ZENSY0470M_AplyPrdTo
MSG('1')
&wErrFlg = Flg.On
Else
&wErrFlg = Flg.Off
EndIf
If ZENSY0470M_AplyPrdFrm <= ZENSY0470M_AplyPrdTo and &ZENSY0470M_AplyPrdTo >= ZENSY0470M_AplyPrdFrm
MSG('2')
&wErrFlg = Flg.On
Else
&wErrFlg = Flg.Off
EndIf
EndFor