A la hora de llamar a un programa desde otro programa, si este es de tipo report y además tiene una transacción que lo ejecute, se puede emplear tanto un "CALL" como un "SUBMIT". ¿Cuáles son las diferencia entre uno y otro? Que yo sepa:
1. El CALL TRANSACTION puede llamar a cualquier tipo de programas, sólo hay que crearles una transacción (si no la tienen).
2. El CALL TRANSACTION permite usar una tabla de tipo BDCDATA, y simular un conjunto de acciones (como en un batch input). También permite usar parámetros.
3. El SUBMIT ejecuta el programa sin preguntar por la pantalla por defecto (es decir, si no se le pasan valores a los rangos, toma los que haya por defecto en el caso de que haya pantalla de selección). También permite el uso de parámetros.
Para ilustrarlo, he hecho el siguiente programita, que básicamente llama a la trasacción WE05 usando el primer número de idoc que encuentre ese día.
*&---------------------------------------------------------------------*
*& Report Z_AGH_CALL
*&
*&---------------------------------------------------------------------*
*& Tres ejemplos para llamar a una transacción.
*& Se usará de ejemplo la transacción WE05 y se le pasará el
*& Número de idoc
*&---------------------------------------------------------------------*
*& Alberto García de Haro
*& http://misprogramasabap.blogspot.com/
*&---------------------------------------------------------------------*
*& Textos de selección:
* P_BDC Call Transacion y bdcdata
* P_PAR Call Transaction y parámetros
* P_SUB Submit
*& Símbolos de texto
* 001 Opciones de ejecución
*&---------------------------------------------------------------------*
report z_agh_call.
*&---------------------------------------------------------------------*
*& TOP: variables, tablas internas, etc.
*&---------------------------------------------------------------------*
data: obj like edidc-docnum.
data: begin of i_bdc_data occurs 10.
include structure bdcdata.
data: end of i_bdc_data.
data: begin of i_rspar occurs 10.
include structure rsparams.
data: end of i_rspar.
tables:
usr02.
data: begin of i_users occurs 10.
include structure usr02.
data: end of i_users.
*&---------------------------------------------------------------------*
*& PANTALLA DE SELECCIÓN
*&---------------------------------------------------------------------*
selection-screen begin of block bl1 with frame title text-001.
parameters:
p_sub radiobutton group gr1,
p_par radiobutton group gr1,
p_bdc radiobutton group gr1.
selection-screen end of block bl1.
*&---------------------------------------------------------------------*
*& EVENTOS
*&---------------------------------------------------------------------*
start-of-selection.
perform seleccionar_idoc changing obj.
if p_sub eq 'X'.
perform llamada_submit.
elseif p_par eq 'X'.
perform llamada_parametros.
else. "debe ser p_bdc eq 'X'
perform llamada_bdcdata.
endif.
*&---------------------------------------------------------------------*
*& SUBRUTINAS
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form seleccionar_idoc
*&---------------------------------------------------------------------*
* Selecciona un número de idoc
*----------------------------------------------------------------------*
* <--P_OBJ nº de idoc
*----------------------------------------------------------------------*
form seleccionar_idoc changing p_obj.
data: fecha like sy-datum, d_cont type i. "Para usar la fecha
fecha = sy-datum.
clear d_cont.
do.
select single docnum into p_obj from edidc
where credat eq sy-datum.
if sy-subrc eq 0 or d_cont = 30.
"encontró un idoc O llegó a 30 días sin encontrar nada
exit.
endif.
****RESTAMOS UN DÍA
call function 'SUBTRACT_TIME_FROM_DATE'
exporting
i_idate = fecha
i_time = 1
i_iprkz = 'D'
importing
o_idate = fecha.
add 1 to d_cont.
enddo.
endform. " seleccionar_idoc
*&---------------------------------------------------------------------*&
*& Form llamada_submit
*&---------------------------------------------------------------------
**& Llamada con la sentencia submit
*----------------------------------------------------------------------*
form llamada_submit .
ranges ndocc for edidc-docnum.
clear: ndocc.
move:
'I' to ndocc-sign,
'EQ' to ndocc-option,
obj to ndocc-low.
append ndocc.
submit rseidoc2 with docnum in ndocc
and return.
endform. " llamada_submit
*&---------------------------------------------------------------------*
*& Form llamada_parametros
*&---------------------------------------------------------------------*
Llamada con call transaction y parámetros
*----------------------------------------------------------------------*
form llamada_parametros .
set parameter id 'DCN' field obj.
call transaction 'WE05'.
endform. " llamada_parametros
*&---------------------------------------------------------------------*
*& Form llamada_bdcdata
*&---------------------------------------------------------------------*
Llamada con call transaction y bdc_data
*----------------------------------------------------------------------*
form llamada_bdcdata .
*Llenamos la tabla
refresh i_bdc_data.
i_bdc_data-program = 'RSEIDOC2'.
i_bdc_data-dynpro = '1000'.
i_bdc_data-dynbegin = 'X'.
append i_bdc_data. clear i_bdc_data.
i_bdc_data-fnam = 'DOCNUM-LOW'.
i_bdc_data-fval = obj.
append i_bdc_data. clear i_bdc_data.
call transaction 'WE05' using i_bdc_data.
endform. " llamada_bdcdata
martes, 9 de octubre de 2007
jueves, 9 de agosto de 2007
z_ordenes
El siguiente report modifica el de Álvaro Tejada, porque lo copié tal cual y no me compilaba. Le metes un programa o transacción, y te dice las órdenes de transporte que afectan a dicho programa; muy útil si tienes que hacer un listado de las órdenes que has liberado y no tienes ni idea, sobre todo en empresas donde el usuario de desarrollo es para varias personas.
report z_ordenes.
*-----------------------------------------------------------------*
* Lista las órdenes de transporte de un programa o transacción *
* p_tcode --> transacción *
* p_pgmna --> programa *
*-----------------------------------------------------------------*
* Alberto García de Haro, 09/08/2007 *
*-----------------------------------------------------------------*
*-----------------------------------------------------------------*
* DECLARACION DE TYPES *
*-----------------------------------------------------------------*
types: begin of ty_e071,
trkorr type e071-trkorr,
object type e071-object,
obj_name type e071-obj_name,
end of ty_e071.
types: begin of ty_e071_entry,
trkorr type e071-trkorr,
end of ty_e071_entry.
types: begin of ty_e070,
trkorr type e070-trkorr,
trstatus type e070-trstatus,
tarsystem type e070-tarsystem,
as4user type e070-as4user,
as4date type e070-as4date,
as4time type e070-as4time,
as4text type e07t-as4text,
end of ty_e070.
types: begin of ctslg_action,
date like tstrfcofil-trdate,
time like tstrfcofil-trtime,
rc like tstrfcofil-retcode,
end of ctslg_action,
ctslg_actions type sorted table of ctslg_action
with unique key date time
initial size 2,
begin of ctslg_step,
clientid like tstrfcofil-tarclient,
stepid like tstrfcofil-function,
rc like tstrfcofil-retcode,
actions type ctslg_actions,
end of ctslg_step,
ctslg_steps type ctslg_step occurs 10,
begin of ctslg_system,
systemid like tstrfcofil-tarsystem,
rc like tstrfcofil-retcode,
steps type ctslg_steps,
end of ctslg_system,
ctslg_systems type ctslg_system occurs 10,
begin of ctslg_mergeline,
trkorr type trkorr,
rc like tstrfcofil-retcode,
end of ctslg_mergeline,
ctslg_mergelines type ctslg_mergeline occurs 0,
begin of ctslg_cofile,
exists type c,
imported type c,
del_lines_only type c,
systems type ctslg_systems,
merges type ctslg_mergelines,
rc type i,
end of ctslg_cofile.
*-----------------------------------------------------------------*
* DECLARACION DE TABLAS INTERNAS *
*-----------------------------------------------------------------*
data: t_e071 type standard table of ty_e071 with header line,
t_e070 type standard table of ty_e070 with header line,
t_e071_entry type standard table of ty_e071_entry
with header line,
doma_values type standard table of rpy_dval
with header line,
es_cofile type standard table of ctslg_cofile
with header line,
es_systems type standard table of ctslg_system,
wa_systems type ctslg_systems with header line,
es_steps type ctslg_steps,
wa_steps type ctslg_steps with header line,
es_actions type ctslg_actions,
wa_actions type ctslg_actions with header line.
*-----------------------------------------------------------------*
* DECLARACION DE VARIABLES *
*-----------------------------------------------------------------*
data: w_pgmna type tstc-pgmna,
w_name(41) type c,
w_flag type c.
*-----------------------------------------------------------------*
* DECLARACION DE FIELD-SYMBOLS *
*-----------------------------------------------------------------*
field-symbols:like line of t_e071,
like line of t_e070.
*-----------------------------------------------------------------*
* SELECTION-SCREEN *
*-----------------------------------------------------------------*
selection-screen begin of block data.
parameters:
p_tcode like tstc-tcode,
p_pgmna like tstc-pgmna.
selection-screen end of block data.
*-----------------------------------------------------------------*
* START-OF-SELECTION *
*-----------------------------------------------------------------*
start-of-selection.
perform validar_entrada.
if w_flag eq space.
perform obtener_ordenes.
perform imprimir_ordenes.
endif.
*&----------------------------------------------------------------*
*& Form VALIDAR_ENTRADA *
*&----------------------------------------------------------------*
form validar_entrada.
if p_tcode ne space.
select single pgmna
into w_pgmna
from tstc
where tcode eq p_tcode.
if sy-subrc eq 0.
w_flag = space.
else.
message s368(00) with 'La transacción solicitada no existe'.
w_flag = 'X'.
endif.
elseif p_pgmna ne space.
select single pgmna
into w_pgmna
from tstc
where pgmna eq p_pgmna.
if sy-subrc eq 0.
w_flag = space.
else.
message s368(00) with 'El programa solicitado no existe'.
w_flag = 'X'.
endif.
endif.
endform. " VALIDAR_ENTRADA
*&----------------------------------------------------------------*
*& Form OBTENER_ORDENES *
*&----------------------------------------------------------------*
form obtener_ordenes.
call function 'RPY_DOMAIN_READ'
exporting
doma_name = 'TRSTATUS'
language = sy-langu
tables
doma_values = doma_values
exceptions
cancelled = 1
not_found = 2
permission_error = 3
illegal_type = 4
others = 5.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
concatenate w_pgmna '%'
into w_name.
select trkorr object obj_name
into table t_e071
from e071
where obj_name like w_name
and object eq 'REPS'.
if not t_e071[] is initial.
loop at t_e071 assigning.
moveto t_e071_entry.
append t_e071_entry.
endloop.
sort t_e071_entry.
delete adjacent duplicates from t_e071_entry.
if not t_e071_entry[] is initial.
select e070~trkorr trstatus tarsystem
as4user as4date as4time
as4text
into table t_e070
from ( e070 inner join e07t
on e070~trkorr eq e07t~trkorr )
for all entries in t_e071_entry
where e070~trkorr eq t_e071_entry-trkorr
and langu eq sy-langu.
sort t_e070 by as4date as4time descending.
endif.
endif.
endform. " OBTENER_ORDENES
*&----------------------------------------------------------------*
*& Form IMPRIMIR_ORDENES *
*&----------------------------------------------------------------*
form imprimir_ordenes.
data: w_trkorr type e070-trkorr.
write:
1 'Orden' ,12 'Estado',
22 'Destino', 31 'Nombre',92 'Fecha',104 'Hora'.
loop at t_e070 assigning .
clear: es_cofile.
refresh: es_cofile.
call function 'TR_READ_GLOBAL_INFO_OF_REQUEST'
exporting
iv_trkorr =-trkorr
iv_dir_type = 'T'
importing
es_cofile = es_cofile.
append es_cofile.
read table es_cofile index 1.
move es_cofile-systems to es_systems.
loop at es_systems into wa_systems.
move wa_systems-steps to es_steps.
loop at es_steps into wa_steps. "WHERE STEPID EQ 'G'.
move wa_steps-actions to es_actions.
loop at es_actions into wa_actions.
endloop.
read table doma_values
with key domvalue_l =-trstatus.
if w_trkorr ne-trkorr.
w_trkorr =-trkorr.
skip 1.
endif.
write:/1-trkorr,12 doma_values-ddtext,
22 wa_systems-systemid,31-as4text,
92 wa_actions-date,104 wa_actions-time.
endloop.
endloop.
endloop.
endform. " IMPRIMIR_ORDENES
*-----------------------------------------------------------------*
* Lista las órdenes de transporte de un programa o transacción *
* p_tcode --> transacción *
* p_pgmna --> programa *
*-----------------------------------------------------------------*
* Alberto García de Haro, 09/08/2007 *
*-----------------------------------------------------------------*
*-----------------------------------------------------------------*
* DECLARACION DE TYPES *
*-----------------------------------------------------------------*
types: begin of ty_e071,
trkorr type e071-trkorr,
object type e071-object,
obj_name type e071-obj_name,
end of ty_e071.
types: begin of ty_e071_entry,
trkorr type e071-trkorr,
end of ty_e071_entry.
types: begin of ty_e070,
trkorr type e070-trkorr,
trstatus type e070-trstatus,
tarsystem type e070-tarsystem,
as4user type e070-as4user,
as4date type e070-as4date,
as4time type e070-as4time,
as4text type e07t-as4text,
end of ty_e070.
types: begin of ctslg_action,
date like tstrfcofil-trdate,
time like tstrfcofil-trtime,
rc like tstrfcofil-retcode,
end of ctslg_action,
ctslg_actions type sorted table of ctslg_action
with unique key date time
initial size 2,
begin of ctslg_step,
clientid like tstrfcofil-tarclient,
stepid like tstrfcofil-function,
rc like tstrfcofil-retcode,
actions type ctslg_actions,
end of ctslg_step,
ctslg_steps type ctslg_step occurs 10,
begin of ctslg_system,
systemid like tstrfcofil-tarsystem,
rc like tstrfcofil-retcode,
steps type ctslg_steps,
end of ctslg_system,
ctslg_systems type ctslg_system occurs 10,
begin of ctslg_mergeline,
trkorr type trkorr,
rc like tstrfcofil-retcode,
end of ctslg_mergeline,
ctslg_mergelines type ctslg_mergeline occurs 0,
begin of ctslg_cofile,
exists type c,
imported type c,
del_lines_only type c,
systems type ctslg_systems,
merges type ctslg_mergelines,
rc type i,
end of ctslg_cofile.
*-----------------------------------------------------------------*
* DECLARACION DE TABLAS INTERNAS *
*-----------------------------------------------------------------*
data: t_e071 type standard table of ty_e071 with header line,
t_e070 type standard table of ty_e070 with header line,
t_e071_entry type standard table of ty_e071_entry
with header line,
doma_values type standard table of rpy_dval
with header line,
es_cofile type standard table of ctslg_cofile
with header line,
es_systems type standard table of ctslg_system,
wa_systems type ctslg_systems with header line,
es_steps type ctslg_steps,
wa_steps type ctslg_steps with header line,
es_actions type ctslg_actions,
wa_actions type ctslg_actions with header line.
*-----------------------------------------------------------------*
* DECLARACION DE VARIABLES *
*-----------------------------------------------------------------*
data: w_pgmna type tstc-pgmna,
w_name(41) type c,
w_flag type c.
*-----------------------------------------------------------------*
* DECLARACION DE FIELD-SYMBOLS *
*-----------------------------------------------------------------*
field-symbols:
*-----------------------------------------------------------------*
* SELECTION-SCREEN *
*-----------------------------------------------------------------*
selection-screen begin of block data.
parameters:
p_tcode like tstc-tcode,
p_pgmna like tstc-pgmna.
selection-screen end of block data.
*-----------------------------------------------------------------*
* START-OF-SELECTION *
*-----------------------------------------------------------------*
start-of-selection.
perform validar_entrada.
if w_flag eq space.
perform obtener_ordenes.
perform imprimir_ordenes.
endif.
*&----------------------------------------------------------------*
*& Form VALIDAR_ENTRADA *
*&----------------------------------------------------------------*
form validar_entrada.
if p_tcode ne space.
select single pgmna
into w_pgmna
from tstc
where tcode eq p_tcode.
if sy-subrc eq 0.
w_flag = space.
else.
message s368(00) with 'La transacción solicitada no existe'.
w_flag = 'X'.
endif.
elseif p_pgmna ne space.
select single pgmna
into w_pgmna
from tstc
where pgmna eq p_pgmna.
if sy-subrc eq 0.
w_flag = space.
else.
message s368(00) with 'El programa solicitado no existe'.
w_flag = 'X'.
endif.
endif.
endform. " VALIDAR_ENTRADA
*&----------------------------------------------------------------*
*& Form OBTENER_ORDENES *
*&----------------------------------------------------------------*
form obtener_ordenes.
call function 'RPY_DOMAIN_READ'
exporting
doma_name = 'TRSTATUS'
language = sy-langu
tables
doma_values = doma_values
exceptions
cancelled = 1
not_found = 2
permission_error = 3
illegal_type = 4
others = 5.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
concatenate w_pgmna '%'
into w_name.
select trkorr object obj_name
into table t_e071
from e071
where obj_name like w_name
and object eq 'REPS'.
if not t_e071[] is initial.
loop at t_e071 assigning
move
append t_e071_entry.
endloop.
sort t_e071_entry.
delete adjacent duplicates from t_e071_entry.
if not t_e071_entry[] is initial.
select e070~trkorr trstatus tarsystem
as4user as4date as4time
as4text
into table t_e070
from ( e070 inner join e07t
on e070~trkorr eq e07t~trkorr )
for all entries in t_e071_entry
where e070~trkorr eq t_e071_entry-trkorr
and langu eq sy-langu.
sort t_e070 by as4date as4time descending.
endif.
endif.
endform. " OBTENER_ORDENES
*&----------------------------------------------------------------*
*& Form IMPRIMIR_ORDENES *
*&----------------------------------------------------------------*
form imprimir_ordenes.
data: w_trkorr type e070-trkorr.
write:
1 'Orden' ,12 'Estado',
22 'Destino', 31 'Nombre',92 'Fecha',104 'Hora'.
clear: es_cofile.
refresh: es_cofile.
call function 'TR_READ_GLOBAL_INFO_OF_REQUEST'
exporting
iv_trkorr =
iv_dir_type = 'T'
importing
es_cofile = es_cofile.
append es_cofile.
read table es_cofile index 1.
move es_cofile-systems to es_systems.
loop at es_systems into wa_systems.
move wa_systems-steps to es_steps.
loop at es_steps into wa_steps. "WHERE STEPID EQ 'G'.
move wa_steps-actions to es_actions.
loop at es_actions into wa_actions.
endloop.
read table doma_values
with key domvalue_l =
if w_trkorr ne
w_trkorr =
skip 1.
endif.
write:/1
22 wa_systems-systemid,31
92 wa_actions-date,104 wa_actions-time.
endloop.
endloop.
endloop.
endform. " IMPRIMIR_ORDENES
lunes, 11 de junio de 2007
ALV Jerárquico
REPORT zalv_jerarquico.
* Por: Jorge Serra (AbapLife) http://abaplife.bitacoras.com
* Se trata de una ejemplo de listado ALV jerarquico.
* Propósito:
* ---------
* Voy mostrar un listado de pedidos de compras (datos de cabecera)
* y sus posiciones (datos de posicion)
* Pasos esenciales (Buscar el simbolo '§')
* ----------------
* 1. Definición estructuras y tablas necesarias
* 2. Definimos las tablas con los datos de salida
* 3. Toma de datos
* 4. Definición estructura y formato de salida
* 5. Mostrar listado
*<-- § Paso 1. Definicion estructuras y tablas necesarias
* Type Pool donde vienen definidas todas las estructuras y tablas
TYPE-POOLS: slis.
* Catálogo de campos: contiene la descripción de los campos de salida
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
* Especificaciones de la disposición de la lista: descripción de la
* estructura de salida
gs_layout TYPE slis_layout_alv,
* Relacion entre los datos de cabecera y posicion
gs_key TYPE slis_keyinfo_alv,
* Nombre del programa g_repid LIKE sy-repid.
*<-- § Paso 2. Definimos las tablas con los datos de salida
TYPES: BEGIN OF st_header.
INCLUDE STRUCTURE ekko.
TYPES: END OF st_header.
TYPES: BEGIN OF st_item.
INCLUDE STRUCTURE ekpo.
TYPES: END OF st_item.
DATA:
gt_header TYPE STANDARD TABLE OF st_header WITH HEADER LINE,
gt_item TYPE STANDARD TABLE OF st_item WITH HEADER LINE.
INITIALIZATION.
g_repid = sy-repid.
START-OF-SELECTION.
*<-- § Paso 3. Toma de datos
PERFORM toma_datos.
*<-- § Paso 4. Estructura y formato de salida
PERFORM init_fieldcat.
PERFORM init_layout.
PERFORM init_key.
*<-- § Paso 5. Mostrar listado
PERFORM listado.
*&&-----------------------------------------------------------------&&*
* SUBRUTINAS DEL PROGRAMA *
*&&-----------------------------------------------------------------&&*
*---------------------------------------------------------------------*
* FORM INIT_FIELDCAT *
*---------------------------------------------------------------------*
FORM init_fieldcat.
* Mediante esta tabla vamos a definir los campos que queremos mostrar
* en el listado de salida.
gt_fieldcat-fieldname = 'EBELN'.
gt_fieldcat-tabname = 'GT_HEADER'.
gt_fieldcat-ref_tabname = 'EKKO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'EBELN'.
gt_fieldcat-tabname = 'GT_ITEM'.
gt_fieldcat-ref_tabname = 'EKPO'.
gt_fieldcat-no_out = 'X'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'EBELP'.
gt_fieldcat-tabname = 'GT_ITEM'.
gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'MATNR'.
gt_fieldcat-tabname = 'GT_ITEM'.
gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'WERKS'.
gt_fieldcat-tabname = 'GT_ITEM'.
gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'MENGE'.
gt_fieldcat-tabname = 'GT_ITEM'.
gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'MEINS'.
gt_fieldcat-tabname = 'GT_ITEM'.
gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
ENDFORM.
*---------------------------------------------------------------------*
* FORM INIT_LAYOUT *
*---------------------------------------------------------------------*
FORM init_layout.
* Mediante esta estructura podemos definir el formato de salida
gs_layout-zebra = 'X'.
gs_layout-f2code = '&ETA'.
gs_layout-detail_popup = 'X'.
ENDFORM.
*---------------------------------------------------------------------*
* FORM TOMA_DATOS *
*---------------------------------------------------------------------*
FORM toma_datos.
* Los datos deben guardarse en la tabla interna de salida
SELECT * FROM ekko
UP TO 100 ROWS
INTO TABLE gt_header.
SELECT * FROM ekpo
INTO TABLE gt_item
FOR ALL ENTRIES IN gt_header
WHERE ebeln = gt_header-ebeln.
ENDFORM. " TOMA_DATOS
*---------------------------------------------------------------------*
* FORM LISTADO *
*---------------------------------------------------------------------*
FORM listado.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
i_callback_program = g_repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
i_tabname_header = 'GT_HEADER'
i_tabname_item = 'GT_ITEM'
* I_STRUCTURE_NAME_HEADER =
* I_STRUCTURE_NAME_ITEM =
is_keyinfo = gs_key
* IS_PRINT =
* IS_REPREP_ID =
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab_header = gt_header[]
t_outtab_item = gt_item[]
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2 .
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " LISTADO
*---------------------------------------------------------------------*
* FORM INIT_KEY *
*---------------------------------------------------------------------*
FORM init_key.
* Relacion entre los campos de cabecera y los de posicion
gs_key-header01 = 'EBELN'.
gs_key-item01 = 'EBELN'.
ENDFORM. " INIT_KEY
* Por: Jorge Serra (AbapLife) http://abaplife.bitacoras.com
* Se trata de una ejemplo de listado ALV jerarquico.
* Propósito:
* ---------
* Voy mostrar un listado de pedidos de compras (datos de cabecera)
* y sus posiciones (datos de posicion)
* Pasos esenciales (Buscar el simbolo '§')
* ----------------
* 1. Definición estructuras y tablas necesarias
* 2. Definimos las tablas con los datos de salida
* 3. Toma de datos
* 4. Definición estructura y formato de salida
* 5. Mostrar listado
*<-- § Paso 1. Definicion estructuras y tablas necesarias
* Type Pool donde vienen definidas todas las estructuras y tablas
TYPE-POOLS: slis.
* Catálogo de campos: contiene la descripción de los campos de salida
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
* Especificaciones de la disposición de la lista: descripción de la
* estructura de salida
gs_layout TYPE slis_layout_alv,
* Relacion entre los datos de cabecera y posicion
gs_key TYPE slis_keyinfo_alv,
* Nombre del programa g_repid LIKE sy-repid.
*<-- § Paso 2. Definimos las tablas con los datos de salida
TYPES: BEGIN OF st_header.
INCLUDE STRUCTURE ekko.
TYPES: END OF st_header.
TYPES: BEGIN OF st_item.
INCLUDE STRUCTURE ekpo.
TYPES: END OF st_item.
DATA:
gt_header TYPE STANDARD TABLE OF st_header WITH HEADER LINE,
gt_item TYPE STANDARD TABLE OF st_item WITH HEADER LINE.
INITIALIZATION.
g_repid = sy-repid.
START-OF-SELECTION.
*<-- § Paso 3. Toma de datos
PERFORM toma_datos.
*<-- § Paso 4. Estructura y formato de salida
PERFORM init_fieldcat.
PERFORM init_layout.
PERFORM init_key.
*<-- § Paso 5. Mostrar listado
PERFORM listado.
*&&-----------------------------------------------------------------&&*
* SUBRUTINAS DEL PROGRAMA *
*&&-----------------------------------------------------------------&&*
*---------------------------------------------------------------------*
* FORM INIT_FIELDCAT *
*---------------------------------------------------------------------*
FORM init_fieldcat.
* Mediante esta tabla vamos a definir los campos que queremos mostrar
* en el listado de salida.
gt_fieldcat-fieldname = 'EBELN'.
gt_fieldcat-tabname = 'GT_HEADER'.
gt_fieldcat-ref_tabname = 'EKKO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'EBELN'.
gt_fieldcat-tabname = 'GT_ITEM'.
gt_fieldcat-ref_tabname = 'EKPO'.
gt_fieldcat-no_out = 'X'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'EBELP'.
gt_fieldcat-tabname = 'GT_ITEM'.
gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'MATNR'.
gt_fieldcat-tabname = 'GT_ITEM'.
gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'WERKS'.
gt_fieldcat-tabname = 'GT_ITEM'.
gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'MENGE'.
gt_fieldcat-tabname = 'GT_ITEM'.
gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'MEINS'.
gt_fieldcat-tabname = 'GT_ITEM'.
gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
ENDFORM.
*---------------------------------------------------------------------*
* FORM INIT_LAYOUT *
*---------------------------------------------------------------------*
FORM init_layout.
* Mediante esta estructura podemos definir el formato de salida
gs_layout-zebra = 'X'.
gs_layout-f2code = '&ETA'.
gs_layout-detail_popup = 'X'.
ENDFORM.
*---------------------------------------------------------------------*
* FORM TOMA_DATOS *
*---------------------------------------------------------------------*
FORM toma_datos.
* Los datos deben guardarse en la tabla interna de salida
SELECT * FROM ekko
UP TO 100 ROWS
INTO TABLE gt_header.
SELECT * FROM ekpo
INTO TABLE gt_item
FOR ALL ENTRIES IN gt_header
WHERE ebeln = gt_header-ebeln.
ENDFORM. " TOMA_DATOS
*---------------------------------------------------------------------*
* FORM LISTADO *
*---------------------------------------------------------------------*
FORM listado.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
i_callback_program = g_repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
i_tabname_header = 'GT_HEADER'
i_tabname_item = 'GT_ITEM'
* I_STRUCTURE_NAME_HEADER =
* I_STRUCTURE_NAME_ITEM =
is_keyinfo = gs_key
* IS_PRINT =
* IS_REPREP_ID =
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab_header = gt_header[]
t_outtab_item = gt_item[]
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2 .
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " LISTADO
*---------------------------------------------------------------------*
* FORM INIT_KEY *
*---------------------------------------------------------------------*
FORM init_key.
* Relacion entre los campos de cabecera y los de posicion
gs_key-header01 = 'EBELN'.
gs_key-item01 = 'EBELN'.
ENDFORM. " INIT_KEY
ALV Simple
REPORT zalv_simple.
* Jorge Serra (AbapLife) http://abaplife.bitacoras.com
* Se trata de un pequeño ejemplo de listado ALV para aquellos que nunca
* han creado uno. Por supuesto, a los que ya sepáis algo de ALV, no
* creo que os sirva de mucho
* Propósito:
* ---------
* Voy mostrar un listado de posiciones de pedidos de compras
* Pasos esenciales (Buscar el simbolo '§')
* ----------------
* 1. Definición estructuras y tablas necesarias
* 2. Definimos la tabla con los datos de salida
* 3. Toma de datos
* 4. Definición estructura y formato de salida
* 5. Mostrar listado
*<-- § Paso 1. Definicion estructuras y tablas necesarias
* Type Pool donde vienen definidas todas las estructuras y tablas
TYPE-POOLS: slis.
* Catálogo de campos: contiene la descripción de los campos de salida
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
* Especificaciones de la disposición de la lista: descripción de la
* estructura de salida
gs_layout TYPE slis_layout_alv,
* Nombre del programa g_repid LIKE sy-repid.
*<-- § Paso 2. Definimos la tabla con los datos de salida
TYPES: BEGIN OF st_output.
INCLUDE STRUCTURE ekpo.
TYPES: END OF st_output.
DATA: gt_output TYPE STANDARD TABLE OF st_output WITH HEADER LINE.
INITIALIZATION. g_repid = sy-repid.
START-OF-SELECTION.
*<-- § Paso 3. Toma de datos
PERFORM toma_datos.
*<-- § Paso 4. Estructura y formato de salida
PERFORM init_fieldcat.
PERFORM init_layout.
*<-- § Paso 5. Mostrar listado
PERFORM listado.
*&&-----------------------------------------------------------------&&*
* SUBRUTINAS DEL PROGRAMA*
*&&-----------------------------------------------------------------&& *
*---------------------------------------------------------------------*
* FORM INIT_FIELDCAT *
*---------------------------------------------------------------------*
FORM init_fieldcat.
* Mediante esta tabla vamos a definir los campos que queremos mostrar
* en el listado de salida.
gt_fieldcat-fieldname = 'EBELN'.
gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'EBELP'.
gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'MATNR'. gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'WERKS'. gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'MENGE'. gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat. gt_fieldcat-fieldname = 'MEINS'.
gt_fieldcat-ref_tabname = 'EKPO'. APPEND gt_fieldcat. CLEAR gt_fieldcat.
ENDFORM.
*---------------------------------------------------------------------*
* FORM INIT_LAYOUT *
*---------------------------------------------------------------------*
FORM init_layout.
* Mediante esta estructura podemos definir el formato de salida
gs_layout-zebra = 'X'.
gs_layout-f2code = '&ETA'.
gs_layout-detail_popup = 'X'.
ENDFORM.
*---------------------------------------------------------------------*
* FORM TOMA_DATOS *
*---------------------------------------------------------------------*
FORM toma_datos.
* Los datos deben guardarse en la tabla interna de salida
SELECT * FROM ekpo UP TO 100 ROWS INTO TABLE gt_output.
ENDFORM. " TOMA_DATOS
*---------------------------------------------------------------------*
* FORM LISTADO *
*---------------------------------------------------------------------*
FORM listado.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = g_repid
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
TABLES t_outtab = gt_output
EXCEPTIONS program_error = 1
OTHERS = 2 .
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " LISTADO
* Jorge Serra (AbapLife) http://abaplife.bitacoras.com
* Se trata de un pequeño ejemplo de listado ALV para aquellos que nunca
* han creado uno. Por supuesto, a los que ya sepáis algo de ALV, no
* creo que os sirva de mucho
* Propósito:
* ---------
* Voy mostrar un listado de posiciones de pedidos de compras
* Pasos esenciales (Buscar el simbolo '§')
* ----------------
* 1. Definición estructuras y tablas necesarias
* 2. Definimos la tabla con los datos de salida
* 3. Toma de datos
* 4. Definición estructura y formato de salida
* 5. Mostrar listado
*<-- § Paso 1. Definicion estructuras y tablas necesarias
* Type Pool donde vienen definidas todas las estructuras y tablas
TYPE-POOLS: slis.
* Catálogo de campos: contiene la descripción de los campos de salida
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
* Especificaciones de la disposición de la lista: descripción de la
* estructura de salida
gs_layout TYPE slis_layout_alv,
* Nombre del programa g_repid LIKE sy-repid.
*<-- § Paso 2. Definimos la tabla con los datos de salida
TYPES: BEGIN OF st_output.
INCLUDE STRUCTURE ekpo.
TYPES: END OF st_output.
DATA: gt_output TYPE STANDARD TABLE OF st_output WITH HEADER LINE.
INITIALIZATION. g_repid = sy-repid.
START-OF-SELECTION.
*<-- § Paso 3. Toma de datos
PERFORM toma_datos.
*<-- § Paso 4. Estructura y formato de salida
PERFORM init_fieldcat.
PERFORM init_layout.
*<-- § Paso 5. Mostrar listado
PERFORM listado.
*&&-----------------------------------------------------------------&&*
* SUBRUTINAS DEL PROGRAMA*
*&&-----------------------------------------------------------------&& *
*---------------------------------------------------------------------*
* FORM INIT_FIELDCAT *
*---------------------------------------------------------------------*
FORM init_fieldcat.
* Mediante esta tabla vamos a definir los campos que queremos mostrar
* en el listado de salida.
gt_fieldcat-fieldname = 'EBELN'.
gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'EBELP'.
gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'MATNR'. gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'WERKS'. gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'MENGE'. gt_fieldcat-ref_tabname = 'EKPO'.
APPEND gt_fieldcat. CLEAR gt_fieldcat. gt_fieldcat-fieldname = 'MEINS'.
gt_fieldcat-ref_tabname = 'EKPO'. APPEND gt_fieldcat. CLEAR gt_fieldcat.
ENDFORM.
*---------------------------------------------------------------------*
* FORM INIT_LAYOUT *
*---------------------------------------------------------------------*
FORM init_layout.
* Mediante esta estructura podemos definir el formato de salida
gs_layout-zebra = 'X'.
gs_layout-f2code = '&ETA'.
gs_layout-detail_popup = 'X'.
ENDFORM.
*---------------------------------------------------------------------*
* FORM TOMA_DATOS *
*---------------------------------------------------------------------*
FORM toma_datos.
* Los datos deben guardarse en la tabla interna de salida
SELECT * FROM ekpo UP TO 100 ROWS INTO TABLE gt_output.
ENDFORM. " TOMA_DATOS
*---------------------------------------------------------------------*
* FORM LISTADO *
*---------------------------------------------------------------------*
FORM listado.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = g_repid
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
TABLES t_outtab = gt_output
EXCEPTIONS program_error = 1
OTHERS = 2 .
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " LISTADO
lunes, 28 de mayo de 2007
Segunda Parte
Curioso que a un informático le roben sus cuentas de yahoo, hotmail y gmail. Para acabar el chiste, me robaron mis blogs (este, y otro que tenía más personal). El lado bueno, si es que lo hay, es que puedo crearlos de nuevo (ya que los han borrado), aunque eso sí, desde cero. Qué se le va a hacer, como decimos en España, más se perdió en Cuba.
Las ganas que tengo de ponerme a escribir entradas son mínimas, pero por lo menos tengo mis blogs. Vacíos, eso sí, pero los tengo. A ver qué puedo hacer...
Suscribirse a:
Entradas (Atom)