‎2006 Sep 26 12:22 AM
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.
My code is working fine for concatenation.
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
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 not l_matkl is initial.
concatenate l_matkl(3) '.' stpob-posnr(3) into-sortf.
modify <table> from stpob.
else.
modify <table> from stpob.
endif.
ENDLOOP.
Thanks
Bhasker
‎2006 Sep 26 1:55 AM
Hi ,
Please check the modified code. i have included the Sy-subcr check after selection.
LOOP AT <TABLE> INTO STPOB.
clear l_matkl
clear stpob-sortf.
select single matkl
from MARA
into l_matkl
where matnr = stpob-idnrk.
<b>if sy-subrc is initial.</b>
if not l_matkl is initial.
concatenate l_matkl(3) '.' stpob-posnr(3) into-sortf.
modify <table> from stpob.
else.
modify <table> from stpob.
<b>endif.</b>
endif.
ENDLOOP.
‎2006 Sep 26 2:54 AM
Hi Jaffer,
Thanks for your reply.
I have already tried with your modifications
still same problem.
Thanks
Bhasker.
‎2006 Sep 26 2:58 AM
Hi Bhasker,
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.
<b>if sy-subrc eq 0.</b>
concatenate l_matkl(3) '.' stpob-posnr(3) into sortf.
modify <table> from stpob.
<b>*else.
*modify <table> from stpob.</b>
endif.
ENDLOOP.
Best regards,
Prashant
PS : Please reward all helpful answers
‎2006 Sep 26 5:19 AM
Hi Prashanth,
thanks for your reply.
Actually problem is in the debug mode I can see that record is getting modified in the table <TABLE> from STPOB.
But when I go back and check the transaction the item record is not getting updated ie value in SORTF field is not getting updated.
Thanks
Bhasker
‎2006 Sep 26 5:39 AM
Hi Bhasker,
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 eq 0.
concatenate l_matkl(3) '.' stpob-posnr(3) into sortf.
modify <table> from stpob.
*else.
*modify <table> from stpob.
endif.
ENDLOOP.
<b>
COMMIT WORK and WAIT.</b>
Best regards,
Prashant
PS : Please reward all helpful answers
Message was edited by: Prashant Patil
‎2006 Sep 26 5:50 AM