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

Split quantity automatically in MIGO

kerem_kayacan
Active Participant
0 Likes
6,687

I have a very odd requirement. In transaction MIGO, if user makes a goods movement referenced by a purchase order and if moved quantity is greater than po quantity, line item will be splitted into two items. There's a "Split Qty" button on screen and I examined the process but didn't have any luck to accomplish this automatically. Has anybody did that before?

1 ACCEPTED SOLUTION
Read only

kerem_kayacan
Active Participant
0 Likes
5,389

Here is what I did. I will paste the code here. If it is not clear, let me know.

Function group: MIGO

Enhancement spot: ES_SAPLMIGO

Enhancement point: LINE_MODIFY_04


  DATA:
  lv_action TYPE goaction,
  lv_refdoc TYPE refdoc,
  lv_remain type bsmng,
  begin of ls_zeil,
    zeile type mblpo,
    global_counter type MIGO_GLOBAL_COUNTER,
  end of ls_zeil,
  lt_zeil like table of ls_zeil,
  lv_zeile type mblpo.

  if sy-tcode eq 'MIGO'.
	
  "Action and refdoc comes from MB_MIGO_BADI. 
  "This check is not obligatory
  CALL FUNCTION 'ZMM_EXPORT_ACTION'
   IMPORTING
     ACTION        = lv_action
     REFDOC        = lv_refdoc.

  if lv_action eq 'A01' AND lv_refdoc eq 'R01' and
     cs_goitem-ebeln is not initial.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      input         = cs_goitem-zeile
   IMPORTING
     OUTPUT        = lv_zeile.

  lv_remain = cs_goitem-bsmng - cs_goitem-wemng.

  IF cs_goitem-erfmg gt lv_remain.

    okcode = 'MIGO_OK_SPLIT_QUAN'.

    CALL FUNCTION 'ZMM_SET_AUTOSPLIT'
      EXPORTING
        autosplit       = 'X'.

    CALL FUNCTION 'ZMM_SET_GOITEM'
      EXPORTING
        goitem        = cs_goitem
        tabix         = sy-tabix.

    CALL FUNCTION 'ZMM_GET_SPLITTED_LINES'
     IMPORTING
       ET_ZEILE       = lt_zeil.

    read table lt_zeil into ls_zeil with key zeile = cs_goitem-zeile.
    IF sy-subrc ne 0.
      ls_zeil-zeile = cs_goitem-zeile.
      ls_zeil-global_counter = cs_goitem-global_counter.
      append ls_zeil to lt_zeil.
      "Send to MB_MIGO_BADI which line is splitted
      CALL FUNCTION 'ZMM_SET_SPLITTED_LINES'
        EXPORTING
          it_zeile       = lt_zeil.
    ENDIF.

  ENDIF."IF cs_goitem-erfmg gt lv_remain.

  endif.  "if lv_action eq 'A01' AND lv_refdoc eq 'R01'.

  ENDIF."if sy-tcode eq 'MIGO'.

Enhancement spot: ES_SAPLMIGO

Enhancement point: POPUP_CALL_03


  LOOP AT lt_fieldmapping INTO l_fieldname.
    CONCATENATE 'GOITEM-' l_fieldname INTO l_tmp_fieldname.
    l_status = lcl_migo_screenmodification=>get(
                 i_global_counter = ps_goitem-global_counter
                 i_field          = l_tmp_fieldname
               ).
    IF l_status < lcl_migo_screenmodification=>c_input.
      l_status = lcl_migo_screenmodification=>c_invisible.
    ELSE.
      l_status = lcl_migo_screenmodification=>c_visible.
    ENDIF.
    CONCATENATE 'GOSPLIT-' l_fieldname INTO l_fieldname.
    CALL METHOD lcl_migo_screenmodification=>set
      EXPORTING
        i_fields = l_fieldname
        i_status = l_status.
  ENDLOOP.
* Default values for the new lines                          "354046
  MOVE-CORRESPONDING ps_goitem TO ps_gosplit_default.
  CLEAR ps_gosplit_default-erfmg.
* Call the popup. Width and height are set automatically.   "354046

  DATA: auto_split TYPE c LENGTH 1,
        ls_goitem  type goitem,
        lv_tabix   type sytabix.
  CALL FUNCTION 'ZMM_GET_AUTOSPLIT'
   IMPORTING
     AUTOSPLIT       = auto_split.

  if auto_split IS INITIAL.
    CALL SCREEN 1000 STARTING AT 5 1.
  ELSE.
    CALL FUNCTION 'ZMM_GET_GOITEM'
     IMPORTING
       GOITEM        = ls_goitem
       tabix         = lv_tabix.
    move-corresponding ls_goitem to gosplit.
    gosplit-erfmg = ls_goitem-bsmng - ls_goitem-wemng.
    CALL METHOD oref_split_quantity->pai_loop.
    gosplit-erfmg = ls_goitem-erfmg -
      ( ls_goitem-bsmng - ls_goitem-wemng ).
    clear gosplit-split_line.
    CALL METHOD oref_split_quantity->pai_loop.
    p_selected_line = lv_tabix.
    ps_goitem = ls_goitem.
    CALL METHOD oref_split_quantity->pai_end.
    CALL FUNCTION 'ZMM_SET_AUTOSPLIT'
      EXPORTING
        autosplit       = space.
  ENDIF.

20 REPLIES 20
Read only

kerem_kayacan
Active Participant
0 Likes
5,389

Anybody tried this before?

Read only

Former Member
0 Likes
5,389

put a break point at rwin_check_subset FM (Junction function)

and also put break point in bp_functions_find FM (BTE)

and check for the event triggered during that time

and according you need to create a ZFM and assign the same in TRWPR table for junction function

and same need to be assingned to one of the following tables TBE31,TBE34 for BTE.

there is always an enhancement option in posting kind of transaction through Business transaction events and Junction function

Thanks and Regards

S.Janagar

Read only

0 Likes
5,389

Actually I found an enhancement point but couldn't resolve the issue. I just wanted to know if anybody did that before. Are those steps you give to find an enhancement point?

Read only

0 Likes
5,389

I put a break-point in rwin_check_subset but it wasn't triggered. I couldn't find the FM bp_functions_find. Could you help me more please?

Read only

kerem_kayacan
Active Participant
0 Likes
5,389

Problem solved. I used some enhancement points in function group MIGO. Solution is very complex, so contact me if you have same problem.

Read only

Former Member
0 Likes
5,389

Hi Kerem,

I have a similar requirement. If you could provide me some more details how to achieve this, that will be much appreciated.

Thanks

Steven

Read only

kerem_kayacan
Active Participant
0 Likes
5,390

Here is what I did. I will paste the code here. If it is not clear, let me know.

Function group: MIGO

Enhancement spot: ES_SAPLMIGO

Enhancement point: LINE_MODIFY_04


  DATA:
  lv_action TYPE goaction,
  lv_refdoc TYPE refdoc,
  lv_remain type bsmng,
  begin of ls_zeil,
    zeile type mblpo,
    global_counter type MIGO_GLOBAL_COUNTER,
  end of ls_zeil,
  lt_zeil like table of ls_zeil,
  lv_zeile type mblpo.

  if sy-tcode eq 'MIGO'.
	
  "Action and refdoc comes from MB_MIGO_BADI. 
  "This check is not obligatory
  CALL FUNCTION 'ZMM_EXPORT_ACTION'
   IMPORTING
     ACTION        = lv_action
     REFDOC        = lv_refdoc.

  if lv_action eq 'A01' AND lv_refdoc eq 'R01' and
     cs_goitem-ebeln is not initial.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      input         = cs_goitem-zeile
   IMPORTING
     OUTPUT        = lv_zeile.

  lv_remain = cs_goitem-bsmng - cs_goitem-wemng.

  IF cs_goitem-erfmg gt lv_remain.

    okcode = 'MIGO_OK_SPLIT_QUAN'.

    CALL FUNCTION 'ZMM_SET_AUTOSPLIT'
      EXPORTING
        autosplit       = 'X'.

    CALL FUNCTION 'ZMM_SET_GOITEM'
      EXPORTING
        goitem        = cs_goitem
        tabix         = sy-tabix.

    CALL FUNCTION 'ZMM_GET_SPLITTED_LINES'
     IMPORTING
       ET_ZEILE       = lt_zeil.

    read table lt_zeil into ls_zeil with key zeile = cs_goitem-zeile.
    IF sy-subrc ne 0.
      ls_zeil-zeile = cs_goitem-zeile.
      ls_zeil-global_counter = cs_goitem-global_counter.
      append ls_zeil to lt_zeil.
      "Send to MB_MIGO_BADI which line is splitted
      CALL FUNCTION 'ZMM_SET_SPLITTED_LINES'
        EXPORTING
          it_zeile       = lt_zeil.
    ENDIF.

  ENDIF."IF cs_goitem-erfmg gt lv_remain.

  endif.  "if lv_action eq 'A01' AND lv_refdoc eq 'R01'.

  ENDIF."if sy-tcode eq 'MIGO'.

Enhancement spot: ES_SAPLMIGO

Enhancement point: POPUP_CALL_03


  LOOP AT lt_fieldmapping INTO l_fieldname.
    CONCATENATE 'GOITEM-' l_fieldname INTO l_tmp_fieldname.
    l_status = lcl_migo_screenmodification=>get(
                 i_global_counter = ps_goitem-global_counter
                 i_field          = l_tmp_fieldname
               ).
    IF l_status < lcl_migo_screenmodification=>c_input.
      l_status = lcl_migo_screenmodification=>c_invisible.
    ELSE.
      l_status = lcl_migo_screenmodification=>c_visible.
    ENDIF.
    CONCATENATE 'GOSPLIT-' l_fieldname INTO l_fieldname.
    CALL METHOD lcl_migo_screenmodification=>set
      EXPORTING
        i_fields = l_fieldname
        i_status = l_status.
  ENDLOOP.
* Default values for the new lines                          "354046
  MOVE-CORRESPONDING ps_goitem TO ps_gosplit_default.
  CLEAR ps_gosplit_default-erfmg.
* Call the popup. Width and height are set automatically.   "354046

  DATA: auto_split TYPE c LENGTH 1,
        ls_goitem  type goitem,
        lv_tabix   type sytabix.
  CALL FUNCTION 'ZMM_GET_AUTOSPLIT'
   IMPORTING
     AUTOSPLIT       = auto_split.

  if auto_split IS INITIAL.
    CALL SCREEN 1000 STARTING AT 5 1.
  ELSE.
    CALL FUNCTION 'ZMM_GET_GOITEM'
     IMPORTING
       GOITEM        = ls_goitem
       tabix         = lv_tabix.
    move-corresponding ls_goitem to gosplit.
    gosplit-erfmg = ls_goitem-bsmng - ls_goitem-wemng.
    CALL METHOD oref_split_quantity->pai_loop.
    gosplit-erfmg = ls_goitem-erfmg -
      ( ls_goitem-bsmng - ls_goitem-wemng ).
    clear gosplit-split_line.
    CALL METHOD oref_split_quantity->pai_loop.
    p_selected_line = lv_tabix.
    ps_goitem = ls_goitem.
    CALL METHOD oref_split_quantity->pai_end.
    CALL FUNCTION 'ZMM_SET_AUTOSPLIT'
      EXPORTING
        autosplit       = space.
  ENDIF.

Read only

0 Likes
5,389

Hi Kerem,

Thank you very much about the info.

I went to the enhancement spot ES_SAPLMIGO and there are implementation point LINE_MODIFY_04. But I do not know how to put new codes into it and there are SAP code there already? I doub clicked on LINE_MODIFY_04 and it bring me to LMIGOKB1. I guess this is the context of this enhancement, and I should have access to all its variables?

I am not quite familar with this type of enhancement technology yet. Could you please share me some more lights on how this enhacement point works and how to create my own enhancement?

Many thanks!

Steven

Read only

0 Likes
5,389

Find the enhancement point in code (you can search the name of enhancement point). Open the code for enhancement by pressing Shift + F4. Right click on the enhancement spot name. Choose "Enhancement Implementation -> Create".

Read only

0 Likes
5,389

Hi Kerem,

With your help, I was able to create the implementation for these 2 enhancement using the code provided. Since the z function modules are not provided, I have not been able to make it work. Would it be possible that you could provide me those z function modules?

Many thanks!

Steven

Read only

0 Likes
5,389

Function group global data:


FUNCTION-POOL zmm_migo_badi.        "MESSAGE-ID ..

types:
begin of gst_zeil,
  zeile type mblpo,
  global_counter type MIGO_GLOBAL_COUNTER,
end of gst_zeil,
gtt_zeil type table of gst_zeil.

data gt_zeil type gtt_zeil.

data: gs_goitem type goitem,
      gv_tabix  type sytabix.

DATA:
gv_action TYPE GOACTION,
gv_refdoc TYPE REFDOC,
gv_autosplit type c length 1.

Function modules:


FUNCTION ZMM_EXPORT_ACTION.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  EXPORTING
*"     REFERENCE(ACTION) TYPE  GOACTION
*"     REFERENCE(REFDOC) TYPE  REFDOC
*"----------------------------------------------------------------------

  action = gv_action.
  refdoc = gv_refdoc.

ENDFUNCTION.


FUNCTION ZMM_SET_AUTOSPLIT.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(AUTOSPLIT) TYPE  CHAR1
*"----------------------------------------------------------------------

  gv_autosplit = autosplit.

ENDFUNCTION.


FUNCTION ZMM_SET_GOITEM.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(GOITEM) TYPE  GOITEM
*"     VALUE(TABIX) TYPE  SYTABIX
*"----------------------------------------------------------------------

  gs_goitem = goitem.
  gv_tabix  = tabix.

ENDFUNCTION.


FUNCTION ZMM_GET_SPLITTED_LINES.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  EXPORTING
*"     REFERENCE(ET_ZEILE)
*"----------------------------------------------------------------------

  et_zeile = gt_zeil.

ENDFUNCTION.


FUNCTION ZMM_SET_SPLITTED_LINES.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(IT_ZEILE)
*"----------------------------------------------------------------------

  gt_zeil = it_zeile.

ENDFUNCTION.


FUNCTION ZMM_GET_AUTOSPLIT.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  EXPORTING
*"     REFERENCE(AUTOSPLIT) TYPE  CHAR1
*"----------------------------------------------------------------------

  autosplit = gv_autosplit.

ENDFUNCTION.


FUNCTION ZMM_GET_GOITEM.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  EXPORTING
*"     REFERENCE(GOITEM) TYPE  GOITEM
*"     REFERENCE(TABIX) TYPE  SYTABIX
*"----------------------------------------------------------------------

  goitem = gs_goitem.
  tabix  = gv_tabix.

ENDFUNCTION.

Read only

0 Likes
5,389

Kerem,

You are brilliant! It worked out!

The enhancement line_modify_04 did the trick with the Z functions. Actually I just noticed that popup_call_03 is not really needed to get this auto split work. It seems only be triggered if you hit the split quanity button. I guess you want to set the split there automatically as well if user hit the button. But, with the code provided, it seems fall into an endless loop?

Anyway, this is fantastic!

Thank you so much!

Steven

Read only

0 Likes
5,389

I'm glad that it worked for you. I think our requirements are a little different. I need the popup_call_03 enhancement point to supress the split quantity window and fill data automatically. Anyway, if you made it work, there's no problem.

Read only

0 Likes
5,389

Hi Kerem,

In my project the Funcional responsible for MM needs only if MTART equal ZXX or ZYY show popup split. I used enhancement Enhancement spot: ES_SAPLMIGO

Enhancement point: LINE_MODIFY_04

but when I fill with Reservation or PO even through the success is attributed to the OKCODE MIGO shows no split.

When you use the existing encoding MIGO event here which you used? Could it be you include the code here?

If I put only material the screen split show. I don't need to fill this screen only show! This is possible ?

Thank you so much

Michele

Read only

Former Member
0 Likes
5,389

Dear Kerem,

I applied your coding in first part and put a break point there.

Function group: MIGO

Enhancement spot: ES_SAPLMIGO

Enhancement point: LINE_MODIFY_04

But when I enter migo and try goods receipt for a PO, i cannot see  debugger screen. I checked the coding, it's active but I think it is not passing through there ..

Can you help on this ..

Best regards,

Read only

0 Likes
5,389

Which line did you set the breakpoint exactly?

Read only

0 Likes
5,389

in LMIGOKL1;

just below the line of  """ENHANCEMENT 19  /CWM/APPL_MM_SAPLMIGO.    "active version

Read only

0 Likes
5,389

You should set above it, not below. Set your breakpoint inside implementation of LINE_MODIFY_04.

Read only

0 Likes
5,389

Dear Kerem,

SAP doesnt allow me to enhance above it.. There  is no """""" sign.

I'm sending you the screenshot of coding.. Can you sende me the screenshot of the coding  where i need to enhance ?

Best regards,

Read only

0 Likes
5,386

Kindly notice enhancement ZLINE_MODIFY_04_SAPLMIGO. You know how to implement an enhancement, don't you?