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: 

Problem in BDC with ( MM01-Dynamic views )

Former Member
0 Kudos

HI

I am working with BDC on material Mater(mm01).

Now while Creating Material,there is option of selecting different views based on MaterialType.

But while recording a BDC i can record it for a particular Material Type.and can select view associated to that particular Material Type.

Is there any solution to create a bdc progarm which can accept a new material based on

any material type and having views on user's choice that are given by user in Input file.

FOr that i think i need to create dynamic views and screen elements for input associated to those views.

After scanning some sites and forums for this particular problem,i got some help on this:-----

-


<b>SELECTION_VIEWS_FIND</b> should be very useful in this case.

There are three FModules totally involved:

a) <b>T130M_SINGLE_READ</b>

Pass TCODE = MM01, and get T130M values

b) <b>BILDSEQUENZ_IDENTIFY</b>

Pass KZRFB = 'X',TCODE_REF=T130M-TRREF and get

BILDSEQUENZ values

c) <b>SELECTION_VIEWS_FIND</b>

Pass BILDSEQUENZ and T130M-PSTAT

Now, this function module holds the values of all the views and the next screen numbers

-


But i am unable to interpret the solution..Can somebody Elaborate on this.or provide me some other solution for this.

Thanks in Advance

Help Will be appreciated.

6 REPLIES 6

christian_wohlfahrt
Active Contributor
0 Kudos

Hi Vijay!

Such dynamic transactions are not supposed to work with call transaction / BDC.

Because you might run into an endless way of new problems, use instead BAPI_MATERIAL_SAVEDATA to create / change articles.

Might be scary in the first moment, but isn't so complicated on the second view.

Regards,

Christian

0 Kudos

Yes, I agree with Christian. You are gonna want to use the BAPI or the underlying function module. It works good and isn't really that complex. Here is sample program. Here the function module is being used to change data, it can also be used to create, you will have to change the Tcode from MM02 to MM01.



report zrich_0001.

data: i_mara type table of mara_ueb with header line.
data: i_marc type table of marc_ueb with header line.
data: i_marcx type table of marc with header line.

parameters: p_matnr type mara-matnr,
            p_plifz type marc-plifz.

start-of-selection.

* Get all plants for that material
  select * into corresponding fields of table i_marcx
        from marc where matnr = p_matnr.

* Now maintain data for each plant
  loop at i_marcx.

* Reset I_Mara to new material number
    clear i_mara. refresh i_mara.
    select * into corresponding fields of table i_mara
          from mara where matnr = p_matnr.
    read table i_mara index 1.
    i_mara-tcode = 'MM02'.
    i_mara-tranc = '0000000001'.
    modify i_mara index 1.

* Get Plant Data
    clear i_marc. refresh i_marc.
    select * into corresponding fields of table i_marc
          from marc where matnr = i_marcx-matnr
                      and werks = i_marcx-werks.
    read table i_marc index 1.
    i_marc-plifz  = p_plifz.        " Plan Del time
    i_marc-tranc = '0000000001'.
    modify i_marc index 1.

* Maintain material
    perform MATERIAL_MAINTAIN_DARK'.

  endloop.

************************************************************************
*  MATERIAL_MAINTAIN_DARK
************************************************************************
form MATERIAL_MAINTAIN_DARK.

* Variable for "Maintain_Material_Dark" Function Module
  data: numerror like tbist-numerror.
  data: last_matnr type mara-matnr.

  data: i_delfields type table of mfieldres with header line.
  data: i_errors    type table of merrdat   with header line.

  call function 'MATERIAL_MAINTAIN_DARK'
         exporting
              sperrmodus                = ' '
              kz_prf                    = 'W'
              max_errors                = ' '
              p_kz_no_warn              = 'X'
              kz_verw                   = 'X'
              kz_aend                   = 'X'
              kz_dispo                  = 'X'
              kz_test                   = ' '
              flag_muss_pruefen         = ' '
              call_mode                 = 'ACT'
         importing
              number_errors_transaction = numerror
              matnr_last     = last_matnr
         tables
             amara_ueb      = i_mara    "Basic Data
*             amakt_ueb      = i_makt    "Descriptions
             amarc_ueb      = i_marc    "Plant
*             amard_ueb      = i_mard    "Storage Location
*            AMFHM_UEB      = I_MFHM    "Production Tools
*             amarm_ueb      = i_marm    "Units of Measure
*            AMEA1_UEB      = I_MEA1    "Internal Mangagement -  EANs
*             ambew_ueb      = i_mbew    "Accounting/Costing
*             asteu_ueb      = i_steu    "Tax Data
*             astmm_ueb      = i_steumm  "Tax Data
*            AMLGN_UEB      = I_MLGN    "Warehouse Data
*            AMLGT_UEB      = I_MLGT    "Storage Type Data
*            AMPGD_UEB      = I_MPGD    "Change Documents
*            AMPOP_UEB      = I_MPOP    "Forcast Parameters
*            AMVEG_UEB      = I_MVEG    "Total Consumption Data
*            AMVEU_UEB      = I_MVEU    "Unplanned Consumption Data
*             amvke_ueb      = i_mvke    "Sales Data
*             altx1_ueb      = i_ltx1    "Sales Text
*            AMPRW_UEB      = I_MPRW    "Forcast Values
             amfieldres     = i_delfields
             amerrdat       = i_errors
         exceptions
              kstatus_empty             = 01
              tkstatus_empty            = 02
              t130m_error               = 03
              internal_error            = 04
              update_error              = 05
              too_many_errors           = 06.

  if sy-subrc <> 0.
    rollback work.
    call function 'DEQUEUE_ALL'.
  else.
    commit work and wait.
    call function 'DEQUEUE_ALL'.
  endif.

  clear: i_mara, i_marc.
  refresh: i_mara, i_marc.

endform.

Regards,

Rich Heilman

former_member214131
Active Contributor
0 Kudos

Hello,

Please use DI object

0020 / 0000 / RMDATIND / D for mass upload in LSMW.

Else MATERIAL_MAINTAIN_DARK or BAPI_MATERIAL_SAVEDATA or IDoc Type MATMAS03 could be used.

Regards, Murugesh AS

Former Member
0 Kudos

Hi Vijay,

Think you are trying to create material (say semi finished, finished, or raw) for all these views to be filled dynamically is not easy. To be frank this is not a cool job as Rich and Christian mentioned.

We had a same problem but could overcome it as the material types we need to use were around 3-4.

1. We recorded all the possible view and made them into separate subroutines.

2. And based on the material type we fetched the possible views and filled them up in a sequence.

But faced a lot of problems when moving through different views but had no choice as BDC was requested.

Please try this if only BDC is to be used, else go for BAPI's.

Hope that helps you.

Cheers

Kathir~

0 Kudos

HI Kathir~

Thanks for replying.

In case it is not compulsary to Use BDC,is BAPI the bEST solution to the problem.

Actually, I never worked on BAPI.Can u tell me something about BAPI.

REGARDS

VIJAY RAHEJA

Former Member
0 Kudos

Hi Vijay,

BAPI are mainly for achieving integration with R/3 and External Apps. They are based on Business Logic.

For the list of BAPI's check this link...

www.sappoint.com/abap/bapilst.pdf

Here is a quick start guide...

http://searchsap.techtarget.com/originalContent/0,289142,sid21_gci948835,00.html

You can find many information if you search

Cheers

Kathir~