cancel
Showing results for 
Search instead for 
Did you mean: 

SAP APO CIF Product Master Data Issue

0 Kudos

Dear Experts,

I have encountered a problem that currently seems to be beyond my abilities to resolve, thus I am asking for your help.

Synapsis for the sake of clarity:

Business wants for following to happen:

a) User marks the product for deletion in MM06 transaction on ERP side

b) Immediately after that, on APO side LVORM (deletion flag) should be set to 'X' and BESKZ (procurement type) should be set to 'P' for the material.

What was done by me:

I debugged the CIF and user exit by tracing the inbound queue on APO side for 4 different scenarios (I chunk these 4 scenarios under two buckets marked in bold italic below):

A) Deletion flag (LVORM) is initially set to 'X' on both APO and ERP side

1) I remove deletion flag on ERP side and immediately it is also removed on APO side (which is fine, it's designed to work that way).

2) I change the procurement type of material on ERP side. Inbound queue is formed in SMQ2, but procurement type is not changed in APO (i.e. not overwritten, which is fine, this is the logic that business implemented in user exit)

B) Deletion flag (LVORM) is initially set to 'SPACE' on both APO and ERP side

1) I change the procurement type of material on ERP side. Inbound queue is formed in SMQ2, but procurement type is not changed in APO (i.e. not overwritten, which is fine, this is the logic that business implemented in user exit)

2) I set deletion flag on ERP side for material, inbound queue is formed, LVORM is set to 'X' on APO side, but procurement type is not changed to "P" (not fine, doesn't match the expected outcome).


Debugging the inbound queue SMQ2 shows that for scenarios A1, A2, B1 the incoming structures IT_CIF_MATKEY, IT_CIF_MATKEYX, IT_CIF_MATLOC and IT_CIF_MATLOCX inside the queue area filled with values.

But for scenario B2 the incoming structures IT_CIF_MATLOC and IT_CIF_MATLOCX inside the queue are empty. Which signals that something is going terribly wrong, because these structures should not be empty, as far as I know.


So, the problem is that for some unknown reason function module CIF_PROD_INBOUND leaves IT_CIF_MATLOC and IT_CIF_MATLOCX structure empty when user sets a deletion flag on ERP side (i.e., scenario B2).

How do I go about resolving the issue? This is certainly not because of the source code of the user exit.
I would deeply appreciate your advices and insights.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

The solution seems to be grab all data from DB tables in APO based on it_matkey structure and populate cif_matloc and cif_matlocx structures, respectively.
Below is the code snippet, I would be more than happy to receive suggestions on how to optimize it (personally I don't like multiple levels of nesting SELECT statements):

FIELD-SYMBOLS: <fs_matkey>       TYPE /sapapo/cif_matkey.

DATA: ls_cifmatmm06 TYPE /sapapo/cif_matloc.
DATA: lt_cifmatmm06 TYPE TABLE OF /sapapo/cif_matloc.
DATA: ls_vlocmat TYPE /sapapo/v_matloc.
DATA: ls_matmapmm06 TYPE /sapapo/matmap.
DATA: ls_matloc TYPE /sapapo/matloc.
DATA: ls_loc TYPE /sapapo/loc.
DATA: lv_length TYPE i.
DATA: ls_matlocx TYPE /sapapo/cif_matlocx.
DATA: lt_matlocx TYPE TABLE OF /sapapo/cif_matlocx.
DATA: lv_mm06_indicator TYPE c.

IF it_matloc[] IS INITIAL.
    LOOP AT it_matkey ASSIGNING <fs_matkey>.
      IF <fs_matkey>-method = 'D'.
        lv_mm06_indicator = 'X'.
        SELECT * INTO ls_matmapmm06 FROM /sapapo/matmap WHERE ext_matnr = <fs_matkey>-ext_matnr.
          SELECT * INTO ls_vlocmat FROM /sapapo/v_matloc WHERE matid = ls_matmapmm06-matid.
            SELECT * INTO ls_matloc FROM /sapapo/matloc WHERE matid = ls_matmapmm06-matid.
              SELECT * INTO ls_loc FROM /sapapo/loc WHERE locid = ls_matloc-locid.

                IF ls_loc-locno CS 'SL'.
                  lv_length = STRLEN( ls_loc-locno ).
                  lv_length = lv_length - 2.
                  ls_loc-locno = ls_loc-locno+2(lv_length).
                  CLEAR lv_length.
                ENDIF.

                MOVE-CORRESPONDING <fs_matkey> TO ls_cifmatmm06.
                MOVE-CORRESPONDING ls_matmapmm06 TO ls_cifmatmm06.
                MOVE-CORRESPONDING ls_vlocmat TO ls_cifmatmm06.
                MOVE-CORRESPONDING ls_matloc TO ls_cifmatmm06.
                MOVE-CORRESPONDING ls_loc TO ls_cifmatmm06.


                ls_cifmatmm06-method = 'D'.
                ls_cifmatmm06-beskz = 'P'.
                ls_cifmatmm06-ext_locno = ls_loc-locno.
                APPEND ls_cifmatmm06 TO lt_cifmatmm06.

                ls_matlocx-method = 'X'.
                ls_matlocx-ext_matnr = ls_cifmatmm06-ext_matnr.
                ls_matlocx-ext_locno = ls_cifmatmm06-ext_locno.
                ls_matlocx-loctype = ls_cifmatmm06-loctype.
                ls_matlocx-mtvfp = 'X'.
                ls_matlocx-chkhor = 'X'.
                ls_matlocx-calind = 'X'.
                ls_matlocx-bstfe = 'X'.
                ls_matlocx-bstmi = 'X'.
                ls_matlocx-bstma = 'X'.
                ls_matlocx-bstrf = 'X'.
                ls_matlocx-ausss = 'X'.
                ls_matlocx-rdprf ='X'.
                ls_matlocx-svtty ='X'.
                ls_matlocx-lgknd ='X'.
                ls_matlocx-sl_lsz_exact = 'X'.
                ls_matlocx-sl_lsz_fixed = 'X'.
                ls_matlocx-sl_lsz_range = 'X'.
                ls_matlocx-vrmod = 'X'.
                ls_matlocx-vint1 = 'X'.
                ls_matlocx-vint2 = 'X'.
                ls_matlocx-sbdkz = 'X'.
                ls_matlocx-miskz = 'X'.
                ls_matlocx-grprt = 'X'.
                ls_matlocx-safty = 'X'.
                ls_matlocx-ekgrp = 'X'.
                ls_matlocx-beskz = 'X'.
                ls_matlocx-lgrad = 'X'.
                ls_matlocx-plifz = 'X'.
                ls_matlocx-erhor = 'X'.
                ls_matlocx-freiz = 'X'.
                APPEND ls_matlocx TO lt_matlocx.
                CLEAR ls_cifmatmm06.
                CLEAR ls_matlocx.
                CLEAR ls_matmapmm06.
                CLEAR ls_vlocmat.
                CLEAR ls_locmat.
              ENDSELECT.
            ENDSELECT.
          ENDSELECT.
        ENDSELECT.
      ENDIF.
    ENDLOOP.

    LOOP AT lt_cifmatmm06 INTO ls_cifmatmm06.
      IF ls_cifmatmm06-ext_matnr = ' '.
        DELETE lt_cifmatmm06 INDEX sy-tabix.
      ENDIF.
    ENDLOOP.

    LOOP AT lt_matlocx INTO ls_matlocx.
      IF ls_matlocx-ext_matnr = ' '.
        DELETE lt_matlocx INDEX sy-tabix.
      ENDIF.
    ENDLOOP.

    it_matloc[] = lt_cifmatmm06[].
    it_matlocx[] = lt_matlocx[].

  ENDIF.

Answers (0)