|
#1
|
|||
|
|||
For All Entries
Hola queria saber como puedo utilizar la sentencia select for all entries para copiar datos desde una tabla fisica a una tabla interna sin necesidad de hacer un LOOP y el resultado sea igual que hacer:
LOOP AT TINTERNA SELECT* FROM BD INTO TINTERNA2 WHERE.......... MOVE-CORRESPONDING BD TO TINTERNA2. APPEND TINTERNA2 ENDSELECT. |
#2
|
|||
|
|||
es un tema recurrente..es cosa que busques
|
#3
|
|||
|
|||
Ejemplo
Hola, te mando un ejemplo:
Report Z_sebas *Mostrar todos los vuelos de todas las aerolineas, junto al modelo del avion, *el fabricante del mismo y su velocidad de operacion. *CARRNAME,CONNID,FLDATE,PRICE,PRODUCER,PLANETYPE,OP_SPEED TYPES: BEGIN OF t_vuelos, carrid TYPE scarr-carrid, connid TYPE sflight-connid, fldate TYPE sflight-fldate, price TYPE sflight-price, planetype TYPE sflight-planetype, END OF t_vuelos, BEGIN OF t_scarr, carrid TYPE scarr-carrid, carrname TYPE scarr-carrname, END OF t_scarr, BEGIN OF t_plane, planetype TYPE saplane-planetype, producer TYPE saplane-producer, op_speed TYPE saplane-op_speed, END OF t_plane. DATA: wa_vuelos TYPE t_vuelos, it_vuelos type TABLE OF t_vuelos, it_vuelos_aux TYPE TABLE OF t_vuelos, wa_scarr TYPE t_scarr, it_scarr TYPE TABLE OF t_scarr, wa_plane TYPE t_plane, it_plane TYPE TABLE OF t_plane, cantidad TYPE sy-dbcnt. START-OF-SELECTION. * OBTENGO LA LISTA DE VUELOS DESDE LA SFLIGHT SELECT carrid connid fldate price planetype from sflight into TABLE it_vuelos. if sy-subrc eq 0. * VERIFICO SI OBTUVE AL MENOS UN REGISTRO * GUARDO LA CANTIDAD DE REGISTROS PROCESADOS. cantidad = sy-dbcnt. * COPIO MI TABLA A UNA TABLA AUXILIAR it_vuelos_aux[] = it_vuelos[]. * ORDENO LA TABLA AUXILIAR POR CARRID sort it_vuelos_aux by carrid. * ELIMINO LOS REGISTROS REPETIDOS EN LA TABLA AUXILIAR DELETE ADJACENT DUPLICATES FROM it_vuelos_aux COMPARING carrid. * OBTENGO CARRID Y CARRNAME DE SCARR EN IT_SCARR PARA TODOS LOS DATOS DE MI TABLA AUXILIAR (comparando por carrid) SELECT carrid carrname from scarr into table it_scarr FOR ALL ENTRIES IN it_vuelos_aux where carrid = it_vuelos_aux-carrid. if sy-subrc eq 0. * SI EL SELECT FUE EXITOSO * VUELVO A HACER UNA COPIA AUXILIAR DE VUELOS * (Recordar que al hacer un DELETE ADJACENT... se borran registros de la tabla it_vuelos_aux) it_vuelos_aux[] = it_vuelos[]. * ORDENO POR PLANETYPE (clave q me permite hacer el FOR ALL ENTRIES IN luego) sort it_vuelos_aux by planetype. * ELIMINO LOS REGISTROS REPETIDOS (los que comparten planetype) DELETE ADJACENT DUPLICATES FROM it_vuelos_aux COMPARING planetype. * OBTENGO LOS CAMPOS NECESARIOS DE SAPLANE EN IT_PLANE PARA TODOS LOS DATOS DE MI TABLA AUXILIAR (comparando por planetype) SELECT planetype producer op_speed from saplane into TABLE it_plane for ALL ENTRIES IN it_vuelos_aux where planetype = it_vuelos_aux-planetype. if sy-subrc eq 0. * SI OBTUVO DATOS * ORDENO LAS TABLAS POR CLAVE DE INGRESO EN FORMA ASCENDENTE (por defecto) sort it_scarr by carrid. SORT it_plane by planetype ASCENDING. * NAVEGO MI TABLA DE VUELOS loop at it_vuelos into wa_vuelos. * POR CADA VUELO, COPIO A WA_SCARR LOS DATOS DEL CARRID ACTUAL READ TABLE it_scarr into wa_scarr with KEY carrid = wa_vuelos-carrid BINARY SEARCH. if sy-subrc eq 0. * SI PUDE VER LA INFORMACION CORRECTAMENTE * POR EL VUELO ACTUAL, OBTENGO LOS DATOS DEL TIPO DE AVION READ TABLE it_plane into wa_plane with key planetype = wa_vuelos-planetype BINARY SEARCH. if sy-subrc eq 0. * SI EL READ TABLE FUE EXITOSO, IMPRIMO TODOS LOS DATOS write: / wa_scarr-carrname, wa_vuelos-connid, wa_vuelos-fldate, wa_vuelos-price, wa_plane-producer, wa_plane-planetype, wa_plane-op_speed. endif. endif. * LIMPIO TODAS LAS WA UTILIZADAS clear wa_vuelos. clear wa_scarr. clear wa_plane. endloop. endif. endif. endif. write: / 'La cantidad de vuelos es:', cantidad. END-OF-SELECTION. espero que te sirva, saludos
__________________
Sebas Desarrollador ABAP. |
Herramientas | Buscar en Tema |
Desplegado | |
|
|