Application Development 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: 

Update the x plant material status and plant speific material status

Former Member
0 Kudos

HI Experts,

I am new to abap. In my requriment i want to update the status of x-plant material status (MSTAE) in MARA and

plant specific material status (MMSTA) in MARC. In master data the status of those fields is blank. Insted of balnk i have to upload '01' or '02'.

using BAPI_MATERIAL_SAVEDATA i am unable to upload. its not working.

is there any another way to upload that two plants status.

thanks in advance

sravan

9 REPLIES 9

nabheetscn
Active Contributor
0 Kudos

Please read the documentation of the BAPI... and make sure you have to use BAPI_TRANSACTION_COMMIT..

Nabheet

Former Member
0 Kudos

Hi,

The BAPI_MATERIAL_SAVEDATA works fine for updating the two fields:


lt_clientx-pur_status = 'X'.
APPEND lt_clientx.

lt_plantx-pur_status = 'X'.
lt_plantx-plant = '1000'.
APPEND lt_plantx.

lt_plant-pur_status = '01'.
lt_plant-plant = '1000'.
APPEND lt_plant.

lt_client-pur_status = '02'.
APPEND lt_client.

  CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
    EXPORTING
      headdata                  = lt_head
      clientdata                 = lt_client
      clientdatax                = lt_clientx
      plantdata                  = lt_plant
      plantdatax                 = lt_plantx
....

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

Best Regards,

Martin

0 Kudos

Hi martin,

i think insted of it_*** (internal table) we have to use work area. please make sure conform this one.

i am giving my logic wat i have written and my requirement also...

The process to update material master data status is described in 'xxxxx' Mark and Release Cost Estimates and BAPu201D.

u2022 As a result of releasing a standard cost, certain master data elements need to be updated by the Cost accountant in order to enable further activities within SAP.

u2022 All material codes for which Cost Accounting has released a new standard cost, need to have their Material Status indicators changed from 02 (reviewed) to 03 (released). This removes the system blocks on certain activities within SAP like purchasing, production and Sales. The status will be needed to change in two views of the Material Master.

u2022 The u201CX-plant matl statusu201D field on the Basic Data 1 view

u2022 The u201CPlant-sp. matl statusu201C field on the Costing 1 view

This update should be automated

Select materials for which a price change document was posted based on selection parameters.

Select price change documents for company code defined in selection screen since last run date

u2022 Reference procedure = PRCHG (MLHD-AWTYP)

u2022 Entered on MLHD-CPUDT u2013 verify against last run date to include in selection

u2022 Entered at MLHD-CPUTM u2013 verify against last run date to include in selection

u2022 Store last run date and time by company code, so that it can be picked up in the next run. (store in table TVARVC?)

Select only the documents of plants which belong to the company code in table MLIT. The link between company code and plant can be found in table T001K.

u2022 Valuation area = Plant MLIT-BWKEY

u2022 Create a list of all materials MLIT-MATNR

The next 2 updates should happen independently;

u2022 Update the u201CPlant-sp. matl statusu201C field (MARC-MMSTA) on all plant views belonging to the company on the Costing 1 view to status 3 with as prerequisite;

u2022 The current plant material status is 02

u2022 This action must be done on all plants belonging to the company code

u2022 Update the u201CX-plant matl statusu201D field (MARA-MSTAE) on the Basic Data 1 view to status 3 with as prerequisite;

u2022 The current X-plant material status is 02.

in pt_final1 i get the data corresponing to given tables.

LOOP AT PT_FINAL1 INTO GS_FINAL1.

*HEADER DATA

GS_HEAD-MATERIAL = GS_FINAL1-MATNR.

GS_HEAD-IND_SECTOR = GS_FINAL1-MBRSH.

GS_HEAD-MATL_TYPE = GS_FINAL1-MTART.

GS_HEAD-BASIC_VIEW = 'X'.

GS_HEAD-COST_VIEW = 'X'.

  • APPEND GS_FINAL1 TO IT_FINAL1.

*CLIENTDATA

GS_CLNT-PUR_STATUS = GS_FINAL1-MSTAE.

GS_CLNTX-PUR_STATUS = 'X'.

*PLANT DATA

GS_PLNT-PLANT = GS_FINAL1-WERKS.

GS_PLNT-PUR_STATUS = GS_FINAL1-MMSTA.

GS_PLNTX-PUR_STATUS = 'X'.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

HEADDATA = GS_HEAD

CLIENTDATA = GS_CLNT

CLIENTDATAX = GS_CLNTX

PLANTDATA = GS_PLNT

PLANTDATAX = GS_PLNTX

IMPORTING

RETURN = GS_RET.

  • Commit to release the locks

  • RETURN-TYPE is 'E' in case of error, else 'S'.

IF GS_RET-TYPE = 'E'.

LOOP AT IT_RET.

WRITE: / RETURNMES-MESSAGE.

ENDLOOP.

ELSEIF GS_RET-TYPE = 'S'..

WRITE: / 'PLANT MATERIAL STATUS '.

ENDIF.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDLOOP.

0 Kudos

Ok.

What does your return table contain?

When I look through your code it strikes me that you might have forgotten to parse the plant in the GS_PLNTX structure. If you look at the code I wrote in my previous post you can see that I parse "lt_plantx-plant = '1000'. You need to parse the plant in "gs_plntx" as well.

Try inserting this:


GS_PLNTX-PLANT = GS_FINAL1-WERKS.

(By the way - A word of advise. Avoid calling internal tables 'Final' in your code. It is not good naming convention and hard to read for other developers.)

Best Regards,

Martin

Edited by: Martin Bendixen on Jan 7, 2012 8:48 PM

0 Kudos

hi martin,

i checked the return table values. in that table i am not getting the expected values wat i want.

Is this code correct upto now?

what do i do in this situation?

insted of final which is better to use. plz suggest me....

could u plz give the logic for my requirement if possible...

thanks in advance

sravan

0 Kudos

Hi Sravan,

Try to do as I suggested in my previous post. Set the plant in GS_PLNTX.

What did you expect in your return table and which values are returned exactly?

Instead of 'Final' use the name of the type of table your are using or use a logical name that says something about the content in the table.

Regards

Martin

0 Kudos

HI Martin,

I set the values for gs_plntx even though i am not getting the output.

This program has to run totally in background.for this i ll create a backgroung job.

In return table i ll get the values of what the parameters we have in gs_ret. But this is not what i want

Could you plz explain me how to do this .

0 Kudos

Hi,

How do your data declarations look?

I mean which message are you getting in your return table. the return table holds messages. You should be able to get an idea of what's wrong based on the error message in your return table.

You could also try taking my little example or the example from the documentation and get that working in your system. Once this works you can add the additional parameters you need. Also remember that you can use SE37 to test the BAPI and see if you are parsing the right parameters.

Regards,

Martin

0 Kudos

Hi Martin,

My Prob was solved with the help of u and my self. In BAPI_MATERIAL_SAVEDATA there is no use of return parameter.

thanku so much....

kumar