2007 Dec 27 8:40 PM
Hello friends!
I have a problem with my program, it's about showing an internal table in an alv. I don't know why this message when checking sintax appears:
"TI_HUERFANOS" is not type-compatible with formal parameter
"IT_OUTTAB".
It's suppose that it_outtab accepts internal table, wright?
Would you please help me telling me what's wrong ?
And what should i do to fix it.
Any suggestion about code is wellcome.
Thanks!
My code:
REPORT ZFBUS061 .
*******TABLAS
TABLES: ANLA,
ANLZ.
****DATA
DATA: ok_code LIKE sy-ucomm.
Declara las variables de referencia a los objetos ALV Grid y su
*contenedor
DATA:
go_grid TYPE REF TO cl_gui_alv_grid,
go_custom_container TYPE REF TO cl_gui_custom_container.
DATA: padre_aux(12) type C.
data: existe_aux(9) type C.
DATA: BEGIN OF ti_assets occurs 0,
anln1 like anla-anln1,
anln2 like anla-anln2,
bukrs like anla-bukrs,
txt50 like anla-txt50, "descripcion
gsber like anlz-gsber,
ernam like anla-ernam,
erdat like anla-erdat,
aenam like anla-aenam,
aedat like anla-aedat,
deakt like anla-deakt, "deactivation date
ZUJHR like anla-ZUJHR, "Fiscal year in which first acquisition
END OF ti_assets.
DATA: BEGIN OF ti_hijos occurs 0,
anln1 like anla-anln1,
anln2 like anla-anln2,
bukrs like anla-bukrs,
txt50 like anla-txt50, "descripcion
gsber like anlz-gsber,
ernam like anla-ernam,
erdat like anla-erdat,
aenam like anla-aenam,
aedat like anla-aedat,
deakt like anla-deakt, "deactivation date
ZUJHR like anla-ZUJHR, "Fiscal year in which first acquisition
padre(12) type C,
END OF ti_hijos.
DATA: BEGIN OF ti_huerfanos OCCURS 0,
anln1 like anla-anln1,
anln2 like anla-anln2,
bukrs like anla-bukrs,
txt50 like anla-txt50, "descripcion
gsber like anlz-gsber,
ernam like anla-ernam,
erdat like anla-erdat,
aenam like anla-aenam,
aedat like anla-aedat,
deakt like anla-deakt, "deactivation date
ZUJHR like anla-ZUJHR, "Fiscal year in which first acquisition
padre like anla-anln1,
existe(9) type C,
END OF ti_huerfanos.
****SELECTION SCREEN
selection-screen begin of block bloque_datos .
select-options: S_BUKRS for ANLA-BUKRS.
*select-options: S_ANLN1 for ANLA-ANLN1.
*No tomamos en cuenta anln1 puesto que es un reporte de hijos sin padre
selection-screen end of block bloque_datos.
start-of-selection.
perform reporte_huerfanos.
SET SCREEN '100'.
end-of-selection.
&----
*& Form reporte_huerfanos
&----
text
----
--> p1 text
<-- p2 text
----
FORM reporte_huerfanos.
SELECT anlaanln1 anlaanln2 anlabukrs anlatxt50 anlz~gsber
anlaernam anlaerdat anla~aenam
anlaaedat anladeakt anla~ZUJHR
INTO CORRESPONDING FIELDS OF TABLE ti_assets
FROM
( anla inner join anlz on anlaanln1 = anlzanln1 and
anlaanln2 = anlzanln2 and anlabukrs = anlzbukrs
).
LOOP AT ti_assets.
if ti_assets-anln1 CP '*8+++++++' and ti_assets-bukrs in S_BUKRS.
move-corresponding ti_assets to ti_hijos.
padre_aux = ti_hijos-anln1.
move '0' to padre_aux+4(1).
move padre_aux to ti_hijos-padre.
append ti_hijos.
endif.
ENDLOOP.
existe_aux = 'NO EXISTE'.
loop at ti_hijos.
READ TABLE ti_assets with key anln1 = ti_hijos-padre bukrs =
ti_hijos-bukrs gsber = ti_hijos-gsber binary search.
if sy-subrc <> 0.
move ti_hijos-anln1 to ti_huerfanos-anln1.
move ti_hijos-anln2 to ti_huerfanos-anln2.
move ti_hijos-bukrs to ti_huerfanos-bukrs.
move ti_hijos-txt50 to ti_huerfanos-txt50.
move ti_hijos-gsber to ti_huerfanos-gsber.
move ti_hijos-ernam to ti_huerfanos-ernam.
move ti_hijos-erdat to ti_huerfanos-erdat.
move ti_hijos-aenam to ti_huerfanos-aenam.
move ti_hijos-aedat to ti_huerfanos-aedat.
move ti_hijos-deakt to ti_huerfanos-deakt.
move ti_hijos-ZUJHR to ti_huerfanos-ZUJHR.
move ti_hijos-padre to ti_huerfanos-PADRE.
move existe_aux to ti_huerfanos-existe.
append ti_huerfanos.
clear ti_huerfanos.
endif.
endloop.
ENDFORM. " reporte_huerfanos
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
Crea los objetos
IF go_custom_container IS INITIAL.
CREATE OBJECT go_custom_container
EXPORTING container_name = 'ALV_CONTAINER'.
CREATE OBJECT go_grid
EXPORTING
i_parent = go_custom_container.
PERFORM load_data_into_grid.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
MODULE USER_COMMAND_0100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Form load_data_into_grid
&----
text
----
--> p1 text
<-- p2 text
----
FORM load_data_into_grid.
Carga los datos en el grid y los muestra por pantalla
CALL METHOD go_grid->set_table_for_first_display
EXPORTING i_structure_name = 'ti_huerfanos'
CHANGING it_outtab = ti_huerfanos.
ENDFORM. " load_data_into_grid
Hello friends!
I have a problem with my program, it's about showing an internal table in an alv. I don't know why this message when checking sintax appears:
"TI_HUERFANOS" is not type-compatible with formal parameter
"IT_OUTTAB".
It's suppose that it_outtab accepts internal table, wright?
Would you please help me telling me what's wrong ?
And what should i do to fix it.
Any suggestion about code is wellcome.
Thanks!
My code:
REPORT ZFBUS061 .
*******TABLAS
TABLES: ANLA,
ANLZ.
****DATA
DATA: ok_code LIKE sy-ucomm.
Declara las variables de referencia a los objetos ALV Grid y su
*contenedor
DATA:
go_grid TYPE REF TO cl_gui_alv_grid,
go_custom_container TYPE REF TO cl_gui_custom_container.
DATA: padre_aux(12) type C.
data: existe_aux(9) type C.
DATA: BEGIN OF ti_assets occurs 0,
anln1 like anla-anln1,
anln2 like anla-anln2,
bukrs like anla-bukrs,
txt50 like anla-txt50, "descripcion
gsber like anlz-gsber,
ernam like anla-ernam,
erdat like anla-erdat,
aenam like anla-aenam,
aedat like anla-aedat,
deakt like anla-deakt, "deactivation date
ZUJHR like anla-ZUJHR, "Fiscal year in which first acquisition
END OF ti_assets.
DATA: BEGIN OF ti_hijos occurs 0,
anln1 like anla-anln1,
anln2 like anla-anln2,
bukrs like anla-bukrs,
txt50 like anla-txt50, "descripcion
gsber like anlz-gsber,
ernam like anla-ernam,
erdat like anla-erdat,
aenam like anla-aenam,
aedat like anla-aedat,
deakt like anla-deakt, "deactivation date
ZUJHR like anla-ZUJHR, "Fiscal year in which first acquisition
padre(12) type C,
END OF ti_hijos.
DATA: BEGIN OF ti_huerfanos OCCURS 0,
anln1 like anla-anln1,
anln2 like anla-anln2,
bukrs like anla-bukrs,
txt50 like anla-txt50, "descripcion
gsber like anlz-gsber,
ernam like anla-ernam,
erdat like anla-erdat,
aenam like anla-aenam,
aedat like anla-aedat,
deakt like anla-deakt, "deactivation date
ZUJHR like anla-ZUJHR, "Fiscal year in which first acquisition
padre like anla-anln1,
existe(9) type C,
END OF ti_huerfanos.
****SELECTION SCREEN
selection-screen begin of block bloque_datos .
select-options: S_BUKRS for ANLA-BUKRS.
*select-options: S_ANLN1 for ANLA-ANLN1.
*No tomamos en cuenta anln1 puesto que es un reporte de hijos sin padre
selection-screen end of block bloque_datos.
start-of-selection.
perform reporte_huerfanos.
SET SCREEN '100'.
end-of-selection.
&----
*& Form reporte_huerfanos
&----
text
----
--> p1 text
<-- p2 text
----
FORM reporte_huerfanos.
SELECT anlaanln1 anlaanln2 anlabukrs anlatxt50 anlz~gsber
anlaernam anlaerdat anla~aenam
anlaaedat anladeakt anla~ZUJHR
INTO CORRESPONDING FIELDS OF TABLE ti_assets
FROM
( anla inner join anlz on anlaanln1 = anlzanln1 and
anlaanln2 = anlzanln2 and anlabukrs = anlzbukrs
).
LOOP AT ti_assets.
if ti_assets-anln1 CP '*8+++++++' and ti_assets-bukrs in S_BUKRS.
move-corresponding ti_assets to ti_hijos.
padre_aux = ti_hijos-anln1.
move '0' to padre_aux+4(1).
move padre_aux to ti_hijos-padre.
append ti_hijos.
endif.
ENDLOOP.
existe_aux = 'NO EXISTE'.
loop at ti_hijos.
READ TABLE ti_assets with key anln1 = ti_hijos-padre bukrs =
ti_hijos-bukrs gsber = ti_hijos-gsber binary search.
if sy-subrc <> 0.
move ti_hijos-anln1 to ti_huerfanos-anln1.
move ti_hijos-anln2 to ti_huerfanos-anln2.
move ti_hijos-bukrs to ti_huerfanos-bukrs.
move ti_hijos-txt50 to ti_huerfanos-txt50.
move ti_hijos-gsber to ti_huerfanos-gsber.
move ti_hijos-ernam to ti_huerfanos-ernam.
move ti_hijos-erdat to ti_huerfanos-erdat.
move ti_hijos-aenam to ti_huerfanos-aenam.
move ti_hijos-aedat to ti_huerfanos-aedat.
move ti_hijos-deakt to ti_huerfanos-deakt.
move ti_hijos-ZUJHR to ti_huerfanos-ZUJHR.
move ti_hijos-padre to ti_huerfanos-PADRE.
move existe_aux to ti_huerfanos-existe.
append ti_huerfanos.
clear ti_huerfanos.
endif.
endloop.
ENDFORM. " reporte_huerfanos
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
Crea los objetos
IF go_custom_container IS INITIAL.
CREATE OBJECT go_custom_container
EXPORTING container_name = 'ALV_CONTAINER'.
CREATE OBJECT go_grid
EXPORTING
i_parent = go_custom_container.
PERFORM load_data_into_grid.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
MODULE USER_COMMAND_0100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Form load_data_into_grid
&----
text
----
--> p1 text
<-- p2 text
----
FORM load_data_into_grid.
Carga los datos en el grid y los muestra por pantalla
CALL METHOD go_grid->set_table_for_first_display
EXPORTING i_structure_name = 'ti_huerfanos'
CHANGING it_outtab = ti_huerfanos.
ENDFORM. " load_data_into_grid
2007 Dec 27 10:15 PM
Hi Lidya,
Your problem is part of a bigger problem.
First of all, stop using obsolete statements in the context of ABAP Objects e.g. defining internal tables using BEGIN OF ... OCCURRS 0, TABLES statement etc.
Now you are trying to use ABAP Objects method and your internal table is defined in an obsolete fashion. When you define an internal table using BEGIN OF... a header line is created by default and it has the same name as the internal table.
First define a type itab_type using TYPES statement:
TYPES: BEGIN OF ty_huerfanos,
anln1 like anla-anln1,
anln2 like anla-anln2,
bukrs like anla-bukrs,
txt50 like anla-txt50, "descripcion
gsber like anlz-gsber,
ernam like anla-ernam,
erdat like anla-erdat,
aenam like anla-aenam,
aedat like anla-aedat,
deakt like anla-deakt, "deactivation date
ZUJHR like anla-ZUJHR, "Fiscal year in which first acquisition
padre like anla-anln1,
existe(9) type C,
END OF ty_huerfanos.
Then use the following statement to define the internal table:
DATA ti_huerfanos TYPE STANDARD TABLE OF ty_huerfanos.
Then call the method as follows:
CALL METHOD go_grid->set_table_for_first_display
EXPORTING i_structure_name = 'TI_HUERFANOS'
CHANGING it_outtab = ti_huerfanos.
This should work.
Earlier, you were passing ti_huerfanos, which was a structure (the header line) and not a table, to it_outab which expects a table. Now, with the same reference ti_huerfanos, you are referring to the table body as there is no header line.
Also, whenever passing a string to a method, use UPPERCASE.
Hope this helps.
Thanks
Sanjeev
2007 Dec 27 11:39 PM
Now, i have another problem. How to add those lines to the new internal table (ti_huerfanos)...is it with "append" ?....and also, i think i need to build a field catalog. Do you have an easy sample program that fills an alv from a defined internal table with different structure from any table declared in data dictionary?
Thanks for your answer
2007 Dec 28 12:39 AM
Hi,
Yes you need to use APPEND to add the lines to internal table.
And look at the sample programs starting with SALV_*.
Regards,
Atish
2007 Dec 28 10:30 PM
Hello Lidya
The improvements by Sanjeev are quite reasonable except that IMPORTING parameter I_STRUCTURE_NAME (of method SET_TABLE_FOR_FIRST_DISPLAY) expects a DDIC structure and not a data type definition within your report.
Since almost all your required fields are derived from table ANLA simply use the automatic way to generate the fieldcatalog:
DATA:
gt_fcat TYPE lvc_t_fcat.
FORM build_fieldcatalog.
define local data
DATA: ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_BUFFER_ACTIVE =
i_structure_name = 'ANLA'
I_CLIENT_NEVER_DISPLAY = 'X'
I_BYPASSING_BUFFER =
I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT gt_fcat INTO ls_fcat.
CASE ls_fcat-fieldname.
WHEN 'ANLN1' OR
'ANLN2' OR
'...'.
WHEN others.
ls_fcat-no_out = 'X'. " not displayed but available in layout OR:
ls_fcat-tech = 'X'. " not available at all to user
ENDCASE.
MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
ENDLOOP.
ENDFORM.
The missing field EXISTE you have to define and add to the fieldcatalog.
When calling method SET_TABLE_FOR_FIRST_DISPLAY do not provide any value for I_STRUCTURE_NAME but set the fieldcatalog (IT_FIELDCATALOG = gt_fcat).
Regards
Uwe
2007 Dec 28 3:21 PM
Lidya,
Now you need to declare a work area for the internal table as the internal table was declared without header line:
DATA ti_huerfanos TYPE ty_huerfanos.
Use this work area to append line to the internal table.
Hope this helps.
Thanks
Sanjeev
2007 Dec 28 3:45 PM
Hello,
Ohhh, now, at runtime it sends me an error about fieldcatalog not found.
Even i have change my program, declaring my internal tables just with the structure of ANLA (transparent table), and the same error about fieldcatalog.
I'll check the code salv*
thanks
2008 Jul 21 10:41 PM