EDUCAÇÃO E TECNOLOGIA

Solution to Product Substituition problem with Idocs (Note 1702275)

Problem Description and Business Scenario

WIthin the IDocs there are materials with or without Configuration segments ‘E1CUCFG’ . In case of a material with Configuration Segments , the first material should be selected. If, there are no configuration segments for that position , the original material should be selected and no substituition should take place. However when the Inbound Orders Idoc is processed , In both the cases , the configured material is selected . i.e. the Material Substituition takes place.

Solution

According to the snote 1702275. There is no solution to this problem , since in the background process, this selection can not be done by the user.

After some Debugging , I was able to solve this problem by doing an enhancement at the following enh Point.

Code as follows:

DATA: ls_idoc_control TYPE edidc, lt_edid4 TYPE TABLE OF edid4, lf_posex TYPE edi1082_a, lf_segnum TYPE idocdsgnum, ls_e1edp01 TYPE e1edp01, ls_e1edp19 TYPE e1edp19, ls_e1cucfg TYPE e1cucfg, lf_idtnr TYPE edi_idtnr, lf_flag TYPE xfeld, lf_flag_config TYPE xfeld, lf_matnr TYPE matnr, lf_ivbap_tabix_aktuell TYPE sy-tabix, lf_ivbap_pos TYPE int4, lf_ivbap_posex TYPE edi1082_a. . FIELD-SYMBOLS : <ls_edid4> TYPE edid4. *This enhancement should work only in case of ORDERS Inbound idoc.
IF idoc_number IS NOT INITIAL.
*Find the current position number using the variable ivbap_tabix_aktuell . lf_ivbap_tabix_aktuell = ivbap_tabix_aktuell . lf_ivbap_pos = lf_ivbap_tabix_aktuell * 10 . lf_ivbap_posex = lf_ivbap_pos . CONDENSE lf_ivbap_posex . IF idoc_edidc-mestyp = 'ORDERS' AND idoc_edidc-direct = '2'.
*Orders Idoc Scenario, read the data segments. SELECT * FROM edid4 INTO TABLE lt_edid4 WHERE docnum = idoc_number. IF lt_edid4 IS NOT INITIAL. LOOP AT lt_edid4 ASSIGNING <ls_edid4> WHERE segnam = 'E1EDP01' OR segnam = 'E1EDP19' . IF lf_flag NE 'X' . IF <ls_edid4>-segnam = 'E1EDP01'. MOVE <ls_edid4>-sdata TO ls_e1edp01 .
*From E1EDP01 segment position number is required. IF ls_e1edp01 IS NOT INITIAL . lf_posex = ls_e1edp01-posex. lf_segnum = <ls_edid4>-segnum. ENDIF. ENDIF.
*From E1EDP19 segment material number is required. IF <ls_edid4>-segnam = 'E1EDP19'. MOVE <ls_edid4>-sdata TO ls_e1edp19 . lf_IDTNR = ls_e1edp19-idtnr . CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT' EXPORTING input = lf_idtnr IMPORTING output = lf_matnr EXCEPTIONS length_error = 1 OTHERS = 2. IF sy-subrc <> 0.
* Implement suitable error handling here ENDIF. IF lf_matnr = vbap-matnr AND lf_posex = lf_ivbap_posex .
*The variables set above are for this position and can be used to find the config segment. lf_flag = 'X' . EXIT. ENDIF. ENDIF. ENDIF. ENDLOOP.
*Check the flag and see if there is any configuration segment for this posex. IF lf_flag = 'X' . LOOP AT lt_edid4 ASSIGNING <ls_edid4> WHERE segnam = 'E1CUCFG' . MOVE <ls_edid4>-sdata TO ls_e1cucfg . IF ls_e1cucfg-posex = lf_posex .
*Configuration segments for this position available in the idoc. First position from the substituition possibilities will be taken.
*No need to do anything. Set the flag to signify that it is a Idoc position with Config segments. lf_flag_config = 'X'. EXIT. ENDIF. ENDLOOP. IF lf_flag_config NE 'X'. REFRESH : konddp_tab[]. ENDIF. ENDIF. ENDIF. ENDIF.
*clear variables here if required .
ENDIF.

The table konddp_tab is cleared in case , no substituition is required. The decision whether the substituition is required or not is taken on the basis of the data segments in the idoc. if the Position does not contain any configuration segments, then the table is cleared , else not.  If the table is not cleared , the first position in the table is always filled with the configured material and the standard logic always takes the first material.

If there are any Questions , please comment below.

Br,

Ketan