Application Development and Automation 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: 
Read only

Internal table structure/ALV Problem

Former Member
0 Likes
727

Hello, Im new to ABAP (third day) so careful explination would be greatly appreciated.

So I'm trying to display two tables together that I've joined into an ALV. Im creating an internal table to hold the information that I want to display from the join I created.

When I call my alv set_table_for_first_display I need to specify i_structure_name. Right now im using the name of my internal table, but I dont know if im doing this right. When I run my program i get an error NO_FIELDCATALOG_AVAILABLE. After searching many other posts i think its because my internal table doesnt have a structure, but im not sure.

Here is my code, thanks in advance!:

CLASS application DEFINITION.

PUBLIC SECTION.

METHODS: constructor,

read_data IMPORTING l_DAUAT TYPE AFPO-DAUAT,

fill_list.

PRIVATE SECTION.

DATA: BEGIN OF tbljoin,

AFPO_AUFNR TYPE AFPO-AUFNR,

AFPO_DAUAT TYPE AFPO-DAUAT,

AFPO_DGLTP TYPE AFPO-DGLTP,

AFPO_DGLTS TYPE AFPO-DGLTS,

AFPO_OBJNP TYPE AFPO-OBJNP,

AFPO_XLOEK TYPE AFPO-XLOEK,

AFKO_GLTRP TYPE AFKO-GLTRP,

END OF tbljoin,

  • afpo_tab TYPE TABLE OF afpo,

join_tab LIKE STANDARD TABLE OF TBLJOIN,

container TYPE REF TO cl_gui_custom_container,

alv_list TYPE REF TO cl_gui_alv_grid.

ENDCLASS.

*Class Implementations

CLASS application IMPLEMENTATION.

METHOD read_data.

Select: POAUFNR PODAUAT PODGLTP PODGLTS POOBJNP POXLOEK

KO~GLTRP

FROM afpo as po INNER JOIN AFKO as KO

on POAUFNR = KOAUFNR

INTO TABLE join_tab

where dauat = l_dauat.

ENDMETHOD.

METHOD constructor.

CREATE OBJECT container

EXPORTING container_name = 'LIST_AREA'.

CREATE OBJECT alv_list

EXPORTING i_parent = container.

CALL METHOD alv_list->set_table_for_first_display

EXPORTING i_structure_name = 'JOINTAB'

CHANGING it_outtab = join_tab.

ENDMETHOD.

METHOD fill_list.

CALL METHOD alv_list->refresh_table_display.

ENDMETHOD.

ENDCLASS.

DATA: object_ref TYPE REF TO application.

*Screens Interfaces

TABLES: AFPO, AFKO.

******************************************************************

*Processing Blocks called by the Runtime Environment *

******************************************************************

*Event Block START-OF-SELECTION

START-OF-SELECTION.

CREATE OBJECT object_ref.

CALL SCREEN 100.

*Dialog Module PBO

MODULE status_0100 OUTPUT.

SET PF-STATUS 'SCREEN_100'.

CALL METHOD object_ref->fill_list.

ENDMODULE.

*Dialog Module PAI

MODULE user_command_0100 INPUT.

IF sy-ucomm = 'BACK' OR

sy-ucomm = 'EXIT' OR

sy-ucomm = 'CANCEL'.

LEAVE PROGRAM.

ELSE.

CALL METHOD object_ref->read_data

EXPORTING l_dauat = afpo-dauat.

ENDIF.

ENDMODULE.

5 REPLIES 5
Read only

former_member186741
Active Contributor
0 Likes
679

not sure, but you culd try TBLJOIN as the structure name.

Read only

venkat_o
Active Contributor
0 Likes
679

Hi Nathan,

Fieldcatalog has important role in ALV .U missed that one .Go through these steps.

<b>1</b>.

Define ur Fieldcatalog table like this .

DATA:

i_field TYPE lvc_t_fcat,

w_field TYPE lvc_s_fcat.

<b>2</b>.

Build like this

FORM build_fieldcatalog_tab .

DATA :pos TYPE i VALUE 1.

CLEAR: w_field,i_field[],pos.

w_field-col_pos = pos + 1.

w_field-fieldname = 'MATNR' .

w_field-tabname = 'I_MARC' .

w_field-scrtext_m = 'Material' .

APPEND w_field TO i_field.

CLEAR w_field.

w_field-col_pos = pos + 1.

w_field-fieldname = 'WERKS' .

w_field-tabname = 'I_MARC' .

w_field-scrtext_m = 'Plant' .

APPEND w_field TO i_field.

CLEAR w_field.

ENDFORM.

<b>3</b>.

Pass through this method

<b> CALL METHOD alv_grid->set_table_for_first_display</b>

EXPORTING

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • I_CONSISTENCY_CHECK =

  • i_structure_name = 'MARA'

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT = 'X'

is_layout = w_layout

  • IS_PRINT = w_print

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

CHANGING

<b> it_outtab = i_marc</b>

<b> it_fieldcatalog = i_field</b>

  • IT_SORT =

  • IT_FILTER =

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4

<b>4</b>.

You should remove

<b>i_structure_name = 'JOINTAB'</b>

y should use this when u pass single table data display.

I hope that it helps u .

<b>Thanks,

Venkat.O</b>

Read only

Former Member
0 Likes
679

Hey Venkat, thanks for the response it was helpful. I have one thing in your code that I dont understand. Where are you getting w_layout from in is_layout = w_layout?

Also, when should I call build_field_catalog_tab? Right after I declare my ALV grid?

Thanks so much! You're very helpful!

Read only

Former Member
0 Likes
679

Hi,

layout is used to pass to get additional features like save variant/change/select variant and colour fields, dropdownfields,styles,Buttons etc.

and also if you have fields from different tables then you can create the ZSTRUCTURE in SE11 and use it for building the fieldcat using the FM <b>LVC_FIELDCATALOG_MERGE</b> or you can do manually as suggested by Venkat.

Regards

vijay

Read only

venkat_o
Active Contributor
0 Likes
679

Hi Nathan,

<b>1</b>.Layout

You change the display of your list using layouts.

<b>2</b>.

Anything u pass through <b>CALL METHOD alv_grid->set_table_for_first_display</b> should be build before that .

<b>Thanks,

Venkat.O</b>