09-13-2018 8:24 PM
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.
09-13-2018 9:44 PM
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.
09-14-2018 2:47 AM
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.
09-14-2018 2:03 PM
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'.
09-14-2018 3:26 AM
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.
09-14-2018 5:22 AM
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/