PDA

Ver la Versión Completa : Alguien conoce alguna bapi para la transacción IW32.


chejoblanco
03/02/09, 16:46:18
Buscando en interne encontré la BAPI_ALM_ORDER_MAINTAIN, pero esta un poco difícil llenarla si alguien tiene algun pequeño ejemplo me lo puede enviar a soblanco@tutopia.com

JuanFCalle
05/05/10, 12:44:56
Hola, tambien necesito un BAPI para modificar la norma de liquidacion en una orden de mantenimiento, alguna idea ?
gracias

alvagu
05/05/10, 13:05:10
El sgte. código lo utilicé para modificar la duración de actividades.

La tabla interna t_modelcant tiene los campos:

AUFNR
MATNR
KWMENG


DATA: lt_operacion TYPE STANDARD TABLE OF bapi_alm_order_operation_e WITH HEADER LINE,
lt_methods TYPE STANDARD TABLE OF bapi_alm_order_method,
lt_operations TYPE STANDARD TABLE OF bapi_alm_order_operation,
lt_operations_up TYPE STANDARD TABLE OF bapi_alm_order_operation_up,
lt_return2 TYPE STANDARD TABLE OF bapiret2.

DATA: wa_header TYPE bapi_alm_order_header_e,
wa_operacion TYPE bapi_alm_order_operation_e,
wa_methods TYPE bapi_alm_order_method,
wa_operations TYPE bapi_alm_order_operation,
wa_operations_up TYPE bapi_alm_order_operation_up,
wa_return2 TYPE bapiret2.

DATA: lw_cont TYPE ifrefnum,
lw_stat TYPE j_status.

CONSTANTS: c_operat TYPE obj_typ VALUE 'OPERATION',
c_change TYPE swo_method VALUE 'CHANGE',
c_save TYPE swo_method VALUE 'SAVE'.

SORT t_modelcant BY aufnr ASCENDING.

LOOP AT t_modelcant.
AT NEW aufnr.
REFRESH: lt_operations, lt_methods, lt_return2, lt_operations.
CLEAR: wa_header, lw_cont, wa_operations, wa_operacion.

*&---------------------------------------------------------------------*
*& O B T E N E R D A T O S D E L A O R D E N
*&---------------------------------------------------------------------*
CALL FUNCTION 'BAPI_ALM_ORDER_GET_DETAIL'
EXPORTING
number = t_modelcant-aufnr
IMPORTING
es_header = wa_header
TABLES
et_operations = lt_operacion
return = lt_return2.

* Verificar que la Orden no ha sido Liberada
SELECT SINGLE stat INTO lw_stat
FROM jcds
WHERE objnr EQ wa_header-object_no
AND stat EQ 'I0002'
AND inact EQ space.

IF sy-subrc EQ 0.
CONTINUE.
ENDIF.

* Verificar que la Orden está asociada a un Pedido
IF wa_header-sales_ord IS INITIAL.
RAISE err_ped.
ENDIF.

* Verificar que no hay error
READ TABLE lt_return2 INTO wa_return2 WITH KEY type = 'E'.
IF sy-subrc EQ 0.
RAISE err_dat.
ELSE.
REFRESH: lt_return2.

* Agregar metodo para grabar
CLEAR wa_methods.
wa_methods-objecttype = space.
wa_methods-method = c_save.
APPEND wa_methods TO lt_methods.

LOOP AT lt_operacion INTO wa_operacion.
CHECK wa_operacion-number_of_capacities NE 0.

* Obtener cantidad de la posición del Pedido
READ TABLE lt_modelcant INTO wa_modelcant WITH KEY aufnr = t_modelcant-aufnr
matnr = wa_operacion-standard_text_key.
IF sy-subrc EQ 0.
ADD 1 TO lw_cont.

* Agregar evento de modificar Operación
CLEAR wa_methods.
wa_methods-refnumber = lw_cont.
wa_methods-objecttype = c_operat.
wa_methods-method = c_change.
wa_methods-objectkey+0(12) = t_modelcant-aufnr.
wa_methods-objectkey+12(4) = wa_operacion-activity.
APPEND wa_methods TO lt_methods.

* Datos a modificar
CLEAR wa_operations.
wa_operations-activity = wa_operacion-activity.
wa_operations-duration_normal = wa_modelcant-kwmeng / wa_operacion-number_of_capacities.
APPEND wa_operations TO lt_operations.

CLEAR wa_operations_up.
wa_operations_up-activity = 'X'.
wa_operations_up-duration_normal = 'X'.
APPEND wa_operations_up TO lt_operations_up.
ENDIF.
ENDLOOP.

*&---------------------------------------------------------------------*
*& M O D I F I C A R O R D E N
*&---------------------------------------------------------------------*
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = lt_methods
it_operation = lt_operations
it_operation_up = lt_operations_up
return = lt_return2.

READ TABLE lt_return2 INTO wa_return2 WITH KEY type = 'E'.
IF sy-subrc EQ 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

RAISE err_mod.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
ENDIF.
ENDAT.
ENDLOOP.

JuanFCalle
07/05/10, 15:31:13
Gracias, este código me ha servido mucho, pero tengo unas preguntas.
Por que haces el SAVE sin un refnumber ? y antes del CHANGE ?
Para que sirve ese refnumber?
Si yo quiero crear una norma de liquidacion (settlement rule) debo incluir el CREATE en el method y despues el SAVE ?

Gracias, espero que esto no sea muy confuso.

alvagu
07/05/10, 17:52:17
No recuerdo muy bien ya que eso lo hice hace mucho tiempo.

Pero me parece que si no le pones el SAVE no modifica nada, asi que es necesario que primero se pase el SAVE.

Nunca he chreado norma de liquidación con esta BAPI, pero supongo que es como comentas.

jeyko
12/05/10, 21:55:40
Tengo una pregunta sobre el tema

Lo que estan haciendo ustedes es modificaciones masivas de data maestra o estan corriendo otro tipo de proceso con las Bapi´s

La pregunta la hago debido a que parecieran modificaciones masivas que se pueden hacer con LSMW, pero seria interesante saber por que es mejor con Bapi.