Ahora veremos como guardar un LOG con los resultados de un JOB (proceso de fondo) y que el mismo se pueda visualizar por medio de la transacción SLG1.
Lo primero es crear una clase de objeto por medio de la transacción SLG0.
Luego dentro del programa se deberán crear las siguientes rutinas:
*&---------------------------------------------------------------------*
*& Include Z_MANEJO_ENVIO_LOG *
*&---------------------------------------------------------------------*
DATA: bal_log_head TYPE bal_s_log,
l_log_handle TYPE balloghndl.
*&---------------------------------------------------------------------*
*& Form open_msg
*&---------------------------------------------------------------------*
* *Se genera y se abre el colector de mensajes
*----------------------------------------------------------------------*
FORM open_msg.
CLEAR: bal_log_head.
* BCT2 es la clase de objeto correspondiente a SLG0
* BETA es la subclase de objeto correspondiente a SLG0
CONCATENATE 'BCT2' sy-datum sy-uzeit sy-uname
sy-repid INTO bal_log_head-extnumber SEPARATED BY space.
bal_log_head-object = 'BCT2'.
bal_log_head-subobject = 'BETA'.
bal_log_head-aldate = sy-datum.
bal_log_head-altime = sy-uzeit.
bal_log_head-aluser = sy-uname.
bal_log_head-altcode = sy-tcode.
bal_log_head-alprog = sy-repid.
bal_log_head-almode = sy-batch.
* create own log handle
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
i_s_log = bal_log_head
IMPORTING
e_log_handle = l_log_handle
EXCEPTIONS
OTHERS = 1.
ENDFORM. " f_open_msg
*&---------------------------------------------------------------------*
*& Form send_msg
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM send_msg USING p_msgty TYPE c
p_msgid TYPE c
p_msgno TYPE i
p_msgv1 TYPE c
p_msgv2 TYPE c
p_msgv3 TYPE c
p_msgv4 TYPE c.
DATA ls_bal_msg TYPE bal_s_msg.
CLEAR ls_bal_msg.
ls_bal_msg-msgty = p_msgty.
ls_bal_msg-msgid = p_msgid.
ls_bal_msg-msgno = p_msgno.
ls_bal_msg-msgv1 = p_msgv1.
ls_bal_msg-msgv2 = p_msgv2.
ls_bal_msg-msgv3 = p_msgv3.
ls_bal_msg-msgv4 = p_msgv4.
* add own message to application log
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
i_log_handle = l_log_handle
i_s_msg = ls_bal_msg
EXCEPTIONS
OTHERS = 1.
PERFORM close_msg.
ENDFORM. "send_msg
*&---------------------------------------------------------------------*
*& Form close_msg
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM close_msg.
DATA lt_log_handles TYPE bal_t_logh.
APPEND l_log_handle TO lt_log_handles.
CALL FUNCTION 'BAL_DB_SAVE'
EXPORTING
i_t_log_handle = lt_log_handles
EXCEPTIONS
log_not_found = 1
save_not_allowed = 2
numbering_error = 3
OTHERS = 4.
* if everything is ok
COMMIT WORK.
ENDFORM. "close_msg
viernes, 5 de agosto de 2011
lunes, 26 de julio de 2010
Alctualizar órdenes de mantenimiento
En esta oportinidad publico un programa para actualizar las operaciones de una orden de mantenimiento.
report zpm_modifica_ordenes no standard page heading line-size 400.
data:
et_partner like standard table of bapi_alm_order_partner with header line,
et_operations like standard table of bapi_alm_order_operation_e with header line,
et_components like standard table of bapi_alm_order_component_e with header line,
et_relations like standard table of bapi_alm_order_relation_export with header line,
et_texts like standard table of bapi_alm_text with header line,
et_text_lines like standard table of bapi_alm_text_lines with header line,
et_prts like standard table of bapi_alm_order_prt_e with header line,
et_costs_sum like standard table of bapi_alm_order_costs_sum_e with header line,
et_costs_details like standard table of bapi_alm_order_costs_detail_e with header line,
return like standard table of bapiret2 with header line,
extension_in like standard table of bapiparex with header line,
extension_out like standard table of bapiparex with header line,
it_methods like standard table of bapi_alm_order_method with header line,
it_header like standard table of bapi_alm_order_headers_i with header line,
it_header_up like standard table of bapi_alm_order_headers_up with header line,
it_header_srv like standard table of bapi_alm_order_srvdat_e with header line,
it_header_srv_up like standard table of bapi_alm_order_srvdat_up with header line,
it_userstatus like standard table of bapi_alm_order_usrstat with header line,
it_partner like standard table of bapi_alm_order_partn_mul with header line,
it_partner_up like standard table of bapi_alm_order_partn_mul_up with header line,
it_operation like standard table of bapi_alm_order_operation with header line,
it_operation_up like standard table of bapi_alm_order_operation_up with header line,
it_relation like standard table of bapi_alm_order_relation with header line,
it_relation_up like standard table of bapi_alm_order_relation_up with header line,
it_component like standard table of bapi_alm_order_component with header line,
it_component_up like standard table of bapi_alm_order_component_up with header line,
it_text like standard table of bapi_alm_text with header line,
it_text_lines like standard table of bapi_alm_text_lines with header line,
et_numbers like standard table of bapi_alm_numbers with header line.
types: begin of ty_datos,
number type bapi_alm_order_header_e-orderid,
activity type bapi_alm_order_operation_e-activity, "Número de Operación a Borrar
plnnr type plko-plnnr ,
plnal type plko-plnal ,
activit2 type bapi_alm_order_operation_e-activity, "Número de Operación modelo de HR
end of ty_datos.
data: t_datos type standard table of ty_datos with header line.
data: it_plko like standard table of plko with header line,
it_plas like standard table of plas with header line,
it_crhd like standard table of crhd with header line,
it_plpo like standard table of plpo with header line.
data: filename type string.
data: v_msgv1 type sy-msgv1,
v_msgv2 type sy-msgv2,
v_msgv3 type sy-msgv3,
v_msgv4 type sy-msgv4.
data: v_error,
v_err_del,
v_err_add,
refnum type ifrefnum.
parameters: p_file like ibipparms-path.
*----------------------------------------------------------------------*
* -- AT SELECTION-SCREEN --
*----------------------------------------------------------------------*
at selection-screen on value-request for p_file.
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
importing
file_name = p_file.
*----------------------------------------------------------------------*
* -- START-OF-SELECTION --
*----------------------------------------------------------------------*
start-of-selection.
* BREAK-POINT.
* Obtiene información del archivo de entrada
perform f_get_data_file.
loop at t_datos.
* Valida campos
if t_datos-number is initial or
t_datos-activity is initial or
t_datos-plnnr is initial or
t_datos-plnal is initial or
t_datos-activit2 is initial.
write:/ t_datos-number, ' - Error en registro, faltan datos'.
continue.
endif.
* Formatea los valores de los campos
perform f_convert_format.
* Obtiene datos de Hoja de Ruta
perform f_get_data_hojaruta.
if not v_error is initial.
continue.
endif.
* Obtiene información de Orden
perform f_get_data_orden.
if not v_error is initial.
continue.
endif.
* Ingresa datos para BAPI
perform f_set_data_bapi.
if not v_err_del is initial.
write:/ t_datos-number, ' - Error en los datos de la operación a ELIMINAR'.
continue.
elseif not v_err_add is initial.
write:/ t_datos-number, ' - Error en los datos de la operación a INSERTAR'.
continue.
endif.
* Ejecuta BAPI para actualizar Orden
perform f_call_bapi.
endloop.
*----------------------------------------------------------------------*
* -- S U B R U T I N A S --
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form F_GET_DATA_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form f_get_data_file .
clear filename.
filename = p_file.
call function 'GUI_UPLOAD'
exporting
filename = filename
filetype = 'DAT'
has_field_separator = 'X'
tables
data_tab = t_datos
exceptions
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
others = 17.
if sy-subrc <> 0.
v_msgv1 = 'Error al leer el archivo'.
v_msgv2 = '(Funcion GUI_UPLOAD)'.
case sy-subrc.
when '1'. v_msgv3 = 'FILE_OPEN_ERROR'.
when '2'. v_msgv3 = 'FILE_READ_ERROR'.
when '3'. v_msgv3 = 'NO_BATCH'.
when '4'. v_msgv3 = 'GUI_REFUSE_FILETRANSFER'.
when '5'. v_msgv3 = 'INVALID_TYPE'.
when '6'. v_msgv3 = 'NO_AUTHORITY'.
when '7'. v_msgv3 = 'UNKNOWN_ERROR'.
when '8'. v_msgv3 = 'BAD_DATA_FORMAT'.
when '9'. v_msgv3 = 'HEADER_NOT_ALLOWED'.
when '10'. v_msgv3 = 'SEPARATOR_NOT_ALLOWED'.
when '11'. v_msgv3 = 'HEADER_TOO_LONG'.
when '12'. v_msgv3 = 'UNKNOWN_DP_ERROR'.
when '13'. v_msgv3 = 'ACCESS_DENIED'.
when '14'. v_msgv3 = 'DP_OUT_OF_MEMORY'.
when '15'. v_msgv3 = 'DISK_FULL'.
when '16'. v_msgv3 = 'DP_TIMEOUT'.
when '17'. v_msgv3 = 'OTHERS'.
endcase.
message i001(zmensajes) with v_msgv1
v_msgv2
v_msgv3
space.
return.
endif.
endform. " F_GET_DATA_FILE
*&---------------------------------------------------------------------*
*& Form F_CONVERT_FORMAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form f_convert_format .
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = t_datos-number
importing
output = t_datos-number.
call function 'CONVERSION_EXIT_NUMCV_INPUT'
exporting
input = t_datos-activity
importing
output = t_datos-activity.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = t_datos-plnal
importing
output = t_datos-plnal.
call function 'CONVERSION_EXIT_NUMCV_INPUT'
exporting
input = t_datos-activit2
importing
output = t_datos-activit2.
endform. " F_CONVERT_FORMAT
*&---------------------------------------------------------------------*
*& Form F_GET_DATA_HOJARUTA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form f_get_data_hojaruta .
refresh: it_plko,
it_plas,
it_plpo,
it_crhd.
clear v_error.
select *
from plko
into table it_plko
where plnty eq 'A'
and plnnr eq t_datos-plnnr
and plnal eq t_datos-plnal
and loekz eq space.
if sy-subrc is initial.
read table it_plko index 1.
select *
from plas
into table it_plas
where plnty eq it_plko-plnty
and plnnr eq it_plko-plnnr
and plnal eq it_plko-plnal
and loekz eq space.
if sy-subrc is initial.
select *
from plpo
into table it_plpo
for all entries in it_plas
where plnty eq it_plas-plnty
and plnnr eq it_plas-plnnr
and plnkn eq it_plas-plnkn
and zaehl eq it_plas-zaehl
and loekz eq space.
if sy-subrc is initial.
select *
from crhd
into table it_crhd
for all entries in it_plpo
where objty eq it_plpo-objty
and objid eq it_plpo-arbid.
if not sy-subrc is initial.
write:/ t_datos-number,
it_plko-plnty,
it_plko-plnnr,
it_plko-plnal,
' - No existen datos en CRHD'.
v_error = 'X'.
endif.
else.
write:/ t_datos-number,
it_plko-plnty,
it_plko-plnnr,
it_plko-plnal,
' - No existen datos en PLPO'.
v_error = 'X'.
endif.
else.
write:/ t_datos-number,
it_plko-plnty,
it_plko-plnnr,
it_plko-plnal,
' - No existen datos en PLAS'.
v_error = 'X'.
endif.
else.
write:/ t_datos-number,
t_datos-plnnr,
t_datos-plnal,
' - No existen datos en PLKO'.
v_error = 'X'.
endif.
endform. " F_GET_DATA_HOJARUTA
*&---------------------------------------------------------------------*
*& Form F_GET_DATA_ORDEN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form f_get_data_orden .
refresh: et_partner,
et_operations,
et_components,
et_relations,
et_texts,
et_text_lines,
et_prts,
et_costs_sum,
et_costs_details,
return.
clear v_error.
call function 'BAPI_ALM_ORDER_GET_DETAIL'
exporting
number = t_datos-number
tables
et_partner = et_partner
et_operations = et_operations
et_components = et_components
et_relations = et_relations
et_texts = et_texts
et_text_lines = et_text_lines
et_prts = et_prts
et_costs_sum = et_costs_sum
et_costs_details = et_costs_details
return = return.
loop at return where type eq 'E'.
write:/ t_datos-number, ' - ', return-message.
v_error = 'X'.
endloop.
endform. " F_GET_DATA_ORDEN
*&---------------------------------------------------------------------*
*& Form F_SET_DATA_BAPI
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form f_set_data_bapi .
refresh: it_methods,
it_operation,
it_operation_up.
clear it_methods.
it_methods-method = 'SAVE'. "Método
append it_methods.
clear refnum.
* Eliminar Operación
* PERFORM f_del_operacion.
* Insertar Operación
perform f_add_operacion.
endform. " F_SET_DATA_BAPI
*&---------------------------------------------------------------------*
*& Form F_DEL_OPERACION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form f_del_operacion .
clear v_err_del.
clear et_operations.
read table et_operations with key activity = t_datos-activity.
if sy-subrc is initial.
add 1 to refnum.
it_methods-refnumber = refnum. "Nº referencia para vincular método objeto - atributo
it_methods-objecttype = 'OPERATION'. "Tipo de objeto
it_methods-method = 'DELETE'. "Método
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = t_datos-number
importing
output = it_methods-objectkey(12).
write et_operations-activity to it_methods-objectkey+12(4).
write '0000' to it_methods-objectkey+16(4).
append it_methods.
clear: it_operation,
it_operation_up.
it_operation-activity = et_operations-activity.
write it_plpo-steus to it_operation-control_key.
append it_operation.
it_operation_up-activity = 'X'.
it_operation_up-control_key = 'X'.
append it_operation_up.
else.
v_err_del = 'X'.
endif.
endform. " F_DEL_OPERACION
*&---------------------------------------------------------------------*
*& Form F_ADD_OPERACION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form f_add_operacion .
clear v_err_add.
clear it_plpo.
clear it_plko.
read table it_plko with key plnty = 'A'
plnnr = t_datos-plnnr
plnal = t_datos-plnal
loekz = space.
if sy-subrc is initial.
clear it_plpo.
read table it_plpo with key vornr = t_datos-activit2.
if sy-subrc is initial.
clear it_crhd.
read table it_crhd with key objty = it_plpo-objty
objid = it_plpo-arbid.
add 1 to refnum.
clear it_methods.
it_methods-refnumber = refnum. "Nº referencia para vincular método objeto - atributo
it_methods-objecttype = 'OPERATION'. "Tipo de objeto
it_methods-method = 'CREATE'. "Método
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = t_datos-number
importing
output = it_methods-objectkey(12).
write t_datos-activity to it_methods-objectkey+12(4).
write '0000' to it_methods-objectkey+16(4).
append it_methods.
clear: it_operation,
it_operation_up.
write t_datos-activity to it_operation-activity.
it_operation_up-activity = 'X'.
* Clave de contrl no debe ser trabajo externo y servicio (T430-LIEF = '+' and T430-SERVICE = 'X')
* pues no esta soportada por la BAPI
it_operation-control_key = 'MASA'. "Se fuerza MASA para estos casos
* it_operation-control_key = it_plpo-steus.
it_operation_up-control_key = 'X'.
if not it_crhd-arbpl is initial.
it_operation-work_cntr = it_crhd-arbpl.
it_operation_up-work_cntr = 'X'.
endif.
if not it_plpo-werks is initial.
it_operation-plant = it_plpo-werks.
it_operation_up-plant = 'X'.
endif.
if not it_plpo-ktsch is initial.
it_operation-standard_text_key = it_plpo-ktsch.
it_operation_up-standard_text_key = 'X'.
endif.
if not it_plpo-ltxa1 is initial.
it_operation-description = it_plpo-ltxa1.
it_operation_up-description = 'X'.
if not it_plpo-txtsp is initial.
it_operation-langu = it_plpo-txtsp.
it_operation_up-langu = 'X'.
else.
it_operation-langu = sy-langu.
it_operation_up-langu = 'X'.
endif.
endif.
if not it_plpo-lar01 is initial.
it_operation-acttype = it_plpo-lar01.
it_operation_up-acttype = 'X'.
elseif not it_plpo-lar02 is initial.
it_operation-acttype = it_plpo-lar02.
it_operation_up-acttype = 'X'.
elseif not it_plpo-lar03 is initial.
it_operation-acttype = it_plpo-lar03.
it_operation_up-acttype = 'X'.
elseif not it_plpo-lar04 is initial.
it_operation-acttype = it_plpo-lar04.
it_operation_up-acttype = 'X'.
elseif not it_plpo-lar05 is initial.
it_operation-acttype = it_plpo-lar05.
it_operation_up-acttype = 'X'.
elseif not it_plpo-lar06 is initial.
it_operation-acttype = it_plpo-lar06.
it_operation_up-acttype = 'X'.
endif.
if not it_plpo-loanz is initial.
it_operation-no_of_time_tickets = it_plpo-loanz.
it_operation_up-no_of_time_tickets = 'X'.
endif.
if not it_plpo-loart is initial.
it_operation-wagetype = it_plpo-loart.
it_operation_up-wagetype = 'X'.
endif.
if not it_plpo-qualf is initial.
it_operation-suitability = it_plpo-qualf.
it_operation_up-suitability = 'X'.
endif.
if not it_plpo-logrp is initial.
it_operation-wagegroup = it_plpo-logrp.
it_operation_up-wagegroup = 'X'.
endif.
if not it_plpo-lifnr is initial.
it_operation-vendor_no = it_plpo-lifnr.
it_operation_up-vendor_no = 'X'.
endif.
if not it_plpo-plifz is initial.
it_operation-plnd_delry = it_plpo-plifz.
it_operation_up-plnd_delry = 'X'.
endif.
if not it_plpo-sakto is initial.
it_operation-cost_element = it_plpo-sakto.
it_operation_up-cost_element = 'X'.
endif.
if not it_plpo-waers is initial.
it_operation-currency = it_plpo-waers.
it_operation_up-currency = 'X'.
endif.
if not it_plpo-infnr is initial.
it_operation-info_rec = it_plpo-infnr.
it_operation_up-info_rec = 'X'.
endif.
if not it_plpo-ekorg is initial.
it_operation-purch_org = it_plpo-ekorg.
it_operation_up-purch_org = 'X'.
endif.
if not it_plpo-ekgrp is initial.
it_operation-pur_group = it_plpo-ekgrp.
it_operation_up-pur_group = 'X'.
endif.
if not it_plpo-matkl is initial.
it_operation-matl_group = it_plpo-matkl.
it_operation_up-matl_group = 'X'.
endif.
if not it_plpo-dauno is initial.
it_operation-duration_normal = it_plpo-dauno.
it_operation_up-duration_normal = 'X'.
endif.
if not it_plpo-daune is initial.
it_operation-duration_normal_unit = it_plpo-daune.
it_operation_up-duration_normal_unit = 'X'.
endif.
if not it_plpo-einsa is initial.
it_operation-constraint_type_start = it_plpo-einsa.
it_operation_up-constraint_type_start = 'X'.
endif.
if not it_plpo-einse is initial.
it_operation-constraint_type_finish = it_plpo-einse.
it_operation_up-constraint_type_finish = 'X'.
endif.
if not it_plpo-arbei is initial.
it_operation-work_activity = it_plpo-arbei.
it_operation_up-work_activity = 'X'.
endif.
if not it_plpo-arbeh is initial.
it_operation-un_work = it_plpo-arbeh.
it_operation_up-un_work = 'X'.
endif.
if not it_plpo-anzzl is initial.
it_operation-number_of_capacities = it_plpo-anzzl.
it_operation_up-number_of_capacities = 'X'.
endif.
if not it_plpo-prznt is initial.
it_operation-percent_of_work = it_plpo-prznt.
it_operation_up-percent_of_work = 'X'.
endif.
if not it_plpo-slwid is initial.
it_operation-field_key = it_plpo-slwid.
it_operation_up-field_key = 'X'.
endif.
if not it_plpo-usr00 is initial.
it_operation-usr00 = it_plpo-usr00.
it_operation_up-usr00 = 'X'.
endif.
if not it_plpo-usr01 is initial.
it_operation-usr01 = it_plpo-usr01.
it_operation_up-usr01 = 'X'.
endif.
if not it_plpo-usr02 is initial.
it_operation-usr02 = it_plpo-usr02.
it_operation_up-usr02 = 'X'.
endif.
if not it_plpo-usr03 is initial.
it_operation-usr03 = it_plpo-usr03.
it_operation_up-usr03 = 'X'.
endif.
if not it_plpo-usr04 is initial.
it_operation-usr04 = it_plpo-usr04.
it_operation_up-usr04 = 'X'.
endif.
if not it_plpo-use04 is initial.
it_operation-use04 = it_plpo-use04.
it_operation_up-use04 = 'X'.
endif.
if not it_plpo-usr05 is initial.
it_operation-usr05 = it_plpo-usr05.
it_operation_up-usr05 = 'X'.
endif.
if not it_plpo-use05 is initial.
it_operation-use05 = it_plpo-use05.
it_operation_up-use05 = 'X'.
endif.
if not it_plpo-usr06 is initial.
it_operation-usr06 = it_plpo-usr06.
it_operation_up-usr06 = 'X'.
endif.
if not it_plpo-use06 is initial.
it_operation-use06 = it_plpo-use06.
it_operation_up-use06 = 'X'.
endif.
if not it_plpo-usr07 is initial.
it_operation-usr07 = it_plpo-usr07.
it_operation_up-usr07 = 'X'.
endif.
if not it_plpo-use07 is initial.
it_operation-use07 = it_plpo-use07.
it_operation_up-use07 = 'X'.
endif.
if not it_plpo-usr08 is initial.
it_operation-usr08 = it_plpo-usr08.
it_operation_up-usr08 = 'X'.
endif.
if not it_plpo-usr09 is initial.
it_operation-usr09 = it_plpo-usr09.
it_operation_up-usr09 = 'X'.
endif.
if not it_plpo-usr10 is initial.
it_operation-usr10 = it_plpo-usr10.
it_operation_up-usr10 = 'X'.
endif.
if not it_plpo-usr11 is initial.
it_operation-usr11 = it_plpo-usr11.
it_operation_up-usr11 = 'X'.
endif.
if not it_plpo-indet is initial.
it_operation-calc_key = it_plpo-indet.
it_operation_up-calc_key = 'X'.
endif.
if not it_plpo-larnt is initial.
it_operation-acttype = it_plpo-larnt.
it_operation_up-acttype = 'X'.
endif.
if not it_plpo-anlzu is initial.
it_operation-systcond = it_plpo-anlzu.
it_operation_up-systcond = 'X'.
endif.
if not it_plpo-istru is initial.
it_operation-assembly = it_plpo-istru.
it_operation_up-assembly = 'X'.
endif.
if not it_plpo-vertn is initial.
it_operation-int_distr = it_plpo-vertn.
it_operation_up-int_distr = 'X'.
endif.
if not it_plpo-aufkt is initial.
it_operation-execfactor = it_plpo-aufkt.
it_operation_up-execfactor = 'X'.
endif.
append it_operation.
append it_operation_up.
else.
v_err_add = 'X'.
endif.
else.
v_err_add = 'X'.
endif.
endform. " F_ADD_OPERACION
*&---------------------------------------------------------------------*
*& Form F_CALL_BAPI
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form f_call_bapi .
refresh return.
clear v_error.
* Actualiza información para una Orden
call function 'BAPI_ALM_ORDER_MAINTAIN'
tables
it_methods = it_methods
it_operation = it_operation
it_operation_up = it_operation_up
return = return.
loop at return.
if return-type eq 'E'.
v_error = 'X'.
endif.
write:/ t_datos-number,
' - ',
return-message.
endloop.
if not v_error is initial.
call function 'BAPI_TRANSACTION_ROLLBACK'.
else.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
endif.
endform. " F_CALL_BAPI
report zpm_modifica_ordenes no standard page heading line-size 400.
data:
et_partner like standard table of bapi_alm_order_partner with header line,
et_operations like standard table of bapi_alm_order_operation_e with header line,
et_components like standard table of bapi_alm_order_component_e with header line,
et_relations like standard table of bapi_alm_order_relation_export with header line,
et_texts like standard table of bapi_alm_text with header line,
et_text_lines like standard table of bapi_alm_text_lines with header line,
et_prts like standard table of bapi_alm_order_prt_e with header line,
et_costs_sum like standard table of bapi_alm_order_costs_sum_e with header line,
et_costs_details like standard table of bapi_alm_order_costs_detail_e with header line,
return like standard table of bapiret2 with header line,
extension_in like standard table of bapiparex with header line,
extension_out like standard table of bapiparex with header line,
it_methods like standard table of bapi_alm_order_method with header line,
it_header like standard table of bapi_alm_order_headers_i with header line,
it_header_up like standard table of bapi_alm_order_headers_up with header line,
it_header_srv like standard table of bapi_alm_order_srvdat_e with header line,
it_header_srv_up like standard table of bapi_alm_order_srvdat_up with header line,
it_userstatus like standard table of bapi_alm_order_usrstat with header line,
it_partner like standard table of bapi_alm_order_partn_mul with header line,
it_partner_up like standard table of bapi_alm_order_partn_mul_up with header line,
it_operation like standard table of bapi_alm_order_operation with header line,
it_operation_up like standard table of bapi_alm_order_operation_up with header line,
it_relation like standard table of bapi_alm_order_relation with header line,
it_relation_up like standard table of bapi_alm_order_relation_up with header line,
it_component like standard table of bapi_alm_order_component with header line,
it_component_up like standard table of bapi_alm_order_component_up with header line,
it_text like standard table of bapi_alm_text with header line,
it_text_lines like standard table of bapi_alm_text_lines with header line,
et_numbers like standard table of bapi_alm_numbers with header line.
types: begin of ty_datos,
number type bapi_alm_order_header_e-orderid,
activity type bapi_alm_order_operation_e-activity, "Número de Operación a Borrar
plnnr type plko-plnnr ,
plnal type plko-plnal ,
activit2 type bapi_alm_order_operation_e-activity, "Número de Operación modelo de HR
end of ty_datos.
data: t_datos type standard table of ty_datos with header line.
data: it_plko like standard table of plko with header line,
it_plas like standard table of plas with header line,
it_crhd like standard table of crhd with header line,
it_plpo like standard table of plpo with header line.
data: filename type string.
data: v_msgv1 type sy-msgv1,
v_msgv2 type sy-msgv2,
v_msgv3 type sy-msgv3,
v_msgv4 type sy-msgv4.
data: v_error,
v_err_del,
v_err_add,
refnum type ifrefnum.
parameters: p_file like ibipparms-path.
*----------------------------------------------------------------------*
* -- AT SELECTION-SCREEN --
*----------------------------------------------------------------------*
at selection-screen on value-request for p_file.
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
importing
file_name = p_file.
*----------------------------------------------------------------------*
* -- START-OF-SELECTION --
*----------------------------------------------------------------------*
start-of-selection.
* BREAK-POINT.
* Obtiene información del archivo de entrada
perform f_get_data_file.
loop at t_datos.
* Valida campos
if t_datos-number is initial or
t_datos-activity is initial or
t_datos-plnnr is initial or
t_datos-plnal is initial or
t_datos-activit2 is initial.
write:/ t_datos-number, ' - Error en registro, faltan datos'.
continue.
endif.
* Formatea los valores de los campos
perform f_convert_format.
* Obtiene datos de Hoja de Ruta
perform f_get_data_hojaruta.
if not v_error is initial.
continue.
endif.
* Obtiene información de Orden
perform f_get_data_orden.
if not v_error is initial.
continue.
endif.
* Ingresa datos para BAPI
perform f_set_data_bapi.
if not v_err_del is initial.
write:/ t_datos-number, ' - Error en los datos de la operación a ELIMINAR'.
continue.
elseif not v_err_add is initial.
write:/ t_datos-number, ' - Error en los datos de la operación a INSERTAR'.
continue.
endif.
* Ejecuta BAPI para actualizar Orden
perform f_call_bapi.
endloop.
*----------------------------------------------------------------------*
* -- S U B R U T I N A S --
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form F_GET_DATA_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form f_get_data_file .
clear filename.
filename = p_file.
call function 'GUI_UPLOAD'
exporting
filename = filename
filetype = 'DAT'
has_field_separator = 'X'
tables
data_tab = t_datos
exceptions
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
others = 17.
if sy-subrc <> 0.
v_msgv1 = 'Error al leer el archivo'.
v_msgv2 = '(Funcion GUI_UPLOAD)'.
case sy-subrc.
when '1'. v_msgv3 = 'FILE_OPEN_ERROR'.
when '2'. v_msgv3 = 'FILE_READ_ERROR'.
when '3'. v_msgv3 = 'NO_BATCH'.
when '4'. v_msgv3 = 'GUI_REFUSE_FILETRANSFER'.
when '5'. v_msgv3 = 'INVALID_TYPE'.
when '6'. v_msgv3 = 'NO_AUTHORITY'.
when '7'. v_msgv3 = 'UNKNOWN_ERROR'.
when '8'. v_msgv3 = 'BAD_DATA_FORMAT'.
when '9'. v_msgv3 = 'HEADER_NOT_ALLOWED'.
when '10'. v_msgv3 = 'SEPARATOR_NOT_ALLOWED'.
when '11'. v_msgv3 = 'HEADER_TOO_LONG'.
when '12'. v_msgv3 = 'UNKNOWN_DP_ERROR'.
when '13'. v_msgv3 = 'ACCESS_DENIED'.
when '14'. v_msgv3 = 'DP_OUT_OF_MEMORY'.
when '15'. v_msgv3 = 'DISK_FULL'.
when '16'. v_msgv3 = 'DP_TIMEOUT'.
when '17'. v_msgv3 = 'OTHERS'.
endcase.
message i001(zmensajes) with v_msgv1
v_msgv2
v_msgv3
space.
return.
endif.
endform. " F_GET_DATA_FILE
*&---------------------------------------------------------------------*
*& Form F_CONVERT_FORMAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form f_convert_format .
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = t_datos-number
importing
output = t_datos-number.
call function 'CONVERSION_EXIT_NUMCV_INPUT'
exporting
input = t_datos-activity
importing
output = t_datos-activity.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = t_datos-plnal
importing
output = t_datos-plnal.
call function 'CONVERSION_EXIT_NUMCV_INPUT'
exporting
input = t_datos-activit2
importing
output = t_datos-activit2.
endform. " F_CONVERT_FORMAT
*&---------------------------------------------------------------------*
*& Form F_GET_DATA_HOJARUTA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form f_get_data_hojaruta .
refresh: it_plko,
it_plas,
it_plpo,
it_crhd.
clear v_error.
select *
from plko
into table it_plko
where plnty eq 'A'
and plnnr eq t_datos-plnnr
and plnal eq t_datos-plnal
and loekz eq space.
if sy-subrc is initial.
read table it_plko index 1.
select *
from plas
into table it_plas
where plnty eq it_plko-plnty
and plnnr eq it_plko-plnnr
and plnal eq it_plko-plnal
and loekz eq space.
if sy-subrc is initial.
select *
from plpo
into table it_plpo
for all entries in it_plas
where plnty eq it_plas-plnty
and plnnr eq it_plas-plnnr
and plnkn eq it_plas-plnkn
and zaehl eq it_plas-zaehl
and loekz eq space.
if sy-subrc is initial.
select *
from crhd
into table it_crhd
for all entries in it_plpo
where objty eq it_plpo-objty
and objid eq it_plpo-arbid.
if not sy-subrc is initial.
write:/ t_datos-number,
it_plko-plnty,
it_plko-plnnr,
it_plko-plnal,
' - No existen datos en CRHD'.
v_error = 'X'.
endif.
else.
write:/ t_datos-number,
it_plko-plnty,
it_plko-plnnr,
it_plko-plnal,
' - No existen datos en PLPO'.
v_error = 'X'.
endif.
else.
write:/ t_datos-number,
it_plko-plnty,
it_plko-plnnr,
it_plko-plnal,
' - No existen datos en PLAS'.
v_error = 'X'.
endif.
else.
write:/ t_datos-number,
t_datos-plnnr,
t_datos-plnal,
' - No existen datos en PLKO'.
v_error = 'X'.
endif.
endform. " F_GET_DATA_HOJARUTA
*&---------------------------------------------------------------------*
*& Form F_GET_DATA_ORDEN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form f_get_data_orden .
refresh: et_partner,
et_operations,
et_components,
et_relations,
et_texts,
et_text_lines,
et_prts,
et_costs_sum,
et_costs_details,
return.
clear v_error.
call function 'BAPI_ALM_ORDER_GET_DETAIL'
exporting
number = t_datos-number
tables
et_partner = et_partner
et_operations = et_operations
et_components = et_components
et_relations = et_relations
et_texts = et_texts
et_text_lines = et_text_lines
et_prts = et_prts
et_costs_sum = et_costs_sum
et_costs_details = et_costs_details
return = return.
loop at return where type eq 'E'.
write:/ t_datos-number, ' - ', return-message.
v_error = 'X'.
endloop.
endform. " F_GET_DATA_ORDEN
*&---------------------------------------------------------------------*
*& Form F_SET_DATA_BAPI
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form f_set_data_bapi .
refresh: it_methods,
it_operation,
it_operation_up.
clear it_methods.
it_methods-method = 'SAVE'. "Método
append it_methods.
clear refnum.
* Eliminar Operación
* PERFORM f_del_operacion.
* Insertar Operación
perform f_add_operacion.
endform. " F_SET_DATA_BAPI
*&---------------------------------------------------------------------*
*& Form F_DEL_OPERACION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form f_del_operacion .
clear v_err_del.
clear et_operations.
read table et_operations with key activity = t_datos-activity.
if sy-subrc is initial.
add 1 to refnum.
it_methods-refnumber = refnum. "Nº referencia para vincular método objeto - atributo
it_methods-objecttype = 'OPERATION'. "Tipo de objeto
it_methods-method = 'DELETE'. "Método
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = t_datos-number
importing
output = it_methods-objectkey(12).
write et_operations-activity to it_methods-objectkey+12(4).
write '0000' to it_methods-objectkey+16(4).
append it_methods.
clear: it_operation,
it_operation_up.
it_operation-activity = et_operations-activity.
write it_plpo-steus to it_operation-control_key.
append it_operation.
it_operation_up-activity = 'X'.
it_operation_up-control_key = 'X'.
append it_operation_up.
else.
v_err_del = 'X'.
endif.
endform. " F_DEL_OPERACION
*&---------------------------------------------------------------------*
*& Form F_ADD_OPERACION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form f_add_operacion .
clear v_err_add.
clear it_plpo.
clear it_plko.
read table it_plko with key plnty = 'A'
plnnr = t_datos-plnnr
plnal = t_datos-plnal
loekz = space.
if sy-subrc is initial.
clear it_plpo.
read table it_plpo with key vornr = t_datos-activit2.
if sy-subrc is initial.
clear it_crhd.
read table it_crhd with key objty = it_plpo-objty
objid = it_plpo-arbid.
add 1 to refnum.
clear it_methods.
it_methods-refnumber = refnum. "Nº referencia para vincular método objeto - atributo
it_methods-objecttype = 'OPERATION'. "Tipo de objeto
it_methods-method = 'CREATE'. "Método
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = t_datos-number
importing
output = it_methods-objectkey(12).
write t_datos-activity to it_methods-objectkey+12(4).
write '0000' to it_methods-objectkey+16(4).
append it_methods.
clear: it_operation,
it_operation_up.
write t_datos-activity to it_operation-activity.
it_operation_up-activity = 'X'.
* Clave de contrl no debe ser trabajo externo y servicio (T430-LIEF = '+' and T430-SERVICE = 'X')
* pues no esta soportada por la BAPI
it_operation-control_key = 'MASA'. "Se fuerza MASA para estos casos
* it_operation-control_key = it_plpo-steus.
it_operation_up-control_key = 'X'.
if not it_crhd-arbpl is initial.
it_operation-work_cntr = it_crhd-arbpl.
it_operation_up-work_cntr = 'X'.
endif.
if not it_plpo-werks is initial.
it_operation-plant = it_plpo-werks.
it_operation_up-plant = 'X'.
endif.
if not it_plpo-ktsch is initial.
it_operation-standard_text_key = it_plpo-ktsch.
it_operation_up-standard_text_key = 'X'.
endif.
if not it_plpo-ltxa1 is initial.
it_operation-description = it_plpo-ltxa1.
it_operation_up-description = 'X'.
if not it_plpo-txtsp is initial.
it_operation-langu = it_plpo-txtsp.
it_operation_up-langu = 'X'.
else.
it_operation-langu = sy-langu.
it_operation_up-langu = 'X'.
endif.
endif.
if not it_plpo-lar01 is initial.
it_operation-acttype = it_plpo-lar01.
it_operation_up-acttype = 'X'.
elseif not it_plpo-lar02 is initial.
it_operation-acttype = it_plpo-lar02.
it_operation_up-acttype = 'X'.
elseif not it_plpo-lar03 is initial.
it_operation-acttype = it_plpo-lar03.
it_operation_up-acttype = 'X'.
elseif not it_plpo-lar04 is initial.
it_operation-acttype = it_plpo-lar04.
it_operation_up-acttype = 'X'.
elseif not it_plpo-lar05 is initial.
it_operation-acttype = it_plpo-lar05.
it_operation_up-acttype = 'X'.
elseif not it_plpo-lar06 is initial.
it_operation-acttype = it_plpo-lar06.
it_operation_up-acttype = 'X'.
endif.
if not it_plpo-loanz is initial.
it_operation-no_of_time_tickets = it_plpo-loanz.
it_operation_up-no_of_time_tickets = 'X'.
endif.
if not it_plpo-loart is initial.
it_operation-wagetype = it_plpo-loart.
it_operation_up-wagetype = 'X'.
endif.
if not it_plpo-qualf is initial.
it_operation-suitability = it_plpo-qualf.
it_operation_up-suitability = 'X'.
endif.
if not it_plpo-logrp is initial.
it_operation-wagegroup = it_plpo-logrp.
it_operation_up-wagegroup = 'X'.
endif.
if not it_plpo-lifnr is initial.
it_operation-vendor_no = it_plpo-lifnr.
it_operation_up-vendor_no = 'X'.
endif.
if not it_plpo-plifz is initial.
it_operation-plnd_delry = it_plpo-plifz.
it_operation_up-plnd_delry = 'X'.
endif.
if not it_plpo-sakto is initial.
it_operation-cost_element = it_plpo-sakto.
it_operation_up-cost_element = 'X'.
endif.
if not it_plpo-waers is initial.
it_operation-currency = it_plpo-waers.
it_operation_up-currency = 'X'.
endif.
if not it_plpo-infnr is initial.
it_operation-info_rec = it_plpo-infnr.
it_operation_up-info_rec = 'X'.
endif.
if not it_plpo-ekorg is initial.
it_operation-purch_org = it_plpo-ekorg.
it_operation_up-purch_org = 'X'.
endif.
if not it_plpo-ekgrp is initial.
it_operation-pur_group = it_plpo-ekgrp.
it_operation_up-pur_group = 'X'.
endif.
if not it_plpo-matkl is initial.
it_operation-matl_group = it_plpo-matkl.
it_operation_up-matl_group = 'X'.
endif.
if not it_plpo-dauno is initial.
it_operation-duration_normal = it_plpo-dauno.
it_operation_up-duration_normal = 'X'.
endif.
if not it_plpo-daune is initial.
it_operation-duration_normal_unit = it_plpo-daune.
it_operation_up-duration_normal_unit = 'X'.
endif.
if not it_plpo-einsa is initial.
it_operation-constraint_type_start = it_plpo-einsa.
it_operation_up-constraint_type_start = 'X'.
endif.
if not it_plpo-einse is initial.
it_operation-constraint_type_finish = it_plpo-einse.
it_operation_up-constraint_type_finish = 'X'.
endif.
if not it_plpo-arbei is initial.
it_operation-work_activity = it_plpo-arbei.
it_operation_up-work_activity = 'X'.
endif.
if not it_plpo-arbeh is initial.
it_operation-un_work = it_plpo-arbeh.
it_operation_up-un_work = 'X'.
endif.
if not it_plpo-anzzl is initial.
it_operation-number_of_capacities = it_plpo-anzzl.
it_operation_up-number_of_capacities = 'X'.
endif.
if not it_plpo-prznt is initial.
it_operation-percent_of_work = it_plpo-prznt.
it_operation_up-percent_of_work = 'X'.
endif.
if not it_plpo-slwid is initial.
it_operation-field_key = it_plpo-slwid.
it_operation_up-field_key = 'X'.
endif.
if not it_plpo-usr00 is initial.
it_operation-usr00 = it_plpo-usr00.
it_operation_up-usr00 = 'X'.
endif.
if not it_plpo-usr01 is initial.
it_operation-usr01 = it_plpo-usr01.
it_operation_up-usr01 = 'X'.
endif.
if not it_plpo-usr02 is initial.
it_operation-usr02 = it_plpo-usr02.
it_operation_up-usr02 = 'X'.
endif.
if not it_plpo-usr03 is initial.
it_operation-usr03 = it_plpo-usr03.
it_operation_up-usr03 = 'X'.
endif.
if not it_plpo-usr04 is initial.
it_operation-usr04 = it_plpo-usr04.
it_operation_up-usr04 = 'X'.
endif.
if not it_plpo-use04 is initial.
it_operation-use04 = it_plpo-use04.
it_operation_up-use04 = 'X'.
endif.
if not it_plpo-usr05 is initial.
it_operation-usr05 = it_plpo-usr05.
it_operation_up-usr05 = 'X'.
endif.
if not it_plpo-use05 is initial.
it_operation-use05 = it_plpo-use05.
it_operation_up-use05 = 'X'.
endif.
if not it_plpo-usr06 is initial.
it_operation-usr06 = it_plpo-usr06.
it_operation_up-usr06 = 'X'.
endif.
if not it_plpo-use06 is initial.
it_operation-use06 = it_plpo-use06.
it_operation_up-use06 = 'X'.
endif.
if not it_plpo-usr07 is initial.
it_operation-usr07 = it_plpo-usr07.
it_operation_up-usr07 = 'X'.
endif.
if not it_plpo-use07 is initial.
it_operation-use07 = it_plpo-use07.
it_operation_up-use07 = 'X'.
endif.
if not it_plpo-usr08 is initial.
it_operation-usr08 = it_plpo-usr08.
it_operation_up-usr08 = 'X'.
endif.
if not it_plpo-usr09 is initial.
it_operation-usr09 = it_plpo-usr09.
it_operation_up-usr09 = 'X'.
endif.
if not it_plpo-usr10 is initial.
it_operation-usr10 = it_plpo-usr10.
it_operation_up-usr10 = 'X'.
endif.
if not it_plpo-usr11 is initial.
it_operation-usr11 = it_plpo-usr11.
it_operation_up-usr11 = 'X'.
endif.
if not it_plpo-indet is initial.
it_operation-calc_key = it_plpo-indet.
it_operation_up-calc_key = 'X'.
endif.
if not it_plpo-larnt is initial.
it_operation-acttype = it_plpo-larnt.
it_operation_up-acttype = 'X'.
endif.
if not it_plpo-anlzu is initial.
it_operation-systcond = it_plpo-anlzu.
it_operation_up-systcond = 'X'.
endif.
if not it_plpo-istru is initial.
it_operation-assembly = it_plpo-istru.
it_operation_up-assembly = 'X'.
endif.
if not it_plpo-vertn is initial.
it_operation-int_distr = it_plpo-vertn.
it_operation_up-int_distr = 'X'.
endif.
if not it_plpo-aufkt is initial.
it_operation-execfactor = it_plpo-aufkt.
it_operation_up-execfactor = 'X'.
endif.
append it_operation.
append it_operation_up.
else.
v_err_add = 'X'.
endif.
else.
v_err_add = 'X'.
endif.
endform. " F_ADD_OPERACION
*&---------------------------------------------------------------------*
*& Form F_CALL_BAPI
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form f_call_bapi .
refresh return.
clear v_error.
* Actualiza información para una Orden
call function 'BAPI_ALM_ORDER_MAINTAIN'
tables
it_methods = it_methods
it_operation = it_operation
it_operation_up = it_operation_up
return = return.
loop at return.
if return-type eq 'E'.
v_error = 'X'.
endif.
write:/ t_datos-number,
' - ',
return-message.
endloop.
if not v_error is initial.
call function 'BAPI_TRANSACTION_ROLLBACK'.
else.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
endif.
endform. " F_CALL_BAPI
jueves, 3 de junio de 2010
Crear/Modificar Condiciones de precio en Pedidos
Para crear/modificar condiciones de precio en un pedido existente se puede utilizar la función 'BAPI_PO_CHANGE'.
Adjunto un código de ejemplo:
tables: t685a,
lfm1,
tmks,
t683s.
data: w_ekko like ekko,
t_konv like standard table of konv with header line,
t_t683s like standard table of t683s with header line.
select single *
from ekko
into w_ekko
where ebeln eq i_costos-notaped.
* Obtener Condiciones del pedido
select *
from konv
into table t_konv
where knumv = w_ekko-knumv.
* Obtener Datos Esquemas de cálculo
select *
from t683s
into table t_t683s
where kalsm eq w_ekko-kalsm.
loop at i_costos into wa_costos where valor ne 0.
clear t685a.
select single *
from t685a
where kschl eq wa_costos-condicion
and kappl eq 'M'.
clear lfm1.
select single *
from lfm1
where lifnr eq w_ekko-lifnr
and ekorg eq w_ekko-ekorg.
clear tmks.
select single *
from tmks
where kalsk eq lfm1-kalsk.
clear t683s.
select single *
from t683s
where kschl eq wa_costos-condicion
and kappl eq 'M'
and kalsm eq tmks-kalsm.
pocondheader-condition_no = wa_costos-knumv.
pocondheader-itm_number = '000000'.
pocondheader-cond_st_no = t683s-stunr. " Número de nivel
pocondheader-cond_count = t683s-zaehk. "contador
pocondheader-cond_type = wa_costos-condicion."Clase de cond
pocondheader-cond_value = wa_costos-valor. "valor
pocondheader-currency = wa_costos-moneda.
pocondheader-currency_iso = wa_costos-moneda.
pocondheader-applicatio = 'M'.
* Verifica condiciones existentes en el pedido a nivel cabecera
read table t_konv with key kposn = '000000'
kschl = wa_costos-condicion.
if sy-subrc is initial.
pocondheader-change_id = 'U'. "Update
else.
pocondheader-change_id = 'I'. "Insert
endif.
append pocondheader.
clear pocondheader.
pocondheaderx-condition_no = wa_costos-knumv.
pocondheaderx-itm_number = '000000'.
pocondheaderx-cond_st_no = t683s-stunr. " Número de nivel
pocondheaderx-cond_count = 'X'."contador
pocondheaderx-cond_type = 'X'."Clase de cond
pocondheaderx-cond_value = 'X'. "valor
pocondheaderx-currency = 'X'. "ti_cond-KOEIN
pocondheaderx-currency_iso = 'X'. "ti_cond-KOEIN
pocondheaderx-applicatio = 'X'.
append pocondheaderx.
clear pocondheaderx.
endloop.
call function 'BAPI_PO_CHANGE'
exporting
purchaseorder = wa_costos-notaped
tables
return = return
pocondheader = pocondheader
pocondheaderx = pocondheaderx.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
Nota: En este ejemplo la tabla interna I_COSTOS posee los campos CONDICION, VALOR y MONEDA.
Presentación del Blog
Hola a todos...!!!
La idea de crear este Blog surgio por la necesidad de compartir conocimientos y experiencias relacionadas al desempeño como analista de sistemas y focalizado en el ambiente SAP/ABAP.
Espero que les sea de utilidad.
Todos los comentarios serán bienvenidos.
Saludos.
La idea de crear este Blog surgio por la necesidad de compartir conocimientos y experiencias relacionadas al desempeño como analista de sistemas y focalizado en el ambiente SAP/ABAP.
Espero que les sea de utilidad.
Todos los comentarios serán bienvenidos.
Saludos.
Suscribirse a:
Entradas (Atom)