CODE FOR MINI PROJECT ( Click Here for Mini Project Home page)
*&---------------------------------------------------------------------*
*& Report ZSIGNUP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZSIGNUP.
data v_data(10) type c.
DATA USERNAME(10) TYPE C.
DATA PASSWORD(10) TYPE C.
v_data = 'leave program'.
data : it_itab type standard table of zsignup.
data wa type zsignup.
TYPES: BEGIN OF SREE,
USERNAME TYPE ZSIGNUP-USERNAME,
DOB TYPE ZSIGNUP-DOB,
GENDER TYPE ZSIGNUP-GENDER,
FULLNAME TYPE ZSIGNUP-FULLNAME,
END OF SREE.
DATA: BODY_SREE TYPE TABLE OF SREE,
WA_SREE TYPE SREE.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
tables ZSIGNUP.
CASE SY-UCOMM.
WHEN 'SUBMIT'.
INSERT ZSIGNUP.
IF ZSIGNUP-PASSWORD1 <> ZSIGNUP-PASSWORD2.
MESSAGE 'PASSWORD MISMATCH' TYPE 'I'.
CLEAR ZSIGNUP.
exit.
ENDIF.
IF SY-SUBRC = 0.
MESSAGE 'SUCESSFULLY SUBMITTED' TYPE 'I'.
clear zsignup.
ELSE.
MESSAGE 'TRY AGAIN' type 'I'.
ENDIF.
WHEN 'RESET'.
CLEAR ZSIGNUP.
WHEN 'CANCEL'.
LEAVE PROGRAM.
WHEN 'REGISTER'.
if zsignup-username = ' '.
CALL SCREEN 0101.
else.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
* TITLEBAR = ' '
* DIAGNOSE_OBJECT = ' '
TEXT_QUESTION = 'Test'
TEXT_BUTTON_1 = 'Yes'
* ICON_BUTTON_1 = ' '
TEXT_BUTTON_2 = 'No'
* ICON_BUTTON_2 = ' '
* DEFAULT_BUTTON = '1'
* DISPLAY_CANCEL_BUTTON = 'X'
* USERDEFINED_F1_HELP = ' '
* START_COLUMN = 25
* START_ROW = 6
* POPUP_TYPE =
* IV_QUICKINFO_BUTTON_1 = ' '
* IV_QUICKINFO_BUTTON_2 = ' '
* IMPORTING
* ANSWER =
* TABLES
* PARAMETER =
* EXCEPTIONS
* TEXT_NOT_FOUND = 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.
if sy-ucomm = 'OPT1'.
call screen 0101.
else.
call screen 0100.
ENDIF.
endif.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
MODULE USER_COMMAND_0101 INPUT.
CASE SY-UCOMM.
WHEN 'LOGIN'.
CALL SCREEN 0102.
WHEN 'RESET'.
CLEAR ZSIGNUP.
WHEN 'REGISTER'.
CALL SCREEN 0100.
ENDCASE.
endmodule.
MODULE zuser_module.
if sy-ucomm = 'LOGIN'.
select username password1 from zsignup into table it_itab where username = zsignup-username and password1 = zsignup-password1.
if sy-subrc <> 0.
message 'try again' type 'I'.
call screen 0101.
endif.
endif.
endmodule.
" USER_COMMAND_0101 INPUT
*&---------------------------------------------------------------------*
*& Module zuser_module INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
" zuser_module INPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0103 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0103 INPUT.
CASE SY-UCOMM.
WHEN 'GET'.
SELECT USERNAME DOB GENDER FULLNAME INTO TABLE BODY_SREE FROM ZSIGNUP WHERE USERNAME = ZSIGNUP-USERNAME.
IF SY-SUBRC = 0.
SORT BODY_SREE BY USERNAME.
ENDIF.
WHEN 'SAVE'.
UPDATE ZSIGNUP.
WHEN 'BACK'.
LEAVE TO SCREEN 0102.
ENDCASE.
ENDMODULE. " USER_COMMAND_0103 INPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0102 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0102 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0102 INPUT.
CASE SY-UCOMM.
WHEN 'UPDATE'.
CALL SCREEN 0103.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0102 INPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0103 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0103 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
LOOP AT BODY_SREE INTO WA_SREE.
MOVE-CORRESPONDING WA_SREE TO ZSIGNUP.
ENDLOOP.
ENDMODULE. " STATUS_0103 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0099 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0099 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0099 INPUT.
CASE SY-UCOMM.
WHEN 'SIGNUP'.
CALL SCREEN 0100.
WHEN 'REGISTER'.
CALL SCREEN 0101.
WHEN 'EXIT'.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
* TITLEBAR = ' '
* DIAGNOSE_OBJECT = ' '
TEXT_QUESTION = 'do you want to continue'
TEXT_BUTTON_1 = 'yes'
* ICON_BUTTON_1 = ' '
TEXT_BUTTON_2 = 'No'
* ICON_BUTTON_2 = ' '
* DEFAULT_BUTTON = '1'
* DISPLAY_CANCEL_BUTTON = 'X'
* USERDEFINED_F1_HELP = ' '
* START_COLUMN = 25
* START_ROW = 6
* POPUP_TYPE =
* IV_QUICKINFO_BUTTON_1 = ' '
* IV_QUICKINFO_BUTTON_2 = ' '
* IMPORTING
* ANSWER =
* TABLES
* PARAMETER =
* EXCEPTIONS
* TEXT_NOT_FOUND = 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.
if sy-ucomm = 'OPT1'.
leave program.
else.
call screen 0099.
endif.
ENDCASE.
ENDMODULE. " USER_COMMAND_0099 INPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0104 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0104 INPUT.
CASE SY-UCOMM.
WHEN 'LOGIN'.
IF USERNAME = 'admin' and PASSWORD = 'admin'.
call screen 0103.
else.
message 'Try again! invalid entry' type 'I'.
call screen 0104.
endif.
WHEN 'RESET'.
CLEAR: USERNAME ,PASSWORD.
WHEN 'CANCEL'.
LEAVE PROGRAM.
WHEN 'HOME'.
CALL SCREEN 0099.
ENDCASE.
ENDMODULE. " USER_COMMAND_0104 INPUT
*&SPWIZARD: TYPE FOR THE DATA OF TABLECONTROL 'ZSIGNUP1'
TYPES: BEGIN OF T_ZSIGNUP1,
USERNAME LIKE ZSIGNUP-USERNAME,
GENDER LIKE ZSIGNUP-GENDER,
DOB LIKE ZSIGNUP-DOB,
END OF T_ZSIGNUP1.
*&SPWIZARD: INTERNAL TABLE FOR TABLECONTROL 'ZSIGNUP1'
DATA: G_ZSIGNUP1_ITAB TYPE T_ZSIGNUP1 OCCURS 0,
G_ZSIGNUP1_WA TYPE T_ZSIGNUP1. "work area
DATA: G_ZSIGNUP1_COPIED. "copy flag
*&SPWIZARD: DECLARATION OF TABLECONTROL 'ZSIGNUP1' ITSELF
CONTROLS: ZSIGNUP1 TYPE TABLEVIEW USING SCREEN 0105.
*&SPWIZARD: LINES OF TABLECONTROL 'ZSIGNUP1'
DATA: G_ZSIGNUP1_LINES LIKE SY-LOOPC.
DATA: OK_CODE LIKE SY-UCOMM.
*&SPWIZARD: OUTPUT MODULE FOR TC 'ZSIGNUP1'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: COPY DDIC-TABLE TO ITAB
MODULE ZSIGNUP1_INIT OUTPUT.
IF G_ZSIGNUP1_COPIED IS INITIAL.
*&SPWIZARD: COPY DDIC-TABLE 'ZSIGNUP'
*&SPWIZARD: INTO INTERNAL TABLE 'g_ZSIGNUP1_itab'
SELECT * FROM ZSIGNUP
INTO CORRESPONDING FIELDS
OF TABLE G_ZSIGNUP1_ITAB.
G_ZSIGNUP1_COPIED = 'X'.
REFRESH CONTROL 'ZSIGNUP1' FROM SCREEN '0105'.
ENDIF.
ENDMODULE.
*&SPWIZARD: OUTPUT MODULE FOR TC 'ZSIGNUP1'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: MOVE ITAB TO DYNPRO
MODULE ZSIGNUP1_MOVE OUTPUT.
MOVE-CORRESPONDING G_ZSIGNUP1_WA TO ZSIGNUP.
ENDMODULE.
*&SPWIZARD: OUTPUT MODULE FOR TC 'ZSIGNUP1'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: GET LINES OF TABLECONTROL
MODULE ZSIGNUP1_GET_LINES OUTPUT.
G_ZSIGNUP1_LINES = SY-LOOPC.
ENDMODULE.
*&SPWIZARD: INPUT MODULE FOR TC 'ZSIGNUP1'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: MODIFY TABLE
MODULE ZSIGNUP1_MODIFY INPUT.
MOVE-CORRESPONDING ZSIGNUP TO G_ZSIGNUP1_WA.
MODIFY G_ZSIGNUP1_ITAB
FROM G_ZSIGNUP1_WA
INDEX ZSIGNUP1-CURRENT_LINE.
ENDMODULE.
*&SPWIZARD: INPUT MODULE FOR TC 'ZSIGNUP1'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: PROCESS USER COMMAND
MODULE ZSIGNUP1_USER_COMMAND INPUT.
OK_CODE = SY-UCOMM.
PERFORM USER_OK_TC USING 'ZSIGNUP1'
'G_ZSIGNUP1_ITAB'
'FLAG'
CHANGING OK_CODE.
SY-UCOMM = OK_CODE.
ENDMODULE.
*----------------------------------------------------------------------*
* INCLUDE TABLECONTROL_FORMS *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form USER_OK_TC *
*&---------------------------------------------------------------------*
FORM USER_OK_TC USING P_TC_NAME TYPE DYNFNAM
P_TABLE_NAME
P_MARK_NAME
CHANGING P_OK LIKE SY-UCOMM.
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*
DATA: L_OK TYPE SY-UCOMM,
L_OFFSET TYPE I.
*&SPWIZARD: END OF LOCAL DATA------------------------------------------*
*&SPWIZARD: Table control specific operations *
*&SPWIZARD: evaluate TC name and operations *
SEARCH P_OK FOR P_TC_NAME.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
L_OFFSET = STRLEN( P_TC_NAME ) + 1.
L_OK = P_OK+L_OFFSET.
*&SPWIZARD: execute general and TC specific operations *
CASE L_OK.
WHEN 'INSR'. "insert row
PERFORM FCODE_INSERT_ROW USING P_TC_NAME
P_TABLE_NAME.
CLEAR P_OK.
WHEN 'DELE'. "delete row
PERFORM FCODE_DELETE_ROW USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME.
CLEAR P_OK.
WHEN 'P--' OR "top of list
'P-' OR "previous page
'P+' OR "next page
'P++'. "bottom of list
PERFORM COMPUTE_SCROLLING_IN_TC USING P_TC_NAME
L_OK.
CLEAR P_OK.
* WHEN 'L--'. "total left
* PERFORM FCODE_TOTAL_LEFT USING P_TC_NAME.
*
* WHEN 'L-'. "column left
* PERFORM FCODE_COLUMN_LEFT USING P_TC_NAME.
*
* WHEN 'R+'. "column right
* PERFORM FCODE_COLUMN_RIGHT USING P_TC_NAME.
*
* WHEN 'R++'. "total right
* PERFORM FCODE_TOTAL_RIGHT USING P_TC_NAME.
*
WHEN 'MARK'. "mark all filled lines
PERFORM FCODE_TC_MARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME .
CLEAR P_OK.
WHEN 'DMRK'. "demark all filled lines
PERFORM FCODE_TC_DEMARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME .
CLEAR P_OK.
* WHEN 'SASCEND' OR
* 'SDESCEND'. "sort column
* PERFORM FCODE_SORT_TC USING P_TC_NAME
* l_ok.
ENDCASE.
ENDFORM. " USER_OK_TC
*&---------------------------------------------------------------------*
*& Form FCODE_INSERT_ROW *
*&---------------------------------------------------------------------*
FORM fcode_insert_row
USING P_TC_NAME TYPE DYNFNAM
P_TABLE_NAME ..
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*
DATA L_LINES_NAME LIKE FELD-NAME.
DATA L_SELLINE LIKE SY-STEPL.
DATA L_LASTLINE TYPE I.
DATA L_LINE TYPE I.
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <LINES> TYPE I.
*&SPWIZARD: END OF LOCAL DATA------------------------------------------*
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline
*&SPWIZARD: get looplines of TableControl *
CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_LINES_NAME.
ASSIGN (L_LINES_NAME) TO <LINES>.
*&SPWIZARD: get current line *
GET CURSOR LINE L_SELLINE.
IF SY-SUBRC <> 0. " append line to table
L_SELLINE = <TC>-LINES + 1.
*&SPWIZARD: set top line *
IF L_SELLINE > <LINES>.
<TC>-TOP_LINE = L_SELLINE - <LINES> + 1 ..
ELSE.
<TC>-TOP_LINE = 1.
ENDIF.
ELSE. " insert line into table
L_SELLINE = <TC>-TOP_LINE + L_SELLINE - 1.
L_LASTLINE = <TC>-TOP_LINE + <LINES> - 1.
ENDIF.
*&SPWIZARD: set new cursor line *
L_LINE = L_SELLINE - <TC>-TOP_LINE + 1.
*&SPWIZARD: insert initial line *
INSERT INITIAL LINE INTO <TABLE> INDEX L_SELLINE.
<TC>-LINES = <TC>-LINES + 1.
*&SPWIZARD: set cursor *
SET CURSOR LINE L_LINE.
ENDFORM. " FCODE_INSERT_ROW
*&---------------------------------------------------------------------*
*& Form FCODE_DELETE_ROW *
*&---------------------------------------------------------------------*
FORM fcode_delete_row
USING P_TC_NAME TYPE DYNFNAM
P_TABLE_NAME
P_MARK_NAME .
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE cxtab_control.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <WA>.
FIELD-SYMBOLS <MARK_FIELD>.
*&SPWIZARD: END OF LOCAL DATA------------------------------------------*
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline
*&SPWIZARD: delete marked lines *
DESCRIBE TABLE <TABLE> LINES <TC>-LINES.
LOOP AT <TABLE> ASSIGNING <WA>.
*&SPWIZARD: access to the component 'FLAG' of the table header *
ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.
IF <MARK_FIELD> = 'X'.
DELETE <TABLE> INDEX SYST-TABIX.
IF SY-SUBRC = 0.
<TC>-LINES = <TC>-LINES - 1.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " FCODE_DELETE_ROW