SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Values of the characteristics of a material



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Sat Jan 31, 2009 4:43 pm    Post subject: Values of the characteristics of a material Reply with quote

Code:
REPORT ZPRUEBA_BAPI .


DATA: u_allocvalueschar TYPE TABLE OF bapi1003_alloc_values_char
WITH HEADER LINE,
u_return_car TYPE TABLE OF bapiret2 WITH HEADER LINE,
u_allocvaluescurrnew TYPE TABLE OF bapi1003_alloc_values_curr
WITH HEADER LINE,
u_allocvaluesnumnew TYPE TABLE OF bapi1003_alloc_values_num
WITH HEADER LINE,
u_return TYPE TABLE OF bapiret2 WITH HEADER LINE,
w_material LIKE bapi1003_key-object.


CLEAR u_allocvalueschar[].
REFRESH u_allocvalueschar[].
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = '1144430'
IMPORTING
OUTPUT = w_material
* EXCEPTIONS
* LENGTH_ERROR = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


* TRANSLATE w_material TO UPPER CASE.

*000000000001144430
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
EXPORTING
objectkey = w_material
objecttable = 'MARA'
classnum = '145000500430' "v_class
classtype = '001' "v_klart
* KEYDATE = SY-DATUM
* UNVALUATED_CHARS = ' '
* LANGUAGE = SY-LANGU
* IMPORTING
* STATUS =
* STANDARDCLASS =
TABLES
allocvaluesnum = u_allocvaluesnumnew
allocvalueschar = u_allocvalueschar
allocvaluescurr = u_allocvaluescurrnew
return = u_return.

IF sy-subrc EQ 0.


ENDIF.

* Asigno Valor a la caracteristica de la clase ---------
* Nombre de característica Nueva
u_allocvalueschar-charact
= 'ATT18'."'Accreditation/Company'."v_mname.
* Valor de la característica Nueva
u_allocvalueschar-value_char = 'AR01'."t_material-atwrt.
u_allocvalueschar-value_neutral = 'AR01'."t_material-atwrt.
APPEND u_allocvalueschar.

CALL FUNCTION 'BAPI_OBJCL_EXISTENCECHECK'
EXPORTING
objectkey = w_material
objecttable = 'MARA'
classnum = '145000500430'
classtype = '001'
keydate = sy-datum
TABLES
return = u_return.

* if sy-subrc eq 0.

DESCRIBE TABLE u_return.
READ TABLE u_return INDEX sy-tfill.

*number 731 asignacion ya creada
IF u_return-number EQ '731'.
*Para modificar el valor del Objeto
CALL FUNCTION 'BAPI_OBJCL_CHANGE'
EXPORTING
objectkey = w_material
objecttable = 'MARA'
classnum = '145000500430'
classtype = '001' "v_klart
status = '1'
* keydate = sy-datum
TABLES
allocvaluesnumnew = u_allocvaluesnumnew
allocvaluescharnew = u_allocvalueschar
allocvaluescurrnew = u_allocvaluescurrnew
return = u_return_car.

ELSE.
*Si no existe la Asignación del Objeto
CALL FUNCTION 'BAPI_OBJCL_CREATE'
EXPORTING
objectkeynew = w_material
objecttablenew = 'MARA'
classnumnew = '145000500430' "v_class
classtypenew = '001' "v_klart
status = '1'
* keydate = sy-datum
TABLES
allocvalueschar = u_allocvalueschar
return = u_return_car.
ENDIF.
* CLEAR t_log.
*lee 1ra 'S'
* read table t_matreturn2 with key type = 'S'.
*lee ultima 'S'
* DESCRIBE TABLE t_matreturn2.
* READ TABLE t_matreturn2 INDEX sy-tfill.
* v_mensaje = t_matreturn2-message.
* t_log-material = t_material-matnr.
* t_log-descripcion = t_material-maktx.
* BEGIN OF LR02
* CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* wait = 'X'.
*
* t_log-status = '1'. "linea celeste
* t_log-mensaje = v_mensaje.
* APPEND t_log.
READ TABLE u_return_car WITH KEY type = 'E'.
IF sy-subrc <> 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.

READ TABLE u_return_car WITH KEY type = 'S'.
* t_log-status = '1'. "linea celeste
ELSE.
* t_log-status = '2'. "linea roja
ENDIF.

* MOVE text-v01 TO w_vista_aux.
* CONCATENATE w_vista_aux ':' u_return_car-message INTO v_mensaje.
* t_log-material = t_material-matnr.
* t_log-descripcion = t_material-maktx.
* t_log-mensaje = v_mensaje.
*
* APPEND t_log.
* END OF LR02
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.