Application Development 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: 

table maintainence

Former Member
0 Kudos
503

Hi abapers,

I have the following requirment:

1) I have to create a custom Z table having various fields.

2) it should have a facility that the user can manually enter update delete or view

enteries from the table.

what can this be carried out.

Regards,

Aditya

1 ACCEPTED SOLUTION

Former Member
0 Kudos
473

Hi aditya

You could achieve this through module programming in SE80.

check out this code

you need to create screens 9000,9001,9002 also

PROGRAM znel_breakdown_details MESSAGE-ID vz.

*---TABLES

TABLES : znel_breakdown,znel_reason.

*---INTERNAL TABLES DECLARATION

DATA : BEGIN OF t_breakdown OCCURS 0.

INCLUDE STRUCTURE znel_breakdown.

DATA : END OF t_breakdown.

DATA : BEGIN OF t_breakdown1 OCCURS 0.

INCLUDE STRUCTURE znel_breakdown.

DATA: pick TYPE char1.

DATA : END OF t_breakdown1.

TYPES : BEGIN OF tp_reason,

reason(40) TYPE c,

END OF tp_reason.

TYPES : BEGIN OF tp_shift,

shift TYPE znel_breakdown-shift,

END OF tp_shift.

DATA : t_reason TYPE STANDARD TABLE OF tp_reason WITH HEADER LINE,

t_shift TYPE STANDARD TABLE OF tp_shift WITH HEADER LINE.

*---TABLE CONTROL DECLARATION

CONTROLS: t_ctrl TYPE TABLEVIEW USING SCREEN '9001',

t_ctrl1 TYPE TABLEVIEW USING SCREEN '9002',

t_ctrl2 TYPE TABLEVIEW USING SCREEN '9003'.

*--VARIABLE DECLARATION

DATA : flg, "Flag to set the change mode

ln TYPE i, "No. of records

ln_1 TYPE i,

l_date TYPE dats,

l_plant TYPE werks,

l_shift TYPE c.

.

&----


*& Module GET_T_CTRL_LINES OUTPUT

&----


  • Get data for screen 9001

----


MODULE get_t_ctrl_lines OUTPUT.

SELECT entry_date

plant

shift

reason

mins

INTO CORRESPONDING FIELDS OF TABLE t_breakdown

FROM znel_breakdown.

IF sy-subrc EQ 0.

SORT t_breakdown BY entry_date.

ELSE.

MESSAGE i000 WITH 'No data found'.

ENDIF.

DESCRIBE TABLE t_breakdown LINES ln_1.

  • To make the vertical scroll bar to come on runtime

T_CTRL-LINES = LN_1 + 100.

ENDMODULE. " GET_T_CTRL_LINES OUTPUT

&----


*& Module SET_SCREEN_FIELDS OUTPUT

&----


  • Set the screen fields

----


MODULE set_screen_fields OUTPUT.

LOOP AT SCREEN.

IF ( screen-name = 'T_BREAKDOWN-ENTRY_DATE'

OR screen-name = 'T_BREAKDOWN-PLANT'

OR screen-name = 'T_BREAKDOWN-SHIFT'

OR screen-name = 'T_BREAKDOWN-REASON'

OR screen-name = 'T_BREAKDOWN-MINS').

screen-input = 0.

ENDIF.

  • Modifying the screen after making changes

MODIFY SCREEN.

ENDLOOP.

ENDMODULE. " SET_SCREEN_FIELDS OUTPUT

&----


*& Module USER_COMMAND_9001 INPUT

&----


  • user command for 9001

----


MODULE user_command_9001 INPUT.

DATA :lv_fcode LIKE sy-ucomm. "Function Code

lv_fcode = sy-ucomm.

CASE lv_fcode.

WHEN 'BACK'.

SET SCREEN '9000'.

WHEN 'EXIT' OR 'CANCEL'.

  • Leaving the program

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_9000 INPUT

&----


*& Module STATUS_9000 OUTPUT

&----


  • text

----


MODULE status_9000 OUTPUT.

SET PF-STATUS 'ZSTATUS'.

SET TITLEBAR 'ZTITLE9000'.

ENDMODULE. " STATUS_9000 OUTPUT

&----


*& Module ON_VALUE_REQUEST_9003 OUTPUT

&----


  • To display values for shift ,palnt and reason

----


MODULE on_value_request_9003 OUTPUT.

*To display values in List Box

TYPE-POOLS: vrm.

DATA: values_1 TYPE vrm_values WITH HEADER LINE,

values_2 TYPE vrm_values WITH HEADER LINE,

values_3 TYPE vrm_values WITH HEADER LINE.

DATA : line1 LIKE LINE OF values_1,

line2 LIKE LINE OF values_2.

CLEAR : values_1,

values_2,

values_3.

REFRESH:values_1,

values_2,

values_3.

line1-key = 'A'.

line1-text = 'A'.

APPEND line1 TO values_1.

line1-key = 'B'.

line1-text = 'B'.

APPEND line1 TO values_1.

line1-key = 'C'.

line1-text = 'C'.

APPEND line1 TO values_1.

SORT values_1 BY text.

DELETE ADJACENT DUPLICATES FROM values_1 COMPARING ALL FIELDS.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'T_BREAKDOWN1-SHIFT'

values = values_1[]

EXCEPTIONS

id_illegal_name = 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.

line2-key = '2000'.

line2-text = '2000'.

APPEND line2 TO values_2.

line2-key = '3000'.

line2-text = '3000'.

APPEND line2 TO values_2.

line2-key = '4000'.

line2-text = '4000'.

APPEND line2 TO values_2.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'T_BREAKDOWN1-PLANT'

values = values_2[]

EXCEPTIONS

id_illegal_name = 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.

SELECT DISTINCT reason FROM znel_reason INTO TABLE t_reason

where plant = znel_breakdown-plant.

LOOP AT t_reason.

values_3-key = t_reason-reason.

values_3-text = t_reason-reason.

APPEND values_3.

CLEAR: values_3.

ENDLOOP.

SORT values_3 BY text.

  • delete adjacent duplicates from values_2 comparing all fields.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'T_BREAKDOWN1-REASON'

values = values_3[]

EXCEPTIONS

id_illegal_name = 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.

ENDMODULE. " ON_VALUE_REQUEST OUTPUT

&----


*& Module GET_T_CTRL_LINES1 OUTPUT

&----


  • Get control lines

----


MODULE get_t_ctrl_lines1 OUTPUT.

SELECT entry_date

plant

shift

reason

mins

INTO CORRESPONDING FIELDS OF TABLE t_breakdown1

FROM znel_breakdown.

DESCRIBE TABLE t_breakdown1 LINES ln.

  • To make the vertical scroll bar to come on runtime

t_ctrl-lines = ln + 100.

ENDMODULE. " GET_T_CTRL_LINES1 OUTPUT

&----


*& Module STATUS_9001 OUTPUT

&----


  • text

----


MODULE status_9001 OUTPUT.

SET PF-STATUS 'ZSTATUS9001'.

SET TITLEBAR 'ZTITLE9001'.

ENDMODULE. " STATUS_9001 OUTPUT

&----


*& Module SET_SCREEN_FIELDS_9003 OUTPUT

&----


  • text

----


MODULE set_screen_fields_9003 OUTPUT.

CLEAR : screen.

REFRESH : t_breakdown1.

LOOP AT SCREEN.

IF screen-name = 'T_BREAKDOWN1-ENTRY_DATE'.

t_breakdown1-entry_date = znel_breakdown-entry_date.

ENDIF.

IF screen-name = 'T_BREAKDOWN1-PLANT'.

t_breakdown1-plant = znel_breakdown-plant.

ENDIF.

IF screen-name = 'T_BREAKDOWN1-SHIFT'.

t_breakdown1-shift = znel_breakdown-shift.

ENDIF.

IF ( screen-name = 'T_BREAKDOWN1-ENTRY_DATE'

OR screen-name = 'T_BREAKDOWN1-PLANT'

OR screen-name = 'T_BREAKDOWN1-SHIFT' ).

screen-input = 0.

ENDIF.

IF ( screen-name = 'T_BREAKDOWN1-REASON'

OR screen-name = 'T_BREAKDOWN1-MINS').

screen-input = 1.

ENDIF.

  • Modifying the screen after making changes

MODIFY SCREEN.

ENDLOOP.

ENDMODULE. " SET_SCREEN_FIELDS_9001 OUTPUT

&----


*& Module CHECK INPUT

&----


  • text

----


MODULE check INPUT.

*Check For Current Line

MODIFY t_breakdown1 INDEX t_ctrl1-current_line.

ENDMODULE. " CHECK INPUT

&----


*& Module USER_COMMAND_9000 INPUT

&----


  • user command for 9000

----


MODULE user_command_9000 INPUT.

DATA :l_fcode LIKE sy-ucomm. "Function Code

l_fcode = sy-ucomm.

CASE l_fcode.

WHEN 'DISPLAY'.

CALL SCREEN 9001.

WHEN 'CHANGE'.

CALL SCREEN 9002.

WHEN 'ADD'.

REFRESH : t_breakdown1.

CALL SCREEN 9003.

WHEN 'BACK'.

LEAVE PROGRAM.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_9000 INPUT

&----


*& Module GET_FIELDS_9001 OUTPUT

&----


  • Get fields

----


MODULE get_fields_9002 OUTPUT.

SELECT entry_date

plant

shift

reason

mins

INTO CORRESPONDING FIELDS OF TABLE t_breakdown1

FROM znel_breakdown

WHERE entry_date = znel_breakdown-entry_date

AND plant = znel_breakdown-plant

AND shift = znel_breakdown-shift.

IF sy-subrc EQ 0.

SORT t_breakdown1 BY entry_date.

ELSE.

MESSAGE i000 WITH 'No data found'.

CALL SCREEN 9000.

ENDIF.

DESCRIBE TABLE t_breakdown LINES ln_1.

  • To make the vertical scroll bar to come on runtime

T_CTRL1-LINES = LN_1 + 100.

CLEAR : l_date,

l_plant,

l_shift.

l_date = znel_breakdown-entry_date.

l_plant = znel_breakdown-plant.

l_shift = znel_breakdown-shift.

LOOP AT SCREEN.

IF ( screen-name = 'T_BREAKDOWN1-ENTRY_DATE'

OR screen-name = 'T_BREAKDOWN1-PLANT'

OR screen-name = 'T_BREAKDOWN1-SHIFT' ).

screen-input = 0.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

ENDMODULE. " GET_FIELDS_9001 OUTPU

&----


*& Module STATUS_9003 OUTPUT

&----


  • text

----


MODULE status_9003 OUTPUT.

SET PF-STATUS 'ZSTATUS3'.

SET TITLEBAR 'ZTITLE9003'.

ENDMODULE. " STATUS_9003 OUTPUT

&----


*& Module USER_COMMAND_9003 INPUT

&----


  • user command for 9003

----


MODULE user_command_9003 INPUT.

DATA : l_fcode1 TYPE sy-ucomm.

l_fcode1 = sy-ucomm.

CASE l_fcode1.

WHEN 'SAVE'.

LOOP AT t_breakdown1.

MODIFY znel_breakdown FROM t_breakdown1.

ENDLOOP.

CLEAR screen.

CALL SCREEN 9000.

WHEN 'BACK'.

CALL SCREEN 9000.

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'STOP'.

STOP.

ENDCASE.

ENDMODULE. " USER_COMMAND_9003 INPUT

&----


*& Module MODIFY_TAB_9003 INPUT

&----


  • Modify table

----


MODULE modify_tab_9003 INPUT.

t_breakdown1-entry_date = l_date.

t_breakdown1-plant = l_plant.

t_breakdown1-shift = l_shift.

t_breakdown1-reason = t_breakdown1-reason.

t_breakdown1-mins = t_breakdown1-mins.

APPEND t_breakdown1.

CLEAR t_breakdown1.

ENDMODULE. " MODIFY_TAB_9003 INPUT

&----


*& Module GET_DATA INPUT

&----


  • Get data

----


MODULE get_data INPUT.

CLEAR : l_date,

l_plant,

l_shift.

l_date = t_breakdown1-entry_date.

l_plant = t_breakdown1-plant.

l_shift = t_breakdown1-shift.

ENDMODULE. " GET_DATA INPUT

&----


*& Module SET_SCREEN_FIELDS_9001 OUTPUT

&----


  • Set screen fields

----


MODULE set_screen_fields_9001 OUTPUT.

t_breakdown1-entry_date = l_date.

t_breakdown1-plant = l_plant.

t_breakdown1-shift = l_shift.

LOOP AT SCREEN.

IF ( screen-name = 'T_BREAKDOWN1-REASON' ).

screen-input = 0.

ELSEIF ( screen-name = 'T_BREAKDOWN1-MINS').

screen-input = 1.

ENDIF.

  • Modifying the screen after making changes

MODIFY SCREEN.

ENDLOOP.

ENDMODULE. " SET_SCREEN_FIELDS_9001 OUTPUT

&----


*& Module MODIFY_TAB_9002 INPUT

&----


  • Modify internal table

----


MODULE modify_tab_9002 INPUT.

t_breakdown1-entry_date = l_date.

t_breakdown1-plant = l_plant.

t_breakdown1-shift = l_shift.

t_breakdown1-reason = t_breakdown1-reason.

t_breakdown1-mins = t_breakdown1-mins.

t_breakdown1-pick = t_breakdown1-pick.

APPEND t_breakdown1.

ENDMODULE. " MODIFY_TAB_9002 INPUT

&----


*& Module USER_COMMAND_9002 INPUT

&----


  • user command for 9002

----


MODULE user_command_9002 INPUT.

DATA : l_fcode2 TYPE sy-ucomm,

lv_answer type c.

l_fcode2 = sy-ucomm.

CASE l_fcode2.

WHEN 'SAVE'.

LOOP AT t_breakdown1.

UPDATE znel_breakdown FROM TABLE t_breakdown1.

ENDLOOP.

WHEN 'DELETE'.

  • Confirmation of delete

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

titlebar = 'Confirm'

text_question = 'Are you sure to delete from database?'

text_button_1 = 'Yes'(001)

text_button_2 = 'No'(002)

IMPORTING

answer = lv_answer.

IF lv_answer EQ '1'.

  • Deleting the selected row from the internal table

LOOP AT t_breakdown1.

IF t_breakdown1-pick = 'X'.

DELETE znel_breakdown FROM t_breakdown1.

ENDIF.

ENDLOOP.

DELETE t_breakdown1 WHERE pick = 'X'.

ELSEIF lv_answer = '2'.

CALL SCREEN 9002.

ENDIF.

WHEN 'BACK'.

SET SCREEN '9000'.

ENDCASE.

ENDMODULE. " USER_COMMAND_9002 IN

&----


*& Module CHECK_DATE INPUT

&----


  • Date validation

----


MODULE check_date INPUT.

IF t_breakdown1-entry_date IS INITIAL.

MESSAGE s000 WITH 'enter date'.

ENDIF.

ENDMODULE. " CHECK_DATE INPUT

&----


*& Module ON_VALUE_REQUEST OUTPUT

&----


  • To default values for field shift

----


MODULE on_value_request OUTPUT.

*To display values in List Box

TYPE-POOLS: vrm.

DATA: values_4 TYPE vrm_values WITH HEADER LINE.

DATA : line4 LIKE LINE OF values_4.

CLEAR : values_4.

REFRESH:values_4.

line4-key = 'A'.

line4-text = 'A'.

APPEND line4 TO values_4.

line4-key = 'B'.

line4-text = 'B'.

APPEND line4 TO values_4.

line4-key = 'C'.

line4-text = 'C'.

APPEND line4 TO values_4.

SORT values_4 BY text.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'ZNEL_BREAKDOWN-SHIFT'

values = values_4[]

EXCEPTIONS

id_illegal_name = 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.

ENDMODULE. " ON_VALUE_REQUEST OUTPUT

&----


*& Module STATUS_9002 OUTPUT

&----


  • Set status

----


MODULE status_9002 OUTPUT.

SET PF-STATUS 'ZSTATUS9002'.

SET TITLEBAR 'ZTITLE9002'.

ENDMODULE. " STATUS_9002 OUTP

&----


*& Module RETURN_EXIT INPUT

&----


  • text

----


module RETURN_EXIT input.

case sy-ucomm.

when 'BACK'.

clear screen.

leave to screen 9000.

endcase.

endmodule. " RETURN_EXIT INPU

10 REPLIES 10

Former Member
0 Kudos
473

Hi Aditya,

Create the necessary Z table using SE11 and use the table maintainance generator option from the menu to allow the users to create new entries and delete the already existing ones.

Thanks,

Pradeep

Former Member
0 Kudos
473

Go to utilities and make a table maintaince generator for it.

Utilities-->Table Maintaince Generator

Authorization Group = &NC&

Function group = " create a function group from se37, activate it and give it here

Maintenance type = One Step

Maint. Screen No. Overview screen " enter any number from 1 to 9999

Single screen " enter any number from 1 to 9999

former_member1245113
Active Contributor
0 Kudos
473

Hi Aditya,

after creating the table and getting it activated, go to utilities there you find the table maintanance generator. if you click on this it will take you to another screen where enter required infromation and get it generated. then go to SM30 and follow the steps .

Hope this will serve your purpse.

Thanks and Regards

Ramchander Rao.Krishnamraju

SuhaSaha
Advisor
Advisor
0 Kudos
473

Hello,

GOTO t-code SE11. then follow the path:

Utilities --> Table Maintenance Generator. The follow the steps:

1. Authorisation Grp: &NC&

2. Function Grp: Enter any name starting with Z.

3. Maintenance Type:

1. Choose single step / double step as reqd.

2. Give the scr. nmbr (u can give any no. u widh ) )

The user then can use SM30 to input/change table entries.

Hope this helps.

BR,

Suhas

Edited by: Suhas Saha on Nov 20, 2008 10:25 AM

Former Member
0 Kudos
473

Guys,

I did try table maintainence generator etc.

But my requirment is to develop a screen where the user should have various options like add enter delete or view the enteries in the table.

how can we go about it.

basically the requirment is to keep the user away from the the technical SM30 stuff!!

0 Kudos
473

Ahh there u go ...

I have a gr8 idea for this ) Goto SE93 & create a parameter transaction for the TMG.

1. Goto SE93, give the name of the t-code. Say, ZTMG & select the last raio button whic saya Parameter Transaction.

2. In the transaction box input SM30 & check the "Skip Initial screen" checkbox

3. At the bottom u will find Default Values table:

Name of the Screen Field Value

VIEWNAME <Name of ur Z-Table>

UPDATE X

Run the t-code & check.

Hope this helps.

BR,

Suhas

Former Member
0 Kudos
473

Hi Aditya,

For this you can create transaction for SM30 for Ztable !

Thanks,

Pradeep

Former Member
0 Kudos
473

Hi,

After you have created a table maintenance , you can create a tcode so that users can use it and don't need to go through SM30.

Any doubt let me know.

Regards,

Chris Gu

Former Member
0 Kudos
474

Hi aditya

You could achieve this through module programming in SE80.

check out this code

you need to create screens 9000,9001,9002 also

PROGRAM znel_breakdown_details MESSAGE-ID vz.

*---TABLES

TABLES : znel_breakdown,znel_reason.

*---INTERNAL TABLES DECLARATION

DATA : BEGIN OF t_breakdown OCCURS 0.

INCLUDE STRUCTURE znel_breakdown.

DATA : END OF t_breakdown.

DATA : BEGIN OF t_breakdown1 OCCURS 0.

INCLUDE STRUCTURE znel_breakdown.

DATA: pick TYPE char1.

DATA : END OF t_breakdown1.

TYPES : BEGIN OF tp_reason,

reason(40) TYPE c,

END OF tp_reason.

TYPES : BEGIN OF tp_shift,

shift TYPE znel_breakdown-shift,

END OF tp_shift.

DATA : t_reason TYPE STANDARD TABLE OF tp_reason WITH HEADER LINE,

t_shift TYPE STANDARD TABLE OF tp_shift WITH HEADER LINE.

*---TABLE CONTROL DECLARATION

CONTROLS: t_ctrl TYPE TABLEVIEW USING SCREEN '9001',

t_ctrl1 TYPE TABLEVIEW USING SCREEN '9002',

t_ctrl2 TYPE TABLEVIEW USING SCREEN '9003'.

*--VARIABLE DECLARATION

DATA : flg, "Flag to set the change mode

ln TYPE i, "No. of records

ln_1 TYPE i,

l_date TYPE dats,

l_plant TYPE werks,

l_shift TYPE c.

.

&----


*& Module GET_T_CTRL_LINES OUTPUT

&----


  • Get data for screen 9001

----


MODULE get_t_ctrl_lines OUTPUT.

SELECT entry_date

plant

shift

reason

mins

INTO CORRESPONDING FIELDS OF TABLE t_breakdown

FROM znel_breakdown.

IF sy-subrc EQ 0.

SORT t_breakdown BY entry_date.

ELSE.

MESSAGE i000 WITH 'No data found'.

ENDIF.

DESCRIBE TABLE t_breakdown LINES ln_1.

  • To make the vertical scroll bar to come on runtime

T_CTRL-LINES = LN_1 + 100.

ENDMODULE. " GET_T_CTRL_LINES OUTPUT

&----


*& Module SET_SCREEN_FIELDS OUTPUT

&----


  • Set the screen fields

----


MODULE set_screen_fields OUTPUT.

LOOP AT SCREEN.

IF ( screen-name = 'T_BREAKDOWN-ENTRY_DATE'

OR screen-name = 'T_BREAKDOWN-PLANT'

OR screen-name = 'T_BREAKDOWN-SHIFT'

OR screen-name = 'T_BREAKDOWN-REASON'

OR screen-name = 'T_BREAKDOWN-MINS').

screen-input = 0.

ENDIF.

  • Modifying the screen after making changes

MODIFY SCREEN.

ENDLOOP.

ENDMODULE. " SET_SCREEN_FIELDS OUTPUT

&----


*& Module USER_COMMAND_9001 INPUT

&----


  • user command for 9001

----


MODULE user_command_9001 INPUT.

DATA :lv_fcode LIKE sy-ucomm. "Function Code

lv_fcode = sy-ucomm.

CASE lv_fcode.

WHEN 'BACK'.

SET SCREEN '9000'.

WHEN 'EXIT' OR 'CANCEL'.

  • Leaving the program

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_9000 INPUT

&----


*& Module STATUS_9000 OUTPUT

&----


  • text

----


MODULE status_9000 OUTPUT.

SET PF-STATUS 'ZSTATUS'.

SET TITLEBAR 'ZTITLE9000'.

ENDMODULE. " STATUS_9000 OUTPUT

&----


*& Module ON_VALUE_REQUEST_9003 OUTPUT

&----


  • To display values for shift ,palnt and reason

----


MODULE on_value_request_9003 OUTPUT.

*To display values in List Box

TYPE-POOLS: vrm.

DATA: values_1 TYPE vrm_values WITH HEADER LINE,

values_2 TYPE vrm_values WITH HEADER LINE,

values_3 TYPE vrm_values WITH HEADER LINE.

DATA : line1 LIKE LINE OF values_1,

line2 LIKE LINE OF values_2.

CLEAR : values_1,

values_2,

values_3.

REFRESH:values_1,

values_2,

values_3.

line1-key = 'A'.

line1-text = 'A'.

APPEND line1 TO values_1.

line1-key = 'B'.

line1-text = 'B'.

APPEND line1 TO values_1.

line1-key = 'C'.

line1-text = 'C'.

APPEND line1 TO values_1.

SORT values_1 BY text.

DELETE ADJACENT DUPLICATES FROM values_1 COMPARING ALL FIELDS.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'T_BREAKDOWN1-SHIFT'

values = values_1[]

EXCEPTIONS

id_illegal_name = 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.

line2-key = '2000'.

line2-text = '2000'.

APPEND line2 TO values_2.

line2-key = '3000'.

line2-text = '3000'.

APPEND line2 TO values_2.

line2-key = '4000'.

line2-text = '4000'.

APPEND line2 TO values_2.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'T_BREAKDOWN1-PLANT'

values = values_2[]

EXCEPTIONS

id_illegal_name = 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.

SELECT DISTINCT reason FROM znel_reason INTO TABLE t_reason

where plant = znel_breakdown-plant.

LOOP AT t_reason.

values_3-key = t_reason-reason.

values_3-text = t_reason-reason.

APPEND values_3.

CLEAR: values_3.

ENDLOOP.

SORT values_3 BY text.

  • delete adjacent duplicates from values_2 comparing all fields.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'T_BREAKDOWN1-REASON'

values = values_3[]

EXCEPTIONS

id_illegal_name = 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.

ENDMODULE. " ON_VALUE_REQUEST OUTPUT

&----


*& Module GET_T_CTRL_LINES1 OUTPUT

&----


  • Get control lines

----


MODULE get_t_ctrl_lines1 OUTPUT.

SELECT entry_date

plant

shift

reason

mins

INTO CORRESPONDING FIELDS OF TABLE t_breakdown1

FROM znel_breakdown.

DESCRIBE TABLE t_breakdown1 LINES ln.

  • To make the vertical scroll bar to come on runtime

t_ctrl-lines = ln + 100.

ENDMODULE. " GET_T_CTRL_LINES1 OUTPUT

&----


*& Module STATUS_9001 OUTPUT

&----


  • text

----


MODULE status_9001 OUTPUT.

SET PF-STATUS 'ZSTATUS9001'.

SET TITLEBAR 'ZTITLE9001'.

ENDMODULE. " STATUS_9001 OUTPUT

&----


*& Module SET_SCREEN_FIELDS_9003 OUTPUT

&----


  • text

----


MODULE set_screen_fields_9003 OUTPUT.

CLEAR : screen.

REFRESH : t_breakdown1.

LOOP AT SCREEN.

IF screen-name = 'T_BREAKDOWN1-ENTRY_DATE'.

t_breakdown1-entry_date = znel_breakdown-entry_date.

ENDIF.

IF screen-name = 'T_BREAKDOWN1-PLANT'.

t_breakdown1-plant = znel_breakdown-plant.

ENDIF.

IF screen-name = 'T_BREAKDOWN1-SHIFT'.

t_breakdown1-shift = znel_breakdown-shift.

ENDIF.

IF ( screen-name = 'T_BREAKDOWN1-ENTRY_DATE'

OR screen-name = 'T_BREAKDOWN1-PLANT'

OR screen-name = 'T_BREAKDOWN1-SHIFT' ).

screen-input = 0.

ENDIF.

IF ( screen-name = 'T_BREAKDOWN1-REASON'

OR screen-name = 'T_BREAKDOWN1-MINS').

screen-input = 1.

ENDIF.

  • Modifying the screen after making changes

MODIFY SCREEN.

ENDLOOP.

ENDMODULE. " SET_SCREEN_FIELDS_9001 OUTPUT

&----


*& Module CHECK INPUT

&----


  • text

----


MODULE check INPUT.

*Check For Current Line

MODIFY t_breakdown1 INDEX t_ctrl1-current_line.

ENDMODULE. " CHECK INPUT

&----


*& Module USER_COMMAND_9000 INPUT

&----


  • user command for 9000

----


MODULE user_command_9000 INPUT.

DATA :l_fcode LIKE sy-ucomm. "Function Code

l_fcode = sy-ucomm.

CASE l_fcode.

WHEN 'DISPLAY'.

CALL SCREEN 9001.

WHEN 'CHANGE'.

CALL SCREEN 9002.

WHEN 'ADD'.

REFRESH : t_breakdown1.

CALL SCREEN 9003.

WHEN 'BACK'.

LEAVE PROGRAM.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_9000 INPUT

&----


*& Module GET_FIELDS_9001 OUTPUT

&----


  • Get fields

----


MODULE get_fields_9002 OUTPUT.

SELECT entry_date

plant

shift

reason

mins

INTO CORRESPONDING FIELDS OF TABLE t_breakdown1

FROM znel_breakdown

WHERE entry_date = znel_breakdown-entry_date

AND plant = znel_breakdown-plant

AND shift = znel_breakdown-shift.

IF sy-subrc EQ 0.

SORT t_breakdown1 BY entry_date.

ELSE.

MESSAGE i000 WITH 'No data found'.

CALL SCREEN 9000.

ENDIF.

DESCRIBE TABLE t_breakdown LINES ln_1.

  • To make the vertical scroll bar to come on runtime

T_CTRL1-LINES = LN_1 + 100.

CLEAR : l_date,

l_plant,

l_shift.

l_date = znel_breakdown-entry_date.

l_plant = znel_breakdown-plant.

l_shift = znel_breakdown-shift.

LOOP AT SCREEN.

IF ( screen-name = 'T_BREAKDOWN1-ENTRY_DATE'

OR screen-name = 'T_BREAKDOWN1-PLANT'

OR screen-name = 'T_BREAKDOWN1-SHIFT' ).

screen-input = 0.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

ENDMODULE. " GET_FIELDS_9001 OUTPU

&----


*& Module STATUS_9003 OUTPUT

&----


  • text

----


MODULE status_9003 OUTPUT.

SET PF-STATUS 'ZSTATUS3'.

SET TITLEBAR 'ZTITLE9003'.

ENDMODULE. " STATUS_9003 OUTPUT

&----


*& Module USER_COMMAND_9003 INPUT

&----


  • user command for 9003

----


MODULE user_command_9003 INPUT.

DATA : l_fcode1 TYPE sy-ucomm.

l_fcode1 = sy-ucomm.

CASE l_fcode1.

WHEN 'SAVE'.

LOOP AT t_breakdown1.

MODIFY znel_breakdown FROM t_breakdown1.

ENDLOOP.

CLEAR screen.

CALL SCREEN 9000.

WHEN 'BACK'.

CALL SCREEN 9000.

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'STOP'.

STOP.

ENDCASE.

ENDMODULE. " USER_COMMAND_9003 INPUT

&----


*& Module MODIFY_TAB_9003 INPUT

&----


  • Modify table

----


MODULE modify_tab_9003 INPUT.

t_breakdown1-entry_date = l_date.

t_breakdown1-plant = l_plant.

t_breakdown1-shift = l_shift.

t_breakdown1-reason = t_breakdown1-reason.

t_breakdown1-mins = t_breakdown1-mins.

APPEND t_breakdown1.

CLEAR t_breakdown1.

ENDMODULE. " MODIFY_TAB_9003 INPUT

&----


*& Module GET_DATA INPUT

&----


  • Get data

----


MODULE get_data INPUT.

CLEAR : l_date,

l_plant,

l_shift.

l_date = t_breakdown1-entry_date.

l_plant = t_breakdown1-plant.

l_shift = t_breakdown1-shift.

ENDMODULE. " GET_DATA INPUT

&----


*& Module SET_SCREEN_FIELDS_9001 OUTPUT

&----


  • Set screen fields

----


MODULE set_screen_fields_9001 OUTPUT.

t_breakdown1-entry_date = l_date.

t_breakdown1-plant = l_plant.

t_breakdown1-shift = l_shift.

LOOP AT SCREEN.

IF ( screen-name = 'T_BREAKDOWN1-REASON' ).

screen-input = 0.

ELSEIF ( screen-name = 'T_BREAKDOWN1-MINS').

screen-input = 1.

ENDIF.

  • Modifying the screen after making changes

MODIFY SCREEN.

ENDLOOP.

ENDMODULE. " SET_SCREEN_FIELDS_9001 OUTPUT

&----


*& Module MODIFY_TAB_9002 INPUT

&----


  • Modify internal table

----


MODULE modify_tab_9002 INPUT.

t_breakdown1-entry_date = l_date.

t_breakdown1-plant = l_plant.

t_breakdown1-shift = l_shift.

t_breakdown1-reason = t_breakdown1-reason.

t_breakdown1-mins = t_breakdown1-mins.

t_breakdown1-pick = t_breakdown1-pick.

APPEND t_breakdown1.

ENDMODULE. " MODIFY_TAB_9002 INPUT

&----


*& Module USER_COMMAND_9002 INPUT

&----


  • user command for 9002

----


MODULE user_command_9002 INPUT.

DATA : l_fcode2 TYPE sy-ucomm,

lv_answer type c.

l_fcode2 = sy-ucomm.

CASE l_fcode2.

WHEN 'SAVE'.

LOOP AT t_breakdown1.

UPDATE znel_breakdown FROM TABLE t_breakdown1.

ENDLOOP.

WHEN 'DELETE'.

  • Confirmation of delete

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

titlebar = 'Confirm'

text_question = 'Are you sure to delete from database?'

text_button_1 = 'Yes'(001)

text_button_2 = 'No'(002)

IMPORTING

answer = lv_answer.

IF lv_answer EQ '1'.

  • Deleting the selected row from the internal table

LOOP AT t_breakdown1.

IF t_breakdown1-pick = 'X'.

DELETE znel_breakdown FROM t_breakdown1.

ENDIF.

ENDLOOP.

DELETE t_breakdown1 WHERE pick = 'X'.

ELSEIF lv_answer = '2'.

CALL SCREEN 9002.

ENDIF.

WHEN 'BACK'.

SET SCREEN '9000'.

ENDCASE.

ENDMODULE. " USER_COMMAND_9002 IN

&----


*& Module CHECK_DATE INPUT

&----


  • Date validation

----


MODULE check_date INPUT.

IF t_breakdown1-entry_date IS INITIAL.

MESSAGE s000 WITH 'enter date'.

ENDIF.

ENDMODULE. " CHECK_DATE INPUT

&----


*& Module ON_VALUE_REQUEST OUTPUT

&----


  • To default values for field shift

----


MODULE on_value_request OUTPUT.

*To display values in List Box

TYPE-POOLS: vrm.

DATA: values_4 TYPE vrm_values WITH HEADER LINE.

DATA : line4 LIKE LINE OF values_4.

CLEAR : values_4.

REFRESH:values_4.

line4-key = 'A'.

line4-text = 'A'.

APPEND line4 TO values_4.

line4-key = 'B'.

line4-text = 'B'.

APPEND line4 TO values_4.

line4-key = 'C'.

line4-text = 'C'.

APPEND line4 TO values_4.

SORT values_4 BY text.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'ZNEL_BREAKDOWN-SHIFT'

values = values_4[]

EXCEPTIONS

id_illegal_name = 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.

ENDMODULE. " ON_VALUE_REQUEST OUTPUT

&----


*& Module STATUS_9002 OUTPUT

&----


  • Set status

----


MODULE status_9002 OUTPUT.

SET PF-STATUS 'ZSTATUS9002'.

SET TITLEBAR 'ZTITLE9002'.

ENDMODULE. " STATUS_9002 OUTP

&----


*& Module RETURN_EXIT INPUT

&----


  • text

----


module RETURN_EXIT input.

case sy-ucomm.

when 'BACK'.

clear screen.

leave to screen 9000.

endcase.

endmodule. " RETURN_EXIT INPU

0 Kudos
473

thanks martina,

this is what i wanted!!