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

Custom tocde for ztable with selection screen

former_member391265
Participant
0 Likes
2,623

Hi all

I have already checked as i didnt get proper solution for my query. hence i am updating this.

I have created a ztcode for ztable and successfully i have created it. It is showing the screen where we can enter or change data in ztable. But my problem is before this screen, i want my selection screen to come where user can select data and den can display and change..

Unable to get the selection screen .

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,667

Hi,

For this particular requirement, you will have to first create a new program with the selection screen for the Z-table as such . Within the program, you will have to call the table maintainance using FM:

   'VIEW_MAINTENANCE_CALL' . I hope this solves your problem.

Please check the following peace of code:

   FORM frm_get_data .
  CALL FUNCTION 'VIEW_GET_DDIC_INFO'
    EXPORTING
      viewname        = 'ZOMD_SUPERSEDE'(001)
    TABLES
      x_header        = gt_header
      x_namtab        = gt_namtab
      sellist         = gt_rangetab
    EXCEPTIONS
      no_tvdir_entry  = 1
      table_not_found = 2.
  IF sy-subrc <> 0.
    MESSAGE 'Error in ZOMD_SUPERSEDE Table'(003) TYPE 'E'.
  ENDIF.
  CLEAR: ls_rangetab,
         gt_rangetab.
  LOOP AT gt_namtab INTO ls_namtab.
    CASE ls_namtab-viewfield.
      WHEN gc_matnr.
        CLEAR ls_rangetab.
        ls_rangetab-viewfield = gc_matnr.
        ls_rangetab-tabix     = sy-tabix.
        ls_rangetab-ddic      = ls_namtab-readonly.
        LOOP AT s_matnr.
          CASE s_matnr-option.
            WHEN gc_eq.
              IF s_matnr-sign       = gc_e.
                ls_rangetab-negation  = gc_not.
              ENDIF.
              IF l_lines > 1.
                ls_rangetab-and_or      = gc_or.
              ELSE.
                ls_rangetab-and_or    = gc_and.
              ENDIF.
              ls_rangetab-operator  = gc_eq.
              ls_rangetab-value     = s_matnr-low.
              APPEND ls_rangetab TO gt_rangetab.
            WHEN gc_bt.
              IF s_matnr-sign       = gc_e.
                ls_rangetab-negation  = gc_not.
              ENDIF.
              ls_rangetab-and_or    = gc_and.
              ls_rangetab-operator = gc_ge.
              ls_rangetab-value     = s_matnr-low.
              APPEND ls_rangetab TO gt_rangetab.
              ls_rangetab-and_or    = gc_and.
              ls_rangetab-operator =  gc_le.
              ls_rangetab-value     = s_matnr-high.
              APPEND ls_rangetab TO gt_rangetab.
            WHEN gc_nb.
              CLEAR: r_matnr,
                     r_matnr[].
              r_matnr-sign = s_matnr-sign.
              r_matnr-option = gc_bt.
              r_matnr-low = s_matnr-low.
              r_matnr-high = s_matnr-high.
              APPEND r_matnr.
              SELECT matnr
                     INTO CORRESPONDING FIELDS OF TABLE gt_matnr
                     FROM zomd_supersede
                     WHERE matnr IN r_matnr.
              DELETE ADJACENT DUPLICATES FROM gt_matnr COMPARING matnr
.
              LOOP AT gt_matnr INTO ls_matnr.
                ls_rangetab-and_or    = gc_and.
                ls_rangetab-operator = gc_ne.
                ls_rangetab-value    = ls_matnr-matnr.
                APPEND ls_rangetab TO gt_rangetab.
              ENDLOOP.
            WHEN gc_ne.
              IF s_matnr-sign       = gc_e.
                ls_rangetab-negation  = gc_not.
              ENDIF.
              ls_rangetab-and_or    = gc_and.
              ls_rangetab-operator  = gc_ne.
              ls_rangetab-value     = s_matnr-low.
              APPEND ls_rangetab TO gt_rangetab.
            WHEN OTHERS.
              IF s_matnr-sign       = gc_e.
                ls_rangetab-negation  = gc_not.
              ENDIF.
              ls_rangetab-and_or    = gc_and.
              ls_rangetab-operator = s_matnr-option.
              ls_rangetab-value    = s_matnr-low.
              APPEND ls_rangetab TO gt_rangetab.
          ENDCASE.
        ENDLOOP.
    ENDCASE.

  ENDLOOP.

  CALL FUNCTION 'VIEW_MAINTENANCE_CALL'
    EXPORTING
      action                       = gc_u
*     SHOW_SELECTION_POPUP         = 'X'
      view_name                    = 'ZOMD_SUPERSEDE'(001)
    TABLES
      dba_sellist                  = gt_rangetab
    EXCEPTIONS
      client_reference             = 1
      foreign_lock                 = 2
      invalid_action               = 3
      no_clientindependent_auth    = 4
      no_database_function         = 5
      no_editor_function           = 6
      no_show_auth                 = 7
      no_tvdir_entry               = 8
      no_upd_auth                  = 9
      only_show_allowed            = 10
      system_failure               = 11
      unknown_field_in_dba_sellist = 12
      view_not_found               = 13
      maintenance_prohibited       = 14
      OTHERS                       = 15.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
       WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

Thanks,

Nitin


   

Hi all

I have already checked as i didnt get proper solution for my query. hence i am updating this.

I have created a ztcode for ztable and successfully i have created it. It is showing the screen where we can enter or change data in ztable. But my problem is before this screen, i want my selection screen to come where user can select data and den can display and change..

Unable to get the selection screen .

Thanks

11 REPLIES 11
Read only

Former Member
0 Likes
1,667

Hi,

Not sure if I have understood your requirement, but have you created a one-step Maintenance Type or two-step Maintenance type ? If its one-step, please create a Table Maintenance Generator with 2-step Maintenance type. To do this, you will have to delete the TMG and create it again.

Hope this is what your requirment is! Try it out and let us know.

Read only

Former Member
0 Likes
1,667

hi,

create a TMG with two step, i mean two screens..

so that your first screen ll be your selection and second ll be your data manipulation.

thanks,

Mathan R.

Read only

0 Likes
1,667

I created but its not working ... see i have created  z tcode  for ztable .. it is displaying data in ztable when i execute the ztcode...but before displaying data in output, it should show selection screen...and den data entries..

Read only

0 Likes
1,667

Hi,

I think you have cretaed TMG for your ZTZBLE ( 2 screen) ,,,,,while assigning Ztransaction to ZTABLE  in se93 do like this,,,,,,,

transaction :SM30.

****bottom,,default values option will be there******

***write like as below*********************************

VIEWNAME :   ZTABLE(your table)

UPDATE    : 'X'

regards.

lingaraj.

Read only

Former Member
0 Likes
1,668

Hi,

For this particular requirement, you will have to first create a new program with the selection screen for the Z-table as such . Within the program, you will have to call the table maintainance using FM:

   'VIEW_MAINTENANCE_CALL' . I hope this solves your problem.

Please check the following peace of code:

   FORM frm_get_data .
  CALL FUNCTION 'VIEW_GET_DDIC_INFO'
    EXPORTING
      viewname        = 'ZOMD_SUPERSEDE'(001)
    TABLES
      x_header        = gt_header
      x_namtab        = gt_namtab
      sellist         = gt_rangetab
    EXCEPTIONS
      no_tvdir_entry  = 1
      table_not_found = 2.
  IF sy-subrc <> 0.
    MESSAGE 'Error in ZOMD_SUPERSEDE Table'(003) TYPE 'E'.
  ENDIF.
  CLEAR: ls_rangetab,
         gt_rangetab.
  LOOP AT gt_namtab INTO ls_namtab.
    CASE ls_namtab-viewfield.
      WHEN gc_matnr.
        CLEAR ls_rangetab.
        ls_rangetab-viewfield = gc_matnr.
        ls_rangetab-tabix     = sy-tabix.
        ls_rangetab-ddic      = ls_namtab-readonly.
        LOOP AT s_matnr.
          CASE s_matnr-option.
            WHEN gc_eq.
              IF s_matnr-sign       = gc_e.
                ls_rangetab-negation  = gc_not.
              ENDIF.
              IF l_lines > 1.
                ls_rangetab-and_or      = gc_or.
              ELSE.
                ls_rangetab-and_or    = gc_and.
              ENDIF.
              ls_rangetab-operator  = gc_eq.
              ls_rangetab-value     = s_matnr-low.
              APPEND ls_rangetab TO gt_rangetab.
            WHEN gc_bt.
              IF s_matnr-sign       = gc_e.
                ls_rangetab-negation  = gc_not.
              ENDIF.
              ls_rangetab-and_or    = gc_and.
              ls_rangetab-operator = gc_ge.
              ls_rangetab-value     = s_matnr-low.
              APPEND ls_rangetab TO gt_rangetab.
              ls_rangetab-and_or    = gc_and.
              ls_rangetab-operator =  gc_le.
              ls_rangetab-value     = s_matnr-high.
              APPEND ls_rangetab TO gt_rangetab.
            WHEN gc_nb.
              CLEAR: r_matnr,
                     r_matnr[].
              r_matnr-sign = s_matnr-sign.
              r_matnr-option = gc_bt.
              r_matnr-low = s_matnr-low.
              r_matnr-high = s_matnr-high.
              APPEND r_matnr.
              SELECT matnr
                     INTO CORRESPONDING FIELDS OF TABLE gt_matnr
                     FROM zomd_supersede
                     WHERE matnr IN r_matnr.
              DELETE ADJACENT DUPLICATES FROM gt_matnr COMPARING matnr
.
              LOOP AT gt_matnr INTO ls_matnr.
                ls_rangetab-and_or    = gc_and.
                ls_rangetab-operator = gc_ne.
                ls_rangetab-value    = ls_matnr-matnr.
                APPEND ls_rangetab TO gt_rangetab.
              ENDLOOP.
            WHEN gc_ne.
              IF s_matnr-sign       = gc_e.
                ls_rangetab-negation  = gc_not.
              ENDIF.
              ls_rangetab-and_or    = gc_and.
              ls_rangetab-operator  = gc_ne.
              ls_rangetab-value     = s_matnr-low.
              APPEND ls_rangetab TO gt_rangetab.
            WHEN OTHERS.
              IF s_matnr-sign       = gc_e.
                ls_rangetab-negation  = gc_not.
              ENDIF.
              ls_rangetab-and_or    = gc_and.
              ls_rangetab-operator = s_matnr-option.
              ls_rangetab-value    = s_matnr-low.
              APPEND ls_rangetab TO gt_rangetab.
          ENDCASE.
        ENDLOOP.
    ENDCASE.

  ENDLOOP.

  CALL FUNCTION 'VIEW_MAINTENANCE_CALL'
    EXPORTING
      action                       = gc_u
*     SHOW_SELECTION_POPUP         = 'X'
      view_name                    = 'ZOMD_SUPERSEDE'(001)
    TABLES
      dba_sellist                  = gt_rangetab
    EXCEPTIONS
      client_reference             = 1
      foreign_lock                 = 2
      invalid_action               = 3
      no_clientindependent_auth    = 4
      no_database_function         = 5
      no_editor_function           = 6
      no_show_auth                 = 7
      no_tvdir_entry               = 8
      no_upd_auth                  = 9
      only_show_allowed            = 10
      system_failure               = 11
      unknown_field_in_dba_sellist = 12
      view_not_found               = 13
      maintenance_prohibited       = 14
      OTHERS                       = 15.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
       WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

Thanks,

Nitin


   

Read only

0 Likes
1,667

Agreed.  I'd also like to add that one way to make this code shorter is by using FM 'VIEW_RANGETAB_TO_SELLIST'.  You can write the entire program in 46 lines plus two for every parameter or select-option.  See the linked document.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,667

Look at answers at display filtered data in SM30. (and use seach tools too)

Regards,

Raymond

Read only

Former Member
0 Likes
1,667

Hi,

As has been already told before, in this case you do not have to create t-code for Z-table but , rather, you have to create a custom report program where you have to add the required selection screen and then yoiu have to call the Table maintainance using the FM:'VIEW_MAINTENANCE_CALL' and you have to pass all the selection screen parameters to the table maintainance .Please check the complete code here for your reference:-

   REPORT  ztable_maintainance.

*--Types declaration for selection to be passed as parameter into
*--VIEW_MAINTENANCE_CALL FM
TYPES: BEGIN OF tp_rangetab.
        INCLUDE STRUCTURE vimsellist.
TYPES: END OF tp_rangetab.
*----------------------------------------------------------------------*
*                D A T A  D E C L A R A T I O N S
*----------------------------------------------------------------------*
DATA: g_matnr TYPE matnr.              " Material Number

*----------------------------------------------------------------------*
*        I N T E R N A L  T A B L E  D E C L A R A T I O N S
*----------------------------------------------------------------------*
* Internal table to subroutine code
*Internal table used as selection for VIEW_MAINTENANCE_CALL FM
DATA: gt_rangetab TYPE STANDARD TABLE OF tp_rangetab,
      ls_rangetab TYPE  vimsellist.
*--Internal table used for getting the tablefields
TYPES: BEGIN OF ty_header.
        INCLUDE STRUCTURE vimdesc.
TYPES:   END   OF ty_header.
*--Name Tabel
TYPES: BEGIN OF ty_namtab.
        INCLUDE STRUCTURE vimnamtab.
TYPES: END OF ty_namtab.
*--Used for handling 'BT' option
TYPES: BEGIN OF ty_matnr,
        matnr TYPE matnr,
   END OF ty_matnr.

DATA: gt_namtab   TYPE STANDARD TABLE OF ty_namtab,
      gt_matnr    TYPE STANDARD TABLE OF  ty_matnr,
      gt_header   TYPE STANDARD TABLE OF ty_header,
      ls_namtab   TYPE ty_namtab,
      ls_matnr    TYPE ty_matnr,
      l_lines TYPE i.
*--Used for handling 'BT' option

CONSTANTS: gc_matnr TYPE char5 VALUE 'MATNR',
           gc_and TYPE char5 VALUE 'AND',
           gc_eq  TYPE char2 VALUE 'EQ',
           gc_le  TYPE char2 VALUE 'LE',
           gc_ge  TYPE char2 VALUE 'GE',
           gc_bt  TYPE char2 VALUE 'BT',
           gc_u   TYPE char1 VALUE 'U',
           gc_i   TYPE char1 VALUE 'I',
           gc_or  TYPE char2 VALUE 'OR',
           gc_nb  TYPE char2 VALUE 'NB',
           gc_ne  TYPE char2 VALUE 'NE',
           gc_e   TYPE char1 VALUE 'E',
           gc_not TYPE char3 VALUE 'NOT'.

*----------------------------------------------------------------------*
*                    I N P U T  S C R E E N
*----------------------------------------------------------------------*

RANGES: r_matnr FOR g_matnr.
SELECTION-SCREEN BEGIN OF BLOCK selscr WITH FRAME TITLE text-002.
* Select Options
SELECT-OPTIONS: s_matnr FOR g_matnr.      " Material
SELECTION-SCREEN END OF BLOCK selscr.

*----------------------------------------------------------------------*
*              A T  S E L E C T I O N  S C R E E N
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
*----------------------------------------------------------------------*
*             S T A R T  O F  S E L E C T I O N
*----------------------------------------------------------------------*
START-OF-SELECTION.

  DESCRIBE TABLE s_matnr LINES l_lines.
* Fetch Data from Data Base
  PERFORM frm_get_data.
*----------------------------------------------------------------------*
*                      S U B  R O U T I N E S
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  frm_get_data
*&---------------------------------------------------------------------*
*       Call the function module VIEW_MAINTENNACE_CALL to get data
*       based on selection criteria
*----------------------------------------------------------------------*
FORM frm_get_data .
  CALL FUNCTION 'VIEW_GET_DDIC_INFO'
    EXPORTING
      viewname        = 'ZOMD_SUPERSEDE'(001)
    TABLES
      x_header        = gt_header
      x_namtab        = gt_namtab
      sellist         = gt_rangetab
    EXCEPTIONS
      no_tvdir_entry  = 1
      table_not_found = 2.
  IF sy-subrc <> 0.
    MESSAGE 'Error in ZOMD_SUPERSEDE Table'(003) TYPE 'E'.
  ENDIF.
  CLEAR: ls_rangetab,
         gt_rangetab.
  LOOP AT gt_namtab INTO ls_namtab.
    CASE ls_namtab-viewfield.
      WHEN gc_matnr.
        CLEAR ls_rangetab.
        ls_rangetab-viewfield = gc_matnr.
        ls_rangetab-tabix     = sy-tabix.
        ls_rangetab-ddic      = ls_namtab-readonly.
        LOOP AT s_matnr.
          CASE s_matnr-option.
            WHEN gc_eq.
              IF s_matnr-sign       = gc_e.
                ls_rangetab-negation  = gc_not.
              ENDIF.
              IF l_lines > 1.
                ls_rangetab-and_or      = gc_or.
              ELSE.
                ls_rangetab-and_or    = gc_and.
              ENDIF.
              ls_rangetab-operator  = gc_eq.
              ls_rangetab-value     = s_matnr-low.
              APPEND ls_rangetab TO gt_rangetab.
            WHEN gc_bt.
              IF s_matnr-sign       = gc_e.
                ls_rangetab-negation  = gc_not.
              ENDIF.
              ls_rangetab-and_or    = gc_and.
              ls_rangetab-operator = gc_ge.
              ls_rangetab-value     = s_matnr-low.
              APPEND ls_rangetab TO gt_rangetab.
              ls_rangetab-and_or    = gc_and.
              ls_rangetab-operator =  gc_le.
              ls_rangetab-value     = s_matnr-high.
              APPEND ls_rangetab TO gt_rangetab.
            WHEN gc_nb.
              CLEAR: r_matnr,
                     r_matnr[].
              r_matnr-sign = s_matnr-sign.
              r_matnr-option = gc_bt.
              r_matnr-low = s_matnr-low.
              r_matnr-high = s_matnr-high.
              APPEND r_matnr.
              SELECT matnr
                     INTO CORRESPONDING FIELDS OF TABLE gt_matnr
                     FROM zomd_supersede
                     WHERE matnr IN r_matnr.
              DELETE ADJACENT DUPLICATES FROM gt_matnr COMPARING matnr
.
              LOOP AT gt_matnr INTO ls_matnr.
                ls_rangetab-and_or    = gc_and.
                ls_rangetab-operator = gc_ne.
                ls_rangetab-value    = ls_matnr-matnr.
                APPEND ls_rangetab TO gt_rangetab.
              ENDLOOP.
            WHEN gc_ne.
              IF s_matnr-sign       = gc_e.
                ls_rangetab-negation  = gc_not.
              ENDIF.
              ls_rangetab-and_or    = gc_and.
              ls_rangetab-operator  = gc_ne.
              ls_rangetab-value     = s_matnr-low.
              APPEND ls_rangetab TO gt_rangetab.
            WHEN OTHERS.
              IF s_matnr-sign       = gc_e.
                ls_rangetab-negation  = gc_not.
              ENDIF.
              ls_rangetab-and_or    = gc_and.
              ls_rangetab-operator = s_matnr-option.
              ls_rangetab-value    = s_matnr-low.
              APPEND ls_rangetab TO gt_rangetab.
          ENDCASE.
        ENDLOOP.
    ENDCASE.

  ENDLOOP.

  CALL FUNCTION 'VIEW_MAINTENANCE_CALL'
    EXPORTING
      action                       = gc_u
*     SHOW_SELECTION_POPUP         = 'X'
      view_name                    = 'ZOMD_SUPERSEDE'(001)
    TABLES
      dba_sellist                  = gt_rangetab
    EXCEPTIONS
      client_reference             = 1
      foreign_lock                 = 2
      invalid_action               = 3
      no_clientindependent_auth    = 4
      no_database_function         = 5
      no_editor_function           = 6
      no_show_auth                 = 7
      no_tvdir_entry               = 8
      no_upd_auth                  = 9
      only_show_allowed            = 10
      system_failure               = 11
      unknown_field_in_dba_sellist = 12
      view_not_found               = 13
      maintenance_prohibited       = 14
      OTHERS                       = 15.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
       WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

ENDFORM.                    " frm_get_data

   

I hope this will help you.

Thanks,

Nitin

Read only

Former Member
0 Likes
1,667

hi ,

after searching for ur post , i got few droughts  to ask u ..

have u created maintenance view?

https://scn.sap.com/thread/544877

Read only

0 Likes
1,667

Hi Raghunath,

It is just a Table Maintainance only.

Thanks,

Nitin

Read only

Former Member
0 Likes
1,667

HI,

first u display the selection-screen then when user executes(F8) it, in start-of-selection event

call ur transaction code by using call transaction 'zXXXX' statement so from selection-screen ur tcode will be called where u can change or display etc .

Regards,

Vineesh.