10-10-2008 4:23 PM
Hello Experts!
Iu2019m trying to update a few material tables (mara, marc, mard & makt) after having values from the text fields. Iu2019m not sure why these values are not getting update in those tables. So far Iu2019ve just try to update u2018maktxu2019 field of makt table. Even though in debug Iu2019ve checked through Move-correspoding statement it goes through (sy-subrc = 0) still MAKT table doesnu2019t update for that particular material number. Here is my code.
Also Iu2019ve declared this Module upder PAI.
MODULE update_req INPUT.
IF matnr IS NOT INITIAL.
CASE okcode.
*======================================================
WHEN 'CHNG'.
*transfer values from fields to gt_mara
MOVE: mara-mtart TO gt_mara-matnr,
mara-mbrsh TO gt_mara-mbrsh,
mara-meins TO gt_mara-meins.
APPEND gt_mara.
*update database table mara from gt_mara.
MOVE-CORRESPONDING gt_mara TO mara.
MOVE: marc-werks TO gt_marc-werks,
marc-pstat TO gt_marc-pstat,
marc-ekgrp TO gt_marc-ekgrp.
APPEND gt_marc.
MOVE-CORRESPONDING gt_marc TO marc.
MOVE: mard-lgort TO gt_mard-lgort.
APPEND gt_mard.
MOVE-CORRESPONDING gt_mard TO mard.
MOVE: makt-spras TO gt_makt-spras,
makt-maktx TO gt_makt-maktx.
APPEND gt_makt.
MOVE-CORRESPONDING gt_makt TO makt.
*======================================================
ENDCASE.
ENDIF.
ENDMODULE. " update_req INPUT
Can somebody please tell me what wrong with my code or what should I do to make it working?
Thanks.
10-10-2008 10:31 PM
Don't try to update the SAP Standard tables. As a consequence, you can loose the integrity of the data.
User BAPI as suggested by the Vijay or Create a Small BDC for the MM02. You can look at this post: [MM02 BDC - Select Specific Material Master View |http://help-abap.blogspot.com/2008/09/mm02-bdc-select-specific-material.html]
You can update the Text in the Basic View, which will in turn update the MAKT
For MARC, you might have to update the Plant view.
Regards,
Naimesh Patel
10-10-2008 4:30 PM
did you moved MATNR to gt_makt?
is this statement of correct
mara-mtart TO gt_mara-matnr
10-10-2008 4:46 PM
Zero -
You are trying to update standard SAP tables. The best way to do this is using standard SAP functionality, not custom programs.
Your code is changing the work area, not the table data. For that you have to use SQL.
Rob
10-10-2008 4:49 PM
10-10-2008 9:58 PM
Hi pawan,
Mara-mtart is the text fields. User updated the value in (mara-mtart) feild then I moved this value in my internal table (gt_mara-matnr). It worked before for me but not sure why it is not working now. Is it necessary to use BAPI?
10-10-2008 10:31 PM
Don't try to update the SAP Standard tables. As a consequence, you can loose the integrity of the data.
User BAPI as suggested by the Vijay or Create a Small BDC for the MM02. You can look at this post: [MM02 BDC - Select Specific Material Master View |http://help-abap.blogspot.com/2008/09/mm02-bdc-select-specific-material.html]
You can update the Text in the Basic View, which will in turn update the MAKT
For MARC, you might have to update the Plant view.
Regards,
Naimesh Patel
10-11-2008 4:16 PM
Thanks a lot to Naimesh, Vijay and all others who respond on my thread. I've worked with BDC haven't used BDC like this before as Naimesh told me. Finally everything is working on my code. Its a really good learning I get through you guys, Specially Naimesh Patel (Special Thanks to you).
Just to share my efforts. Here is my code.
MODULE update_req INPUT.
IF matnr IS NOT INITIAL.
CASE okcode.
WHEN 'CHNG'.
PERFORM BDC_UPDATE.
ENDCASE.
ENDIF.
ENDMODULE. " update_req INPUT
&----
*& Form BDC_UPDATE
&----
text
----
--> p1 text
<-- p2 text
----
form BDC_UPDATE .
*Material Views
DATA: l_vpsta LIKE t130m-pstat.
SELECT SINGLE vpsta
INTO l_vpsta
FROM mara
WHERE matnr = mara-matnr.
*Get view sequence
DATA: l_bild LIKE t133a-bilds,
lt_bild LIKE mbildtab OCCURS 0 WITH HEADER LINE.
*Screen Sequence for Standard Industry tab pages in material master
l_bild = '21'.
*Get screen sequence
CALL FUNCTION 'SELECTION_VIEWS_FIND'
EXPORTING
bildsequenz = l_bild
pflegestatus = l_vpsta
TABLES
bildtab = lt_bild
EXCEPTIONS
call_wrong = 1
empty_selection = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*Get the tab page for MRP1
DATA: l_tab_mrp1 TYPE sy-ucomm.
*Reading table wirh MRP view
READ TABLE lt_bild WITH KEY pstat = 'E'.
IF sy-subrc = 0.
l_tab_mrp1 = lt_bild-guifu.
ENDIF.
*Make ok code for the MRP1
CONCATENATE '=' l_tab_mrp1 INTO l_tab_mrp1.
*BDC
perform bdc_dynpro USING 'SAPLMGMM' '0060'.
perform bdc_field USING 'RMMG1-MATNR'
mara-matnr.
perform bdc_field USING 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro USING 'SAPLMGMM' '0070'.
PERFORM bdc_field USING 'MSICHTAUSW-KZSEL(01)'
'X'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_dynpro USING 'SAPLMGMM' '4004'.
perform bdc_field USING 'MAKT-MAKTX'
makt-maktx.
PERFORM bdc_field USING 'BDC_OKCODE'
l_tab_mrp1.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
perform bdc_transaction USING 'MM02'.
endform. " BDC_UPDATE
&----
*& Form bdc_dynpro
&----
text
----
-->P_0248 text
-->P_0249 text
----
form bdc_dynpro using p_program
p_screen.
move: p_program to bdcdata-program,
p_screen to bdcdata-dynpro,
'X' to bdcdata-dynbegin.
append bdcdata.
clear bdcdata.
endform. " bdc_dynpro
&----
*& Form bdc_field
&----
text
----
-->P_0235 text
-->P_P_MATNR text
----
form bdc_field using p_field_name
p_field_value.
move: p_field_name to bdcdata-fnam,
p_field_value to bdcdata-fval.
append bdcdata.
clear bdcdata.
endform. " bdc_field
&----
*& Form bdc_transaction
&----
text
----
-->P_0280 text
----
form bdc_transaction using tcode.
Data: l_msting(480).
Data: l_subrc LIKE sy-subrc.
*batch input session
refresh messtab.
call transaction tcode USING bdcdata
MODE 'A'
"A: show all dynpros
"E: show dynpro on error only
"N: do not display dynpro
UPDATE 'L'
MESSAGES INTO messtab.
REFRESH bdcdata.
endform. " bdc_transaction
Thanks alot guys.
Edited by: zero cool on Oct 11, 2008 5:16 PM