2011 Jul 21 7:50 AM
HI
I have added append structure in MARA table
ZZCNAME is append structure name. and below the custom fields.
1)ZZCUSTOMERID NUMC(10)
2)ZZCUSTOMERNAE CHAR(4)
I want to insert data to these fields using CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'.
can you please tell me how to do this.
I tried like this after searching from internet .. but does not updated. should i have to create structure forZZCNAMEX also?
rex-STRUCTURE = 'ZZCNAME'.
rex-VALUEPART1+0(10) = 'ZZCUSTOMERID'.
rex-VALUEPART1+10(10) = 'ZZCUSTOMERNAME'.
APPEND rex.
rexx-STRUCTURE = 'ZZCNAMEX'.
rexx-VALUEPART1+0(1) = 'X'.
rexx-VALUEPART1+1(1) = 'X'.
APPEND rexx.
passing to bapi as
extensionin = rex "APPEND TABLE FIELDS
extensioninx = rexx.
2011 Jul 22 2:12 AM
2011 Jul 21 12:59 PM
Hi princeck,
Please add your append structure ZZCNAME to the standard structure BAPI_TE_MARA and BAPI_TE_MARAX.
After this change your code as :
rex-STRUCTURE = 'BAPI_TE_MARA'.
rex-VALUEPART1+0(18) = matnr.
rex-VALUEPART1+18(10) = 'ZZCUSTOMERID'.
rex-VALUEPART1+28(10) = 'ZZCUSTOMERNAME'.
APPEND rex.
rexx-STRUCTURE = 'BAPI_TE_MARAX'.
rex-VALUEPART1+0(18) = matnr.
rexx-VALUEPART1+18(1) = 'X'.
rexx-VALUEPART1+28(1) = 'X'.
APPEND rexx.
passing to bapi as
extensionin = rex "APPEND TABLE FIELDS
extensioninx = rexx.
Hope this helps!
2011 Jul 21 3:02 PM
Hi Shailesh
Thanks for your prompt reply.
I dont understand how standard structure BAPI_TE_MARA and BAPI_TE_MARAX is related with Mara table.
I could not find any BAPI structure inside MARA table. Should i have to append custom structure to Both BAPI_TE_MARA and MARAX?
can you tell me whats the meaning for below statements.
rex-STRUCTURE = 'BAPI_TE_MARA'.
rex-VALUEPART1+0(18) = matnr.
rexx-STRUCTURE = 'BAPI_TE_MARAX'.
rex-VALUEPART1+0(18) = matnr.
Matnr is value or variable or key field?
Little confusion in understanding this structure.
Regards
Chandra
2011 Jul 22 1:53 AM
Hi
I have two doubts. can sombody shed light on this.
1)Should i have to add cust append structure(ZZXXX) in MARA table and BAPI structures BAPI_TE_MARA and BAPI_TE_MARAX too?
If i try to append structure in BAP I structure BAPI_TE_MARA after adding MARA table it says its already exist?
2) both below Matnr is field name? which is correct value to be passed.
rex-STRUCTURE = 'BAPI_TE_MARA'.
rex-VALUEPART1+0(18) = matnr.
rexx-STRUCTURE = 'BAPI_TE_MARAX'.
rex-VALUEPART1+0(18) = matnr.
Pls advice.
2011 Jul 22 1:59 AM
Hi,
BAPI_TE_MARA and BAPI_TE_MARAX are the standard structures to be used with any BAPI that updates MARA.
First you need to open BAPI_TE_MARA and append your custom structure ZZCNAME.
Once you do that, BAPI_TE_MARA will have three fields
1)MATNR (Standard) 18 char
2)ZZCUSTOMERID NUMC(10)
3)ZZCUSTOMERNAE CHAR(4)
Next you need to open BAPI_TE_MARAX and append another custom structure ZZCNAMEX.
Once you do that, BAPI_TE_MARAX will have three fields
1)MATNR (Standard) 18 char
2)ZZCUSTOMERID C(1)
3)ZZCUSTOMERNAE C(1)
Now while calling the BAPI:
DATA: lv_zzcname TYPE BAPI_TE_MARA,
lv_zzcnamex TYPE BAPI_TE_MARAX.
lv_zzcname-MATNR = ??? ( Here you need to put the material number that you are trying to update)
lv_zzcname-ZZCUSTOMERID = xyz
lv_zzcname-ZZCUSTOMERNAE = abc.
rex-STRUCTURE = 'BAPI_TE_MARA'.
rex+30 = lv_zzcname.
APPEND rex.
lv_zzcnamex-MATNR = ??? ( Here you need to put the material number that you are trying to update)
lv_zzcnamex-ZZCUSTOMERIDX = 'X'
lv_zzcnamex-ZZCUSTOMERNAEX = 'X'.
rexx-STRUCTURE = 'BAPI_TE_MARAX'.
rexx+30 = lv_zzcnamex.
APPEND rexx.
Then call bapi with rex and rexx.
2011 Jul 22 2:02 AM
Hi Shailesh
Thanks for your reply.
So finally Mara table needs to be added custom append structure(ZZCNAME) or not?
just adding only standard structure BAPIXXX is enough?
Can you pls confirm this.
REgards
Edited by: princeck on Jul 22, 2011 3:02 AM
2011 Jul 22 2:12 AM
2011 Jul 22 2:54 AM
Hi
Sorry to ask you so many questions.
I tried adding one field zzIfflg of char(1) with custom structure ZZCUSTM in MARA.(different name ZZCUSTM)
Then i added ZZCUST in BAPI_TE_MARA and ZZCUSTX in BAPI_TE_MARAX
I did code like this
DATA : rex LIKE bapiparex OCCURS 0 WITH HEADER LINE,
rexx LIKE bapiparexx OCCURS 0 WITH HEADER LINE,
LS_BAPI_TE_MARA TYPE BAPI_TE_MARA,
LS_BAPI_TE_MARAX TYPE BAPI_TE_MARAX.
ls_bapi_te_mara-material = ls_headdata-material. " material number value
ls_bapi_te_mara-ZZIFFLG = 'I'." Pass the zfield and the value
ls_bapi_te_marax-material = ls_headdata-material. " material number value
ls_bapi_te_marax-ZZIFFLG = 'X'.
rex-STRUCTURE = 'BAPI_TE_MARA'.
rex-VALUEPART1+0(18) = ls_bapi_te_mara-material.
rex-VALUEPART1+18(1) = ls_bapi_te_mara-ZZIFFLG.
APPEND rex.
rexx-STRUCTURE = 'BAPI_TE_MARAX'.
rexx-VALUEPART1+0(18) = ls_bapi_te_marax-material.
rexx-VALUEPART1+18(1) = ls_bapi_te_marax-ZZIFFLG.
APPEND rexx.
Just added one flag field and value I need to be inserted.
But bapi is failing. can you pls correct me.
Regard
Chandra
Edited by: princeck on Jul 22, 2011 4:15 AM
2011 Jul 22 3:44 AM
Please debug at line 1294 in L1001UEBF01 and see why its failing.
Hope you have called the Commits.
Also ensure that the fields have the same name in BAPI_TE_MARA and BAPI_TE_MARAX.
In BAPI_TE_MARA it should be ZZIFLAG and in BAPI_TE_MARAX also it should be ZZIFLAG.
2011 Jul 22 3:55 AM
Hi
yes, All field names are same ZZIFFLG.
BAPI is updating for other fields except extension parameter.
I am confused of using below code
rex-STRUCTURE = 'BAPI_TE_MARA'.
rex-VALUEPART1+0(18) = 'MATERIAL'. "what should be given here?
In Mara table key is MATNR but BAPI_TE_MARA structure has defaut MATERIAL as parameter. there is not MATNR field.
rex-VALUEPART1+18(1) = 'ZZIFFLG'. "what should be given here?
18(1) is lenght of field name? and 'ZZIFFLG' is field name .
APPEND rex.
rexx-STRUCTURE = 'BAPI_TE_MARAX'.
rexx-VALUEPART1+0(18) = ls_bapi_te_marax-material. "what should be given here?
rexx-VALUEPART1+18(1) = ls_bapi_te_marax-ZZIFFLG. "what should be given here?
APPEND rexx.
can you pls clear me this..
2011 Jul 22 4:38 AM
Hi Prince,
Are you able to see that field in BAPI_TE_MARA.If there is any issue please check the oss note 914251.
Regards,
Madhu.
2011 Jul 22 5:08 AM
Hi Madhurao
Thanks for your reply.
Yes the note is alread applied in my system.
Any comments about my above source code.
Regards
Chandra
2011 Jul 22 5:16 AM
Hi Chandra,
Are you able to see that field in BAPI_TE_MARA.
Regards,
Madhu.
2011 Jul 22 5:25 AM
Hi Chandra,
How you declared those fields .The extension of bapi_te_marax must contain the same named fields as the other two extensions, but all must have a type BAPIUPDATE (CHAR 1)
Edited by: madhurao123 on Jul 22, 2011 9:55 AM
Edited by: madhurao123 on Jul 22, 2011 10:02 AM
2011 Jul 22 5:35 AM
Hi
I can see ZZIFFLG field in both structures BAPI_TE_MARA and MARAX. and also MARA.
All have thesame char(1) type.
When i debug it.
I can see
EXTENSIONIN of BAPI_TE_MARA
with
TESTxx-01 I " Materialnumber value and Zfield value.
EXTENSIONIN of BAPI_TE_MARAX
with
TESTxx-01 X " Materialnumber value and X value.
But bapi is notupdating it
pls advice as per my code. anything should be changed.
Regards
Edited by: princeck on Jul 22, 2011 6:35 AM
2011 Jul 22 5:39 AM
Hi
In Both structure BAPI_TE_MARA and MARAx
I have changed the type as BAPIUPDATE char(1). before its only CHar(1)
how about MARA also should have type BAPIUPDATE ?
2011 Jul 22 5:44 AM
Hi Prince,
See the below code how i updated for sales order bapi .
f you have custom ZZ fields on VBAP and VBAK then you can update these fields using the standard BAPI to create or change the order and update these fields.
A lot has been spoken about this but nowhere does it spell out the pitfalls and give you an end-to-end procedure on how to do it. I even found some "SAP Experts - Ask a question" on Search SAP give a complete wrong answer!!! So here is the correct way to do it.
To do so you first need to ensure that the following 5 tables are in synch.
1) VBAP: In your append structure you specify your ZZFIELD with the data type as needed
2) BAPE_VBAP: In the append structure here also add the ZZFIELD with the data type as needed with limitations. No decimals. Try and stick to char characters
3) BAPE_VBAPX: In the append structure add the field ZZFIELD of type BAPIUPDATE
(NOTE: (2) and (3) must have the same number of fields in the same order)
4) VBAPKOZ: In the append structure here also add the ZZFIELD with the data type as needed with limitations. No decimals. Try and stick to char characters
5) VBAPKOZX: In the append structure add the field ZZFIELD of type BAPIUPDATE
(NOTE: (4) and (5) must have the same number of fields in the same order)
Similarly do for VBAK, BAPE_VBAK, BAPE_VBAKX, VBAKKOZ and VBAKKOZX.
Next we get to the code to fill in the structure EXTENSIONIN
I will demonstrate how to call the create sales order BAPI with custom fields.
Local definitions
DATA: wa_extensionin TYPE bapiparex,
wa_bape_vbap TYPE bape_vbap,
wa_bape_vbapx TYPE bape_vbapx,
wa_bape_vbak TYPE bape_vbak,
wa_bape_vbakx TYPE bape_vbakx,
lv_posnr TYPE posnr.
Processing the header extension
CLEAR wa_bape_vbak.
wa_bape_vbak-ZZFIELD = 'HDRTEST'.
wa_extensionin-structure = 'BAPE_VBAK'.
wa_extensionin+30(960) = wa_bape_vbak.
append wa_extensionin to lt_extensionin.
clear wa_extensionin.
Processing the line extension
LOOP AT line_items INTO wa_lineitems.
ADD 10 TO lv_posnr.
CLEAR wa_bape_vbap.
wa_bape_vbap-ZZFIELD = 'TEST'.
wa_extensionin-structure = 'BAPE_VBAP'.
wa_bape_vbap-posnr = lv_posnr.
wa_extensionin+30(960) = wa_bape_vbap.
append wa_extensionin to lt_extensionin.
clear wa_extensionin.
CLEAR wa_bape_vbapx.
wa_bape_vbapx-ZZFIELD = 'X'.
wa_extensionin-structure = 'BAPE_VBAPX'.
wa_bape_vbapx-posnr = lv_posnr.
wa_extensionin+30(960) = wa_bape_vbapx.
append wa_extensionin to lt_extensionin.
clear wa_extensionin.
ENDLOOP.
Then the call to the BAPI
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
order_header_in = ls_order_header_in
order_header_inx = ls_order_header_inx
IMPORTING
salesdocument = lv_salesdocument
TABLES
return = lt_ret2
order_items_in = lt_order_items_in
order_items_inx = lt_order_items_inx
order_partners = lt_order_partners
order_keys = lt_order_keys
extensionin = lt_extensionin.
Try in the same way in that bapi structures.
Regards,
Madhu.
2011 Jul 22 6:03 AM
Hi Prince,
Please post entire code before calling BAPI and structures BAPI_TE_MARA and BAPI_TE_MARAX with data types.
Regards,
Shailesh
2011 Jul 22 6:12 AM
Hi Shailesh
sending you the code
*Append table fields
DATA : rex LIKE bapiparex OCCURS 0 WITH HEADER LINE,
rexx LIKE bapiparexx OCCURS 0 WITH HEADER LINE,
LS_BAPI_TE_MARA TYPE BAPI_TE_MARA,
LS_BAPI_TE_MARAX TYPE BAPI_TE_MARAX.
ls_bapi_te_mara-material = ls_headdata-material.
ls_bapi_te_mara-ZZIFFLG = 'I'." Pass the zfield and the value
ls_bapi_te_marax-material = ls_headdata-material.
ls_bapi_te_marax-ZZIFFLG = 'X'.
rex-STRUCTURE = 'BAPI_TE_MARA'.
rex-VALUEPART1+0(18) = ls_bapi_te_mara-material.
rex-VALUEPART1+18(1) = ls_bapi_te_mara-ZZIFFLG.
APPEND rex.
rexx-STRUCTURE = 'BAPI_TE_MARAX'.
rexx-VALUEPART1+0(18) = ls_bapi_te_marax-material.
rexx-VALUEPART1+18(1) = 'X'.
APPEND rexx.
品目マスタの登録/変更
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = ls_headdata
clientdata = ls_clientdata
clientdatax = ls_clientdatax
plantdata = ls_plantdata
plantdatax = ls_plantdatax
storagelocationdata = ls_storagelocationdata
storagelocationdatax = ls_storagelocationdatax
valuationdata = ls_valuationdata
valuationdatax = ls_valuationdatax
IMPORTING
return = es_return
TABLES
materialdescription = lt_materialdescription[]
extensionin = rex "APPEND TABLE FIELDS
extensioninx = rexx.
After subroutine return
IF s_return_save-type = 'E' OR
s_return_save-type = 'A'.
" 更新の取消
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
" 更新に失敗しました
s_message-message = text-003.
APPEND s_message TO t_messages[].
CONTINUE.
ELSE.
" 更新の確定
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
" 正常に更新されました
s_message-message = text-004.
APPEND s_message TO t_messages[].
CONTINUE.
ENDIF.
Table and structure fields
Table : MARA
Append Structure : ZZCUSTM
Component : ZZIFFLG
Data Type : CHAR
Length :1
Structure : BAPI_TE_MARA
Append Structure : ZZCUST
Component : ZZIFFLG
Component type : BAPIUPDATE
Data Type : CHAR
Length :1
Structure : BAPI_TE_MARAX
Append Structure : ZZCUSTX
Component : ZZIFFLG
Component type : BAPIUPDATE
Data Type : CHAR
Length :1
Edited by: princeck on Jul 22, 2011 7:12 AM
2011 Jul 22 6:24 AM
You'll need to do some customizing to get this code running properly.
SPRO -> Logistics - General->Material Master->Field Selection->Assign Fields to Field Selection Groups
Click on "New Entries". Now you can fill the field "Field name" ( MARA-ZZIFLG) and, VERY IMPORTANT, fill the field "Maint.status" with 'ABCDEFGKLPQSVXZ' (with F1 on this you'll get a description what that means).
So, now you can save this data and go back to the preceding screen.
Now in the displayed list you should have your new field displayed, you now need to fill the field "Sel.Group" with a selection group number (choose the 111). Now save, and everithing should now run.
2011 Jul 22 9:09 AM
Hi Sailesh and Madhav
Thanks for your all support.
I solve this problem by customizing as sailesh said.
I awarded points to all replied
Thankyou so much.
Regards
Chanda