Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI_MATERIAL_SAVEDATA with custom z-fields

Former Member
0 Likes
26,322

Hi,

I'm using the fm BAPI_MATERIAL_SAVEDATA to create a material in our R/3 (4.7) test system. That works fine, but now I have an additional field to fill with data. This field is an customer field in an mara-append (MARA-ZFORST). I fill this field in the extentionin structure of the BAPI_MATERIAL_SAVEDATA. When I'm debugging the fm, I see there ist a call of fm MATERIAL_MAINTAIN_DARK. This fm has the table TMARA_UEB. A look in this table shows that my z-field is filled correctly. The call ends with no error, the material is created, BUT without my z-field in mara.

Have you any idea?

thx

Yvonne Adler

31 REPLIES 31
Read only

Former Member
0 Likes
14,097

Dear Yvonne,

the given BAPI - BAPI_MATERIAL_SAVEDATA contains EXTENSIONIN and EXTENSIONINX under TABLES tab. z-fields in MARA table can be passed to this internal table, which will update the specific value in MARA.

The structures BAPI_TE_<NAME> (<NAME> = MARA, MARC, MARD, MBEW, MLGN, MLGT, MVKE) and the relevant checkbox structures BAPI_TE_<NAME> (<NAME> = MARAX, etc.) must first be extended by the customer to include the fields required. The standard structures contain only the corresponding key fields. When including new fields in these structures, make sure that the field has the same name as the field in the database table. In addition, the fields in the structures BAPI_TE_<NAME> may only be of the

type CHARACTER. The data element BAPIUPDATE must be used for the fields in the checkbox structure (except for key fields).

Regards

Rahul.

Read only

Former Member
0 Likes
14,097

Hi Yvonne,

Could you pls. let us kow how extensionIN and ExtensionINX structues are populated?

Just a thought, for populating ExtensionIn and ExtensionINX parameters for this BAPI,

Have you filled both BAPI_TE_MARA and BAPI_TE_MARAX structures properly?

Regds,

Akshay Bhagwat

Read only

Former Member
0 Likes
14,097

Hi,

BAPI_MATERIAL_SAVEDATA you have table prameters

<b>EXTENSIONIN

EXTENSIONINX</b>

read the documentation on these two parameters.

Regards

vijay

Read only

0 Likes
14,097

Hi Sir

I want to create generic articles and its variants through bapi in IS RETAIL.

I am facing issue during creation of variants.

I am using  WRF_MATERIAL_MAINTAINDATA_RT to create articles.

Can u plz give me code to do so.

Thanks

Read only

Former Member
0 Likes
14,097

Thx for your quick replies,

At first I extend the structures BAPI_TE_MARA by my customer field ZZFORST (char 10), then I extend the structure BAPI_TE_MARAX by field ZZFORST (BAPIUPDATE).

Call of the fm:

********************************************************

  • STRUCTURE

********************************************************

TABLES:

BAPIMATHEAD, "Headerdata

BAPI_MARA, "Clientdata

BAPI_MARAX, "Clientdatax

BAPI_MARC, "Plantdata

BAPI_MARCX, "Plantdatax

BAPI_MAKT, "Material description

BAPIPAREX, "Extensionstruktur

BAPIPAREXX,

BAPIRET2. "Return messages

DATA:

BAPI_TE_MARA LIKE BAPI_TE_MARA,

BAPI_TE_MARAX LIKE BAPI_TE_MARAX,

V_FILE TYPE STRING.

********************************************************

  • INTERNAL TABLE

********************************************************

*to store the output data

DATA:BEGIN OF it_material_number OCCURS 0.

INCLUDE STRUCTURE BAPIMATINR.

DATA:END OF it_material_number.

*for materialtext

DATA:BEGIN OF IT_MATERIALDESC OCCURS 0.

INCLUDE STRUCTURE BAPI_MAKT .

DATA:END OF IT_MATERIALDESC.

*für z-feld

DATA:BEGIN OF IT_BAPIPAREX OCCURS 0.

INCLUDE STRUCTURE BAPIPAREX.

DATA:END OF IT_BAPIPAREX.

*für z-feldx

DATA:BEGIN OF IT_BAPIPAREXX OCCURS 0.

INCLUDE STRUCTURE BAPIPAREXX.

DATA:END OF IT_BAPIPAREXX.

*to return messages

DATA:BEGIN OF IT_RETURN2 OCCURS 0.

INCLUDE STRUCTURE BAPIRET2.

DATA:END OF IT_RETURN2.

DATA:BEGIN OF IT_RETURN OCCURS 0.

INCLUDE STRUCTURE BAPIRET1.

DATA:END OF IT_RETURN.

********************************************************

  • PROCESSING

********************************************************

BAPIMATHEAD-MATERIAL = IT_MATERIAL_NUMBER-MATERIAL.

BAPIMATHEAD-IND_SECTOR = 'S'.

BAPIMATHEAD-MATL_TYPE = 'ZRHD'.

BAPIMATHEAD-BASIC_VIEW = 'X'.

BAPIMATHEAD-PURCHASE_VIEW = 'X'.

BAPI_MARA-MATL_GROUP = 'RH01'.

BAPI_MARA-OLD_MAT_NO = '0815'.

BAPI_MARA-BASE_UOM = 'FM'.

BAPI_MARAX-MATL_GROUP = 'X'.

BAPI_MARAX-OLD_MAT_NO = 'X'.

BAPI_MARAX-BASE_UOM = 'X'.

BAPI_MARC-PLANT = '0100'.

BAPI_MARCX-PLANT = '0100'.

IT_MATERIALDESC-LANGU = 'DE'.

IT_MATERIALDESC-MATL_DESC = 'RH TEST-Material'.

APPEND IT_MATERIALDESC.

BAPI_TE_MARA-MATERIAL = IT_MATERIAL_NUMBER-MATERIAL.

BAPI_TE_MARA-ZZFORST = '0000704148'.

BAPI_TE_MARAX-MATERIAL = IT_MATERIAL_NUMBER-MATERIAL.

BAPI_TE_MARAX-ZZFORST = 'X'.

IT_BAPIPAREX-STRUCTURE = 'BAPI_TE_MARA'.

IT_BAPIPAREX-VALUEPART1 = BAPI_TE_MARA.

APPEND IT_BAPIPAREX.

IT_BAPIPAREXX-STRUCTURE = 'BAPI_TE_MARAX'.

IT_BAPIPAREXX-VALUEPART1 = BAPI_TE_MARAX.

APPEND IT_BAPIPAREXX.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = BAPIMATHEAD

CLIENTDATA = BAPI_MARA

CLIENTDATAX = BAPI_MARAX

PLANTDATA = BAPI_MARc

PLANTDATAX = BAPI_MARcx

IMPORTING

RETURN = IT_RETURN2

TABLES

MATERIALDESCRIPTION = IT_MATERIALDESC

EXTENSIONIN = IT_BAPIPAREX

EXTENSIONINX = IT_BAPIPAREXX.

The report runs without an error, the material was created, but without z-field. Does anyone see the error in coding?

Read only

0 Likes
14,097

Hi,

after your BAPI call ,call this BAPI <b>BAPI_TRANSACTION_COMMIT</b>

 if not IT_RETURN2[] is intial.
 loop at it_return2 where TYPE = 'S'.
 call function 'BAPI_TRANSACTION_COMMIT'.
 exit.
 endloop.
  endif.

Regards

vijay

Read only

0 Likes
14,097

Hi Vijay,

I tried your coding, but the same result: material without z-field was created.

Regards

yvonne

Read only

0 Likes
14,097

Dear Yvonne,

did you find a solution for that? I'm in a similar situation. I try to change only a z-field of the mara through the BAPI.

During debugging I can see that the extension-table is correctly setting the z-field at the structure of TMARA_UEB. The FuMo MATERIAL_MAINTAIN_DARK comes back without errors only with message: No changes made, because no maintainable data given.

If I change a standard field of mara the changes are written to db, but the z-field is still untouched. I called the MATERIAL_MAINTAIN_DARK directly - same result.

Any idea?

Kind regards,

Klaus

Read only

0 Likes
14,097

Hi Klaus,

I'm so sorry, but I have no solution, yet. An other ABAP coder advised me to make a hard UPDATE on DB after the successful call of the FB 'BAPI_MATERIAL_SAVEDATA'.

Something like that:

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = BAPIMATHEAD

CLIENTDATA = BAPI_MARA

CLIENTDATAX = BAPI_MARAX

PLANTDATA = BAPI_MARc

PLANTDATAX = BAPI_MARcx

IMPORTING

RETURN = IT_RETURN2

TABLES

MATERIALDESCRIPTION = IT_MATERIALDESC

EXTENSIONIN = IT_BAPIPAREX

EXTENSIONINX = IT_BAPIPAREXX.

IF SY-SUBRC EQ 0.

UPDATE MARA SET ZZFORST = '0000704148'

WHERE MATNR = IT_MATERIAL_NUMBER-MATERIAL.

ENDIF.

But I think that's not the best solution, I#d rather like to use only the FB. If you solve the problem, please let me know.

Kind regards,

Yvonne

Read only

0 Likes
14,097

Hey,

Just a guess... In your program after the statement

BAPI_TE_MARA-MATERIAL = IT_MATERIAL_NUMBER-MATERIAL call the conversion function i.e. CONVERSION_EXIT_MATN1_OUTPUT

You need to pass the material number in the internal format. Is this happenning in your program?

-Kiran

Read only

0 Likes
14,097

__________________________________________________________

From the function module documentation:

The number of characters reserved in the two parameters for the content of a customer-defined field must be the same as the number of characters for the corresponding work area field. <b>If the number of characters required is smaller, the remaining characters in the two parameters must be filled with blanks. Only then may the content of another field be transferred.</b>

__________________________________________________________

Length of material number is 18 characters. So, when you do BAPI_TE_MARAX-MATERIAL = IT_MATERIAL_NUMBER-MATERIAL make sure that IT_MATERIAL_NUMBER-MATERIAL is right-filled with spaces (i.e. if it is does not have 18 characters by itself).

Hope this solves your problem!

Read only

0 Likes
14,097

Hi All,

Iam also in same situation. I could create material, but I could not save custom fields. did you find any solution. If you have the solutions pl let me know.

Thanks

Read only

0 Likes
14,097

Hi M Master Gurus,

Any solutions to update zfields from this Bapi?. I tried as explained in documentation. but zfield not updating.

Appreciate your help.

thanks

Read only

0 Likes
14,097

Hi,

thnx for your hint, but I get my new material number from the function BAPI_STDMATERIAL_GETINTNUMBER. So it is in the right format with 18 characters, e.g '000000000000600281'. That should not be the problem.

Kind regards

Yvonne Adler

Read only

0 Likes
14,097

Hi Yvonne,

I realised SAP released new OSS note for BAPI BAPI_MATERIAL_SAVEDATA for updating user-defined fields.

Make sure the patch applied on your system. Iam also waiting to apply this note by our Basis team. But in Our environment is take min couple of weeks to apply patch. Hope this should solve our problem.

OSS Note # 914251

Support Package:SAP_APPL SAPKH60004

Look at the oss note text.

Symptom

If user-defined fields are defined for table MARA, and the values are entered in table EXTENSIONIN when BAPI_MATERIAL_SAVEDATA is called, then the values of the user-defined fields cannot be saved.

Other terms

BUS1001 MM17

BAPI_MATERIAL_SAVEDATA

MARA BAPI_TE_MARA

EXTENSIONIN EXTENSIONINX

Reason and Prerequisites

The material number is missing in the internal table for BAPI_TE_MARA.

Solution

Use the correction instructions to implement the correction.

Read only

0 Likes
14,097

Hi Hariprasad,

thank you for the note. Our basis team implement the correction in our test system, but it seems to have no affect to our problem. The z-field is still empty.

Kind regards

Yvonne

Read only

0 Likes
14,097

Hi Yvonne,

Pl update this conversation if you find any solution for updating zzfields. I have close to 100 custom fileds and configurd custom Material Master. Iam also trying to update custom data using this function. I too have same problem. did you make sure maintaing all fields in table T130F. SAP asking to maintain T130f table for custom fields.

thanks

Read only

0 Likes
14,097

Hi Guys,

I solved the problem myself. The reason zzfields are not updating when you call this bapi is maintaining all zzfields in table T130f. Not only makinfg an entry in this table , make sure maintain status is filled and field status group also filled.

t130f- PSTAT -Maintenance status

t130f-SFGRU - Special field selection group

these two fields should filled with proper values.

Hope this will help.

thanks

Read only

0 Likes
14,097

Hi all,

I am facing the same problem of updating Z field in MARA through BAPI BAPI_MATERIAL_SAVEDATA. I correctly extended the structures BAPI_TE_MARA by my customer field ZZWAUK_MATNR (char 18), then I extend the structure BAPI_TE_MARAX by field ZZFORST (BAPIUPDATE). Did you guys find any solution.

Kindly help me how to do it because you allready had this issue, hope will get some help from any one of you.

Warm Regards

Tanweer Zaki

Read only

14,097

Hello,

I was also facing the same problem, but I could bring the BAPI to work correctly.

First, here my program:


REPORT  zp601931_test_004.
DATA: ls_headdata      TYPE bapimathead,
      lt_extensionin   TYPE STANDARD TABLE OF bapiparex,
      ls_extensionin   LIKE LINE OF lt_extensionin,
      lt_extensioninx  TYPE STANDARD TABLE OF bapiparexx,
      ls_extensioninx  LIKE LINE OF lt_extensioninx,
      lt_messages      TYPE bapiret2_t,
      ls_bapi_te_mara  TYPE bapi_te_mara,
      ls_bapi_te_marax TYPE bapi_te_marax.


CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
  EXPORTING
    input  = '2'
  IMPORTING
    output = ls_headdata-material.

ls_headdata-basic_view = 'X'.

ls_bapi_te_mara-material = ls_headdata-material.
* Here I want to write 4 in my Append Field !!!!!
ls_bapi_te_mara-zztest1 = '4'.

ls_bapi_te_marax-material         = ls_headdata-material.
ls_bapi_te_marax-zztest1          = 'X'.

ls_extensionin-structure         = 'BAPI_TE_MARA'.
ls_extensionin-valuepart1+0(18)  = ls_bapi_te_mara-material.
ls_extensionin-valuepart1+18(1)  = ls_bapi_te_mara-zztest1.
APPEND ls_extensionin TO lt_extensionin.

ls_extensioninx-structure         = 'BAPI_TE_MARAX'.
ls_extensioninx-valuepart1+0(18)  = ls_bapi_te_mara-material.
ls_extensioninx-valuepart1+18(1)  = ls_bapi_te_marax-zztest1.
APPEND ls_extensioninx TO lt_extensioninx.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
  EXPORTING
    headdata       = ls_headdata
  TABLES
    returnmessages = lt_messages
    extensionin    = lt_extensionin
    extensioninx   = lt_extensioninx.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  EXPORTING
    wait = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    i_structure_name = 'BAPIRET2'
  TABLES

Of course, the structures BAPI_TE_MARA and BAPI_TE_MARAX were extended to match the append-field of structure MARA (here ZZTEST1)

But, you'll need to do some customizing to get this code running properly.

So, call the transaction SPRO and open the activity "<i>Logistics - General->Material Master->Field Selection->Assign Fields to Field Selection Groups</i>"

Click on "<i>New Entries</i>". Now you can fill the field "<i>Field name</i>" (I wrote MARA-ZZTEST2) and, VERY IMPORTANT, fill the field "<i>Maint.status</i>" 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 "<i>Sel.Group</i>" with a selection group number (I choose the 111). Now save, and everithing should now run.

Regards

Dominique Delesse

Read only

0 Likes
14,097

Hi Hariprasad Gangavarapu,

Its nice to know that you solved your problem yourself.

Can you please let me know how to maitain these field selection groups and special field selection as you informed in your post?

We are facing the same problem at present.

please help us by providing the needful information.

Thanks,

Marella.

Read only

0 Likes
14,097

Hello,

Did anyone learn how to update the T130F table with the appropriate PSTAT and SFGRU field values?

Thanks!

Read only

0 Likes
14,097

Hi All,

I have faced the similar issue.

The below information will be helpfull for the people who face similar kind of issues.

the way to maintian the table entry for T130F is through transaction SPRO or maintenance view V_130F.

Goto SPRO -> Logistics-General -> Material Master -> Field Selection -> Assign fields to field Selection Groups and maintain the entry in the table.

once the entry is created we need to transport it to the other systems.

Thanks & Regards,

Phani.

Read only

0 Likes
14,097

Thanks for the post... Helpfull topic....

Edited by: jhayyy on May 17, 2011 7:34 AM

Read only

0 Likes
14,097

Hi Dominique Delesse,

Is it necessary to extend the structures BAPI_TE_MARA and BAPI_TE_MARAX with all fields I've extended in MARA?

I've extended MARA with lots of new fields, but now I only want to fill one field when I call BAPI_MATERIAL_SAVEDATA function.

I've done like you say, but it doesn't work

THANKS!!!!

Read only

0 Likes
14,097

Thanks!  This was very helpful.

The only value that seemed to matter in T130F was Maintenance Status.

Read only

0 Likes
14,097

Thanks Dominique, I adapted your program to successfully test this functionality.  Very helpful!

I did find it was a bit easier to just assign the structure to valuepart1 without parsing it out, .e.g

-------

ls_bapi_te_mara-material = ls_headdata-material.
* Here I want to write 4 in my Append Field !!!!!
*ls_bapi_te_mara-AENNR = '1'.
ls_bapi_te_mara-ZZCUSBRAND = 'D300'.
ls_bapi_te_mara-ZZCOLOR    = '01'.
ls_bapi_te_mara-ZZSIZE     = '12'.
ls_bapi_te_mara-ZZSHAPE    = '22'.
ls_bapi_te_mara-ZZORDSEQ   = '32'.

ls_bapi_te_marax-material         = ls_headdata-material.
*ls_bapi_te_marax-AENNR          = ' '.
ls_bapi_te_marax-ZZCUSBRAND = 'X'.
ls_bapi_te_marax-ZZCOLOR    = 'X'.
ls_bapi_te_marax-ZZSIZE      = 'X'.
ls_bapi_te_marax-ZZSHAPE     = 'X'.
ls_bapi_te_marax-ZZORDSEQ    = 'X'.

ls_extensionin-structure         = 'BAPI_TE_MARA'.
ls_extensionin-valuepart1        = ls_BAPI_TE_MARA.
*ls_extensionin-valuepart1+0(18)  = ls_bapi_te_mara-material.
*ls_extensionin-valuepart1+18(1)  = ls_bapi_te_mara-ZZCUSBRAND.
APPEND ls_extensionin TO lt_extensionin.

ls_extensioninx-structure         = 'BAPI_TE_MARAX'.
ls_extensioninx-valuepart1        = ls_BAPI_TE_MARAX.
*ls_extensioninx-valuepart1+0(18)  = ls_bapi_te_mara-material.
*ls_extensioninx-valuepart1+18(1)  = ls_bapi_te_marax-ZZCUSBRAND.
APPEND ls_extensioninx TO lt_extensioninx.

*write /: ls_extensioninx-valuepart1.
*write /: ls_extensionin-valuepart1.

Read only

0 Likes
14,097

I could not find a way to update T130F-SFGRU.

when i go thru IMG assignfields to field selection group there is no SGFRU field.

with out this i could not able to update the custom field.

please help if any one figured it out ?

Thanks,

Mahesh

Read only

0 Likes
14,097

Very helpful!

Worked for me!

Thanks

Read only

Former Member
14,097

Hi,

please check, that your customer field is correctly configured in the filed groups. Transaction OMSR.

1., If the field dowsn't exist in the list, then add it with the button: "New Entries". The attributes should look like this

2., Assign a selection group to this field:

3., Configure the group (Hide, Display, ...)

So when your structures are also well enhanced (BAPI_TE_MARA, BAPI_TE_MARAX), then it should work properly.

Regards,

Arpad

Read only

Former Member
0 Likes
14,097

just check the following code it will help


DATA: ls_headdata      TYPE bapimathead,
lt_extensionin  
TYPE STANDARD TABLE OF bapiparex,
ls_extensionin  
LIKE LINE OF lt_extensionin,
lt_extensioninx 
TYPE STANDARD TABLE OF bapiparexx,
ls_extensioninx 
LIKE LINE OF lt_extensioninx,
lt_messages     
TYPE bapiret2_t,
ls_bapi_te_mara 
TYPE bapi_te_mara,
ls_bapi_te_marax
TYPE bapi_te_marax.

DATA :
ls_CLIENTDATA
TYPE BAPI_MARA,
ls_CLIENTDATAX
TYPE BAPI_MARAX.
DATA : lT_MATERIALDESCRIPTION TYPE TABLE OF BAPI_MAKT,
ls_MATERIALDESCRIPTION
TYPE BAPI_MAKT.
DATA : lt_RETURN TYPE TABLE OF BAPIRET2,
ls_RETURN
TYPE BAPIRET2.
TYPES: BEGIN OF TY_MARA, "internal table as per flat file structure
MATNR
TYPE MARA-MATNR,
MTART
TYPE MARA-MTART,
MBRSH
TYPE MARA-MBRSH,
MATKL
TYPE MARA-MATKL,
MEINS
TYPE MARA-MEINS,
MAKTX
TYPE MAKT-MAKTX,
END OF TY_MARA.
DATA:BEGIN OF IT_BAPIPAREX OCCURS 0.
INCLUDE STRUCTURE BAPIPAREX.
DATA:END OF IT_BAPIPAREX.

*für z-feldx
DATA:BEGIN OF IT_BAPIPAREXX OCCURS 0.
INCLUDE STRUCTURE BAPIPAREXX.
DATA:END OF IT_BAPIPAREXX.
DATA : lt_MARA TYPE TABLE OF TY_MARA,
ls_MARA
TYPE TY_MARA.
*DATA:
*  BAPI_TE_MARA  LIKE BAPI_TE_MARA,
*  BAPI_TE_MARAX LIKE BAPI_TE_MARAX.


*data:
*it_EXTENSIONIN  TYPE TABLE OF BAPIPAREX,
*wa_EXTENSIONIN  TYPE  BAPIPAREX,
*wa_EXTENSIONINX  TYPE TABLE OF BAPIPAREXX,
*itEXTENSIONINX  TYPE TABLE OF BAPIPAREXX.




PARAMETERS: P_FILE TYPE RLGRAP-FILENAME. "file input

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE. "f4 helop for file input
PERFORM FILE_HELP.

AT SELECTION-SCREEN ON HELP-REQUEST FOR P_FILE. "F1 help for file input
MESSAGE 'Please press f4 to select file' TYPE 'I'.

START-OF-SELECTION.
DATA : LV_FILE TYPE STRING.
LV_FILE
= P_FILE. "to avoid type conflict
CALL FUNCTION 'GUI_UPLOAD' "upload flat file
EXPORTING
FILENAME           
= LV_FILE
FILETYPE           
= 'ASC'
HAS_FIELD_SEPARATOR
= 'X'
*     HEADER_LENGTH       = 0
*     READ_BY_LINE        = 'X'
*     DAT_MODE            = ' '
*     CODEPAGE            = ' '
*     IGNORE_CERR         = ABAP_TRUE
*     REPLACEMENT         = '#'
*     CHECK_BOM           = ' '
*     VIRUS_SCAN_PROFILE  =
*     NO_AUTH_CHECK       = ' '
* IMPORTING
*     FILELENGTH          =
*     HEADER              =
TABLES
DATA_TAB           
= lT_MARA "internal table
* CHANGING
*     ISSCANPERFORMED     = ' '
* EXCEPTIONS
*     FILE_OPEN_ERROR     = 1
*     FILE_READ_ERROR     = 2
*     NO_BATCH            = 3
*     GUI_REFUSE_FILETRANSFER       = 4
*     INVALID_TYPE        = 5
*     NO_AUTHORITY        = 6
*     UNKNOWN_ERROR       = 7
*     BAD_DATA_FORMAT     = 8
*     HEADER_NOT_ALLOWED  = 9
*     SEPARATOR_NOT_ALLOWED         = 10
*     HEADER_TOO_LONG     = 11
*     UNKNOWN_DP_ERROR    = 12
*     ACCESS_DENIED       = 13
*     DP_OUT_OF_MEMORY    = 14
*     DISK_FULL           = 15
*     DP_TIMEOUT          = 16
*     OTHERS              = 17
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
LOOP AT lt_MARA INTO ls_MARA.
ls_HEADDATA
-MATERIAL = ls_MARA-MATNR. "material no
ls_HEADDATA
-IND_SECTOR = ls_MARA-MBRSH. "industry sector
ls_HEADDATA
-MATL_TYPE = ls_MARA-MTART. "material type
ls_HEADDATA
-BASIC_VIEW = 'X'. "basic view
ls_CLIENTDATA
-MATL_GROUP = ls_MARA-MATKL. "material group
ls_CLIENTDATA
-BASE_UOM = ls_MARA-MEINS. "base Unit Of measure
ls_CLIENTDATAX
-MATL_GROUP = 'X'. "passing material group
ls_CLIENTDATAX
-BASE_UOM = 'X'. "passing base unit of measure

ls_MATERIALDESCRIPTION
-LANGU = 'EN'. "english language
ls_MATERIALDESCRIPTION
-LANGU_ISO = 'EN'. "ISO language
ls_MATERIALDESCRIPTION
-MATL_DESC = ls_MARA-MAKTX. "material descriptions
APPEND ls_MATERIALDESCRIPTION TO lt_MATERIALDESCRIPTION.
CLEAR ls_MATERIALDESCRIPTION.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input  = ls_headdata-material
IMPORTING
output = ls_headdata-material.

ls_headdata
-basic_view = 'X'.

ls_bapi_te_mara
-material = ls_headdata-material.
* Here I want to write 4 in my Append Field !!!!!
ls_bapi_te_mara
-zzsize = '4'.

ls_bapi_te_marax
-material         = ls_headdata-material.
ls_bapi_te_marax
-zzsize         = 'X'.

ls_extensionin
-structure         = 'BAPI_TE_MARA'.
ls_extensionin
-valuepart1+0(18)  = ls_bapi_te_mara-material.
ls_extensionin
-valuepart1+28(2)  = ls_bapi_te_mara-zzsize.
APPEND ls_extensionin TO lt_extensionin.

ls_extensioninx
-structure         = 'BAPI_TE_MARAX'.
ls_extensioninx
-valuepart1+0(18)  = ls_bapi_te_mara-material.
ls_extensioninx
-valuepart1+20(2)  = ls_bapi_te_marax-zzsize.
APPEND ls_extensioninx TO lt_extensioninx.




*
**Create/update materials using BAPI_MATERIAL_SAVEDATA
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
HEADDATA           
= ls_HEADDATA
CLIENTDATA         
= ls_CLIENTDATA
CLIENTDATAX        
= ls_CLIENTDATAX
*       PLANTDATA           = WA_PLANTDATA
*       PLANTDATAX          = WA_PLANTDATAX
*       FORECASTPARAMETERS  =
*       FORECASTPARAMETERSX =
*       PLANNINGDATA        =
*       PLANNINGDATAX       =
*       STORAGELOCATIONDATA = WA_STORAGELOCATIONDATA
*       STORAGELOCATIONDATAX = WA_STORAGELOCATIONDATAX
*       VALUATIONDATA       =
*       VALUATIONDATAX      =
*       WAREHOUSENUMBERDATA =
*       WAREHOUSENUMBERDATAX =
*       SALESDATA           = WA_SALESDATA
*       SALESDATAX          = WA_SALESDATAX
*       STORAGETYPEDATA     =
*       STORAGETYPEDATAX    =
*       FLAG_ONLINE         = ' '
*       FLAG_CAD_CALL       = ' '
*       NO_DEQUEUE          = ' '
*       NO_ROLLBACK_WORK    = ' '
IMPORTING
RETURN              = ls_RETURN
TABLES
MATERIALDESCRIPTION
= lt_MATERIALDESCRIPTION
*       UNITSOFMEASURE      = IT_UNITSOFMEASURE
*       UNITSOFMEASUREX     = IT_UNITSOFMEASUREX
*       INTERNATIONALARTNOS =
*       MATERIALLONGTEXT    = IT_MATERIALLONGTEXT
*       TAXCLASSIFICATIONS  = IT_TAXCLASSIFICATIONS
*       RETURNMESSAGES      = IT_RETURN
*       PRTDATA             =
*       PRTDATAX            =
EXTENSIONIN        
= lt_extensionin
EXTENSIONINX              
= lt_extensioninx.

.
*
*      update mara set zzsize = '3' where matnr = bapi_te_mara-material.
*       update mara set zzapprover = 'Data Analyst' where matnr = wa_mara-matnr.

IF ls_RETURN-TYPE = 'E'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
WRITE:/ ls_HEADDATA-MATERIAL, 'is not created' COLOR 3.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.

WRITE:/ ls_HEADDATA-MATERIAL, 'is created' COLOR 5.
ENDIF.

ENDLOOP.
FORM FILE_HELP .
CALL FUNCTION 'KD_GET_FILENAME_ON_F4' "get file name on F4 help
* EXPORTING
*   PROGRAM_NAME        = SYST-REPID
*   DYNPRO_NUMBER       = SYST-DYNNR
*   FIELD_NAME          = ' '
*   STATIC              = ' '
*   MASK                = ' '
*   FILEOPERATION       = 'R'
*   PATH                =
CHANGING
FILE_NAME
= P_FILE
*     LOCATION_FLAG       = 'P'
* EXCEPTIONS
*     MASK_TOO_LONG       = 1
*     OTHERS    = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.                    " FILE_HELP

File :

DEMOFINALMAT             HALB     C             002         EA           materialdescription