‎2006 Sep 27 9:29 PM
Hi All
I am working on BAdI BOM_UPDATE ( method Change_at_save)
I need to populate the sort string field (sortf) at the commponent level at BOM save (CS01 and CS02) with Material Group value + Component Item number.
If the item doesnt have a material group I should not populate the sort string
But if the sort string field is already populated and the item doesnt have the material group value, I need to clear the sort string(sortf).
When I see in the debug mode sort string is getting cleared for the materials which doesnt have material group.
When I bo back and check the tranasaction after change sort string field is not blank (not getting cleared)
Can any one tell me whats wrong with my code.
Here is the code in the method
The field symbol <TABLE> refers to the method(CHANGE_AT_SAVE) parameter DELTA_STPOB.
The issue is after end method statement updated values in the table <TABLE> are not going into DELTA_STPOB.
DATA: l_matkl type mara-matkl.
DATA: stpob TYPE stpob.
DATA: FIELD_NAME(30) VALUE '(SAPLCSBT)O1-STPOB[]'.
FIELD-SYMBOLS: <TABLE> TYPE TABLE.
ASSIGN (FIELD_NAME) TO <TABLE>.
LOOP AT <TABLE> INTO STPOB.
clear l_matkl
clear stpob-sortf.
select single matkl
from MARA
into l_matkl
where matnr = stpob-idnrk.
if sy-subrc = 0.
if not l_matkl is initial.
concatenate l_matkl(3) '.' stpob-posnr(3) into-sortf.
modify <table> from stpob.
else.
modify <table> from stpob.
endif.
endif
ENDLOOP.
Thanks
Bhasker
‎2006 Sep 27 10:56 PM
Hello Bhasker
Before diving into your code I would recommend a simple "smoke" test:
- clear the field SORTF for all entries in your itab and see what happens. If nothing happens this suggests that you cannot update your entries with empty SORTF using this BAdI method.
With respect to the coding I have some suggestions:
(1) You know that the structure of your itab is STPOB. Thus, there is no need to use a field symbol.
(2) Define a second itab (with fields MATNR MATKL) and make a single SELECT on MARA with the option FOR ALL ENTRIES IN gt_stpob. Sort this itab by matnr. Within the loop you make a READ gt_2nd_itab with BINARY SEARCH.
Regards
Uwe
‎2006 Sep 28 12:00 AM
Hi Uwe,
Thanks for your reply.
As per your suggestion I tried to clear the field for all entries in <TABLE>, but nothing happend.
In cs02 when I change some field for BOM component item then only sortf field is getting updated for that particular component, but remaining components are not getting updated. When I add a new BOM component item, then also sortf field is getting updated ie my code is working fine.
But I need to update all the components at save eventhough there is no change in components.
Thanks
Bhasker