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

ALV Grid Traffic control Example program implemented with function modules

Former Member
0 Likes
528

Hi Friends,

Can any one please give me ALV Grid control traffic lights example program implented using function modules instead of OOP ALV. It is very urgent,

Thanks in advance,

Santosh Kumar.

3 REPLIES 3
Read only

Former Member
Read only

marius_greeff
Active Participant
0 Likes
428

Hi Santosh,

In your ALV table/structure define field 1 char like 'rob'.

  • define a single character column as a traffic light

  • '1' = red, '2' = yellow, 3 = 'Green'

alv_layoutcat-lights_fieldname = 'ROB'.

it_list_data-rob = 1.

APPEND it_list_data.

it_list_data-rob = 2.

APPEND it_list_data.

it_list_data-rob = 3.

APPEND it_list_data.

ALF Function module something like this then

  • Call ABAP/4 List Viewer

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = 'ZREPORT'

is_layout = alv_layoutcat

it_fieldcat = it_fieldcat

TABLES

t_outtab = it_list_data.

Regards,

Marius

Read only

Former Member
0 Likes
428

Hi Santosh ,

Here is a sampla code for the same

TYPE-POOLS : SLIS.

DATA : BEGIN OF IT_1 OCCURS 0 ,
           MATNR TYPE matnr ,
           FLAG TYPE C ,  " added for the traffic control
       END OF IT_1.

SELECT MATNR INTO TABLE IT_1 " Select Data
UP TO 10 ROWS
FROM MARA.

DATA : CATALOG TYPE SLIS_T_FIELDCAT_ALV ,
       WA_CATALOG TYPE SLIS_FIELDCAT_ALV ,
       LAYOUT TYPE SLIS_LAYOUT_ALV .
*" create catalog
WA_CATALOG-FIELDNAME = 'FLAG'.
WA_CATALOG-TABNAME = 'IT_1'.
APPEND WA_CATALOG TO CATALOG.

WA_CATALOG-FIELDNAME = 'MATNR'.
WA_CATALOG-TABNAME = 'IT_1'.
APPEND WA_CATALOG TO CATALOG.
DATA : FLAG_T TYPE I.
*"assign value to traffic signal 
LOOP AT IT_1.
FLAG_T = SY-TABIX MOD 2.
IF FLAG_T = 0.
IT_1-FLAG = '1'.
ELSE.
IT_1-FLAG = '2'.
ENDIF.
MODIFY IT_1.
ENDLOOP.
*"specify the traffic signal field in the layout
LAYOUT-LIGHTS_FIELDNAME = 'FLAG'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
 EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                =
*   I_BUFFER_ACTIVE                   = ' '
*   I_CALLBACK_PROGRAM                = ' '
*   I_CALLBACK_PF_STATUS_SET          = ' '
*   I_CALLBACK_USER_COMMAND           = ' '
*   I_CALLBACK_TOP_OF_PAGE            = ' '
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   I_STRUCTURE_NAME                  =
*   I_BACKGROUND_ID                   = ' '
*   I_GRID_TITLE                      =
*   I_GRID_SETTINGS                   =
   IS_LAYOUT                         = LAYOUT
   IT_FIELDCAT                       = CATALOG
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
*   I_SAVE                            = ' '
*   IS_VARIANT                        =
*   IT_EVENTS                         =
*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_ADD_FIELDCAT                   =
*   IT_HYPERLINK                      =
*   I_HTML_HEIGHT_TOP                 =
*   I_HTML_HEIGHT_END                 =
*   IT_EXCEPT_QINFO                   =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
  TABLES
    T_OUTTAB                          = IT_1
* 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.

so rem all you need to do is add a feild in internal table for the traffic signal , assign values 0 , 1, 2 to it and last specify the name of this feild in the layout.

Regards

Arun