Ansicht
Dokumentation

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

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

ROGBILLS - Synchronize billing plans   Addresses (Business Address Services)  
This documentation is copyright by SAP AG.
SAP E-Book

Functionality

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).

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 data
FUNCTION LIKE BAPIE1MARCEXTRT-FUNCTION, "Key field
MATERIAL LIKE BAPIE1MARCEXTRT-MATERIAL, "Key field
PLANT LIKE BAPIE1MARCEXTRT-PLANT. "Key field
INCLUDE STRUCTURE ZMARC.
DATA: END OF H_PLANTEXT.

DATA: BEGIN OF H_PLANTEXTX, "Customer update information
FUNCTION LIKE BAPIE1MARCEXTRTX-FUNCTION, "Key field
MATERIAL LIKE BAPIE1MARCEXTRTX-MATERIAL, "Key field
PLANT LIKE BAPIE1MARCEXTRTX-PLANT, "Key field
ZCUST1 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 INITIAL
OR NOT F_HEADDATA-ALL_FIELDS IS INITIAL.
* Corresponding data field is relevant for update
IF 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 INITIAL
OR NOT F_HEADDATA-ALL_FIELDS IS INITIAL.
* Corresponding data field is relevant for update
IF 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 INITIAL
OR NOT F_HEADDATA-ALL_FIELDS IS INITIAL.
* Corresponding data field is relevant for update
IF 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)

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 format
FUNCTION LIKE BAPIE1MARCEXTRT-FUNCTION, "Key field
MATERIAL LIKE BAPIE1MARCEXTRT-MATERIAL, "Key field
PLANT LIKE BAPIE1MARCEXTRT-PLANT. "Key field
ZCUST1 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 format
FUNCTION LIKE BAPIE1MARCEXTRT-FUNCTION, "Key field
MATERIAL LIKE BAPIE1MARCEXTRT-MATERIAL, "Key field
PLANT LIKE BAPIE1MARCEXTRT-PLANT. "Key field
INCLUDE STRUCTURE ZMARC.
DATA: END OF H_PLANTEXT.

DATA: BEGIN OF H_PLANTEXTX, "Customer update information
FUNCTION LIKE BAPIE1MARCEXTRTX-FUNCTION, "Key field
MATERIAL LIKE BAPIE1MARCEXTRTX-MATERIAL, "Key field
PLANT LIKE BAPIE1MARCEXTRTX-PLANT, "Key field
ZCUST1 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 format
H_PLANTEXT_C = F_PLANTEXT.
* Map from structured CHAR format to real format
MOVE-CORRESPONDING H_PLANTEXT_C TO H_PLANTEXT.
H_PLANTEXTX = F_PLANTEXTX.

IF NOT H_PLANTEXTX-ZCUST1 IS INITIAL
OR NOT F_HEADDATA-ALL_FIELDS IS INITIAL.
* Corresponding data field is relevant for update
IF 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 INITIAL
OR NOT F_HEADDATA-ALL_FIELDS IS INITIAL.
* Corresponding data field is relevant for update
IF 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 INITIAL
OR NOT F_HEADDATA-ALL_FIELDS IS INITIAL.
* Corresponding data field is relevant for update
IF 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 information





Parameters

F_CLIENTEXT
F_CLIENTEXTX
F_HEADDATA
F_MARA_UEB
F_MARC_UEB
F_MARD_UEB
F_MBEW_UEB
F_MLGN_UEB
F_MLGT_UEB
F_MVKE_UEB
F_PLANTEXT
F_PLANTEXTX
F_POSEXT
F_POSEXTX
F_SALESEXT
F_SALESEXTX
F_STORAGELOCATIONEXT
F_STORAGELOCATIONEXTX
F_STORAGETYPEEXT
F_STORAGETYPEEXTX
F_VALUATIONEXT
F_VALUATIONEXTX
F_WAREHOUSENUMBEREXT
F_WAREHOUSENUMBEREXTX
F_WLK2_UEB
PARAMETER_NAME
T_RES_FIELDS

Exceptions

APPLICATION_ERROR

Function Group

XMGV

CPI1466 during Backup   RFUMSV00 - Advance Return for Tax on Sales/Purchases  
This documentation is copyright by SAP AG.

Length: 9017 Date: 20240604 Time: 053538     sap01-206 ( 88 ms )