Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

multiple tables in ALV

Former Member
0 Kudos

Hi,

I want to print the report in ALV format. Here i am fetching the data from 4 database tables, and passing in one internal table. I want to print the report using that one internal table. But the problem is every time it is giving me an error as the internal table is not in the outtab format.

I tried using the same program to print with one DB table and one ITab, it works.

The report is printing data in normal report form also.

How to call the same report using ALV grid.

pls help.

simi

10 REPLIES 10

former_member183804
Active Contributor
0 Kudos

Hello Simi,

it seems your data table has a differnt structure like the alv field catalogue. This should be not to tricky if you already have an DDIC type of your joined table. The name of this structure must somehow passed to the ALV functionality.

Of course that depends on the concrete ALV function module or ALV class. In case you need more help please provide some information on this.

Best Regards

Klaus

0 Kudos

Hi,

Thanks for your prompt reply. This is the sampe code that i am using.

DATA: OK_CODE LIKE SY-UCOMM.

TYPES: BEGIN OF ISQALS1,

PRUEFLOS LIKE QALS-PRUEFLOS,

MATNR LIKE QALS-MATNR,

REVLV LIKE QALS-REVLV,

KTEXTMAT LIKE QALS-KTEXTMAT,

EBELN LIKE QALS-EBELN,

MBLNR LIKE QALS-MBLNR,

LOSMENGE LIKE QALS-LOSMENGE,

MENGENEINH LIKE QALS-MENGENEINH,

PASTRTERM LIKE QALS-PASTRTERM,

UMDAT LIKE MDTB-UMDAT,

MNG01 LIKE MDTB-MNG01,

DELNR LIKE MDTB-DELNR,

STPRS LIKE MBEW-STPRS,

TVALUE LIKE MBEW-STPRS.

TYPES: END OF ISQALS1.

DATA: ITQALS1 TYPE TABLE OF ISQALS1 WITH HEADER LINE,

WAQALS1 TYPE ISQALS1.

G_CONTAINER TYPE SCRFNAME VALUE 'grid_CONT1',

GRID1 TYPE REF TO CL_GUI_ALV_GRID,

G_CUSTOM_CONTAINER TYPE REF TO

CL_GUI_CUSTOM_CONTAINER.

***********

whole set of code, now data is in ITQALS1.

********

MODULE PBO OUTPUT.

SET PF-STATUS 'MAIN100'.

IF G_CUSTOM_CONTAINER IS INITIAL.

CREATE OBJECT G_CUSTOM_CONTAINER

EXPORTING CONTAINER_NAME = G_CONTAINER.

CREATE OBJECT GRID1

EXPORTING I_PARENT = G_CUSTOM_CONTAINER.

CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING I_STRUCTURE_NAME = 'ISQALS1'

CHANGING IT_OUTTAB = ITQALS1.

ENDIF.

ENDMODULE.

pls suggest what can be done.

Thanks,

Simi

0 Kudos

Hello Simi,

by sorrow the ALV cannot handle local types easily, as the structure type 'ISQALS1' defined in the report. The easiest way would be to move the structure definition to the DDIC. A more elegant way may be the use of the it_FieldCatalog argument, where you can give a program driven description of the columns. You should check the result of FuBa 'LVC_FIELDCATALOG_MERGE' on a DDIC structure first.

Best Regards

Klaus

PS: you can use the following sequences to mark coding ( without the extra blanks in the brackets)


[code ]
  write:  'bla'.
[/code ]

0 Kudos

Hi,

pls suggest how can i assign an internal table to DDIC. I heard it can be done using table types, but i never used it.

Thanks

simi.

0 Kudos

Hi,

pls suggest how can i assign an internal table to DDIC. I heard it can be done using table types, but i never used it.

Thanks

simi.

0 Kudos

Hi Simi

It is vague for me what you mean by assigning an internal table to DDIC.

You can define table types in DDIC via the transaction SE11. Use 'Data Element' option and choose 'Create'. It will ask you what to create. Choose 'Table Type'. To create a table type, you should enter a row type and optionally you can specify the key to be handled with the table type.

In your programs, you can simply refer to a table type with the <b>TYPE</b> keyword.

e.g.

*--Table type: ZTT_MARA

*-An internal table without header line
DATA lt_itab TYPE ztt_mara .

*-Another internal table with a header line
DATA lt_itab2 TYPE ztt_mara WITH HEADER LINE .

Hope this can be helpful

Regards

*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

-


<u>Correction:</u>

"Data Elemet" --> "Data Type"

Message was edited by: Serdar Simsekler

0 Kudos

Hi,

In the call method, pass p_output = ITQALS1

and p_fieldcat as i_fieldcat TYPE lvc_t_fcat.

w_layout TYPE lvc_s_layo ,

w_variant TYPE disvariant.

c_a = 'A'

<b>I_STRUCTURE_NAME type DD02L-TABNAME optional</b>

CALL METHOD o_alvgrid->set_table_for_first_display

EXPORTING

is_variant = w_variant

i_save = c_a

is_layout = w_layout

CHANGING

it_outtab = p_output[]

it_fieldcatalog = p_fieldcat[]

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE i001 WITH Error in ALV report display.

LEAVE LIST-PROCESSING.

ENDIF.

Recheck with the structure name in the exporting part.

While defining an output structure, GOTO SE11 select option Data type "ZZ_OUTPUT" > create, then define all the fields u want in the output table as a structure.

Then u can define the <b>i_output TYPE STANDARD TABLE OF ZZ_OUTPUT.</b>

w_output TYPE ZZ_OUTPUT.

Also u can pass the structure for creating a field catalog.

<b>* Building the field catalog</b>

PERFORM f9001_build_field_cat TABLES i_fieldcat

USING 'ZZ_OUTPUT'.

FORM f9001_build_field_cat TABLES p_fieldcat STRUCTURE lvc_s_fcat

USING value(p_structure).

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = p_structure

CHANGING

ct_fieldcat = p_fieldcat[]

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE i000 WITH Error in ALV field catalogue creation.

LEAVE LIST-PROCESSING.

ENDIF.

ENDFORM. " f9001_build_field_cat

Try this out.

Thanks & Regards,

Judith.

ssimsekler
Active Contributor
0 Kudos

Hi Simi

If you want to use the class version of the ALV Grid control, you can make use of the tutorial <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/an%20easy%20reference%20for%20alv%20grid%20control.pdf">"An Easy Reference for ALV Grid Control"</a>.

Regards

*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

0 Kudos

Hi Simi

Just refer to the tutorial

Regards

*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

0 Kudos

Hi,

The documents is very useful, thanks for the link.

simi