SM66 DEBUG & CANCEL
Sunday, August 28, 2016
Tuesday, April 7, 2015
109.ABAP Tip - Dynamic Selection screen
Chapter 109
Dynamic Selection screen
Let's develop a program which can expand/close the columns in selection
screen when user click the button.
|
*&---------------------------------------------------------------------*
*& Report ZDYNAMIC_SEL *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT zdynamic_sel. INCLUDE <icon>. TABLES: sscrfields, scarr. DATA: v_stat_cr TYPE char1. " O-Open, C-Closed, V-Closed with Value. DATA: v_value TYPE flag. DATA : gt_scarr TYPE TABLE OF scarr WITH HEADER LINE. CONSTANTS: c_on TYPE char1 VALUE '1', c_off TYPE char1 VALUE '0'. CONSTANTS: BEGIN OF c_stat, open TYPE char1 VALUE 'O', close TYPE char1 VALUE 'C', close_val TYPE char1 VALUE 'V', END OF c_stat. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN PUSHBUTTON (4) pb_cr USER-COMMAND u_cr. SELECTION-SCREEN COMMENT 6(25) v_cr. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN: BEGIN OF BLOCK blk1 WITH FRAME TITLE text-t01. SELECT-OPTIONS: s_carrid FOR scarr-carrid MODIF ID cr. SELECTION-SCREEN: END OF BLOCK blk1. INITIALIZATION. v_cr = 'Carrier ID'. MOVE c_stat-close TO: v_stat_cr. PERFORM set_icon USING v_stat_cr CHANGING pb_cr. AT SELECTION-SCREEN OUTPUT. LOOP AT SCREEN. CASE screen-group1. WHEN 'CR'. IF v_stat_cr = c_stat-open. screen-active = c_on. ELSE. screen-active = c_off. ENDIF. ENDCASE. MODIFY SCREEN. ENDLOOP. PERFORM set_icon USING v_stat_cr CHANGING pb_cr. AT SELECTION-SCREEN. CASE sscrfields-ucomm. WHEN 'U_CR'. CLEAR v_value. IF s_carrid[] IS NOT INITIAL. v_value = 'X'. ENDIF. PERFORM set_stat USING v_value CHANGING v_stat_cr. ENDCASE. START-OF-SELECTION. SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_scarr FROM scarr WHERE carrid IN s_carrid. LOOP AT gt_scarr. WRITE :/ gt_scarr-carrid, gt_scarr-carrname. ENDLOOP. *&---------------------------------------------------------------------* *& Form SET_ICON *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_V_STAT_CR text * <--P_PB_CR text *----------------------------------------------------------------------* FORM set_icon USING pv_stat CHANGING pb_cr. CASE pv_stat. WHEN c_stat-close. pb_cr = icon_data_area_expand. WHEN c_stat-open. pb_cr = icon_data_area_collapse. WHEN c_stat-close_val. pb_cr = icon_view_create. " ICON_status_best. ENDCASE. ENDFORM. " SET_ICON *&---------------------------------------------------------------------* *& Form SET_STAT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_v_value text * <--P_V_STAT_CR text *----------------------------------------------------------------------* FORM set_stat USING pv_value CHANGING pv_stat. IF pv_stat = c_stat-open. IF pv_value IS INITIAL. pv_stat = c_stat-close. ELSE. pv_stat = c_stat-close_val. ENDIF. ELSEIF ( pv_stat = c_stat-close OR pv_stat = c_stat-close_val ). pv_stat = c_stat-open. ENDIF. ENDFORM. " SET_STAT |
Friday, March 13, 2015
108. ABAP TIP - Popup Screen
Chapter 108
ABAP TIP - Popup Screen
Source : http://abapjoy.blogspot.com
Normally,
we use the function ‘ POPUP_GET_VALUES’ to implement popup, but
there is a limitation when adding a radio button, checkbox like a below screen.
For this demands, you can make it using the class ‘cl_ci_query_attributes’.
|
REPORT zpopup_screen.
START-OF-SELECTION.
PERFORM call_popup.
FORM call_popup.
TABLES : sflight.
DATA: lv_carrid TYPE s_carr_id,
lt_werks TYPE
gds_selrange_werks_tab,
lv_check TYPE xfeld,
lv_radio1 TYPE xfeld,
lv_radio2 TYPE xfeld.
DATA : lt_att TYPE sci_atttab
,
ls_att TYPE
sci_attent.
DATA : l_ref TYPE REF TO
data.
CREATE DATA l_ref TYPE REF TO
xfeld.
* parameters
GET REFERENCE OF lv_carrid
INTO l_ref.
ls_att-kind = 'S'.
ls_att-text = 'Parameter'.
ls_att-obligatory = 'Y'.
ls_att-ref = l_ref.
APPEND ls_att TO lt_att.
* SELECT-OPTIONS
GET REFERENCE OF lt_werks
INTO l_ref.
ls_att-kind = 'S'.
ls_att-text = 'Select
Option'.
ls_att-ref = l_ref.
APPEND ls_att TO lt_att.
* Check box
GET REFERENCE OF lv_check
INTO l_ref.
ls_att-kind = 'C'.
ls_att-text = 'Check box'.
ls_att-ref = l_ref.
APPEND ls_att TO lt_att.
* Radio button
GET REFERENCE OF lv_radio1
INTO l_ref.
ls_att-kind = 'R'.
ls_att-text = 'Radio 1'.
ls_att-button_group = 'MOD'.
ls_att-ref = l_ref.
APPEND ls_att TO lt_att.
GET REFERENCE OF lv_radio2
INTO l_ref.
ls_att-kind = 'R'.
ls_att-text = 'Radio 2'.
ls_att-button_group = 'MOD'.
ls_att-ref = l_ref.
APPEND ls_att TO lt_att.
CALL METHOD
cl_ci_query_attributes=>generic
EXPORTING
p_name = 'TEST'
p_title = 'TEST2'
p_attributes = lt_att
* p_message =
p_display = ''
* receiving
* p_break =
.
BREAK-POINT.
ENDFORM.
|
After
execution program, enter the value like below.
And
you can see the variable value in debugger. That is, the data you entered in
the popup screen.
Please,
note that you should create range table type first for select-options.
Let’s see the structure in
T-CODE:SE11
gds_selrange_werks_tab
Monday, March 9, 2015
107.ABAP TIP - Field Exit
Chapter 107
ABAP TIP - Field Exit
Source
: http://abapjoy.blogspot.com
Field
Exit enables individual column of standard program to add extra logic.
For
example, You can customize the some column in T-CODE:MK02(VENDOR MASTER).
Especially,
it’s very
useful you need to enable only the corresponding table when occurring error.
But,
simply if you want to restrict the values in column, you can use the feather of
domain ‘fixed
value append’.
Let’s find out the data element
name in the technical information of the column we want to customize.
Perform
T-CODE:SE38 and enter 'RSMODPRF'.
Enter
the data element name you already checked before.
Note
that if it is first time to create field exit for the column, you should not
enter the number of field exit.
Now
we can program for the field exit and activate.
Re-execute
program leaving all columns blank.
Choose
the line and push the menu : field exit -> assign prog/screen.
Enter
the program name and screen name that we want to customize. You can figure out
in menu : SYSTEM -> STATUS.
And,
activate the field exit.
Now,
once you input the unavailable value in column, you can see the error message
like below.
Subscribe to:
Posts (Atom)














