*& Mdulo...........: SD
*& Programa.........: ZSDD_RPT_TRAZA
*& Autor............: Villarreal Murillo,Fredy (BIZ)
*& Fecha ..........: 15/11/2016
*& Descripcin......: Reporte de Trazabilidad SDD - ALV
*&---------------------------------------------------------------------*
REPORT zsdd_rpt_traza.
"**--Tables
tables : zrmm_sdd_mov_c , zrmm_sdd_mov_d.
"**-type-pools: slis.
"**-types :
"**-begin of ty_sdd_mov_c ,
cd
type zrmm_sdd_mov_c-cd,
"Centro Distribucion
tienda
type zrmm_sdd_mov_c-tienda,
"Tienda
tipo
type char7 ,
"Tipo E=Electro u B=Bazar
*
tipo
type zrmm_sdd_mov_c-tipo,
"Tipo E=Electro u B=Bazar
k_num_op type zrmm_sdd_mov_c-k_num_op, "Numero de Operacion
num_op_can type zrmm_sdd_mov_c-num_op_can, "Numero de Operacion de Cance
lacion
fecent
type zrmm_sdd_mov_c-fec_ent, "Numero de Operacion
pedido_sap type zrmm_sdd_mov_c-pedido_sap,"Pedido Venta
solped
type zrmm_sdd_mov_c-solped,
"Solicitud de Pedido
oc
type zrmm_sdd_mov_c-oc,
"Orden de Compra
end of ty_sdd_mov_c,
"**-begin of ty_sdd_tienda ,
werks
type zrmm_sdd_mov_c-tienda, "Tienda
name1
type t001w-name1,
"Descripcion
end of ty_sdd_tienda,
"**-*
BEGIN OF ty_sdd_doc_mt,
*
ebeln
TYPE ekbe-ebeln,
"Orden de Compra
*
belnr
TYPE ekbe-belnr,
"Documento de Material de Recep
cion de la OC
*
END OF ty_sdd_doc_mt,
*
**-*
BEGIN OF ty_sdd_desp_oc,
*
ebeln
TYPE ekbe-ebeln,
"Orden de Compra
*
cpudt
TYPE ekbe-cpudt,
"Recp.OC
*
cputm
TYPE ekbe-cputm,
"Hora recepcion OC
*
ernam
TYPE ekbe-ernam,
"Usuario recpcion OC
*
END OF ty_sdd_desp_oc,
"**-begin of ty_sdd_doc_mt,
ebeln
type ekbe-ebeln,
"Orden de Compra
belnr
type ekbe-belnr,
"Documento de Material de Recepc
ion de la OC
bwart
type ekbe-bwart,
"Orden de Compra
cpudt
type ekbe-cpudt,
"Recp.OC
cputm
type ekbe-cputm,
"Hora recepcion OC
ernam
type ekbe-ernam,
"Usuario recpcion OC
end of ty_sdd_doc_mt,
"**-begin of ty_sdd_carga,
numop
type zrmm_sdd2_d-numop,
"Numero de Operacion
carga
type zrmm_sdd2_d-carga,
"Numero de Carga del Desp
acho
mblnr
type zrmm_sdd2_d-mblnr,
pacho
end of ty_sdd_carga,
"**-begin of ty_sdd_mov_d,
k_num_op type zrmm_sdd_mov_d-k_num_op,
"Numero de Operacion
matnr
type zrmm_sdd_mov_d-matnr,
"Material
qty
type zrmm_sdd_mov_d-qty,
"10.Cantidad
doc1
type zrmm_sdd_mov_d-doc1,
"Mov 252
doc2
type zrmm_sdd_mov_d-doc2,
"Mov 251
end of ty_sdd_mov_d,
"**-begin of ty_sdd_material,
matnr
type zrmm_sdd_mov_d-matnr,
"Material
maktx
type makt-maktx,
"Descripcion
end of ty_sdd_material,
"**-begin of ty_sdd_um,
matnr
type zrmm_sdd_mov_d-matnr,
"Material
meins
type mara-meins,
"Unidad de Medida Base
end of ty_sdd_um,
"**-begin of ty_sdd_mblnr,
mblnr
type mkpf-mblnr,
*
tienda
type zrmm_sdd_mov_c-tienda,
matnr
type zrmm_sdd_mov_d-matnr,
*
budat
TYPE mkpf-budat,
end of ty_sdd_mblnr,
"**-begin of ty_sdd_mov,
sel,
cd
type zrmm_sdd_mov_c-cd,
"1.Centro Distribucion
tienda
type zrmm_sdd_mov_c-tienda,
"2.Tienda
name1
type t001w-name1,
"3.Descripcion de la Tienda
tipo
type char7,
"4.Tipo E=Electro u B=Bazar
num_op
type zrmm_sdd_mov_c-k_num_op, "5.Numero de Operacion
num_op_can type zrmm_sdd_mov_c-num_op_can, "6.Numero de Operacion de Can
celacion
fecent
type zrmm_sdd_mov_c-fec_ent,
"7.Fecha Entrega
fecen5
type zrmm_sdd_mov_c-fec_ent,
"7.Fecha Entrega - 5 dias
matnr
type zrmm_sdd_mov_d-matnr,
"8.Material
maktx
type makt-maktx,
"9.Descripcion de Material
qty
type zrmm_sdd_mov_d-qty,
"10.Cantidad
meins
type mara-meins,
"11.Unidad de Medida Base
pventa
type zrmm_sdd_mov_c-pedido_sap, "12.Pedido Venta
solped
type zrmm_sdd_mov_c-solped,
"13.Solicitud de Pedido
oc
type zrmm_sdd_mov_c-oc,
"14.Orden de Compra
belnr
type ekbe-belnr,
"15.Documento de Material de l
a recepcion de la OC
cpudt
type ekbe-cpudt,
"16.Fecha OC
cputm
type ekbe-cputm,
"17.Hora OC
ernam
type ekbe-ernam,
"18.User OC
doc1
type zrmm_sdd_mov_d-doc1,
"19.Mov 252 (TD)
carga
type zrmm_sdd2_d-carga,
"20.Carga
doc2
type zrmm_sdd_mov_d-doc2,
"21.Mov 251 (CD)
mblnr
type mkpf-mblnr,
end of ty_sdd_mov.
data: "**--Work Areas -
"**--Tabla Cabecera
"Tabla Descripcion Tienda
"Tabla Doc.Material
"Tabla Descripcion OC
"Tabla Carga
"**--Tabla Detalle - Mov
"Tabla Material - UM
"Tabla Material - UM
"Tabla UM
"Tabla Numero de Docuemento de
material
wa_out type ty_sdd_mov,
"**--Internal Tables ------------------------------------------it_data1 type standard table of ty_sdd_mov_c ,
"**--Tabla Cab
ecera
it_data2 type standard table of ty_sdd_tienda,
"Tabla Descripc
ion Tienda
it_data3 type standard table of ty_sdd_doc_mt,
"Tabla Doc.Mate
"Tabla Doc.Mate
rial
rial
*
cion OC
"Tabla Descrip
"Tabla Carga
"**--Tabla Deta
"Tabla Material
"Tabla Materia
lle - Mov
- UM
l - UM
it_data8 type standard table of ty_sdd_um,
it_data9 type standard table of ty_sdd_mblnr,
de Docuemento de material
it_out type table of ty_sdd_mov.
data:
type slis_layout_alv,
type slis_listheader,
it_top
type slis_t_listheader,
wa_event
it_event
type slis_alv_event,
type slis_t_event,
r_ucomm
rs_selfield
v_selfield
v_prog
v_name
type
type
type
type
type
lv_lines
type i.
sy-ucomm,
slis_selfield,
slis_selfield-value,
sy-repid,
sy-uname,
"Tabla UM
"Tabla Numero
*---Event Initialization-----------------------------------------------*
initialization.
selection-screen begin of block b01 with frame title text-b01.
select-options:
s_cd
for zrmm_sdd_mov_c-cd,
"Centro Distribucion
s_tienda
for zrmm_sdd_mov_c-tienda,
"Tienda
s_tipo
for zrmm_sdd_mov_c-tipo,
"Tipo E=Electro u B=Ba
zar
s_num_op
for zrmm_sdd_mov_c-k_num_op, "Numero de Operacion
s_fecent
for zrmm_sdd_mov_c-fec_ent, "Numero de Operacion
s_matnr
for zrmm_sdd_mov_d-matnr,
"Material
s_pventa
for zrmm_sdd_mov_c-pedido_sap,"Pedido Venta
s_solped
for zrmm_sdd_mov_c-solped,
"Solicitud de Pedido
s_oc
for zrmm_sdd_mov_c-oc.
"Orden de Compra
selection-screen end of block b01.
*---Event Start of Selection-------------------------------------------*
start-of-selection.
perform get_mov_c.
perform get_mov_d.
perform prepare_output.
perform prepare_fieldcat.
perform prepare_layout.
perform event_data1.
perform alv_list_display.
perform ucomm_out using r_ucomm
changing rs_selfield.
top-of-page.
perform top_of_page.
form get_mov_c.
select a~cd a~tienda a~tipo a~k_num_op a~num_op_can a~fec_ent a~pedido
_sap a~solped a~oc
into table it_data1
from zrmm_sdd_mov_c as a
where a~cd
in s_cd and
a~tienda
in s_tienda and
a~tipo
in s_tipo and
a~k_num_op
in s_num_op and
a~fec_ent
in s_fecent and
a~pedido_sap in s_pventa and
a~solped
in s_solped and
a~oc
in s_oc.
select f~werks f~name1
"name1 - Descripcion de la Ti
enda
into table it_data2
from t001w as f
for all entries in it_data1
where werks = it_data1-tienda.
*
SELECT g~ebeln g~belnr
"belnr - Documento de Materi
al de Recepcion de la OC
*
INTO TABLE it_data3
*
FROM ekbe as g
*
FOR ALL ENTRIES IN it_data1
*
WHERE g~ebeln = it_data1-oc AND
*
g~bwart IN ('101', '102', '105', '106').
select g~ebeln g~belnr g~bwart g~cpudt g~cputm g~ernam "belnr - Docu
mento de Material de Recepcion de la OC
if sy-subrc eq 0.
sort it_data1 by k_num_op.
else.
message 'Numero de Operacion no existe' type 'I'.
endif.
endform.
form get_mov_d.
if it_data1 is not initial.
select b~k_num_op b~matnr b~qty b~doc1 b~doc2
into table it_data6
from zrmm_sdd_mov_d as b
if sy-subrc eq 0.
endif.
endif.
endform.
*
form prepare_output.
"**-if it_data1 is not initial.
*
*
*
*
*
IF sy-subrc eq 0.
wa_out-belnr
= wa_data3-belnr.
ENDIF.
data : i type i.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
on
clear : wa_data6,wa_data7,wa_data8,wa_data9.
refresh : it_data9.
endloop.
clear : wa_out,lv_lines,wa_data1,wa_data2,wa_data3,wa_data5.
endloop.
endif.
endform.
form prepare_fieldcat.
clear wa_fcat_out.
refresh it_fcat_out.
if it_out is not initial.
data: lv_col type i value 0.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'CD'.
= 'IT_OUT'.
= 'Centro'.
it_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'TIENDA'.
= 'IT_OUT'.
= 'Tienda'.
it_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'NAME1'.
= 'IT_OUT'.
= 'Descripcion Tienda'.
it_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'TIPO'.
= 'IT_OUT'.
= 'Tipo Venta'.
it_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'NUM_OP'.
= 'IT_OUT'.
= 'N.Op.'.
it_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'NUM_OP_CAN'.
= 'IT_OUT'.
= 'N.Op.Canc.'.
it_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'FECENT'.
= 'IT_OUT'.
= 'Fecha Entrega'.
it_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'MATNR'.
= 'IT_OUT'.
= 'Material'.
it_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'MAKTX'.
= 'IT_OUT'.
= 'Descripcin Material'.
it_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'QTY'.
= 'IT_OUT'.
= 'Cantidad'.
it_fcat_out.
lv_col
= 1 + lv_col.
wa_fcat_out-col_pos = lv_col.
wa_fcat_out-fieldname = 'MEINS'.
wa_fcat_out-tabname = 'IT_OUT'.
wa_fcat_out-seltext_l = 'UM'.
append wa_fcat_out to it_fcat_out.
clear wa_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'PVENTA'.
= 'IT_OUT'.
= 'Pedido SAP'.
it_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'SOLPED'.
= 'IT_OUT'.
= 'Solicitud Pedido'.
it_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'OC'.
= 'IT_OUT'.
= 'Orden de Compra'.
it_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'BELNR'.
= 'IT_OUT'.
= 'Doc. OC'.
it_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'CPUDT'.
= 'IT_OUT'.
= 'Fecha OC'.
it_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'CPUTM'.
= 'IT_OUT'.
= 'Hora. OC'.
it_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'ERNAM'.
= 'IT_OUT'.
= 'User OC'.
it_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'DOC1'.
= 'IT_OUT'.
= 'Mov. 252(TD)'.
it_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'CARGA'.
= 'IT_OUT'.
= 'Carga'.
it_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'DOC2'.
= 'IT_OUT'.
= 'Mov. 251(CD)'.
it_fcat_out.
lv_col
wa_fcat_out-col_pos
wa_fcat_out-fieldname
wa_fcat_out-tabname
wa_fcat_out-seltext_l
append wa_fcat_out to
clear wa_fcat_out.
= 1 + lv_col.
= lv_col.
= 'MBLNR'.
= 'IT_OUT'.
= 'Mov251(TD)'.
it_fcat_out.
endif.
endform.
form alv_list_display.
v_prog = sy-repid.
v_name = sy-uname.
if it_out is not initial
and it_fcat_out is not initial.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program
= v_prog
i_callback_user_command
= 'UCOMM_OUT'
i_callback_top_of_page
= 'TOP_OF_PAGE'
is_layout
= wa_layout
it_fieldcat
= it_fcat_out
it_events
= it_event
i_save
= 'X'
tables
t_outtab
= it_out[]
exceptions
program_error
= 1
others
if sy-subrc <> 0.
exit.
endif.
endif.
endform.
= 2.
form top_of_page.
clear wa_top.
refresh it_top.
data v_date type char12.
call function 'CONVERT_DATE_TO_EXTERNAL'
exporting
date_internal
= sy-datum
importing
date_external
= v_date
exceptions
date_internal_is_invalid
= 1
others
= 2.
*
*
*
.
wa_top-typ
wa_top-info
append wa_top to it_top.
clear wa_top.
= 'H'.
= 'Reporte de Trazabilidad SDD'.
wa_top-typ
wa_top-info
concatenate wa_top-info v_prog
into wa_top-info.
append wa_top to it_top.
clear wa_top.
= 'S'.
= 'Programa : '.
wa_top-typ
wa_top-info
concatenate wa_top-info v_date
into wa_top-info.
append wa_top to it_top.
clear wa_top.
= 'S'.
= 'Fecha : '.
= 'X'.
= 'X'.
= 'SEL'.
*
*