MUNDOSAP

MUNDOSAP (foro/index.php)
-   Programación ABAP IV (foro/forumdisplay.php?f=4)
-   -   S.o.s. Con Reporte (foro/showthread.php?t=12999)

camaron 29/04/08 15:00:40

S.o.s. Con Reporte
 
Hola a todos como estan? tengo un problemita con un reporte resulta que tengo una tabla interna con n registros, donde tengo que sumar el monto de cada oferta por codigo de material y mostar la cantidad mas grande con ese codigo, (pueden varias cantidades con el mismo codigo de material) por
el momento estoy perdido, alguien me puede ayudar??? el codigo es el siguiente:


REPORT zmm_resumen_economico.
*&---------------------------------------------------------------------*
* DECLARACION DE TABLAS Y VARIABLES
**&---------------------------------------------------------------------*
DATA: ti_header TYPE zmmt_chrg_ofer_h OCCURS 0 WITH HEADER LINE.
DATA: ti_detail TYPE zmmt_chrg_ofer_d OCCURS 0 WITH HEADER LINE.
DATA: it_struc TYPE zmm_carofertas OCCURS 0 WITH HEADER LINE.
DATA: ti_items TYPE zmmt_chrg_ofer_i OCCURS 0 WITH HEADER LINE.
DATA: wa_items TYPE zmmt_chrg_ofer_i OCCURS 0 WITH HEADER LINE.
DATA: vfuncion TYPE rs38l_fnam,
cparam TYPE ssfctrlop,
outop TYPE ssfcompop,
fm_name TYPE rs38l_fnam,
vtot TYPE mkpf-frath,
vgara TYPE mkpf-frath.
data: bandera1(01).
*----------------------------------------------------------------------*
* PANTALLA DE SELECCION CON PARAMETROS
*----------------------------------------------------------------------*
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
PARAMETERS: p_lifnr LIKE lfa1-lifnr OBLIGATORY,
p_submi LIKE zmmt_chrg_ofer_h-submi OBLIGATORY.
SELECTION-SCREEN END OF BLOCK a1.
*----------------------------------------------------------------------*
* SELECCION DE DATOS
*----------------------------------------------------------------------*
START-OF-SELECTION.

*----------------------------------------------------------------------*
* SUBRUTINA PARA LA OBTENCION DE DATOS
*----------------------------------------------------------------------*
PERFORM call_info.

*----------------------------------------------------------------------*
* SUBRUTINA PARA IMPRECION DEL FORMULARIO
*----------------------------------------------------------------------*
PERFORM print_info.
*&---------------------------------------------------------------------*
*& Form call_info
*&---------------------------------------------------------------------*
FORM call_info .
*SELECCION DE DATOS DE CABECERA
SELECT SINGLE *
FROM zmmt_chrg_ofer_h
INTO ti_header
WHERE lifnr EQ p_lifnr
AND submi EQ p_submi.

*SELECCION DE DATOS POR ITEM
SELECT *
FROM zmmt_chrg_ofer_i
INTO TABLE ti_items
WHERE lifnr EQ ti_header-lifnr
AND ebeln EQ ti_header-ebeln
AND tipo NE space.

*SELECCION DE DETALLE
SELECT *
FROM zmmt_chrg_ofer_d
INTO TABLE ti_detail
WHERE lifnr EQ ti_header-lifnr
AND ebeln EQ ti_header-ebeln
AND tipo NE space.
*--------------------------------------------------------------------*
*ORDENACION DE TALAS INTERNAS ITEMS Y DETALLES
**--------------------------------------------------------------------*
SORT ti_detail BY ebeln ebelp.
SORT ti_items BY ebeln ebelp.

*LIMPIANDO WA WA_ITEMS Y VARIABLES
REFRESH wa_items.
CLEAR: vtot, vgara.

*PASANDO DATOS A LA TABLA DE WA
LOOP AT ti_items INTO wa_items.

*LEYENDO TABLA INTERNA TI_DETAIL CN LLAVE PRIMARIA EBELN Y EBELP
READ TABLE ti_detail WITH KEY ebeln = wa_items-ebeln
ebelp = wa_items-ebelp BINARY SEARCH.
IF sy-subrc EQ 0.
it_struc-nocom = ti_detail-nocom.
MOVE-CORRESPONDING wa_items TO it_struc.
ENDIF.
APPEND it_struc.

SORT it_struc by matnr totpr totfi.
at new matnr.
IF it_struc-totpr > vtot.
vtot = it_struc-totpr + vtot .
ENDIF.
IF it_struc-totfi > vgara.
vgara = it_struc-totfi + vgara.
ENDIF.
ENDAT.
ENDLOOP.
ENDFORM. " traer_info

saludos amigos,:mad:

ballan 29/04/08 16:09:10

Tienes una tabla interna con los campos
Material
Monto

1.- Si quieres calcular el total por material

loop at gt_material into gs_material_wa.

*si utilizas los eventos at te mete asteriscos en la estructura
gs_material_aux = gs_material_wa

at new matnr.

clear gv_total.

endat.

add gs_material_aux-monto to gv_total.

endloop.

2.- Si quieres calcular el maximo de cada uno

sort gt_material by matnr monto descending

loop at gt_material into gs_material_wa.

*si utilizas los eventos at te mete asteriscos en la estructura
gs_material_aux = gs_material_wa

at new matnr.

*en la primera fila de cada material tendras el valor maximo
gv_valor_maximo = gs_material_aux-monto.

endat.

add gs_material_aux-monto to gv_total.

endloop.

esepe 30/04/08 18:25:45

Hola,

para sumar los montos por material puedes usar "COLLECT".
Disculpa, pero no lo estoy poniendo con código porque no logro entender bien el funcionamiento de la parte en que comparas con vtot.

Espero te sirva...

Saludos,

Soledad


Husos Horarios son GMT. La hora en este momento es 18:29:28.

www.mundosap.com 2006 - Spain
software crm, crm on demand, software call center, crm act, crm solutions, crm gratis, crm web