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

dialog programming query

Former Member
0 Likes
673

hi all,

I have encountered a problem.

5000	ADMN	CIHE	5
5000	BIDE	ADMN	5
5000	BIDE	HR	5
5000	BIDE	IT	5
5000	BIDE	PROJ	15
5000	BIDE	QUAL	5
5000	BIDE	S&M	5
5000	BIDE	SCM	5

The problem here is I have selected first BIDE.

But the display is showing the last one in the table control and also the last record in the table with ref to particular dept.

The requirement is whatever I have selected I should get that record in display.

For this I have used the following logic.

if v_field = 'ZITRDEPESC-DEPT' and v_dept is not INITIAL.
        flag = 'X'.
        clear wa_zitrdepesc.
        select * from zitrdepesc into wa_zitrdepesc where dept = v_dept.
        endselect.

The following code is written in separate module.

GET CURSOR field v_field
             value v_dept.

6 REPLIES 6
Read only

Former Member
0 Likes
651

Replace this


select * from zitrdepesc into wa_zitrdepesc where dept = v_dept.
        endselect.

with this


select SINGLE * from zitrdepesc into wa_zitrdepesc where dept = v_dept.

Read only

0 Likes
651

Dear paul,

Sorry your code hasn't worked. it is now picking the first record for all the selected dept BIDE's in the screen.

regards

samarendra

Read only

0 Likes
651

Sam,

I'm not much of a fan of Table Controls in a dialog screen. Pleae review this code and use if you feel it will benefit you.


DATA:
  BEGIN OF wt_zlmcont_rec.
        INCLUDE STRUCTURE zlmcont.
DATA:
    apptypdesc(15) TYPE c,
    relatdesc(10)  TYPE c,
  END OF wt_zlmcont_rec.
DATA:
  wt_zlmcont LIKE STANDARD TABLE OF wt_zlmcont_rec.


*---------------------------------------------------------------------*
*       CLASS lcl_event_receiver_0108 DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_event_receiver_0108 DEFINITION DEFERRED.
DATA:
  cust_cont_0108        TYPE REF TO cl_gui_custom_container,
  grid_action_0108      TYPE REF TO cl_gui_alv_grid,
  event_receiver_0108   TYPE REF TO lcl_event_receiver_0108,
  wa_row_no_0108        TYPE lvc_s_roid,
  it_row_no_0108        TYPE lvc_t_roid.

*---------------------------------------------------------------------*
*       CLASS lcl_event_receiver_0108 DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_event_receiver_0108 DEFINITION.

  PUBLIC SECTION.
    METHODS:

    handle_double_click_0108
        FOR EVENT double_click OF cl_gui_alv_grid
            IMPORTING e_row e_column.

  PRIVATE SECTION.

ENDCLASS.
*---------------------------------------------------------------------*
*       CLASS lcl_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS lcl_event_receiver_0108 IMPLEMENTATION.

  METHOD handle_double_click_0108.
* § 4.The event DOUBLE_CLICK provides parameters for row and column
*   of the click. Use row parameter to select a line of the
*   corresponding internal table.

* read selected row from internal table
    READ TABLE wt_zlmcont INTO wt_zlmcont_rec "here you get the record you want
      INDEX e_row-index.

    sub_mode = c_change.
    CALL SCREEN 208 STARTING AT 10 1.

  ENDMETHOD.                           "handle_double_click

Sceen PBO/PAI


PROCESS BEFORE OUTPUT.
* MODULE STATUS_0108.

  MODULE init_0108.

  MODULE init_grid_0108.
*
PROCESS AFTER INPUT.

  MODULE user_command_0108.

Populating the table object


*---------------------------------------------------------------------*
*       MODULE init_grid_0108 OUTPUT                                  *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
MODULE init_grid_0108 OUTPUT.
  PERFORM init_grid_0108.
ENDMODULE.                 " init_grid_0108  OUTPUT
*&---------------------------------------------------------------------*
*&      Form  init_grid_0108
*&---------------------------------------------------------------------*
FORM init_grid_0108.
  DATA:
* Layout
    wa_layout_action_0108 TYPE lvc_s_layo,
* Field catalog
    it_fcat_action_0108 TYPE lvc_t_fcat.

  IF cust_cont_0108 IS INITIAL.          "CREATE: Yes

*   Create customer container
    CREATE OBJECT cust_cont_0108
      EXPORTING
*        PARENT                      =
         container_name              = 'CUST_CONT_0108'
*        STYLE                       =
*        LIFETIME                    = lifetime_default
*        REPID                       =
*        DYNNR                       =
*        NO_AUTODEF_PROGID_DYNNR     =
       EXCEPTIONS
         cntl_error                  = 1
         cntl_system_error           = 2
         create_error                = 3
         lifetime_error              = 4
         lifetime_dynpro_dynpro_link = 5
         others                      = 6
        .
    IF sy-subrc <> 0.
      MESSAGE e208(00) WITH 'Error: Create Cust Control CUST_CONT'.
    ENDIF.

*   Create grid
    CREATE OBJECT grid_action_0108
      EXPORTING
*        I_SHELLSTYLE      = 0
*        I_LIFETIME        =
         i_parent          = cust_cont_0108
*        I_APPL_EVENTS     = space
*        I_PARENTDBG       =
*        I_APPLOGPARENT    =
*        I_GRAPHICSPARENT  =
*        I_USE_VARIANT_CLASS = SPACE
*        I_NAME            =
       EXCEPTIONS
         error_cntl_create = 1
         error_cntl_init   = 2
         error_cntl_link   = 3
         error_dp_create   = 4
         others            = 5
        .
    IF sy-subrc <> 0.
      MESSAGE e208(00) WITH 'Error: Create Grid GRID_ACTION'.
    ENDIF.

*   Build field catalog
    PERFORM build_fcat_action_0108 CHANGING it_fcat_action_0108.

*   Build layout
    PERFORM build_layout_action_0108 CHANGING wa_layout_action_0108.

*   Display grid (First)
    CALL METHOD grid_action_0108->set_table_for_first_display
       EXPORTING
*        I_BYPASSING_BUFFER            =
*        I_BUFFER_ACTIVE               =
*        I_CONSISTENCY_CHECK           =
*        I_STRUCTURE_NAME              =
*        IS_VARIANT                    =
*        I_SAVE                        =
*        I_DEFAULT                     = 'X'
         is_layout                     = wa_layout_action_0108
*        IS_PRINT                      =
*        IT_SPECIAL_GROUPS             =
*        IT_TOOLBAR_EXCLUDING          =
*        IT_HYPERLINK                  =
*        IT_ALV_GRAPHICS               =
*        IT_EXCEPT_QINFO               =
      CHANGING
         it_outtab                     = wt_zlmcont
         it_fieldcatalog               = it_fcat_action_0108
*        IT_SORT                       =
*        IT_FILTER                     =
*      EXCEPTIONS
*        INVALID_PARAMETER_COMBINATION = 1
*        PROGRAM_ERROR                 = 2
*        TOO_MANY_LINES                = 3
*        others                        = 4
         .
    IF sy-subrc <> 0.
      MESSAGE e208(00) WITH 'Error: Display GRID_ACTION (first)'.
    ENDIF.


    CREATE OBJECT event_receiver_0108.
    SET HANDLER event_receiver_0108->handle_double_click_0108
            FOR grid_action_0108.

  ELSE.                             "CREATE: No

*   ----- Refresh ALV -----
    CALL METHOD grid_action_0108->refresh_table_display
*      EXPORTING
*        IS_STABLE      =
*        I_SOFT_REFRESH =
       EXCEPTIONS
         finished       = 1
         OTHERS         = 2
            .
    IF sy-subrc <> 0.
      MESSAGE e208(00) WITH 'Error: Display GRID_ACTION_0108 (refresh)'.
    ENDIF.

  ENDIF.                            "CREATE
*
*  CREATE OBJECT event_receiver_0108.
*  SET HANDLER event_receiver_0108->handle_double_click_0108
*          FOR grid_action_0108.

* Set selected cell
*  CALL METHOD grid_action_0108->set_selected_rows
*     EXPORTING
**      IT_INDEX_ROWS =
*       it_row_no     = it_row_no_0108.

ENDFORM.                    " init_grid_0100

*&---------------------------------------------------------------------*
*&      Form  build_fcat_action_0108
*&---------------------------------------------------------------------*
*      <--P_IT_FCAT_ACTION  text
*----------------------------------------------------------------------*
FORM build_fcat_action_0108 CHANGING it_fcat TYPE lvc_t_fcat.
  DATA:
    wa_fcat TYPE lvc_s_fcat.

* init
  REFRESH it_fcat.

* Applicant Type
  CLEAR wa_fcat.
  wa_fcat-fieldname = 'APPTYPDESC'.
  wa_fcat-ref_table = 'WT_ZLMCONT'.
  wa_fcat-ref_field = 'APPTYPDESC'.
*  wa_fcat-hotspot   = 'X'.
  wa_fcat-outputlen = 12.
  wa_fcat-coltext   = 'Appl Type'.
  APPEND wa_fcat TO it_fcat.

* First Name
  CLEAR wa_fcat.
  wa_fcat-fieldname = 'FNAME'.
  wa_fcat-ref_table = 'WT_ZLMCONT'.
  wa_fcat-ref_field = 'FNAME'.
  wa_fcat-outputlen = 15.
*  wa_fcat-hotspot   = 'X'.
  wa_fcat-coltext   = 'First Name'.
  APPEND wa_fcat TO it_fcat.

* Middle Name
  CLEAR wa_fcat.
  wa_fcat-fieldname = 'MNAME'.
  wa_fcat-ref_table = 'WT_ZLMCONT'.
  wa_fcat-ref_field = 'MNAME'.
*  wa_fcat-hotspot   = 'X'.
  wa_fcat-outputlen = 10.
  wa_fcat-coltext   = 'Middle'.
  APPEND wa_fcat TO it_fcat.

* Last Name
  CLEAR wa_fcat.
  wa_fcat-fieldname = 'LNAME'.
  wa_fcat-ref_table = 'WT_ZLMCONT'.
  wa_fcat-ref_field = 'LNAME'.
*  wa_fcat-hotspot   = 'X'.
  wa_fcat-outputlen = 20.
  wa_fcat-coltext   = 'Last Name'.
  APPEND wa_fcat TO it_fcat.

* Relationship to Applicant
  CLEAR wa_fcat.
  wa_fcat-fieldname = 'RELATDESC'.
  wa_fcat-ref_table = 'WT_ZLMCONT'.
  wa_fcat-ref_field = 'RELATDESC'.
*  wa_fcat-hotspot   = 'X'.
  wa_fcat-outputlen = 10.
  wa_fcat-coltext   = 'Relation'.
  APPEND wa_fcat TO it_fcat.

* Home Phone
  CLEAR wa_fcat.
  wa_fcat-fieldname = 'PH_HOME'.
  wa_fcat-ref_table = 'WT_ZLMCONT'.
  wa_fcat-ref_field = 'PH_HOME'.
*  wa_fcat-hotspot   = 'X'.
  wa_fcat-outputlen = 10.
  wa_fcat-coltext   = 'Home Phone'.
  APPEND wa_fcat TO it_fcat.

* Cell Phone
  CLEAR wa_fcat.
  wa_fcat-fieldname = 'PH_CELL'.
  wa_fcat-ref_table = 'WT_ZLMCONT'.
  wa_fcat-ref_field = 'PH_CELL'.
*  wa_fcat-hotspot   = 'X'.
  wa_fcat-outputlen = 10.
  wa_fcat-coltext   = 'Cell Phone'.
  APPEND wa_fcat TO it_fcat.

* Work Phone
  CLEAR wa_fcat.
  wa_fcat-fieldname = 'PH_WORK'.
  wa_fcat-ref_table = 'WT_ZLMCONT'.
  wa_fcat-ref_field = 'PH_WORK'.
*  wa_fcat-hotspot   = 'X'.
  wa_fcat-outputlen = 10.
  wa_fcat-coltext   = 'Work Phone'.
  APPEND wa_fcat TO it_fcat.

* Work Phone Ext
  CLEAR wa_fcat.
  wa_fcat-fieldname = 'PH_WORK_EXT'.
  wa_fcat-ref_table = 'WT_ZLMCONT'.
  wa_fcat-ref_field = 'PH_WORK_EXT'.
*  wa_fcat-hotspot   = 'X'.
  wa_fcat-outputlen = 6.
  wa_fcat-coltext   = 'Wk Ext'.
  APPEND wa_fcat TO it_fcat.
ENDFORM.                    " build_fcat_action_0108

*&---------------------------------------------------------------------*
*&      Form  build_layout_action_0108
*&---------------------------------------------------------------------*
*      <--P_WA_LAYOUT_ACTION  text
*----------------------------------------------------------------------*
FORM build_layout_action_0108 CHANGING wa_layout TYPE lvc_s_layo.

*  Init
  CLEAR wa_layout.

*  wa_layout-sel_mode = 'A'.
*  wa_layout-edit       = 'X'.
  wa_layout-no_toolbar = 'X'.
  wa_layout-grid_title = 'Contacts'.
  wa_layout-smalltitle = 'X'.

ENDFORM.                    " build_layout_action

Read only

0 Likes
651

Sam,

If you are using a report list then perhaps this can help. I don't know the structure of your table you are trying to read, so it is difficult to help with the SELECT statement, because I don't know what else would make the record you are trying to SELECT more unique.

With this example, you can use more of the fields possibly to assist in the SELECT. In this code I HIDE the WA record with the write so that it is returned when I do select. Perhaps there is more fields in your internal table that will help you in the WHERE of the select.


DATA:  f(30)   TYPE c,
       val(40) TYPE c.
DATA:
  BEGIN OF wa,
    fld1(4)    TYPE c,
    fld2(4)    TYPE c,
    fld3(4)    TYPE c,
    fld4(4)    TYPE c,
  END OF wa,
  it_fields LIKE STANDARD TABLE OF wa.

*---------------------------------------------------- Count Drill Down
AT LINE-SELECTION.

  GET CURSOR FIELD f
             VALUE val.

  WRITE:/ 'F ', f,
          'VAL ', val.
  WRITE:/1 'Field 1',
        10 'Field 2',
        20 'Field 3',
        30 'Field 4'.
  WRITE:/ wa-fld1 UNDER 'Field 1',
          wa-fld2 UNDER 'Field 2',
          wa-fld3 UNDER 'Field 3',
          wa-fld4 UNDER 'Field 4'.

START-OF-SELECTION.
  PERFORM load_table.
  WRITE:/1 'Field 1',
        10 'Field 2',
        20 'Field 3',
        30 'Field 4'.
  LOOP AT it_fields INTO wa.
    WRITE:/ wa-fld1 UNDER 'Field 1' HOTSPOT,
            wa-fld2 UNDER 'Field 2' HOTSPOT,
            wa-fld3 UNDER 'Field 3' HOTSPOT,
            wa-fld4 UNDER 'Field 4' HOTSPOT.
    HIDE: wa.
  ENDLOOP.

  CLEAR: wa.   " This is here to prove that the WA is return when the line is selected.

*&---------------------------------------------------------------------*
*&      Form  load_table
*&---------------------------------------------------------------------*
FORM load_table.
  wa-fld1 = '5000'. wa-fld2 = 'ADMN'. wa-fld3 = 'CIHE'. wa-fld4 = '5'.
  APPEND wa TO it_fields.
  wa-fld1 = '5000'. wa-fld2 = 'BIDE'. wa-fld3 = 'ADMN'. wa-fld4 = '5'.
  APPEND wa TO it_fields.
  wa-fld1 = '5000'. wa-fld2 = 'BIDE'. wa-fld3 = 'HR'. wa-fld4 = '5'.
  APPEND wa TO it_fields.
  wa-fld1 = '5000'. wa-fld2 = 'BIDE'. wa-fld3 = 'IT'. wa-fld4 = '5'.
  APPEND wa TO it_fields.
  wa-fld1 = '5000'. wa-fld2 = 'BIDE'. wa-fld3 = 'PROJ'. wa-fld4 = '15'.
  APPEND wa TO it_fields.
  wa-fld1 = '5000'. wa-fld2 = 'BIDE'. wa-fld3 = 'QUAL'. wa-fld4 = '5'.
  APPEND wa TO it_fields.
  wa-fld1 = '5000'. wa-fld2 = 'BIDE'. wa-fld3 = 'S&M'. wa-fld4 = '5'.
  APPEND wa TO it_fields.
  wa-fld1 = '5000'. wa-fld2 = 'BIDE'. wa-fld3 = 'SCM'. wa-fld4 = '5'.
  APPEND wa TO it_fields.

ENDFORM.                    " load_table

This is the primary OUTPUT


Field 1  Field 2   Field 3   Field 4  
5000     ADMN      CIHE      5        
5000     BIDE      ADMN      5        
5000     BIDE      HR        5        
5000     BIDE      IT        5        
5000     BIDE      PROJ      15       <==  I select this one
5000     BIDE      QUAL      5        
5000     BIDE      S&M       5        
5000     BIDE      SCM       5        

Selected OUTPUT


F  WA-FLD4                        VAL  15      
Field 1  Field 2   Field 3   Field 4           
5000     BIDE      PROJ      15                

Read only

0 Likes
651

Hey Paul,

Thanks for the effort taken by you to solve this problem.

my requirement is to achieve in the case of table controls only.

so thats why i insisted on this.

any ways the problem got solved by introducing a Serial Number field into the table control as well as the internal table which is very unique.

i can give you the screen shot also.

1	5000	ADMN	CIHE	5
2	5000	BIDE	ADMN	5
3	5000	BIDE	HR	5
4	5000	BIDE	IT	5
5	5000	BIDE	PROJ	15
6	5000	BIDE	QUAL	5
7	5000	BIDE	S&M	5
8	5000	BIDE	SCM	5

i thank you for the suggestions given by you.

if those suggestions were not given i would have not thought of this logic.

regards

samarendra

Read only

Former Member
0 Likes
651

Timely responded by Mr.Paul.

Thank you and Mr.Paul