trafic light in sap abap programming
Some time requirement to print traffic light in your program so here simple code to print traffic light
REPORT ychatest.
TYPES: BEGIN OF ty_final,
light(4) TYPE c,
name1 TYPE char40,
name2 TYPE char40,
name3 TYPE char40,
END OF ty_final.
DATA: gt_final TYPE STANDARD TABLE OF ty_final,
gs_final TYPE ty_final.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat LIKE LINE OF it_fieldcat.
wa_fieldcat-fieldname = 'LIGHT'.
wa_fieldcat-col_pos = 0.
** wa_fieldcat-EDIT = 'X'.
** wa_fieldcat-checkbox = 'X'.
wa_fieldcat-seltext_m = 'LiGHT'(000).
APPEND wa_fieldcat TO it_fieldcat.
* CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'NAME1'.
wa_fieldcat-col_pos = 0.
** wa_fieldcat-EDIT = 'X'.
** wa_fieldcat-checkbox = 'X'.
wa_fieldcat-seltext_m = 'Fist Name'(000).
APPEND wa_fieldcat TO it_fieldcat.
* CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'NAME2'.
wa_fieldcat-col_pos = 0.
** wa_fieldcat-EDIT = 'X'.
** wa_fieldcat-checkbox = 'X'.
wa_fieldcat-seltext_m = 'Second Name'(000).
APPEND wa_fieldcat TO it_fieldcat.
* CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'NAME3'.
wa_fieldcat-col_pos = 0.
** wa_fieldcat-EDIT = 'X'.
** wa_fieldcat-checkbox = 'X'.
wa_fieldcat-seltext_m = 'Last Name'(000).
APPEND wa_fieldcat TO it_fieldcat.
* CLEAR wa_fieldcat.
gs_final-name1 = 'ROHAN'.
gs_final-name2 = 'KUMAR'.
gs_final-name3 = 'PANDEY'.
*gs_final-light = '@08@'. " green
APPEND gs_final TO gt_final.
CLEAR: gs_final.
gs_final-name1 = 'DEV'.
gs_final-name2 = 'KUMAR'.
gs_final-name3 = 'MISHRA'.
*gs_final-light = '@09@'. " yellow
APPEND gs_final TO gt_final.
CLEAR: gs_final.
gs_final-name1 = 'SUMIT'.
gs_final-name2 = 'KUMAR'.
gs_final-name3 = 'SHUKLA'.
*gs_final-light = '@0A@'. " read
APPEND gs_final TO gt_final.
CLEAR: gs_final.
gs_final-name1 = 'SUMIT'.
gs_final-name2 = 'KUMAR'.
gs_final-name3 = 'SHUKLA'.
*gs_final-light = '@0A@'. " read
APPEND gs_final TO gt_final.
CLEAR: gs_final.
LOOP AT gt_final INTO gs_final.
IF gs_final-name1 EQ 'SUMIT'.
gs_final-light = '@0A@'. " read
ELSE.
gs_final-light = '@09@'. " yellow
ENDIF.
MODIFY gt_final FROM gs_final TRANSPORTING light.
CLEAR: gs_final.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = it_fieldcat[]
i_save = 'A'
TABLES
t_outtab = gt_final
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.
*DATA: EV_DATE TYPE D.
*
*CALL FUNCTION 'ZDATE_POP'
* EXPORTING
* IV_TITLE = 'Enter value date'
* IV_DESCRIPTION1 = 'Enter value date'
** IV_DESCRIPTION2 =
* IV_DATE = sy-datum
* IMPORTING
* EV_DATE = EV_DATE
** EXCEPTIONS
** ACTION_ABORTED_BY_USER = 1
** VALUE_NOT_CHANGED = 2
** OTHERS = 3
* .
*IF sy-subrc <> 0.
** Implement suitable error handling here
*ENDIF.
*DATA:
*zaddress TYPE bapiaddr3,
*BAPIBNAME Type XUBNAME,
*return TYPE STANDARD TABLE OF bapiret2,
*lv_name TYPE c LENGTH 30.
*MOVE SY-uname to BAPIBNAME.
*
*
*CALL FUNCTION 'BAPI_USER_GET_DETAIL'
* EXPORTING
* username = BAPIBNAME
* IMPORTING
* address = zaddress
* TABLES
* return = return.
BREAK-POINT.
*CALL METHOD cl_gui_frontend_services=>get_user_name
* CHANGING
* user_name = os_user
* EXCEPTIONS
* cntl_error = 1
* error_no_gui = 2
* not_supported_by_gui = 3
* 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.
*
*CALL METHOD cl_gui_cfw=>flush
* EXCEPTIONS
* cntl_system_error = 1
* cntl_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.
*
*WRITE os_user.
**data : FIELDS type STANDARD TABLE OF SVAL.
**
**DATA: EV_DATE TYPE D.
**
**CALL FUNCTION 'TR_POPUP_INPUT_DATE'
** EXPORTING
** IV_TITLE = 'Enter valu date'
*** IV_DESCRIPTION1 =
*** IV_DESCRIPTION2 =
*** IV_DATE =
** IMPORTING
** EV_DATE = EV_DATE.
** .
**IF sy-subrc <> 0.
*** Implement suitable error handling here
**ENDIF.
**
**WRITE: EV_daTE.
*CALL FUNCTION 'POPUP_GET_VALUES'
* EXPORTING
* NO_VALUE_CHECK = ' '
* popup_title = 'Hello'
* START_COLUMN = '5'
* START_ROW = '5'
** IMPORTING
** RETURNCODE =
* tables
* fields = FIELDS.
** EXCEPTIONS
** ERROR_IN_FIELDS = 1
** OTHERS = 2
** .
**IF sy-subrc <> 0.
*** Implement suitable error handling here
**ENDIF.
*CALL FUNCTION 'TRM_POPUP_TEXT_INPUT'
* EXPORTING
* SOURCETEXT = 'Valu date '
* TITEL = 'valu date'
* START_COLUMN = 10
* START_ROW = 6
** CHANGING
** TARGETTEXT =
* .
*TABLES : MARA.
*SELECTION-SCREEN BEGIN OF LINE.
*SELECTION-SCREEN COMMENT 1(10) TEXT-001 FOR FIELD P_MATNR.
*PARAMETERS : P_MATNR LIKE MARA-MATNR.
*SELECTION-SCREEN COMMENT 40(10) TEXT-002 FOR FIELD S_MATNR.
*SELECT-OPTIONS : S_MATNR FOR MARA-MATNR NO INTERVALS.
*SELECTION-SCREEN COMMENT 80(10) TEXT-003 FOR FIELD S_MATNR.
*SELECT-OPTIONS : S_MATNR1 FOR MARA-MATNR NO INTERVALS.
*SELECTION-SCREEN END OF LINE.
*data: git_text type CATSXT_LONGTEXT_ITAB,
* gs_test LIKE LINE OF git_text.
*
*CALL FUNCTION 'CATSXT_SIMPLE_TEXT_EDITOR'
* EXPORTING
* im_title = 'Reason for rejection'
** im_display_mode = abap_true
* IM_START_COLUMN = 2
* IM_START_ROW = 2
* CHANGING
* ch_text = git_text.
*
*BREAK-POINT.
*
*LOOP AT git_text INTO gs_test.
*
*ENDLOOP.
REPORT ychatest.
TYPES: BEGIN OF ty_final,
light(4) TYPE c,
name1 TYPE char40,
name2 TYPE char40,
name3 TYPE char40,
END OF ty_final.
DATA: gt_final TYPE STANDARD TABLE OF ty_final,
gs_final TYPE ty_final.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat LIKE LINE OF it_fieldcat.
wa_fieldcat-fieldname = 'LIGHT'.
wa_fieldcat-col_pos = 0.
** wa_fieldcat-EDIT = 'X'.
** wa_fieldcat-checkbox = 'X'.
wa_fieldcat-seltext_m = 'LiGHT'(000).
APPEND wa_fieldcat TO it_fieldcat.
* CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'NAME1'.
wa_fieldcat-col_pos = 0.
** wa_fieldcat-EDIT = 'X'.
** wa_fieldcat-checkbox = 'X'.
wa_fieldcat-seltext_m = 'Fist Name'(000).
APPEND wa_fieldcat TO it_fieldcat.
* CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'NAME2'.
wa_fieldcat-col_pos = 0.
** wa_fieldcat-EDIT = 'X'.
** wa_fieldcat-checkbox = 'X'.
wa_fieldcat-seltext_m = 'Second Name'(000).
APPEND wa_fieldcat TO it_fieldcat.
* CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'NAME3'.
wa_fieldcat-col_pos = 0.
** wa_fieldcat-EDIT = 'X'.
** wa_fieldcat-checkbox = 'X'.
wa_fieldcat-seltext_m = 'Last Name'(000).
APPEND wa_fieldcat TO it_fieldcat.
* CLEAR wa_fieldcat.
gs_final-name1 = 'ROHAN'.
gs_final-name2 = 'KUMAR'.
gs_final-name3 = 'PANDEY'.
*gs_final-light = '@08@'. " green
APPEND gs_final TO gt_final.
CLEAR: gs_final.
gs_final-name1 = 'DEV'.
gs_final-name2 = 'KUMAR'.
gs_final-name3 = 'MISHRA'.
*gs_final-light = '@09@'. " yellow
APPEND gs_final TO gt_final.
CLEAR: gs_final.
gs_final-name1 = 'SUMIT'.
gs_final-name2 = 'KUMAR'.
gs_final-name3 = 'SHUKLA'.
*gs_final-light = '@0A@'. " read
APPEND gs_final TO gt_final.
CLEAR: gs_final.
gs_final-name1 = 'SUMIT'.
gs_final-name2 = 'KUMAR'.
gs_final-name3 = 'SHUKLA'.
*gs_final-light = '@0A@'. " read
APPEND gs_final TO gt_final.
CLEAR: gs_final.
LOOP AT gt_final INTO gs_final.
IF gs_final-name1 EQ 'SUMIT'.
gs_final-light = '@0A@'. " read
ELSE.
gs_final-light = '@09@'. " yellow
ENDIF.
MODIFY gt_final FROM gs_final TRANSPORTING light.
CLEAR: gs_final.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = it_fieldcat[]
i_save = 'A'
TABLES
t_outtab = gt_final
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.
*DATA: EV_DATE TYPE D.
*
*CALL FUNCTION 'ZDATE_POP'
* EXPORTING
* IV_TITLE = 'Enter value date'
* IV_DESCRIPTION1 = 'Enter value date'
** IV_DESCRIPTION2 =
* IV_DATE = sy-datum
* IMPORTING
* EV_DATE = EV_DATE
** EXCEPTIONS
** ACTION_ABORTED_BY_USER = 1
** VALUE_NOT_CHANGED = 2
** OTHERS = 3
* .
*IF sy-subrc <> 0.
** Implement suitable error handling here
*ENDIF.
*DATA:
*zaddress TYPE bapiaddr3,
*BAPIBNAME Type XUBNAME,
*return TYPE STANDARD TABLE OF bapiret2,
*lv_name TYPE c LENGTH 30.
*MOVE SY-uname to BAPIBNAME.
*
*
*CALL FUNCTION 'BAPI_USER_GET_DETAIL'
* EXPORTING
* username = BAPIBNAME
* IMPORTING
* address = zaddress
* TABLES
* return = return.
BREAK-POINT.
*CALL METHOD cl_gui_frontend_services=>get_user_name
* CHANGING
* user_name = os_user
* EXCEPTIONS
* cntl_error = 1
* error_no_gui = 2
* not_supported_by_gui = 3
* 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.
*
*CALL METHOD cl_gui_cfw=>flush
* EXCEPTIONS
* cntl_system_error = 1
* cntl_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.
*
*WRITE os_user.
**data : FIELDS type STANDARD TABLE OF SVAL.
**
**DATA: EV_DATE TYPE D.
**
**CALL FUNCTION 'TR_POPUP_INPUT_DATE'
** EXPORTING
** IV_TITLE = 'Enter valu date'
*** IV_DESCRIPTION1 =
*** IV_DESCRIPTION2 =
*** IV_DATE =
** IMPORTING
** EV_DATE = EV_DATE.
** .
**IF sy-subrc <> 0.
*** Implement suitable error handling here
**ENDIF.
**
**WRITE: EV_daTE.
*CALL FUNCTION 'POPUP_GET_VALUES'
* EXPORTING
* NO_VALUE_CHECK = ' '
* popup_title = 'Hello'
* START_COLUMN = '5'
* START_ROW = '5'
** IMPORTING
** RETURNCODE =
* tables
* fields = FIELDS.
** EXCEPTIONS
** ERROR_IN_FIELDS = 1
** OTHERS = 2
** .
**IF sy-subrc <> 0.
*** Implement suitable error handling here
**ENDIF.
*CALL FUNCTION 'TRM_POPUP_TEXT_INPUT'
* EXPORTING
* SOURCETEXT = 'Valu date '
* TITEL = 'valu date'
* START_COLUMN = 10
* START_ROW = 6
** CHANGING
** TARGETTEXT =
* .
*TABLES : MARA.
*SELECTION-SCREEN BEGIN OF LINE.
*SELECTION-SCREEN COMMENT 1(10) TEXT-001 FOR FIELD P_MATNR.
*PARAMETERS : P_MATNR LIKE MARA-MATNR.
*SELECTION-SCREEN COMMENT 40(10) TEXT-002 FOR FIELD S_MATNR.
*SELECT-OPTIONS : S_MATNR FOR MARA-MATNR NO INTERVALS.
*SELECTION-SCREEN COMMENT 80(10) TEXT-003 FOR FIELD S_MATNR.
*SELECT-OPTIONS : S_MATNR1 FOR MARA-MATNR NO INTERVALS.
*SELECTION-SCREEN END OF LINE.
*data: git_text type CATSXT_LONGTEXT_ITAB,
* gs_test LIKE LINE OF git_text.
*
*CALL FUNCTION 'CATSXT_SIMPLE_TEXT_EDITOR'
* EXPORTING
* im_title = 'Reason for rejection'
** im_display_mode = abap_true
* IM_START_COLUMN = 2
* IM_START_ROW = 2
* CHANGING
* ch_text = git_text.
*
*BREAK-POINT.
*
*LOOP AT git_text INTO gs_test.
*
*ENDLOOP.
Comments
Post a Comment