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

BDC for MM02 view selection problem

Former Member
0 Likes
2,901

Hello Experts,

I want to do BDC for transaction MM02 for 1 particular view.

I 1st put the material no. & click on enter and then a window comes for selecting views.

But all materials dont have same no. of views.

some materials have 8 views of which the view that I want is on 5th place.

some have 21 views and the view I want suddenly goes on 19th place and also in the window for view, I can only select upto 17 views through bdc, any other view after 17th place I cannot access through bdc. It says that field value does not exist in that screen.

So when I run the bdc by putting

perform bdc_dynpro using 'SAPLMGMM' '0070'.

perform bdc_field using 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(05)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'MSICHTAUSW-KZSEL(05)'

'X'.

Then if the view for another material is not on 5th place, it tries to insert the values on the view whichever is present on 5th place and gives error.

How can I select the same view for any material, irrespective of the position of the view that I want in the list.

In simple words irrespective of no. of views present for any material, I always want the BDC to select the same view in which I want to insert data through BDC.

Please help I'm not able to start my bdc.

Kash.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,705

Hi DalviKashyap,

Hey I have worked on this, I had come across exactly same issue, i'll paste the code which I had written. And my BDC is working perfectly fine.

you can have the description of the fields from the respective tables from SE11.

Declare few variables

Data : lv_mtart like mara-mtart,

lv_cnt(2) type c, " its a count

lv_dytxt(30) type c,

lv_kzsel(30) type c.

Declare an internal table

Data : lt_btci type STANDARD TABLE OF bdcdata with HEADER LINE.

NOTE : Add the following code inside your LOOP statement before the BDC recording

Fire a select query on the table MARA where Material no. is equal to the material No. u require

here wa_material_details-matnr is the field in my workarea which has the material no, that I read from

the flat file

select single mtart into lv_mtart from mara where matnr eq wa_material_details-matnr.

following function module will select the number on which your required view is

in my case i have written Q, as i wanted Quality Management view

CALL FUNCTION 'MATERIAL_BTCI_SELECTION_NEW'

EXPORTING

material = wa_material_details-matnr

MATERIALART = lv_mtart

selection = 'Q'

tcode = 'MM02'

TABLES

btci_d0070 = lt_btci.

following code takes in the number on which your required view is in the list

the 2 digits after 1st 17 in the field FNAM indicate the number on which ur view is for that particular material no. (it can be 5 or 19 as u mentioned)

READ TABLE lt_btci WITH KEY FVAL = 'X'.

IF SY-SUBRC = 0.

lv_cnt = lt_btci-FNAM+17(2).

ENDIF.

Hello Experts,

I want to do BDC for transaction MM02 for 1 particular view.

I 1st put the material no. & click on enter and then a window comes for selecting views.

But all materials dont have same no. of views.

some materials have 8 views of which the view that I want is on 5th place.

some have 21 views and the view I want suddenly goes on 19th place and also in the window for view, I can only select upto 17 views through bdc, any other view after 17th place I cannot access through bdc. It says that field value does not exist in that screen.

So when I run the bdc by putting

perform bdc_dynpro using 'SAPLMGMM' '0070'.

perform bdc_field using 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(05)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'MSICHTAUSW-KZSEL(05)'

'X'.

Then if the view for another material is not on 5th place, it tries to insert the values on the view whichever is present on 5th place and gives error.

How can I select the same view for any material, irrespective of the position of the view that I want in the list.

In simple words irrespective of no. of views present for any material, I always want the BDC to select the same view in which I want to insert data through BDC.

Please help I'm not able to start my bdc.

Kash.

7 REPLIES 7
Read only

former_member229729
Active Participant
0 Likes
1,705

Hi Kash,

Here is a simple way.

You know the material name, right.
Now your query for getting the View Name should be:

Select PSTAT from mara into V_VIEW 
          Where matnr = p_matnr.
Note: PSTAT --> is Maintenance Status
Now, you can use the above V_VIEW, and assign it throu the BDC. This will work.

All the best,

Rgds,

Ramani N.

Read only

Former Member
0 Likes
1,706

Hi DalviKashyap,

Hey I have worked on this, I had come across exactly same issue, i'll paste the code which I had written. And my BDC is working perfectly fine.

you can have the description of the fields from the respective tables from SE11.

Declare few variables

Data : lv_mtart like mara-mtart,

lv_cnt(2) type c, " its a count

lv_dytxt(30) type c,

lv_kzsel(30) type c.

Declare an internal table

Data : lt_btci type STANDARD TABLE OF bdcdata with HEADER LINE.

NOTE : Add the following code inside your LOOP statement before the BDC recording

Fire a select query on the table MARA where Material no. is equal to the material No. u require

here wa_material_details-matnr is the field in my workarea which has the material no, that I read from

the flat file

select single mtart into lv_mtart from mara where matnr eq wa_material_details-matnr.

following function module will select the number on which your required view is

in my case i have written Q, as i wanted Quality Management view

CALL FUNCTION 'MATERIAL_BTCI_SELECTION_NEW'

EXPORTING

material = wa_material_details-matnr

MATERIALART = lv_mtart

selection = 'Q'

tcode = 'MM02'

TABLES

btci_d0070 = lt_btci.

following code takes in the number on which your required view is in the list

the 2 digits after 1st 17 in the field FNAM indicate the number on which ur view is for that particular material no. (it can be 5 or 19 as u mentioned)

READ TABLE lt_btci WITH KEY FVAL = 'X'.

IF SY-SUBRC = 0.

lv_cnt = lt_btci-FNAM+17(2).

ENDIF.

Read only

Former Member
0 Likes
1,705

Now for the BDC recording, make the following changes

this code in ur recording will chk the position of the view, if the view is after 17 position

BDC_OKCODE = P+ will scroll the window down i.e out of total views will subtract 1st 17, so that u can see the rest ones

if it is after 17 it will select the view u want, if no then it will do normal processing

clear : lv_cnt.

clear : lt_bdcdata.

refresh : lt_bdcdata.

perform bdc_dynpro using 'SAPLMGMM' '0070'.

if lv_cnt > '17'.

lv_cnt = lv_cnt - 17.

perform bdc_field using 'BDC_OKCODE' '=P+'.

perform bdc_dynpro using 'SAPLMGMM' '0070'.

concatenate 'MSICHTAUSW-DYTXT(' lv_cnt ')' into lv_dytxt.

perform bdc_field using 'BDC_CURSOR' lv_dytxt.

perform bdc_field using 'BDC_OKCODE' '=ENTR'.

concatenate 'MSICHTAUSW-KZSEL(' lv_cnt ')' into lv_kzsel.

perform bdc_field using lv_kzsel 'X'.

else.

concatenate 'MSICHTAUSW-DYTXT(' lv_cnt ')' into lv_dytxt.

perform bdc_field using 'BDC_CURSOR' lv_dytxt.

perform bdc_field using 'BDC_OKCODE' '=ENTR'.

concatenate 'MSICHTAUSW-KZSEL(' lv_cnt ')' into lv_kzsel.

perform bdc_field using lv_kzsel 'X'.

endif.

Hope this helps u...infact i'm sure it will work smoothly

Regards,

RadhikaS

Read only

0 Likes
1,705

THANKS RADHIKA ITS REALLY HELP FULL THE CODE YOU HAVE POSTED

Regards,

Mahesh Dasari.

Read only

0 Likes
1,705

Hi Former Member

That was excellent.

Thank you for sharing and your kindness.

Read only

Former Member
0 Likes
1,705

thank u all

Read only

Former Member
0 Likes
1,705

thanks