Application Development 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: 

some problems in my bdc program for mm02

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

former_member188827
Active Contributor
0 Kudos

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

12 REPLIES 12

Former Member
0 Kudos

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

former_member188827
Active Contributor
0 Kudos

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

0 Kudos

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

0 Kudos

my text file [bdc.text]

KR119953Cover plate4
M-01Sunny Sunny 101

0 Kudos

Try running this with Mode "A" (Display all screens) and check if the value is getting passed to the description field.

Regards

Former Member
0 Kudos

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.

0 Kudos

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

venkateswaran_k
Active Contributor
0 Kudos

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

0 Kudos

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'

0 Kudos

it seems you have resolved the issue.  What was the solution?

0 Kudos

Dear Venkateswaran K,

No solution found..

Regards Naveed.

0 Kudos

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?