05-23-2007 3:32 PM
Hi ,
I need to populate 'ZZ' fields which are appended to 'MARA' table using the BAPI function 'BAPI_MATERIAL_MAINTAINDATA_RT'. I see there are two parameters for custom fields. They are 'clientext' and 'clientextx'. I need to populate 40 custom fields which are appended to the MARA table. Say for example if I want to populate two custom fields. One is 'ZCOLOR' the value of which is black , the second one is 'ZFABRIC' , the value of which is 'COTTON'. If I want to populate this info using 'clientext' and 'clientextx' , how to do it. Please let me know if you guys have sample code.
Thanks
JC
07-07-2007 9:53 PM
Hi J Consultant,
no complete code but some hints:
Say you have a MARA append structure called ZMARA.
in the extension structure clientext you se the FUNCTION. This must be set to
003 Delete: Message contains objects to be deleted
004 Change: Message contains changes
005 Replace: This message replaces previous messages
009 Original: First message for process
023 Wait/Adjust: Data should not be imported
018 Resend
If material exists, 004 if new 009.
MATERIAL for material number; I'm not sure if you can leave it when creating material or have to put in $.
Then, your 40 fields might not fit in one ogf the extension fields
FIELD1 CONTAINER229
FIELD2 CONTAINER250
FIELD3 CONTAINER250
FIELD4 CONTAINER250
It should be like
FIELD1 = ZMARA(229).
FIELD2 = ZMARA+229(250).
...
Do exactly the same for clientextx. But use a second ZMARA structure where you put an 'X' into every update field.
And the the fun starts:
You have to create an extension project for extension MGV00003 with transaction CMOD for userexit funtion EXIT_SAPL1001_003 (customer-function '003', called from form mara_uebergeben, called from BAPI_MATERIAL_MAINTAINDATA_RT)
In the include, do as described:
declare
data:
ls_zmara type zmara,
ls_zmarax type zmara.
field-symbols:
<src> type any,
<dst> type any,
<x> type any,
<zmara> type zmara.
ls_zmara = F_CLIENTEXT-field1.
ls_zmara+229(250) = F_CLIENTEXT-field2.
...
ls_zmarax = F_CLIENTEXTX-field1.
ls_zmarax+229(250) = F_CLIENTEXTX-field2.
...
assign F_MARA_UEB+xxx(yyy) to <zmara>,
*find out xxx and yyy from run time object in DDIC
...
do.
assign component sy-index of structure ls_zmarax to <x>.
if sy-subrc <> 0.
exit.
endif.
check <X> = 'X'.
assign component sy-index of structure ls_zmara to <src>.
assign component sy-index of structure <zmara> to <dst>.
<dst> = <src>.
enddo.
This will transfer your extension values field by field to internal structure F_MARA_UEB which contains MARA and ZMARA.
You can find sample code in documentation of FM EXIT_SAPL1001_003. I do not understand it completely. I know my code works - maybe some typos here because it's just out of my head.
Don't forget to acticate your project as the function module itself.
Good luck,
Clemens
10-01-2010 7:23 PM
Hello J Consultant,
I hope you finished the object on article master load scenario where MARA has extension.
I have similar requirement. Can you post your sample code please.
Thanks.
08-30-2012 6:30 PM
Hello Gurus,
I recently used the Function Module EXIT_SAPL1001_003 mentioned above. And I found that in Unicode system there might be offset issues when assigning the value of a structure directly to another one if either of them had non-character like components (refer to this ABAP Keyword Documentation).
So I changed the SAP sample code for this function module a little.
*-----------------------------------------------------------------------
* Sample code
*-----------------------------------------------------------------------
*----------------------------------------------------------------------*
* INCLUDE LXMGVF07 *
*----------------------------------------------------------------------*
************************************************************************
* Example2: Customer-specific data contains also numerical data types *
* Customer structure ZMARC has the following definition: *
* Field name Data type Length *
* ZZCUS1 CHAR 10 *
* ZZCUS2 DEC 3 -> numerical!!!! *
* ZZCUS3 CHAR 5 *
************************************************************************
DATA: error_occured LIKE sy-datar.
DATA: BEGIN OF h_clientext_c, "Customer data in CHAR format
function LIKE bapie1marcextrt-function, "Key field
material LIKE bapie1marcextrt-material, "Key field
zzsccj1 LIKE zsmm_bcxx-zzsccj1,
zzpzwh LIKE zsmm_bcxx-zzpzwh,
zzjx LIKE zsmm_bcxx-zzjx,
zztssp LIKE zsmm_bcxx-zztssp,
zzybsp LIKE zsmm_bcxx-zzybsp,
zzpp LIKE zsmm_bcxx-zzpp,
zzsccj2 LIKE zsmm_bcxx-zzsccj2,
zzzgxj(14) TYPE c, "CURR 11, DEC 2
zzzgxj_waers LIKE zsmm_bcxx-zzzgxj_waers,
zzzgxj_peinh LIKE zsmm_bcxx-zzzgxj_peinh,
zzzgxj_bprme LIKE zsmm_bcxx-zzzgxj_bprme,
zzzdxj(14) TYPE c, "CURR 11, DEC 2
zzzdxj_waers LIKE zsmm_bcxx-zzzdxj_waers,
zzzdxj_peinh LIKE zsmm_bcxx-zzzdxj_peinh,
zzzdxj_bprme LIKE zsmm_bcxx-zzzdxj_bprme,
zzjmdsj(14) TYPE c, "CURR 11, DEC 2
zzjmdsj_waers LIKE zsmm_bcxx-zzjmdsj_waers,
zzjmdsj_peinh LIKE zsmm_bcxx-zzjmdsj_peinh,
zzjmdsj_bprme LIKE zsmm_bcxx-zzjmdsj_bprme,
zzypbx LIKE zsmm_bcxx-zzypbx,
zzgg LIKE zsmm_bcxx-zzgg,
zzbqdw LIKE zsmm_bcxx-zzbqdw,
zztym LIKE zsmm_bcxx-zztym,
END OF h_clientext_c.
DATA: BEGIN OF h_clientext, "Customer data in actual format
function LIKE bapie1marcextrt-function, "Key field
material LIKE bapie1marcextrt-material. "Key field
INCLUDE STRUCTURE zsmm_bcxx.
DATA: END OF h_clientext.
DATA: BEGIN OF h_clientextx, "Customer update information
function LIKE bapie1marcextrtx-function, "Key field
material LIKE bapie1marcextrtx-material, "Key field
zzsccj1 TYPE c,
zzpzwh TYPE c,
zzjx TYPE c,
zztssp TYPE c,
zzybsp TYPE c,
zzpp TYPE c,
zzsccj2 TYPE c,
zzzgxj TYPE c,
zzzgxj_waers TYPE c,
zzzgxj_peinh TYPE c,
zzzgxj_bprme TYPE c,
zzzdxj TYPE c,
zzzdxj_waers TYPE c,
zzzdxj_peinh TYPE c,
zzzdxj_bprme TYPE c,
zzjmdsj TYPE c,
zzjmdsj_waers TYPE c,
zzjmdsj_peinh TYPE c,
zzjmdsj_bprme TYPE c,
zzypbx TYPE c,
zzgg TYPE c,
zzbqdw TYPE c,
zztym TYPE c,
END OF h_clientextx.
CASE parameter_name.
WHEN c_parnam_clientext.
* Copy from unstructured BAPI format to structured CHAR format
h_clientext_c-zzsccj1 = f_clientext-field1+0(40).
h_clientext_c-zzpzwh = f_clientext-field1+40(25).
h_clientext_c-zzjx = f_clientext-field1+65(10).
h_clientext_c-zztssp = f_clientext-field1+75(10).
h_clientext_c-zzybsp = f_clientext-field1+85(2).
h_clientext_c-zzpp = f_clientext-field1+87(10).
h_clientext_c-zzsccj2 = f_clientext-field1+97(10).
h_clientext_c-zzzgxj = f_clientext-field1+107(14).
h_clientext_c-zzzgxj_waers = f_clientext-field1+121(5).
h_clientext_c-zzzgxj_peinh = f_clientext-field1+126(5).
h_clientext_c-zzzgxj_bprme = f_clientext-field1+131(3).
h_clientext_c-zzzdxj = f_clientext-field1+134(14).
h_clientext_c-zzzdxj_waers = f_clientext-field1+148(5).
h_clientext_c-zzzdxj_peinh = f_clientext-field1+153(5).
h_clientext_c-zzzdxj_bprme = f_clientext-field1+158(3).
h_clientext_c-zzjmdsj = f_clientext-field1+161(14).
h_clientext_c-zzjmdsj_waers = f_clientext-field1+175(5).
h_clientext_c-zzjmdsj_peinh = f_clientext-field1+180(5).
h_clientext_c-zzjmdsj_bprme = f_clientext-field1+188(3).
h_clientext_c-zzypbx = f_clientext-field1+191(1).
h_clientext_c-zzgg = f_clientext-field1+192(12).
h_clientext_c-zzbqdw = f_clientext-field1+204(3).
CONCATENATE f_clientext-field1+207(22)
f_clientext-field2+0(18)
INTO h_clientext_c-zztym.
* Copy from structured CHAR format to actual format
MOVE-CORRESPONDING h_clientext_c TO h_clientext.
h_clientextx = f_clientextx.
IF NOT h_clientextx-zzsccj1 IS INITIAL
OR NOT f_headdata-all_fields IS INITIAL.
* Corresponding data field is relevant for update
IF h_clientext-zzsccj1 IS INITIAL.
t_res_fields-feldname = 'MARA-ZZSCCJ1'.
APPEND t_res_fields.
ENDIF.
ELSE.
CLEAR h_clientext-zzsccj1.
ENDIF.
f_mara_ueb-zzsccj1 = h_clientext-zzsccj1.
IF NOT h_clientextx-zzpzwh IS INITIAL
OR NOT f_headdata-all_fields IS INITIAL.
* Corresponding data field is relevant for update
IF h_clientext-zzpzwh IS INITIAL.
t_res_fields-feldname = 'MARA-ZZPZWH'.
APPEND t_res_fields.
ENDIF.
ELSE.
CLEAR h_clientext-zzpzwh.
ENDIF.
f_mara_ueb-zzpzwh = h_clientext-zzpzwh.
* ...
ENDCASE.
* Example for raising an exception if an application error occurred
IF NOT error_occured IS INITIAL.
MESSAGE e544(mg) WITH parameter_name RAISING application_error.
ENDIF.
消息编辑者为:Arwen Liu
09-10-2015 2:08 PM
Dear All,
When I try to update blank value for any custom field , its not getting updated. How to do that ?
Pls suggest.
Thanks.