Headerless Detail Form Records Update Problem

Wong

Active Member
Dear all,

I'm working on the Inventory Adjustment program, when i perform inventory adjustment, the lot expiration date will be retrieve from Lot Master (F4108) by business function F4114 Edit Line.

Here is my problem, i able to overwrite the lot expired date at grid row exit events by taking system date + the shelf life days from Item Master.

When i click on button OK, i want to update this new lot expired date to Lot Master. So i put the customization code at Clear Screen After Add event (headerless detail form). But the update doesn't work properly. When i put a debug in fat client to test, the update is working fine. When i disable the debug function then the update doesn't work again.

Why & what causes the update not working properly? Why with debug & without debug will have 2 different result? Anyone can help me?

Here is my code:

M & D Debug Function
// ---------------------------------------------------------------------------
// Update F4108 item expiration date - by WongYK 19/07/13
// ---------------------------------------------------------------------------
F4111.Select
F4111.Fetch Next
While SV File_IO_Status is not equal to CO ERROR
F4101.Fetch Single
VA frm_Temp_ExpiredDate = add_days([SL DateToday],[VA frm_Temp_ShelfLifeDays])
F4108.Fetch Single
If SV File_IO_Status is equal to CO SUCCESS
F4108.Update
End If
VA frm_Temp_ExpiredDate = ""
VA frm_Temp_ItemNo = ""
VA frm_Temp_LotNo = ""
VA frm_Temp_ShelfLifeDays = ""
F4111.Fetch Next
End While
//
// ---------------------------------------------------------------------------
// Reset Variable
// ---------------------------------------------------------------------------
VA frm_Temp_MCU = ""
VA frm_Temp_ICU = ""
VA frm_Temp_DGL = ""
 

Attachments

  • 184261-AttachFile.xls
    47 KB · Views: 43
I try to delay the process by putting in some counter but still the update process doesn't work. Anyone of you got any idea?
 
Just a guess, but the function that actually commits the transfer (F4114EndDocument) is run asynchronously in the Post Button Clicked event. Since your update is done within the application events, you cannot guarantee that your code will occur after EndDoc as you would like. But with the M&D debug call your code is delayed (until the user hits OK) and the asynch function is completing first.
 
Change the function to run synchronously. Using a counter is delay is a bad idea.
 
If the function is getting called in the "Post Button Click - Async" event you will need to disable it and add it to the end of the "Post Button Click" event instead. If it is not there, open the business function call, there should be a check box called "Run Async" and it will be checked. In this case do not uncheck it. Copy and paste this function call so it is duplicated in the code. Disable one to leave the original in place. Open the other one, uncheck the async check box. The reason we make a copy is just in case you want to go back to Async. Once you uncheck it the async check box will never appear again.
 
I would recommend not to change the behavior of sync/async on MBF, rather put your code in an NER and call that NER from the bottom of the master business function. I have written a white paper on the same issue, which I am attaching. In this example, I am calling MDDEBUG bsfn from Sales Order MBF. I think this approach will solve your problem.
 

Attachments

  • 184324-Steps to call NER from a C Business Function.pdf
    882.2 KB · Views: 239
I agree with putting the logic in the MBF instead. Except for your step 5: I'm not too keen on updating a table AFTER standard JDE has done the table add/update. Instead, I prefer to change the desired values in the datastructure that gets written to the table, BEFORE it gets written to the table. Exact place depending on which table/which field. For example, if my memory serves me right, SO MBF has a part where the date fields are defaulted/validated.. If I needed to overwrite one of these dates, then that's the place I'd put it in.
 
Dear all,

Thanks of yours advise, i will try the methods you'll suggested and see which is best suit. Anyway it is good for knowledge improvement.
 
Back
Top