You are on page 1of 4

7/14/2018 The SAP Fan Club Forums • View topic - /AFS/BAPI_MATERIAL_SAVEDATA or MATERIAL_MAINTAIN_DARK

The SAP Fan Club Forums


The most active SAP community on the net

Skip to content
This website is not affiliated with, sponsored by, or approved by SAP AG.

Search… Search
Advanced search

Board index ‹ Technical ‹ ABAP


Home
• ABAP
• R/3
• Suggestions
Change font size
Print view

FAQ
Register
Login

This website is not affiliated with, sponsored by, or approved by SAP AG.

/AFS/BAPI_MATERIAL_SAVEDATA or MATERIAL_MAINTAIN_DARK
Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Post a reply
Search this topic… Search

1 post • Page 1 of 1

/AFS/BAPI_MATERIAL_SAVEDATA or MATERIAL_MAINTAIN_DARK
by Guest » Thu Feb 24, 2005 5:00 am

Hi Sapfans,

I'm abap programmer and I want to fill MARC-J_3ASLHMOD field.

I create one program with BAPI /AFS/BAPI_MATERIAL_SAVEDATA, But it doesn't work.

This is the function when call BAPI:


* p_matnr has the material
* p_werks has the plant
* p_j_3aslhmod is a radiobutton when is equal 'X' fill when is ' ' put this
* fields enpty

header-MATERIAL = p_matnr.
header-cost_VIEW = 'X'.

itab_bapi_marc-plant = p_werks.

if p_j_3aslhmod = 'X'.
itab_bapi_marc-HORIZON_METHOD_2 = 'X'.

http://sapfans.com/forums/viewtopic.php?t=168972&start=0&postdays=0&postorder=asc&highlight=&sid=86981e335c256d7a7690866b3ee02fd8 1/4
7/14/2018 The SAP Fan Club Forums • View topic - /AFS/BAPI_MATERIAL_SAVEDATA or MATERIAL_MAINTAIN_DARK
else.
itab_bapi_marc-HORIZON_METHOD_2 = ' '.
endif.

itab_bapi_marcx-plant = p_werks.
itab_bapi_marcx-HORIZON_METHOD_2 = 'X'.

CALL FUNCTION '/AFS/BAPI_MATERIAL_SAVEDATA'


EXPORTING
HEADDATA = header
PlantData = itab_bapi_marc
PlantDataX = itab_bapi_marcx
IMPORTING
RETURN = BAPIRET2r
TABLES
RETURNMESSAGES = returnmessage
SKU_PLANTDATA_MRP = itab_bapi_j_3amad.
.

loop at returnmessage.
Write:/ returnmessage.
endloop.

sort returnmessage by type id number.

read table returnmessage with key type = 'S'


id = 'M3'
number = '801' binary search.
if sy-subrc = 0.
i_error_log-matnr = p_matnr.
i_error_log-werks = p_werks.
i_error_log-j_3aslhmod = p_j_3aslhmod.
i_error_log-msg = 'Updated.'.
APPEND i_error_log.
else.
i_error_log-matnr = p_matnr.
i_error_log-werks = p_werks.
i_error_log-j_3aslhmod = p_j_3aslhmod.
i_error_log-msg = 'Updated failed.'.
APPEND i_error_log.
endif.

loop at returnmessage where


( TYPE = 'S' or TYPE = 'E' or TYPE = 'A' ) .

IF returnmessage-type CA 'AE'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
IMPORTING
return = returnmessage.
else.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = returnmessage.
endif.
endloop.

CLEAR : returnmessage.
REFRESH : returnmessage.

I already run this lot of times, but it doesn't work.

Now I found one solution:

FORM func1.

PERFORM GET_MARA.

PERFORM GET_MARC.

marc-j_3aslhmod = p_j_3aslhmod.
modify marc.
PERFORM DEQUEUE_MATERIAL.

CALL FUNCTION 'MATERIAL_MAINTAIN_DARK'


EXPORTING
FLAG_MUSS_PRUEFEN = ' '
SPERRMODUS = 'S'

http://sapfans.com/forums/viewtopic.php?t=168972&start=0&postdays=0&postorder=asc&highlight=&sid=86981e335c256d7a7690866b3ee02fd8 2/4
7/14/2018 The SAP Fan Club Forums • View topic - /AFS/BAPI_MATERIAL_SAVEDATA or MATERIAL_MAINTAIN_DARK
P_KZ_NO_WARN = 'X'
KZ_PRF = ' '
KZ_DISPO = ' '
TABLES
AMARA_UEB = AMARA_UEB
AMARC_UEB = AMARC_UEB
EXCEPTIONS
KSTATUS_EMPTY = 1
TKSTATUS_EMPTY = 2
T130M_ERROR = 3
INTERNAL_ERROR = 4
TOO_MANY_ERRORS = 5
UPDATE_ERROR = 6
OTHERS = 7.

COMMIT WORK.

LOOP AT MESSTAB.

MESSAGE ID MESSTAB-MSGID
TYPE MESSTAB-MSGTYP
NUMBER MESSTAB-MSGNR
WITH MESSTAB-MSGV1
MESSTAB-MSGV2
MESSTAB-MSGV3
MESSTAB-MSGV4.
ENDLOOP.
MESSAGE S043(SV).

ENDFORM.
FORM GET_MARA.

CALL FUNCTION 'MARA_SINGLE_READ'


EXPORTING
MATNR = P_MATNR
IMPORTING
WMARA = MARA
EXCEPTIONS
LOCK_ON_MATERIAL = 1
LOCK_SYSTEM_ERROR = 2
WRONG_CALL = 3
NOT_FOUND = 4
OTHERS = 5.

ENDFORM. " GET_MARA


FORM GET_MARC.
CALL FUNCTION 'MARC_SINGLE_READ'
EXPORTING
MATNR = p_matnr
WERKS = p_werks
IMPORTING
WMARC = MARC.
ENDFORM. " GET_MARC
FORM DEQUEUE_MATERIAL.
CALL FUNCTION 'DEQUEUE_EMMARAS'
EXPORTING
MODE_MARA = 'S'
MANDT = SY-MANDT
MATNR = P_MATNR
EXCEPTIONS
OTHERS = 1.

CALL FUNCTION 'DEQUEUE_EMMARCS'


EXPORTING
MODE_MARC = 'S'
MANDT = SY-MANDT
MATNR = P_MATNR
WERKS = P_WERKS
EXCEPTIONS
OTHERS = 1.

ENDFORM. " DEQUEUE_MATERIAL

So, I'd like to know is: have any problem do this with this function?

But with BAPI It doesn't work.

Every soltions and ideas are wellcome.

Thanks in advanced.

http://sapfans.com/forums/viewtopic.php?t=168972&start=0&postdays=0&postorder=asc&highlight=&sid=86981e335c256d7a7690866b3ee02fd8 3/4
7/14/2018 The SAP Fan Club Forums • View topic - /AFS/BAPI_MATERIAL_SAVEDATA or MATERIAL_MAINTAIN_DARK
Best regards,
Ana

Guest

Top

Post a reply
1 post • Page 1 of 1

Return to ABAP

Jump to: ABAP Go

Who is online

Users browsing this forum: No registered users and 1 guest

Sap Tables ABAP Function Function Module

Board index
The team • Delete all board cookies • All times are UTC - 6 hours [ DST ]

Copyright 2012 SAPFANS • All Rights Reserved.


This website is not affiliated with, sponsored by, or approved by SAP AG.

http://sapfans.com/forums/viewtopic.php?t=168972&start=0&postdays=0&postorder=asc&highlight=&sid=86981e335c256d7a7690866b3ee02fd8 4/4

You might also like