MUNDOSAP

Regresar   MUNDOSAP > DESARROLLO > Programación ABAP IV
Nombre de Usuario
Contraseña
Home Descargas Registrar FAQ Miembros Calendario Buscar Temas de Hoy Marcar Foros Como Leídos




 
Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Viejo 30/03/16, 18:08:15
Angela Eloisa Angela Eloisa is offline
Junior Member
 
Fecha de Ingreso: sep 2014
Mensajes: 2
Smile Agregar n registros de un campo a un solo registro de un campo

Hola!
Espero me puedan ayudar.
Resulta que tengo una tabla interna como esta.

Asig Cege Fondo Importe Doc
543 1J03 1160 20.0 1001
543 1J03 1160 10.0 1002
543 1J03 1160 50.0 1003

y se hará un acumulado por asig, cege y fondo, eso lo resolví con un collect, quedando así.
Asig Cege Fondo Importe Doc
543 1J03 1160 80.0

Pero como los documentos son distintos deben quedar esos tres doc en un solo registro dentro del campo doc quedando así.

Asig Cege Fondo Importe Doc
543 1J03 1160 80.0 1001 1002 1003

Alguien tiene una idea de como puedo resolver este tema ??
Responder Con Cita
  #2  
Viejo 30/03/16, 22:01:59
omegaotaku omegaotaku is offline
Member
 
Fecha de Ingreso: nov 2011
Mensajes: 43

Buenas tardes. Espero que te sea util, nose si sera la solucion que necesitas pero por lo menos es algo:

*&---------------------------------------------------------------------*
*& Report YTEMPO
*&
*&---------------------------------------------------------------------*
REPORT YTEMPO.

TYPES:BEGIN OF ty_table,
asig(3) TYPE C,
cege(4) TYPE C,
fondo(4) TYPE C,
importe TYPE DMBTR,
doc(4) TYPE C,
END OF ty_table.

TYPES:BEGIN OF ty_docs,
doc(4) TYPE C,
END OF ty_docs.

DATA:BEGIN OF td_aux_table.
INCLUDE TYPE ty_table.
DATA st_doc TYPE STANDARD TABLE OF ty_docs INITIAL SIZE 0.
DATA:END OF td_aux_table.

DATA: it_table TYPE STANDARD TABLE OF ty_table INITIAL SIZE 0,
wa_table LIKE LINE OF it_table,
it_aux_table LIKE STANDARD TABLE OF td_aux_table INITIAL SIZE 0,
wa_aux_table LIKE LINE OF it_aux_table,
wa_doc TYPE ty_docs.

FIELD-SYMBOLS: <fs_aux_table> LIKE LINE OF it_aux_table.

START-OF-SELECTION.

wa_table-asig = '543'.
wa_table-cege = '1J03'.
wa_table-fondo = '1160'.
wa_table-importe = '20.0'.
wa_table-doc = '1001'.

APPEND wa_table TO it_table.

wa_table-asig = '543'.
wa_table-cege = '1J03'.
wa_table-fondo = '1160'.
wa_table-importe = '10.0'.
wa_table-doc = '1002'.

APPEND wa_table TO it_table.

wa_table-asig = '543'.
wa_table-cege = '1J03'.
wa_table-fondo = '1160'.
wa_table-importe = '50.0'.
wa_table-doc = '1003'.

APPEND wa_table TO it_table.
CLEAR wa_table.

LOOP AT it_table INTO wa_table.

READ TABLE it_aux_table ASSIGNING <fs_aux_table> WITH KEY asig = wa_table-asig.

IF sy-subrc EQ 0.

<fs_aux_table>-importe = <fs_aux_table>-importe + wa_table-importe.

wa_doc = wa_table-doc.

APPEND wa_doc TO <fs_aux_table>-st_doc.

UNASSIGN <fs_aux_table>.

ELSE.

wa_aux_table-asig = wa_table-asig.
wa_aux_table-cege = wa_table-cege.
wa_aux_table-fondo = wa_table-fondo.
wa_aux_table-importe = wa_table-importe.
wa_doc = wa_table-doc.

APPEND:wa_doc TO wa_aux_table-st_doc,
wa_aux_table TO it_aux_table.

ENDIF.

CLEAR:wa_table,wa_aux_table,wa_doc.

ENDLOOP.

PD: Para ver como funciona seguirlo por debug.
Saludos.

Úlima edición por omegaotaku fecha: 31/03/16 a las 11:55:00.
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Reglas de Mensajes
no puedes crear nuevos temas
no puedes responder temas
no puedes adjuntar archivos
no puedes editar tus mensajes

El código vB está On
Las caritas están On
Código [IMG] está On
Código HTML está Off
Saltar a Foro


Husos Horarios son GMT. La hora en este momento es 15:43:17.


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