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

User-exit

Former Member
0 Likes
507

Hi,

i am scheduking a background job in the user-exit for engineering change management and i am using the function module BAPI_MATERIAL_SAVEDATA to update the mara table but i am enable to update the table i have done the same thing in other exit and it was working fine without using the bapi_transaction_commit, bwlow is the code ,

CONCATENATE sy-uname '_' v_aennr INTO v_jobnm.

V_TIME = SY-UZEIT + 30.

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = v_jobnm

sdlstrtdt = sy-datum

IMPORTING

jobcount = v_jobcnt

EXCEPTIONS

cant_create_job = 1

invalid_job_data = 2

jobname_missing = 3

OTHERS.

IF sy-subrc = 0.

submit zecr via job v_jobnm

NUMBER v_jobcnt

with p_matnr = v_matnr

WITH p_aennr = v_aennr

AND RETURN

.

ENDIF.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = v_jobcnt

jobname = v_jobnm

sdlstrtdt = sy-datum

sdlstrttm = v_time

EXCEPTIONS

cant_start_immediate = 1

invalid_startdate = 2

jobname_missing = 3

job_close_failed = 4

job_nosteps = 5

job_notex = 6

lock_failed = 7

invalid_target = 8

OTHERS = 9.

SELECT SINGLE prdha FROM mara INTO v_prdha

WHERE matnr = v_matnr ."ECM_OBJMNGREC-objkt.

IF v_prdha <> ''.

SELECT SINGLE mtart mbrsh

FROM mara

INTO (v_matl , v_sector)

WHERE matnr = v_matnr.

IF SY-SUBRC = 0.

bapi_head-material = v_matnr.

bapi_head-ind_sector = v_sector.

bapi_head-matl_type = v_matl.

bapi_head-basic_view = 'X'.

bapi_head-sales_view = 'X'.

client_data-pur_status = 'CC'.

client_data-sal_status = 'CC'.

client_datax-pur_status = 'X'.

client_datax-sal_status = 'X'.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = bapi_head

clientdata = client_data

clientdatax = client_datax.

ENDIF.

Thanks & Regards

Syed

5 REPLIES 5
Read only

Former Member
0 Likes
471

HI ,

It would be advisable to use the FM

<b>BAPI_TRANSACTION COMMIT</b> because there might have been a implicit or explicit COMMIT WORK in your other exit

which was the reason that it was working fine.

Read only

Former Member
0 Likes
471

Hi,

Check the RETURN parameter from the BAPI..There might be errors in updating the material..

Thanks,

Naren

Read only

Former Member
0 Likes
471

Hi,

Thanks for ur reply , but that still doesn't help.

Regards

Syed

Read only

0 Likes
471

Hi

Are u sure u can update thoe fields?

Try to run MM02 and check if those fields can be changed.

U have indicated to change the sales data but you haven't indicate for which sales area:

<b>bapi_head-sales_view = 'X'. ??????</b>

Max

Read only

Former Member
0 Likes
471

Syed,

Did u submit the program before closing the job using JOB_CLOSE?

like

SUBMIT ZPROG VIA JOB JOBNAME

NUMBER JOBCOUNT

WITH IN_NAME = 'X'

WITH GEN_NAME = ' '

WITH XFR_FILE = FILENAME

WITH DOCTYPE = DOCTYPE

WITH POSTKEY = POSTKEY

WITH DAYRANGE IN DAYRANGE

AND RETURN.