Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BOM_UPDATE

Former Member
0 Likes
1,510

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

6 REPLIES 6
Read only

Former Member
0 Likes
951

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.

Read only

0 Likes
951

Hi Jaffer,

Thanks for your reply.

I have already tried with your modifications

still same problem.

Thanks

Bhasker.

Read only

Former Member
0 Likes
951

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

Read only

0 Likes
951

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

Read only

Former Member
0 Likes
951

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

Read only

0 Likes
951

Hi Prashanth,

Commit work is also not working out for me

thanks