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

BADI SMOD_APOCF005 code does not update product master

Former Member
0 Likes
1,665

Hello Folks,

I am trying to update the APO product master in BADI

SMOD_APOCF005 with below code but it is not updating certain fields such as

REORD_METHOD and

TARGET_METHOD where as MTVFP is getting updated .

Am I missing something ?

method IF_EX_SMOD_APOCF005~EXIT_/SAPAPO/SAPLCIF_PROD_001.


Data: ls_matlocx TYPE /SAPAPO/CIF_MATLOCX.

DATA: ls_matloc TYPE /SAPAPO/CIF_MATLOC.


loop at it_matloc into ls_matloc where ext_locno ='1000'.

if ls_matloc-EXT_LOCNO = '1000' and ls_matloc-EXT_MATNR = 'P-102'.

LS_MATLOC-REORD_METHOD = '2'.
LS_MATLOC-TARGET_METHOD = '5'.
LS_MATLOC-MTVFP = 'Z2'.

MODIFY IT_MATLOC FROM LS_MATLOC.

clear ls_matloc.

ENDIF.

endloop.

5 REPLIES 5
Read only

srikanthnalluri
Active Participant
0 Likes
1,298

Use TRANSPORTING comp1 comp2 ....With MODIFY statement - Refer documentation - link

You can try field symbols instead of modifying looping ITAB

*Declare Field symbol
LOOP AT it_matloc INTO <ls_matloc> WHERE ext_locno = '1000'.
                                     AND ext_matnr = 'P-102'.
      <ls_matloc>-reord_method = '2'.
      <ls_matloc>-target_method = '5'.
      <ls_matloc>-mtvfp = 'Z2'.
 ENDLOOP.

Read only

0 Likes
1,298

Please correct code, I am new to development.

FIELD-SYMBOLS : <fs_matloc> TYPE /SAPAPO/CIF_MATLOC.
LOOP AT it_matloc ASSIGNING <fs_matloc> WHERE ext_locno ='1000' and ext_matnr = 'P-102'.
IF sy-subrc IS INITIAL.
<fs_matloc>-reord_method = '2'.
<fs_matloc>-target_method = '5'.
<fs_matloc>-mtvfp = 'Z2'.
ENDIF.

ENDLOOP.

It did not work on product master. It is working in debug mode.

Read only

0 Likes
1,298

I am not sure what you mean it didn't work on product master. By the way i have updated my answer and also we no need to loop to update the fields. We can do with only MODIFY statement.

*Fill the Work area with values
ls_matloc-record_method = '2'.
ls_matloc-target_method = '5'.
ls_matloc-mtvfp         = 'Z2'.
MODIFY it_matloc FROM ls_matloc TRANSPORTING record_method target_method mtvfp
                                       WHERE ext_locno = '1000' AND ext_matnr = 'P-102'.

Read only

Former Member
0 Likes
1,298

Please correct code, I am new to development.

FIELD-SYMBOLS : <fs_matloc> TYPE /SAPAPO/CIF_MATLOC.
LOOP AT it_matloc ASSIGNING <fs_matloc> WHERE ext_locno ='1000' and ext_matnr = 'P-102'.
IF sy-subrc IS INITIAL.
<fs_matloc>-reord_method = '2'.
<fs_matloc>-target_method = '5'.
<fs_matloc>-mtvfp = 'Z2'.
ENDIF.

ENDLOOP.

It did not work on product master. It is working in debug mode.

Read only

DoanManhQuynh
Active Contributor
0 Likes
1,298

I think maybe you should have to set data to it_matlocx too. look at this blog if it help:

https://blogs.sap.com/2014/07/18/apo-snp-master-data-automation/