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 : Error-No authorization for material type...

Arun_Prabhu_K
Active Contributor
0 Likes
2,296

Hi guys.

I am using BAPI_MATERIAL_SAVEDATA to change a material MRP parameters.

I am getting the error "No authorization for material type.."

On /nsu53, it is found to be trying for material creation activity.

I don't want to give this material creation authorisation to the end-user.

How to restrict BAPI_MATERIAL_SAVEDATA to change a material and not try for creating?

CLEAR : hd_data,hd_data[],plnt_data,plnt_data[],

           plnt_datax,plnt_datax[].

   hd_data-material        = itab1-matnr .  "MATL NO AS INPUT

  hd_data-mrp_view        = 'X'.              "MRP VIEW OF MM02

  hd_data-work_sched_view = 'X'.         "Work Scheduling View

   append hd_data.

   plnt_data-plant                 = 'TPFH'.

   plnt_data-mrp_group             = itab1-mrpgrp1.  "MRP Group

   plnt_data-pur_group           = itab1-prgrp1. "Purchasing Group

   plnt_data-mrp_ctrler            = itab1-mrp1.     "MRP Controller

   plnt_data-proc_type             = itab1-ptype1.   "Procurement Type

   plnt_data-spproctype            = 'FT'"Special Procurement Type

   plnt_data-backflush             = ' '.            "Backflush Indicator

   plnt_data-production_scheduler  = ' '. "Prodn.Supervisor

   plnt_data-prodprof              = 'Z00001'.       "Prod.Sched.Profile

   plnt_data-iss_st_loc          = itab1-loc1.

   append plnt_data.

   plnt_datax-plant                 = 'TPFH'.

   plnt_datax-pur_group             = 'X'"Purchasing Group

   plnt_datax-mrp_group             = 'X'"MRP Group

   plnt_datax-mrp_ctrler            = 'X'"MRP Controller

   plnt_datax-proc_type             = 'X'"Procurement Type

   plnt_datax-spproctype            = 'X'"Special Procurement Type

   plnt_datax-iss_st_loc            = 'X'"Prod.Stor.Location

   plnt_datax-backflush             = 'X'"Backflush Indicator

   plnt_datax-production_scheduler  = 'X'"Prodn.Supervisor

   plnt_dataX-prodprof              = 'X'"Prod.Sched.Profile

   append plnt_datax.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

     EXPORTING

       HEADDATA   = hd_data

       PLANTDATA  = plnt_data

       PLANTDATAX = plnt_datax

     IMPORTING

       RETURN     = main_bapi_ret.

if main_bapi_ret-type = 'E'.

     MESSAGE main_bapi_ret-message TYPE 'E'.

   else.

     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

       EXPORTING

         wait = 'X'

       IMPORTING

         RETURN = commit_bapi_ret.

   endif.

   CLEAR : main_bapi_ret,commit_bapi_ret.

3 REPLIES 3
Read only

former_member209818
Active Contributor
0 Likes
1,261

Hi Arun,

Its actually difficult to restrict that way.. instead you can actually handle the case using your program logic.

You must be aware for what purpose you want to use the BAPI.. eg change the plant data. Before passing the changed data to the BAPI, check if that material is already extended for that plant or not. If material is already created for Material, then only you pass the data to change that material using BAPI.. otherwise do not call the BAPI and give error that user is not authorised to create / Extend material...

hope this helps

Read only

Former Member
0 Likes
1,261

Hi Arun,

Activate a security trace and use the BAPI to create and change. Compare the traces for the authorization objects. If you do not find a way to restrict using auth objects then do it in the program (Check if the data exists already and throw an error).

Regards,

Shravan

Read only

Former Member
0 Likes
1,261

I'm curious about why an end user would be maintaining materials.  This is a material master data function, and IMHO, the program that does this update should ONLY be executable by users within the organization that have the necessary authorizations.  I would NOT try to code for a way around security....that's not appropriate...the user doesn't have authority to do this, they should not be executing the program.