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: 

threshold value with LED

vijy_mukunthan
Active Contributor
0 Kudos

hi friends

Can any one say how to get the led with green light or red light according to the condition. That is am doing a report program for the workflow tracking wheather the request is approved or rejected. If approved it should be in green colour led if its rejected it should be in Red color LED. Can any one explain me the piece of code. Dont give the example of SFLIGHT . I have already analysed that. But i want some thing different.

Regards

vijay

12 REPLIES 12

uwe_schieferstein
Active Contributor
0 Kudos

Hello Vijay

The crucial parts of sample report ZUS_SDN_ALVGRID_LED are the type definition of GT_OUTTAB and the routines SET_LAYOUT_AND_VARIANT and CHECK_CONDITION.


*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_ALVGRID_LED
*&
*&---------------------------------------------------------------------*
*& Thread: threshold value with LED
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1054842"></a>
*&---------------------------------------------------------------------*
*& Screen '0100': ok-code -> GD_OKCODE, no screen elements:
**    PROCESS BEFORE OUTPUT.
**      MODULE STATUS_0100.
***
**    PROCESS AFTER INPUT.
**      MODULE USER_COMMAND_0100.
*&---------------------------------------------------------------------*

REPORT  zus_sdn_alvgrid_led.

TYPE-POOLS: abap.


TYPES: BEGIN OF ty_s_outtab.
TYPES: exception   TYPE lvc_exled.
INCLUDE TYPE knb1.
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE OF ty_s_outtab
                   WITH DEFAULT KEY.

DATA:
  gd_repid         TYPE syrepid,
  gd_okcode        TYPE ui_func,
*
  gt_fcat          TYPE lvc_t_fcat,
  gs_layout        TYPE lvc_s_layo,
  gs_variant       TYPE disvariant,
  go_docking       TYPE REF TO cl_gui_docking_container,
  go_grid          TYPE REF TO cl_gui_alv_grid.


DATA:
  gt_outtab        TYPE ty_t_outtab.


PARAMETERS:
  p_bukrs      TYPE bukrs  DEFAULT '2000'  OBLIGATORY.






START-OF-SELECTION.

  SELECT * FROM  knb1 INTO CORRESPONDING FIELDS OF TABLE gt_outtab
         WHERE  bukrs  = p_bukrs.

  PERFORM init_controls.

  PERFORM check_condition.

* Display data
  CALL METHOD go_grid->set_table_for_first_display
    EXPORTING
      is_layout       = gs_layout
      is_variant      = gs_variant
      i_save          = 'A'
    CHANGING
      it_outtab       = gt_outtab
      it_fieldcatalog = gt_fcat
    EXCEPTIONS
      OTHERS          = 4.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.



* Link the docking container to the target dynpro
  gd_repid = syst-repid.
  CALL METHOD go_docking->link
    EXPORTING
      repid                       = gd_repid
      dynnr                       = '0100'
*      CONTAINER                   =
    EXCEPTIONS
      OTHERS                      = 4.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


* ok-code field = GD_OKCODE
  CALL SCREEN '0100'.


END-OF-SELECTION.

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STATUS_0100'.
*  SET TITLEBAR 'xxx'.

**      CALL METHOD go_grid1->refresh_table_display
***        EXPORTING
***          IS_STABLE      =
***          I_SOFT_REFRESH =
**        EXCEPTIONS
**          FINISHED       = 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.

ENDMODULE.                 " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  CASE gd_okcode.
    WHEN 'BACK' OR
         'END'  OR
         'CANC'.
      SET SCREEN 0. LEAVE SCREEN.



    WHEN OTHERS.
      CALL METHOD go_grid->refresh_table_display
*        EXPORTING
*          IS_STABLE      =
*          I_SOFT_REFRESH =
        EXCEPTIONS
          finished       = 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.



  ENDCASE.

  CLEAR: gd_okcode.

ENDMODULE.                 " USER_COMMAND_0100  INPUT


*&---------------------------------------------------------------------*
*&      Form  INIT_CONTROLS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM init_controls .

* Create docking container
  CREATE OBJECT go_docking
    EXPORTING
      parent = cl_gui_container=>screen0
      ratio  = 90
    EXCEPTIONS
      OTHERS = 6.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


* Create ALV grid
  CREATE OBJECT go_grid
    EXPORTING
      i_parent = go_docking
    EXCEPTIONS
      OTHERS   = 5.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  PERFORM build_fieldcatalog.
  PERFORM set_layout_and_variant.

ENDFORM.                    " INIT_CONTROLS


*&---------------------------------------------------------------------*
*&      Form  BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
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             = 'KNB1'
*     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.


*** Only non-key fields are editable
**  ls_fcat-edit = 'X'.
**  MODIFY gt_fcat FROM ls_fcat
**    TRANSPORTING edit
**    WHERE ( key NE 'X' ).


ENDFORM.                    " BUILD_FIELDCATALOG_KNB1


*&---------------------------------------------------------------------*
*&      Form  SET_LAYOUT_AND_VARIANT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM set_layout_and_variant .

  CLEAR: gs_layout,
         gs_variant.

  gs_layout-cwidth_opt = abap_true.
  gs_layout-zebra      = abap_true.
  gs_layout-excp_fname = 'EXCEPTION'.  " define column for LED
  gs_layout-excp_led   = abap_true.

  gs_variant-report = syst-repid.
  gs_variant-handle = 'GRID'.

ENDFORM.                    " SET_LAYOUT_AND_VARIANT


*&---------------------------------------------------------------------*
*&      Form  CHECK_CONDITION
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM check_condition .
* define local data
  DATA: ls_outtab   TYPE ty_s_outtab.

  LOOP AT gt_outtab INTO ls_outtab.
    IF ( ls_outtab-erdat < '20000101' ).
      ls_outtab-exception = '1'.  " red LED/traffic light
    ELSE.
      ls_outtab-exception = '3'.  " green LED / traffic light
    ENDIF.

    MODIFY gt_outtab FROM ls_outtab INDEX syst-tabix.
  ENDLOOP.

ENDFORM.                    " CHECK_CONDITION

Regards

Uwe

0 Kudos

hi Uwe Schieferstein

I copied your program and pasted and executed it shows run time error .

The error analysis says that

The system attempted to use dynpro 0100 in program "ZWF_TRACKING"

This dynpro does not exist.

"ZWF_TRACKING" is my program name.

Regards

vijay

0 Kudos

Hi V ,

u need to create screen 100.

regards

Prabhu

0 Kudos

Create the Screen 100 and Uncomment the Flow Logic PBO and PAI modules.

0 Kudos

HI friends

I have reframed the code to my need but am not getting any out put. This is my code.


TYPE-POOLS: abap.


TYPES: BEGIN OF ty_s_outtab.
TYPES: exception   TYPE lvc_exled.
INCLUDE TYPE PTREQ_ATTABSDATA.
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE OF ty_s_outtab
                   WITH DEFAULT KEY.

DATA:
  gd_repid         TYPE syrepid,
  gd_okcode        TYPE ui_func,
*
  gt_fcat          TYPE lvc_t_fcat,
  gs_layout        TYPE lvc_s_layo,
  gs_variant       TYPE disvariant,
  go_docking       TYPE REF TO cl_gui_docking_container,
  go_grid          TYPE REF TO cl_gui_alv_grid.


DATA:
  gt_outtab        TYPE ty_t_outtab.


PARAMETERS:
 PERNR      TYPE PA0001-PERNR,
 LEA_TY      TYPE PA0001-SUBTY,
 BEGDA      TYPE PA0001-BEGDA,
 ENDDA      TYPE PA0001-ENDDA.






START-OF-SELECTION.

  SELECT * FROM  PTREQ_ATTABSDATA INTO CORRESPONDING FIELDS OF TABLE gt_outtab
         WHERE  PERNR  = PERNR AND SUBTY = LEA_TY.

  PERFORM init_controls.

  PERFORM check_condition.

* Display data
  CALL METHOD go_grid->set_table_for_first_display
    EXPORTING
      is_layout       = gs_layout
      is_variant      = gs_variant
      i_save          = 'A'
    CHANGING
      it_outtab       = gt_outtab
      it_fieldcatalog = gt_fcat
    EXCEPTIONS
      OTHERS          = 4.
  IF sy-subrc = 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.



* Link the docking container to the target dynpro
*  gd_repid = syst-repid.
*  CALL METHOD go_docking->link
*    EXPORTING
*      repid                       = gd_repid
**      dynnr                       = '0100'
**      CONTAINER                   =
*    EXCEPTIONS
*      OTHERS                      = 4.
*  IF sy-subrc = 0.
**   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
**              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*  ENDIF.
*
*
** ok-code field = GD_OKCODE
*  CALL SCREEN '0100'.


END-OF-SELECTION.

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STATUS_0100'.
*  SET TITLEBAR 'xxx'.

**      CALL METHOD go_grid1->refresh_table_display
***        EXPORTING
***          IS_STABLE      =
***          I_SOFT_REFRESH =
**        EXCEPTIONS
**          FINISHED       = 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.

ENDMODULE.                 " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  CASE gd_okcode.
    WHEN 'BACK' OR
         'END'  OR
         'CANC'.
      SET SCREEN 0. LEAVE SCREEN.



    WHEN OTHERS.
      CALL METHOD go_grid->refresh_table_display
*        EXPORTING
*          IS_STABLE      =
*          I_SOFT_REFRESH =
        EXCEPTIONS
          finished       = 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.



  ENDCASE.

  CLEAR: gd_okcode.

ENDMODULE.                 " USER_COMMAND_0100  INPUT


*&---------------------------------------------------------------------*
*&      Form  INIT_CONTROLS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM init_controls .

** Create docking container
*  CREATE OBJECT go_docking
*    EXPORTING
*      parent = cl_gui_container=>screen0
*      ratio  = 90
*    EXCEPTIONS
*      OTHERS = 6.
*  IF sy-subrc = 0.
**   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
**              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*  ENDIF.


* Create ALV grid
  CREATE OBJECT go_grid
    EXPORTING
      i_parent = go_docking
    EXCEPTIONS
      OTHERS   = 5.
  IF sy-subrc = 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  PERFORM build_fieldcatalog.
  PERFORM set_layout_and_variant.

ENDFORM.                    " INIT_CONTROLS


*&---------------------------------------------------------------------*
*&      Form  BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
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             = 'PTREQ_ATTABSDATA'
*     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.


*** Only non-key fields are editable
**  ls_fcat-edit = 'X'.
**  MODIFY gt_fcat FROM ls_fcat
**    TRANSPORTING edit
**    WHERE ( key NE 'X' ).


ENDFORM.                    " BUILD_FIELDCATALOG_KNB1


*&---------------------------------------------------------------------*
*&      Form  SET_LAYOUT_AND_VARIANT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM set_layout_and_variant .

  CLEAR: gs_layout,
         gs_variant.

  gs_layout-cwidth_opt = abap_true.
  gs_layout-zebra      = abap_true.
  gs_layout-excp_fname = 'EXCEPTION'.  " define column for LED
  gs_layout-excp_led   = abap_true.

  gs_variant-report = syst-repid.
  gs_variant-handle = 'GRID'.

ENDFORM.                    " SET_LAYOUT_AND_VARIANT


*&---------------------------------------------------------------------*
*&      Form  CHECK_CONDITION
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM check_condition .
* define local data
  DATA: ls_outtab   TYPE ty_s_outtab.

  LOOP AT gt_outtab INTO ls_outtab.
    IF ( ls_outtab-SUBTY = '0001' ).
      ls_outtab-exception = '1'.  " red LED/traffic light
    ELSE.
      ls_outtab-exception = '3'.  " green LED / traffic light
    ENDIF.

    MODIFY gt_outtab FROM ls_outtab INDEX syst-tabix.
  ENDLOOP.

ENDFORM.                    " CHECK_CONDITION

0 Kudos
** Create docking container
*  CREATE OBJECT go_docking
*    EXPORTING
*      parent = cl_gui_container=>screen0
*      ratio  = 90
*    EXCEPTIONS
*      OTHERS = 6.
*  IF sy-subrc = 0.
**   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
**              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*  ENDIF.

Uncomment this code in the form FORM init_controls .

0 Kudos

hi friend

I have uncommented that line and try to execute it. Its showing run time error.


 An exception occurred that is explained in detail below.
 The exception, which is assigned to class 'CX_SY_REF_IS_INITIAL', was not
  caught and
 therefore caused a runtime error.
 The reason for the exception is:
 You attempted to use a 'NULL' object reference (points to 'nothing')
 access a component (variable: "GO_DOCKING").
 An object reference must point to an object (an instance of a class)
 before it can be used to access components.
 Either the reference was never set or it was set to 'NULL' using the
 CLEAR statement.

This is the error its shows.

Regards

vijay

0 Kudos
*  CALL SCREEN '0100'.

i just uncommented the line from your code and created an empty screen 100. and i am able to see the report output.

0 Kudos

hi Vijay Babu

I have uncommented the clear screen 100. Even its showing the same error. How to create the screen.

Regards

vijay

0 Kudos

this is the modifed code , from your post.

See the Commnets...

TYPE-POOLS: abap.


TYPES: BEGIN OF ty_s_outtab.
TYPES: exception   TYPE lvc_exled.
INCLUDE TYPE PTREQ_ATTABSDATA.
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE OF ty_s_outtab
                   WITH DEFAULT KEY.

DATA:
  gd_repid         TYPE syrepid,
  gd_okcode        TYPE ui_func,
*
  gt_fcat          TYPE lvc_t_fcat,
  gs_layout        TYPE lvc_s_layo,
  gs_variant       TYPE disvariant,
  go_docking       TYPE REF TO cl_gui_docking_container,
  go_grid          TYPE REF TO cl_gui_alv_grid.


DATA:
  gt_outtab        TYPE ty_t_outtab.


PARAMETERS:
 PERNR      TYPE PA0001-PERNR,
 LEA_TY      TYPE PA0001-SUBTY,
 BEGDA      TYPE PA0001-BEGDA,
 ENDDA      TYPE PA0001-ENDDA.






START-OF-SELECTION.

  SELECT * FROM  PTREQ_ATTABSDATA INTO CORRESPONDING FIELDS OF TABLE
gt_outtab
up to 10 rows.
*         WHERE  PERNR  in PERNR ."AND SUBTY = LEA_TY.

  PERFORM init_controls.

  PERFORM check_condition.

* Display data
  CALL METHOD go_grid->set_table_for_first_display
    EXPORTING
      is_layout       = gs_layout
      is_variant      = gs_variant
      i_save          = 'A'
    CHANGING
      it_outtab       = gt_outtab
      it_fieldcatalog = gt_fcat
    EXCEPTIONS
      OTHERS          = 4.
  IF sy-subrc = 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

 "Here you double click on the 100 and create the screen 
"once it is done then save and activate the screen. 
"and come back and test,
  CALL SCREEN '0100'.


END-OF-SELECTION.

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STATUS_0100'.
*  SET TITLEBAR 'xxx'.

**      CALL METHOD go_grid1->refresh_table_display
***        EXPORTING
***          IS_STABLE      =
***          I_SOFT_REFRESH =
**        EXCEPTIONS
**          FINISHED       = 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.

ENDMODULE.                 " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  CASE gd_okcode.
    WHEN 'BACK' OR
         'END'  OR
         'CANC'.
      SET SCREEN 0. LEAVE SCREEN.



    WHEN OTHERS.
      CALL METHOD go_grid->refresh_table_display
*        EXPORTING
*          IS_STABLE      =
*          I_SOFT_REFRESH =
        EXCEPTIONS
          finished       = 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.



  ENDCASE.

  CLEAR: gd_okcode.

ENDMODULE.                 " USER_COMMAND_0100  INPUT


*&---------------------------------------------------------------------*
*&      Form  INIT_CONTROLS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM init_controls .

** Create docking container
*  CREATE OBJECT go_docking
*    EXPORTING
*      parent = cl_gui_container=>screen0
*      ratio  = 90
*    EXCEPTIONS
*      OTHERS = 6.
*  IF sy-subrc = 0.
**   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
**              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*  ENDIF.


* Create ALV grid
  CREATE OBJECT go_grid
    EXPORTING
      i_parent = go_docking
    EXCEPTIONS
      OTHERS   = 5.
  IF sy-subrc = 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  PERFORM build_fieldcatalog.
  PERFORM set_layout_and_variant.

ENDFORM.                    " INIT_CONTROLS


*&---------------------------------------------------------------------*
*&      Form  BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
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             = 'PTREQ_ATTABSDATA'
*     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.


*** Only non-key fields are editable
**  ls_fcat-edit = 'X'.
**  MODIFY gt_fcat FROM ls_fcat
**    TRANSPORTING edit
**    WHERE ( key NE 'X' ).


ENDFORM.                    " BUILD_FIELDCATALOG_KNB1


*&---------------------------------------------------------------------*
*&      Form  SET_LAYOUT_AND_VARIANT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM set_layout_and_variant .

  CLEAR: gs_layout,
         gs_variant.

  gs_layout-cwidth_opt = abap_true.
  gs_layout-zebra      = abap_true.
  gs_layout-excp_fname = 'EXCEPTION'.  " define column for LED
  gs_layout-excp_led   = abap_true.

  gs_variant-report = syst-repid.
  gs_variant-handle = 'GRID'.

ENDFORM.                    " SET_LAYOUT_AND_VARIANT


*&---------------------------------------------------------------------*
*&      Form  CHECK_CONDITION
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM check_condition .
* define local data
  DATA: ls_outtab   TYPE ty_s_outtab.

  LOOP AT gt_outtab INTO ls_outtab.
    IF ( ls_outtab-SUBTY = '0001' ).
      ls_outtab-exception = '1'.  " red LED/traffic light
    ELSE.
      ls_outtab-exception = '3'.  " green LED / traffic light
    ENDIF.

    MODIFY gt_outtab FROM ls_outtab INDEX syst-tabix.
  ENDLOOP.

ENDFORM.                    " CHECK_CONDITION

0 Kudos

hi Vijay Babu

Thank you very much. Now its working. This is the initial state i need to get the Approved and Rejected state. i will work on that.

Thank you

Regards

vijay

0 Kudos

Hello Vijay

Below you see how screen '0100' looks like.


*& Screen '0100': ok-code -> GD_OKCODE, no screen elements:
    PROCESS BEFORE OUTPUT.
      MODULE STATUS_0100.
*
    PROCESS AFTER INPUT.
      MODULE USER_COMMAND_0100.

In addition, you need to define a GUI-status 'STATUS_0100' including the following ok-code:

CASE gd_okcode.
    WHEN 'BACK' OR
         'END'  OR
         'CANC'.
      SET SCREEN 0. LEAVE SCREEN.

Regards

Uwe