Can someone explain the importance of having the code below? I'm new to ABAP and currently trying to create an ALV in a docking container. Thanks.
* Field Catalog
wa_fieldcat TYPE lvc_s_fcat.
Can someone explain the importance of having the code below? I'm new to ABAP and currently trying to create an ALV in a docking container. Thanks.
* Field Catalog
wa_fieldcat TYPE lvc_s_fcat.
The code in the example has this subroutine:
*&--------------------------------------------------------------*
*& Form FILL_FIELDCAT *
*&--------------------------------------------------------------*
* To Fill the Field Catalog *
*---------------------------------------------------------------*
* Three Parameters are passed *
* pv_field TYPE any for Field *
* pv_tabname TYPE any for Table Name *
* pv_coltext TYPE any for Header Text *
*---------------------------------------------------------------*
FORM fill_fieldcat USING pv_field TYPE any
pv_tabname TYPE any
pv_coltext TYPE any .
wa_fieldcat-fieldname = pv_field.
wa_fieldcat-tabname = pv_tabname.
wa_fieldcat-coltext = pv_coltext.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " FILL_FIELDCAT
The structure wa_fieldcat
is used as a container for the information that is about to be added to t_fieldcat
.
Since pv_field
, pv_tabname
, and pv_coltext
are three disjoint variables, you cannot APPEND
them to t_fieldcat
before putting them in a central, unified structure.
That being said, I see no reason why the variable declaration you pointed out couldn't be placed inside of the subroutine FILL_FIELDCAT
rather than being a global variable. Keeping the scope of variables only as large as they need to be is good coding practice.