Skip to Content

EWM Code to Add "Process Code" to ODO Item

Does anyone know of a function module or method I can use to duplicate the actions executed when I add a process code (O002 - Warehouse Difference, Adj. Doc. + Qty / Adjustment of Delivery Quantity and Del. Quant. Transferred) to an ODO item and save? I know its calling method ACTION_EXECUTE (/SCDL/CL_SP) with action = SC_ADJUST_QUANTITY, to zero the quantity, but after that I'm not sure how the new delivery is created. I'm hoping there's some easy way to code this so I don't have to figure out the whole process!

Thanks for any help anyone can provide,

Mike

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    May 03 at 02:11 PM

    I figured it out. In case anyone searches and finds this question, here's the code for the solution...

      DATA: ls_sp_k_head   TYPE /scdl/s_sp_k_head,
            lt_sp_k_head   TYPE /scdl/t_sp_k_head,
            ls_prcodes_in  TYPE /scdl/s_sp_a_item_prcodes,
            lt_prcodes_in  TYPE /scdl/t_sp_a_item_prcodes,
            lt_prcodes_out TYPE /scdl/t_sp_a_item_prcodes.
    
      FIELD-SYMBOLS: <ls_prcodes_in>  TYPE /scdl/s_sp_a_item_prcodes.
    
      TRY.
          CREATE OBJECT lo_message_box.
          CREATE OBJECT lo_sp
            EXPORTING
              io_message_box = lo_message_box
              iv_doccat      = /scdl/if_dl_doc_c=>sc_doccat_out_prd
              iv_mode        = /scdl/cl_sp=>sc_mode_classic.
        CATCH /scdl/cx_sp_message_box.
          pv_error = 'X'.
          EXIT.
      ENDTRY.
    
      SELECT docid itemid qty uom
        FROM /scdl/db_proci_o
        INTO CORRESPONDING FIELDS OF TABLE lt_prcodes_in
         FOR ALL ENTRIES IN pt_data
       WHERE doccat = 'PDO'
         AND docno  = pt_data-docno    " 1 docno
         AND itemno = pt_data-itemno   " Could have multiple items we're splitting off
         AND qty   GT 0.               " Just in case the user tries to reprocess the same data twice!
      IF sy-subrc NE 0.
        EXIT.
      ENDIF.
    
    * Lock the ODO
      READ TABLE lt_prcodes_in INTO ls_prcodes_in INDEX 1.
      ls_sp_k_head-docid = ls_prcodes_in-docid.
      APPEND ls_sp_k_head TO lt_sp_k_head.
      CLEAR:  lt_return_codes, lv_rejected.
      lo_sp->lock(
        EXPORTING
          inkeys       = lt_sp_k_head
          aspect       = /scdl/if_sp_c=>sc_asp_head
          lockmode     = /scdl/if_sp1_locking=>sc_exclusive_lock
        IMPORTING
          rejected     = lv_rejected
          return_codes = lt_return_codes ).
      READ TABLE lt_return_codes TRANSPORTING NO FIELDS WITH KEY failed = abap_true.
      IF sy-subrc = 0 OR lv_rejected = abap_true.
        pv_error = abap_true.
        MESSAGE s999 WITH 'Unable to Lock ODO' ls_data-docno DISPLAY LIKE 'E'.
        EXIT.
      ENDIF.
    
    * Add the process code(s) and update!
      LOOP AT lt_prcodes_in ASSIGNING <ls_prcodes_in>.
        <ls_prcodes_in>-prcode  = 'O002'.
        <ls_prcodes_in>-qty    = -1 * <ls_prcodes_in>-qty.
      ENDLOOP.
    
      CLEAR: lt_return_codes, lv_rejected.
      lo_sp->update(
        EXPORTING
          inrecords    = lt_prcodes_in
          aspect       = /scdl/if_sp_c=>sc_asp_item_prcodes
        IMPORTING
          outrecords   = lt_prcodes_out
          rejected     = lv_rejected
          return_codes = lt_return_codes ).
      READ TABLE lt_return_codes TRANSPORTING NO FIELDS WITH KEY failed = abap_true.
      IF sy-subrc = 0 OR lv_rejected = abap_true.
        pv_error = abap_true.
        MESSAGE s999 WITH 'ODO Update Error'  DISPLAY LIKE 'E'.
        EXIT.
      ENDIF.
    
    * Save the data (we still need a commit, but that will happen all or none at the end)
      lo_sp->save( IMPORTING rejected = lv_rejected ).
      IF lv_rejected = abap_true.
        MESSAGE s999 WITH 'ODO Save Error'.
        pv_error = abap_true.
      ENDIF.
    
    Add comment
    10|10000 characters needed characters exceeded

  • Apr 25 at 10:44 AM

    Hi Mike,

    not sure what you want to achieve. The creation of the new delivery is done during the transition service from the ODR (outbound delivery request) to the ODO.

    If you adjust the quantity you will see that on the ODR on the PPF tab there is a new entry for the transition service. Inside it is decided whether there is an open quantity and if a new delivery has to be created. So there is basically no "simple" action that does this.

    Therefore I wanted to ask what you are trying to do. E.g. if you call the adjust quantity action with the correct process code this will be done automatically. Therefore I do not know why you want to know the details how and where the delivery is created.

    Best regards

    Markus



    Add comment
    10|10000 characters needed characters exceeded

    • Hi Markus,

      We have an interface with a 3rd party shipper which can dictate if and when a delivery must be split for shipping. At times the shipper, via the interface, can tell us to split the ODO into two ODO's. My functional analyst told me the way he would do that in /SCWM/PRDO would be to hi-light the items that must be split off and click Process Codes -> Adjust Delivery Quantity, then select process code O002, and save - and now I need to code that within the interface.

      I don't really understand the ODR -> ODO part of what you said, but I'm going to try to do what you said... "if you call the adjust quantity action with the correct process code this will be done automatically", and see if that works.

      Let me know if you have any additional thoughts now that you know (hopefully, I explained it correctly) what I want. Otherwise, I'm going to write a test program and see if it works.

      Mike