EXIT_SAPL1001_003 SAP Function module - Enhancements in Material Master: IDoc - Post (Retail)

来源:互联网 发布:c语言函数的调用 编辑:程序博客网 时间:2024/05/01 06:47

修正MM46不能对自建字段时行操作的增强, 未测试

原文地址: http://www.se80.co.uk/sapfms/e/exit/exit_sapl1001_003.htm

 

SAP Documentation for FM EXIT_SAPL1001_003



FUNCTIONALITY

INCLUDE RETAIL_EXIT OBJECT DOKU ID TX LANGUAGE EN
INCLUDE EXIT_EINGANG OBJECT DOKU ID TX LANGUAGE EN
If a serious error is detected during processing, the exception APPLICATION_ERROR can be triggered in conjunction with the message MG544 to prevent the data transferred from being updated (see below for an example of a call of this kind).

EXAMPLE
The customer-defined code must be stored in Include ZXMGVU07.
The following example shows how values from the BAPI structure / IDoc structure can be transferred to the corresponding customer-defined fields so that these values can be updated in the receiving system. The example shows a customer-specific enhancement of table MARC. Enhancements to other tables (MARA, MARD, MLGN, MLGT, MBEW, MVKE, WLK2) are carried out in the same way.
Example 1

Note
The code specified applies in this form only if the customer-defined fields are of the data type CHAR. If numeric fields are also used, a special procedure is necessary (see example 2).
INCLUDE SZENARIO1 OBJECT DOKU ID TX LANGUAGE EN
The following code describes the transfer of customer-defined fields from the corresponding BAPI structure / IDoc structure (for example, PLANTEXT / PLANTEXTX) to the assigned internal structure (for example, MARC).
*---------------------------------------------------------------------**   INCLUDE ZXMGVU07                                                  **---------------------------------------------------------------------*DATA: BEGIN OF H_PLANTEXT,      "Customer dataFUNCTION  LIKE BAPIE1MARCEXTRT-FUNCTION,  "Key fieldMATERIAL  LIKE BAPIE1MARCEXTRT-MATERIAL,  "Key fieldPLANT     LIKE BAPIE1MARCEXTRT-PLANT.     "Key fieldINCLUDE STRUCTURE ZMARC.DATA: END   OF H_PLANTEXT.
DATA: BEGIN OF H_PLANTEXTX, "Customer update informationFUNCTION LIKE BAPIE1MARCEXTRTX-FUNCTION, "Key fieldMATERIAL LIKE BAPIE1MARCEXTRTX-MATERIAL, "Key fieldPLANT LIKE BAPIE1MARCEXTRTX-PLANT, "Key fieldZCUST1 TYPE C,ZCUST2 TYPE C,ZCUST3 TYPE C,END OF H_PLANTEXTX.
CASE PARAMETER_NAME.WHEN C_PARNAM_PLANTEXT.H_PLANTEXT = F_PLANTEXT.H_PLANTEXTX = F_PLANTEXTX.
IF NOT H_PLANTEXTX-ZCUST1 IS INITIALOR NOT F_HEADDATA-ALL_FIELDS IS INITIAL.* Corresponding data field is relevant for updateIF H_PLANTEXT-ZCUST1 IS INITIAL.T_RES_FIELDS-FELDNAME = 'MARC-ZCUST1'.APPEND T_RES_FIELDS.ENDIF.ELSE.CLEAR H_PLANTEXT-ZCUST1.ENDIF.F_MARC_UEB-ZCUST1 = H_PLANTEXT-ZCUST1.
IF NOT H_PLANTEXTX-ZCUST2 IS INITIALOR NOT F_HEADDATA-ALL_FIELDS IS INITIAL.* Corresponding data field is relevant for updateIF H_PLANTEXT-ZCUST2 IS INITIAL.T_RES_FIELDS-FELDNAME = 'MARC-ZCUST2'.APPEND T_RES_FIELDS.ENDIF.ELSE.CLEAR H_PLANTEXT-ZCUST2.ENDIF.F_MARC_UEB-ZCUST2 = H_PLANTEXT-ZCUST2.
IF NOT H_PLANTEXTX-ZCUST3 IS INITIALOR NOT F_HEADDATA-ALL_FIELDS IS INITIAL.* Corresponding data field is relevant for updateIF H_PLANTEXT-ZCUST3 IS INITIAL.T_RES_FIELDS-FELDNAME = 'MARC-ZCUST3'.APPEND T_RES_FIELDS.ENDIF.ELSE.CLEAR H_PLANTEXT-ZCUST3.ENDIF.F_MARC_UEB-ZCUST3 = H_PLANTEXT-ZCUST3.WHEN C_PARNAM_CLIENTEXT." . . . . customer data for table MARA" WHEN . . . . customer data for table ....ENDCASE.
* Example for raising an exception if an application error occurred* IF .* MESSAGE E544(MG) WITH PARAMETER_NAME RAISING APPLICATION_ERROR.* ENDIF.

Example 2 (also numeric customer fields)

INCLUDE SZENARIO2 OBJECT DOKU ID TX LANGUAGE EN
The following code describes the transfer of customer-defined fields from the corresponding BAPI structure / IDoc structure (for example, PLANTEXT / PLANTEXTX) to the assigned internal structure (for example, MARC) when numeric customer fields are also involved.
For each numeric field, a corresponding field of the type CHAR must be defined in the auxiliary structure H_PLANTEXT_C. The length of the data field depends on the underlying numeric data type (with DEC3, you have to choose CHAR4 so that there is space for the three decimal places and any sign).
*---------------------------------------------------------------------**   INCLUDE ZXMGVU07                                                  **---------------------------------------------------------------------*DATA: BEGIN OF H_PLANTEXT_C,      "Customer data in CHAR formatFUNCTION  LIKE BAPIE1MARCEXTRT-FUNCTION,  "Key fieldMATERIAL  LIKE BAPIE1MARCEXTRT-MATERIAL,  "Key fieldPLANT     LIKE BAPIE1MARCEXTRT-PLANT.     "Key fieldZCUST1    LIKE ZMARC-ZCUST1,ZCUST2(4) TYPE C,              "CHAR4 instead of DEC3!!!!ZCUST3    LIKE ZMARC-ZCUST3,END   OF H_PLANTEXT_C.
DATA: BEGIN OF H_PLANTEXT, "Customer data in real formatFUNCTION LIKE BAPIE1MARCEXTRT-FUNCTION, "Key fieldMATERIAL LIKE BAPIE1MARCEXTRT-MATERIAL, "Key fieldPLANT LIKE BAPIE1MARCEXTRT-PLANT. "Key fieldINCLUDE STRUCTURE ZMARC.DATA: END OF H_PLANTEXT.
DATA: BEGIN OF H_PLANTEXTX, "Customer update informationFUNCTION LIKE BAPIE1MARCEXTRTX-FUNCTION, "Key fieldMATERIAL LIKE BAPIE1MARCEXTRTX-MATERIAL, "Key fieldPLANT LIKE BAPIE1MARCEXTRTX-PLANT, "Key fieldZCUST1 TYPE C,ZCUST2 TYPE C,ZCUST3 TYPE C,END OF H_PLANTEXTX.
CASE PARAMETER_NAME.WHEN C_PARNAM_PLANTEXT.* Map from unstructured BAPI format to structured CHAR formatH_PLANTEXT_C = F_PLANTEXT.* Map from structured CHAR format to real formatMOVE-CORRESPONDING H_PLANTEXT_C TO H_PLANTEXT.H_PLANTEXTX = F_PLANTEXTX.
IF NOT H_PLANTEXTX-ZCUST1 IS INITIALOR NOT F_HEADDATA-ALL_FIELDS IS INITIAL.* Corresponding data field is relevant for updateIF H_PLANTEXT-ZCUST1 IS INITIAL.T_RES_FIELDS-FELDNAME = 'MARC-ZCUST1'.APPEND T_RES_FIELDS.ENDIF.ELSE.CLEAR H_PLANTEXT-ZCUST1.ENDIF.F_MARC_UEB-ZCUST1 = H_PLANTEXT-ZCUST1.
IF NOT H_PLANTEXTX-ZCUST2 IS INITIALOR NOT F_HEADDATA-ALL_FIELDS IS INITIAL.* Corresponding data field is relevant for updateIF H_PLANTEXT-ZCUST2 IS INITIAL.T_RES_FIELDS-FELDNAME = 'MARC-ZCUST2'.APPEND T_RES_FIELDS.ENDIF.ELSE.CLEAR H_PLANTEXT-ZCUST2.ENDIF.F_MARC_UEB-ZCUST2 = H_PLANTEXT-ZCUST2.
IF NOT H_PLANTEXTX-ZCUST3 IS INITIALOR NOT F_HEADDATA-ALL_FIELDS IS INITIAL.* Corresponding data field is relevant for updateIF H_PLANTEXT-ZCUST3 IS INITIAL.T_RES_FIELDS-FELDNAME = 'MARC-ZCUST3'.APPEND T_RES_FIELDS.ENDIF.ELSE.CLEAR H_PLANTEXT-ZCUST3.ENDIF.F_MARC_UEB-ZCUST3 = H_PLANTEXT-ZCUST3.WHEN C_PARNAM_CLIENTEXT." . . . . customer data for table MARA" WHEN . . . . customer data for table ....ENDCASE.
* Example for raising an exception if an application error occurred* IF .* MESSAGE E544(MG) WITH PARAMETER_NAME RAISING APPLICATION_ERROR.* ENDIF.


FURTHER_SOURCES_OF_INF

INCLUDE FURTHER_INFO_ALE OBJECT DOKU ID TX LANGUAGE EN

 

原创粉丝点击