Read the order BoM in a PI-Sheet

To manage BoM within a PI-Sheet, you should work with the class CL_IM_COCR_CMX_BI_GEN_MAT, but for some reason, I’ve not been able to do it properly, nor I could found a viable BAdI enhancement.

So I had to create a new enhancement for CMX_XS_SRV_GEN to do it.

Just there, I had to create a reference to that class and populate the system’s memory with the order BoM (it’s an old piece of code, just forgive my mistakes there):

* A lot of declarations missed
DATA: cl_super    TYPE REF TO cl_im_cocr_cmx_bi_gen_mat.
* Get context
lo_context = query->get_context( ).
CHECK NOT lo_context IS INITIAL.
ls_context = me->xs_get_context( lo_context ).
CHECK NOT ls_context-aufnr IS INITIAL.
* Let's go!
CREATE OBJECT cl_super.

* tried to inherit the class, but it's a final one and cannot be
* inherited, I had to try the hard way
TRY.
    CALL METHOD cl_super->if_cmx_xs_service_generation~get_data
      EXPORTING
        flt_val = flt_val
        query = query.
  CATCH cx_root INTO oref.
    err_text = oref->get_text( ).
ENDTRY.
* Check the number of created steps
mycount = query->get_count( ).
CHECK mycount > 0.
From there, you will work with the different symbols in a "DO mycount TIMES" loop:
TRY.
    mysymbol = query->get_symbols( myindex ).
    myname-namespace = 'SAP'.
    myname-symbol = 'MATERIAL'.
    CALL METHOD mysymbol->get_value
      EXPORTING
        symbol = myname
      RECEIVING
        value  = myvalue.
  CATCH cx_root INTO oref.
    err_text = oref->get_text( ).
    CONTINUE.
ENDTRY.
 With these pieces of code you should be able to "mount" a nice grid with the BoM details, adding any number of colums per row.

Enjoy!

Advertisements

The Pomodoro Technique(TM)

I’m a confused mind. It’s something natural being a chimp, but it doesn’t help too much to my productivity. When I’m feeling “unfocused” or too tired to continue with my current task, I find easy ways to rest my mind. Sadly, personal situations affect my worktime (as they do to everyone but robots and jedi knights), and when I’m tired my rest times tend to space themselves shorter (more rests, less work… it hurts… to my work). Continue reading