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.

Lets 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, its 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.



Lets 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.