基于系统内的全配置BOM设定,全部的子配置是由四大配置产生(即车身颜色、内饰颜色、车型、选装)。如果按某一车型,要带出该车的全部BOM子物料,首先需要具备通过四大配置,得到全部子配置的能力,然后才能把200个配置去得到相应的物料。
CU50中的四大配置:
四大配置确定后出现的200项子配置清单:
测试环境用程序来实现:
*&---------------------------------------------------------------------*
*& Report ZTEST_CFG
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZTEST_CFG.
INCLUDE LCEI0FTY.
TYPES: BEGIN OF TY_ALV,
MNAME TYPE RCTMS-MNAME,
ATBEZ TYPE ATBEZ,
MWERT TYPE RCTMS-MWERT,
ATWTB TYPE ATWTB,
END OF TY_ALV.
DATA:GT_ALV TYPE STANDARD TABLE OF TY_ALV.
TYPES TY_PKG0 TYPE RANGE OF CAWN-ATWRT.
DATA PT_PKG0 TYPE TY_PKG0.
DATA:
LV_TXT TYPE ATNAM,
LV_ATNAM_COLOR TYPE ATNAM,
LV_ATNAM_INTERI TYPE ATNAM,
LV_ATNAM_MODEL TYPE ATNAM,
LV_ATNAM_OPTPAC TYPE ATNAM,
GT_BOM TYPE /SAPAPO/RTOUI_COMPONENT_T,
GO_APP_LOG TYPE REF TO ZCL_CA_APP_LOG.
CONSTANTS:GV_KEY_COLOR TYPE ZZ_CONFIG_KEY VALUE 'ZDP_0001_COLOR',
GV_KEY_INTERI TYPE ZZ_CONFIG_KEY VALUE 'ZDP_0001_INTERI',
GV_KEY_MODEL TYPE ZZ_CONFIG_KEY VALUE 'ZDP_0001_MODEL',
GV_KEY_OPTPAC TYPE ZZ_CONFIG_KEY VALUE 'ZDP_0001_OPTPAC'.
DATA P_MATNR TYPE MARA-MATNR VALUE 'F2'.
PERFORM FRM_CONFIG_GET TABLES PT_PKG0
USING 'CC01'
'PA01'
'B27FRF8JA4L01'
''.
FORM FRM_CONFIG_GET TABLES IT_PKG0 TYPE TY_PKG0
USING PI_CC00
PI_PA00
PI_PM
PI_PKG0.
DATA: LT_INPUT TYPE TABLE OF CLTABLE,
LT_OUTPUT TYPE TABLE OF CLTABLE,
LV_REF TYPE INOB-CUOBJ,
LV_OBJ TYPE INOB-ROBJEK,
LT_CONFIG TYPE TABLE OF CONF_OUT.
FIELD-SYMBOLS: <FT_MI> TYPE TT_MI,
<FT_WI> TYPE TT_WI,
<FT_GI> TYPE TT_INST,
<FS_GI> TYPE LINE OF TT_INST,
<FS_RCTMS> TYPE RCTMS,
<FV_CHANGED> TYPE C.
ASSIGN ('(SAPLCEI0)MI[]') TO <FT_MI>.
ASSIGN ('(SAPLCEI0)WI[]') TO <FT_WI>.
ASSIGN ('(SAPLCEI0)G_I[]') TO <FT_GI>.
ASSIGN ('(SAPLCEI0)RCTMS') TO <FS_RCTMS>.
ASSIGN ('(SAPLCEI0)GV_CHANGE') TO <FV_CHANGED>.
IF <FT_MI> IS ASSIGNED.
CLEAR:<FT_MI>[].
ENDIF.
IF <FT_WI> IS ASSIGNED.
CLEAR <FT_WI>[].
ENDIF.
IF <FT_GI> IS ASSIGNED.
CLEAR <FT_GI>[].
ENDIF.
IF <FS_RCTMS> IS ASSIGNED.
CLEAR <FS_RCTMS>.
ENDIF.
IF <FV_CHANGED> IS ASSIGNED.
CLEAR <FV_CHANGED>.
ENDIF..
LV_OBJ = P_MATNR = 'F2'.
CALL FUNCTION 'CE_C_PROCESSING'
EXPORTING
INSTANCE = '000000000000000000'
* REFERENCE_INSTANCE =
DATE = SY-DATUM
* DISPLAY = ' '
OBJECT_ID = 'MARA'
OBJECT = LV_OBJ
"OWNER_ID = 'VBPS'
* HEADER_SCREEN =
PLANT = '1000'
NO_DIALOG = 'X'
* MATERIAL_VARIANT =
NO_F8 = 'X'
NO_F11 = 'X'
* SUB_TYPE = ' '
" SIMULATION = 'X'
TYPE = 'S'
* EFFECTIVITY =
* INITIALIZATION = ' '
* CALLED_FROM_SALES = ' '
* BOM_APPLICATION =
* IS_BUSINESS_OBJECT =
* IV_PROFILE_COUNTER =
IMPORTING
* RETURN_WITH_FUNCTIONKEY =
NEW_INSTANCE = LV_REF
TABLES
APPLICATION_INPUT = LT_INPUT
APPLICATION_OUTPUT = LT_OUTPUT
EXCEPTIONS
INTERNAL_ERROR = 1
INSTANCE_NOT_FOUND = 2
REFERENCE_INSTANCE_NOT_FOUND = 3
INSTANCE_IS_A_CLASSIFICATION = 4
NO_PLANT = 5
NO_QUANTITY = 6
NO_CONNECTION_TO_CONFIGURATION = 7
MATERIAL_VARIANT_NOT_ALLOWED = 8
INTERNAL_ERROR_ECM = 9
EOASL_NOT_ALLOWED = 10
MAXASL_NOT_ALLOWED = 11
XC_UNPROCESSED_DATA = 12
XC_FAILURE_PROCESSING_DATA = 13
NO_BOM = 14
NO_KNOWLEDGE_BASE_FOUND = 15
ORDER_BOM_ERROR = 16
OTHERS = 17.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
* <ft_gt_bild> like bild,
* <ft_bild> like bild.
ASSIGN ('(SAPLCEI0)MI[]') TO <FT_MI>.
ASSIGN ('(SAPLCEI0)WI[]') TO <FT_WI>.
ASSIGN ('(SAPLCEI0)G_I[]') TO <FT_GI>.
ASSIGN ('(SAPLCEI0)RCTMS') TO <FS_RCTMS>.
ASSIGN ('(SAPLCEI0)GV_CHANGE') TO <FV_CHANGED>.
* ASSIGN ('(SAPLCEI0)BILD[]') to <ft_bild>.
*
* ASSIGN ('(SAPLCEI0)GT_BILD[]') to <ft_gt_bild>.
* ---------------------------------------------------
DATA: LT_API_VAL_SUCCESS TYPE TT_API_VAL_C,
LS_MI TYPE TS_MI,
LS_WI TYPE TS_WI,
LS_ICV TYPE TS_VALUE,
LS_ICV_INDEX TYPE SY-TABIX,
LV_ATWRT_TO_CHECK TYPE ATWRT.
* ---------------------------------------------------
IF PI_CC00 IS NOT INITIAL.
<FV_CHANGED> = 'X'.
CLEAR LV_ATNAM_COLOR.
PERFORM FRM_GET_HC USING P_MATNR GV_KEY_COLOR
CHANGING LV_ATNAM_COLOR.
CLEAR:LS_MI.
READ TABLE <FT_MI> INTO LS_MI WITH KEY ATNAM = LV_ATNAM_COLOR.
IF SY-SUBRC = 0.
<FS_RCTMS>-MNAME = LV_ATNAM_COLOR.
<FS_RCTMS>-MWERT = PI_CC00.
LV_ATWRT_TO_CHECK = PI_CC00.
PERFORM CHECK_INPUT IN PROGRAM SAPLCEI0
USING
LV_ATWRT_TO_CHECK
'X'
'1'
SPACE
SPACE
0
SPACE
CHANGING
LT_API_VAL_SUCCESS
LS_MI
LS_ICV
LS_ICV_INDEX
IF FOUND .
ASSIGN ('(SAPLCEI0)G_I') TO <FS_GI>.
MODIFY <FT_GI> FROM <FS_GI> INDEX 1.
ENDIF.
ENDIF.
IF PI_PA00 IS NOT INITIAL.
<FV_CHANGED> = 'X'.
PERFORM FRM_GET_HC USING P_MATNR GV_KEY_INTERI
CHANGING LV_ATNAM_INTERI.
CLEAR:LS_MI.
READ TABLE <FT_MI> INTO LS_MI WITH KEY ATNAM = LV_ATNAM_INTERI.
IF SY-SUBRC = 0.
<FS_RCTMS>-MNAME = LV_ATNAM_INTERI.
<FS_RCTMS>-MWERT = PI_PA00.
LV_ATWRT_TO_CHECK = PI_PA00.
PERFORM CHECK_INPUT IN PROGRAM SAPLCEI0
USING
LV_ATWRT_TO_CHECK
'X'
'1'
SPACE
SPACE
0
SPACE
CHANGING
LT_API_VAL_SUCCESS
LS_MI
LS_ICV
LS_ICV_INDEX
IF FOUND .
ASSIGN ('(SAPLCEI0)G_I') TO <FS_GI>.
MODIFY <FT_GI> FROM <FS_GI> INDEX 1.
ENDIF.
ENDIF.
IF PI_PM IS NOT INITIAL.
<FV_CHANGED> = 'X'.
PERFORM FRM_GET_HC USING P_MATNR GV_KEY_MODEL CHANGING LV_ATNAM_MODEL.
CLEAR:LS_MI.
READ TABLE <FT_MI> INTO LS_MI WITH KEY ATNAM = LV_ATNAM_MODEL.
IF SY-SUBRC = 0.
<FS_RCTMS>-MNAME = LV_ATNAM_MODEL.
<FS_RCTMS>-MWERT = PI_PM.
LV_ATWRT_TO_CHECK = PI_PM.
PERFORM CHECK_INPUT IN PROGRAM SAPLCEI0
USING
LV_ATWRT_TO_CHECK
'X'
'1'
SPACE
SPACE
0
SPACE
CHANGING
LT_API_VAL_SUCCESS
LS_MI
LS_ICV
LS_ICV_INDEX
IF FOUND .
ASSIGN ('(SAPLCEI0)G_I') TO <FS_GI>.
MODIFY <FT_GI> FROM <FS_GI> INDEX 1.
ENDIF.
ENDIF.
PERFORM FRM_GET_HC USING P_MATNR GV_KEY_OPTPAC CHANGING LV_ATNAM_OPTPAC.
IF IT_PKG0[] IS NOT INITIAL .
LOOP AT IT_PKG0.
<FV_CHANGED> = 'X'.
CLEAR:LS_MI.
READ TABLE <FT_MI> INTO LS_MI WITH KEY ATNAM = LV_ATNAM_OPTPAC.
IF SY-SUBRC = 0.
<FS_RCTMS>-MNAME = LV_ATNAM_OPTPAC.
<FS_RCTMS>-MWERT = IT_PKG0-LOW.
LV_ATWRT_TO_CHECK = IT_PKG0-LOW.
PERFORM CHECK_INPUT IN PROGRAM SAPLCEI0
USING
LV_ATWRT_TO_CHECK
'X'
'1'
SPACE
SPACE
0
SPACE
CHANGING
LT_API_VAL_SUCCESS
LS_MI
LS_ICV
LS_ICV_INDEX
IF FOUND .
ASSIGN ('(SAPLCEI0)G_I') TO <FS_GI>.
MODIFY <FT_GI> FROM <FS_GI> INDEX 1.
ENDIF.
ENDLOOP.
ELSEIF PI_PKG0 IS NOT INITIAL.
<FV_CHANGED> = 'X'.
CLEAR:LS_MI.
READ TABLE <FT_MI> INTO LS_MI WITH KEY ATNAM = LV_ATNAM_OPTPAC.
IF SY-SUBRC = 0.
<FS_RCTMS>-MNAME = LV_ATNAM_OPTPAC.
<FS_RCTMS>-MWERT = PI_PKG0.
LV_ATWRT_TO_CHECK = PI_PKG0.
PERFORM CHECK_INPUT IN PROGRAM SAPLCEI0
USING
LV_ATWRT_TO_CHECK
'X'
'1'
SPACE
SPACE
0
SPACE
CHANGING
LT_API_VAL_SUCCESS
LS_MI
LS_ICV
LS_ICV_INDEX
IF FOUND .
ASSIGN ('(SAPLCEI0)G_I') TO <FS_GI>.
MODIFY <FT_GI> FROM <FS_GI> INDEX 1.
ENDIF.
ENDIF.
PERFORM F0100_CONFIGURE IN PROGRAM SAPLCEI0.
DATA:LS_G_IC TYPE TS_CHAR,
LS_CL TYPE TS_CHAR_DESCRIPTION,
LS_VALUE TYPE TS_VALUE,
LS_VL TYPE TS_VALUE_DESCRIPTION,
LS_ALV TYPE TY_ALV.
CHECK <FT_GI> IS ASSIGNED.
READ TABLE <FT_GI> ASSIGNING <FS_GI> INDEX 1.
REFRESH GT_ALV.
CHECK <FS_GI> IS ASSIGNED.
LOOP AT <FS_GI>-G_IC INTO LS_G_IC.
CLEAR:LS_ALV.
READ TABLE <FT_MI> INTO LS_MI WITH KEY MINDX = LS_G_IC-MINDX.
IF SY-SUBRC = 0.
LS_ALV-MNAME = LS_MI-ATNAM.
ENDIF.
READ TABLE LS_MI-CL INTO LS_CL WITH KEY LANGU = SY-LANGU.
IF SY-SUBRC = 0.
LS_ALV-ATBEZ = LS_CL-ATBEZ.
ENDIF.
LOOP AT LS_G_IC-V INTO LS_VALUE.
READ TABLE <FT_WI> INTO LS_WI WITH KEY MINDX = LS_G_IC-MINDX WINDX = LS_VALUE-WINDX.
IF SY-SUBRC = 0.
IF LS_WI-WOHNE <> 'X'.
LS_ALV-MWERT = LS_WI-NATWRT.
ELSE.
LS_ALV-MWERT = LS_VALUE-ATWRT.
ENDIF.
ENDIF.
READ TABLE LS_WI-VL INTO LS_VL WITH KEY LANGU = SY-LANGU.
IF SY-SUBRC = 0.
CONCATENATE LS_ALV-ATWTB LS_VL-ATWTB INTO LS_ALV-ATWTB SEPARATED BY SPACE.
ENDIF.
APPEND LS_ALV TO GT_ALV.
ENDLOOP.
* APPEND ls_alv TO gt_alv.
ENDLOOP.
LOOP AT GT_ALV ASSIGNING FIELD-SYMBOL(<LS_ALV>).
CONDENSE <LS_ALV>-ATWTB.
IF <LS_ALV>-MWERT = <LS_ALV>-ATWTB.
PERFORM FRM_READ_TEXT IN PROGRAM ZPDU0011 USING '1' <LS_ALV>-MWERT <LS_ALV>-MNAME
CHANGING <LS_ALV>-ATWTB <LS_ALV>-ATWTB IF FOUND.
ENDIF.
ENDLOOP.
BREAK-POINT.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_GET_HC
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> P_
*&---------------------------------------------------------------------*
FORM FRM_GET_HC USING PI_MATNR TYPE MATNR PI_KEY TYPE ZZ_CONFIG_KEY
CHANGING PO_ATNAM TYPE ATNAM.
CLEAR PO_ATNAM.
CALL METHOD ZCL_CA_TOOLS=>GET_HC_SINGLE
EXPORTING
IV_CONFIG_KEY = PI_KEY
IMPORTING
EV_SINGLE = PO_ATNAM
EXCEPTIONS
DYNAMIC_ERROR = 1
OTHERS = 2.
CONCATENATE PI_MATNR '_' PO_ATNAM INTO PO_ATNAM.
ENDFORM.