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: 

How to get the where used list of a Class in Material?

Former Member
0 Kudos

Hello all,

Can anyoine help me out in finding out where all a CLASS is used in materials.

I have the CLASS name aavailable and i need to find out in which all Materials the class is being used.

Any Function Module or Table ?

Regards,

Arun

4 REPLIES 4

pepl
Active Participant
0 Kudos

Hi!

I don't know what class do u need to use exactly, but i give u an example how i've done the same case.

For example, I have several classes of 023 class type. This is for batches classification. so i want to get all objects (in my case it is batches, table MCH1), that are related to neccessary class.

report zjdtest32.

parameters: p_class type klah-class matchcode object clas,
            p_rows  type i default 10.

types: begin of ty_s_cuobj,
         cuobj type cuobj,
       end of ty_s_cuobj,
       ty_t_cuobj type table of ty_s_cuobj.

data: ls_klah  type klah.
data: lt_kssk  type table of kssk.
data: ls_kssk  type kssk.
data: lt_mch1  type table of mch1.
data: lt_cuobj type ty_t_cuobj.
data: ls_cuobj type ty_s_cuobj.

start-of-selection.
* Search for internal number of class.
  select single * from klah into ls_klah
    where class eq p_class.

* Select all objects that are related to this class
  select * from kssk into table lt_kssk
    where clint eq ls_klah-clint.

* Because of differnt types OBJEK must be transformed to CUOBJ.
  loop at lt_kssk into ls_kssk.
    check sy-tabix le p_rows. " <- this is prevention from huge selection
    ls_cuobj-cuobj = ls_kssk-objek.
    append ls_cuobj to lt_cuobj.
  endloop.

* Select searched objects
  check lt_cuobj[] is not initial.
  select * from mch1 into table lt_mch1
    for all entries in lt_cuobj
    where cuobj_bm eq lt_cuobj-cuobj.

end-of-selection.
* Output results in ALV Grid
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
   EXPORTING
     I_STRUCTURE_NAME                  = 'MCH1'
    TABLES
      t_outtab                          = lt_mch1.

In your case you need I suppose to use MARA table (CUOBF field) or MARC (CUOBJ) . It depends on view u have used to classify materials

pepl
Active Participant
0 Kudos

i think this is more convinient variant:

REPORT  zjdtest2.

DATA: itab TYPE TABLE OF mch1,
      gr_table TYPE REF TO cl_salv_table.

PARAMETERS: p_class TYPE klah-class MATCHCODE OBJECT clas.

START-OF-SELECTION.
  SELECT mch1~matnr mch1~charg mch1~cuobj_bm
    FROM mch1 INNER JOIN kssk ON mch1~cuobj_bm EQ kssk~objek
              INNER JOIN klah ON kssk~clint EQ klah~clint
    INTO CORRESPONDING FIELDS OF TABLE itab
    WHERE klah~class EQ p_class.
  IF sy-subrc <> 0.
    MESSAGE e701(bc) WITH 'No entries found'.
  ENDIF.

END-OF-SELECTION.
  cl_salv_table=>factory( IMPORTING r_salv_table = gr_table
                          CHANGING t_table = itab ).

  gr_table->display( ).

andrea_olivieri
Contributor
0 Kudos

Arun wrote:

I have the CLASS name aavailable and i need to find out in which all Materials the class is being used

Hi Arun,

the Bapi method BAPI_CLASS_SELECT_OBJECTS should be the right one; this function module starts the "find objects in class" function in the classification system.

Set as importing parameters:

ClassType = '001' (Material Class Type)
CLASSNUM = <Your Class Name>

and get the results in the SELECTEDOBJECTS [ ] tables parameter.

Regards,

Andrea

Former Member
0 Kudos

thx