07-15-2013 8:46 AM
records are not changing in mm02 after successfull execution of my following program-->
report ZBDCNEWMM02
no standard page heading line-size 255.
DATA: BEGIN OF it_data OCCURS 0,
MATNR TYPE MARA-MATNR,
DESC TYPE MAKT-MAKTX,
END OF IT_DATA.
DATA IT_BDCDATA TYPE STANDARD TABLE OF BDCDATA WITH HEADER LINE.
start-of-selection.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'D:\BDC.TXT'
HAS_FIELD_SEPARATOR = 'X'
TABLES
data_tab = IT_DATA[].
IF sy-subrc <> 0.
ENDIF.
perform open_group.
LOOP AT IT_DATA.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'RMMG1-MATNR'
IT_DATA-MATNR.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
IT_DATA-DESC.
perform bdc_transaction using 'MM02'.
ENDLOOP.
perform close_group.
*&---------------------------------------------------------------------*
*& Form OPEN_GROUP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM OPEN_GROUP .
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'SESSION'
KEEP = 'X'
USER = SY-UNAME.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " ZOPEN_GROUP
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0057 text
* -->P_0058 text
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR IT_BDCDATA.
IT_BDCDATA-PROGRAM = PROGRAM.
IT_BDCDATA-DYNPRO = DYNPRO.
IT_BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDCDATA.
ENDFORM. " BDC_DYNPRO
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0062 text
* -->P_0063 text
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FLDNAM FLDVAL.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = FLDNAM.
IT_BDCDATA-FVAL = FLDVAL.
APPEND IT_BDCDATA.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_TRANSACTION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0117 text
*----------------------------------------------------------------------*
FORM BDC_TRANSACTION USING TCOD.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'MM02'
TABLES
DYNPROTAB = IT_BDCDATA[].
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " BDC_TRANSACTION
*&---------------------------------------------------------------------*
*& Form CLOSE_GROUP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CLOSE_GROUP .
CALL FUNCTION 'BDC_CLOSE_GROUP'
* EXCEPTIONS
* NOT_OPEN = 1
* QUEUE_ERROR = 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.
ENDFORM. " CLOSE_GROUP
07-15-2013 9:23 AM
Instead of :
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
IT_DATA-DESC.
change sequence of perform, use:
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
IT_DATA-DESC.
perform bdc_field using 'BDC_OKCODE' "This calls save so it should be in the end.
'=BU'.
Regards
07-15-2013 9:17 AM
S/m Naveed,
For MM02 the last thing we do is write a BDC it is never recommended.
Use BAPI_MATERIAL_SAVEDATA to create a material you can reuse this code in later projects also and is easier to maintain.
SAMPLE CODE : http://scn.sap.com/thread/164617
Regards
07-15-2013 9:23 AM
Instead of :
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
IT_DATA-DESC.
change sequence of perform, use:
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
IT_DATA-DESC.
perform bdc_field using 'BDC_OKCODE' "This calls save so it should be in the end.
'=BU'.
Regards
07-15-2013 11:23 AM
after changing my code look like as follows:---> but still not updating the records..
report ZBDCNEWMM02
no standard page heading line-size 255.
DATA: BEGIN OF it_data OCCURS 0,
MATNR TYPE MARA-MATNR,
DESC TYPE MAKT-MAKTX,
END OF IT_DATA.
DATA IT_BDCDATA TYPE STANDARD TABLE OF BDCDATA WITH HEADER LINE.
start-of-selection.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'D:\BDC.TXT'
HAS_FIELD_SEPARATOR = 'X'
TABLES
data_tab = IT_DATA[].
IF sy-subrc <> 0.
ENDIF.
perform open_group.
LOOP AT IT_DATA.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'RMMG1-MATNR'
IT_DATA-MATNR.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
IT_DATA-DESC.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_transaction using 'MM02'.
ENDLOOP.
perform close_group.
*&---------------------------------------------------------------------*
*& Form OPEN_GROUP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM OPEN_GROUP .
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'SESSION'
KEEP = 'X'
USER = SY-UNAME.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " ZOPEN_GROUP
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0057 text
* -->P_0058 text
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR IT_BDCDATA.
IT_BDCDATA-PROGRAM = PROGRAM.
IT_BDCDATA-DYNPRO = DYNPRO.
IT_BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDCDATA.
ENDFORM. " BDC_DYNPRO
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0062 text
* -->P_0063 text
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FLDNAM FLDVAL.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = FLDNAM.
IT_BDCDATA-FVAL = FLDVAL.
APPEND IT_BDCDATA.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_TRANSACTION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0117 text
*----------------------------------------------------------------------*
FORM BDC_TRANSACTION USING TCOD.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'MM02'
TABLES
DYNPROTAB = IT_BDCDATA[].
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " BDC_TRANSACTION
*&---------------------------------------------------------------------*
*& Form CLOSE_GROUP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CLOSE_GROUP .
CALL FUNCTION 'BDC_CLOSE_GROUP'
* EXCEPTIONS
* NOT_OPEN = 1
* QUEUE_ERROR = 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.
ENDFORM. " CLOSE_GROUP
07-15-2013 11:25 AM
07-15-2013 7:25 PM
Try running this with Mode "A" (Display all screens) and check if the value is getting passed to the description field.
Regards
07-15-2013 8:23 PM
If you have multiple materials,
Use BAPI_MATERIAL_SAVEREPLICA to change materials. it is faster.
Also, you can use LSMW . Check for standard programs there.
07-17-2013 8:11 AM
Daer gaurav guglani,
thank for ur suggestion ...
i know from BAPI it can be changed material desc but i need the same thing from BDC program..
Regards Naveed
07-15-2013 9:16 PM
Dear Naveed,
Check the following points.
1. Check the Value of the IT_DATA-MATNR. Is it having the leading 0s. ( before passing it please use conversion exit function to get the correct format of matnr).
2. Try to run in foreground and see what is wrong in update.
Kindly update your feedback
Regards,
Venkat
07-17-2013 8:09 AM
Dear Venkateswaran K,
i was followed the step as per your suggestion .. but still im not seeing any change in mm02 with the same material number 'KR119953'
07-17-2013 10:57 AM
07-17-2013 12:36 PM
07-17-2013 5:31 PM
Since your question is marked as Resolved, I asked for solution.
Anyway
Can you send me the screen shot of your Foreground display of BDC run.
Also send me the txt file.
In foreground run, what value come in material description?