Saturday, September 15, 2018

SIMPLE LOG IN SCREEN (AT SELECTION SCREEN EVENT)







*&---------------------------------------------------------------------*
*& Report  ZSR_DRIVER
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZSR_DRIVER.
TABLES  SSCRFIELDS.

*****************************************************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERSP_USER TYPE ZUSER_LOGIN-USER_ID.
PARAMETERSp_pass TYPE ZUSER_LOGIN-PASSWORD.
SELECTION-SCREEN END OF BLOCK B1.
***************************************************************************************************************************
DATA COUNT TYPE I.
SELECTION-SCREEN :
 PUSHBUTTON /9(20)  BUTTON1  USER-COMMAND BUT1,
  PUSHBUTTON /9(20button2 USER-COMMAND BUT2.
**PARAMETERS : P1 AS LISTBOX

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    IF screen-name 'P_PASS'.
      screen-invisible 1.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.


AT SELECTION-SCREEN.
  CASE sscrfields.
    WHEN 'BUT1'.
      IF P_USER 'SOURAV' AND P_PASS 'SHREYA'.
        CLEAR P_PASS.
        clear p_user.
       CALL TRANSACTION 'ZSR'.
       ELSE.
CLEAR P_PASS.
CLEAR P_USER.
        MESSAGE 'WRONG USER ID OR PASSWORD' TYPE 'I'.
        COUNT COUNT 3.
        IF COUNT 3.
           LOOP AT SCREEN .
             SCREEN-INVISIBLE 1.
             MODIFY SCREEN .
*          LOOP AT SCREEN .
*        IF SCREEN-NAME = 'P_PASS' AND SCREEN-NAME = 'P_USER'.
*          SCREEN-INVISIBLE = 1.
*          MODIFY SCREEN .

          ENDLOOP.
         ENDIF.
       ENDIF.
    WHEN 'BUT2'.
      MESSAGE 'Button 2 was clicked' TYPE 'I'.

  ENDCASE.
*--------------------------------------------------------------*
*Initialization
*--------------------------------------------------------------*

INITIALIZATION.
  button1 'LOGIN'.
  button2 'CREATE USER'.

CALL FUNCTION 'ICON_CREATE'
  EXPORTING
    NAME                        icon_okay
   TEXT                        'LOG IN'
   INFO                        'SIGN IN'
*   ADD_STDINF                  = 'X'
 IMPORTING
   RESULT                      button1
* EXCEPTIONS
*   ICON_NOT_FOUND              = 1
*   OUTPUTFIELD_TOO_SHORT       = 2
*   OTHERS                      = 3
          .
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

CALL FUNCTION 'ICON_CREATE'
  EXPORTING
    NAME                        icon_cancel
   TEXT                        'SIGN UP'
   INFO                        'SIGN UP '
*   ADD_STDINF                  = 'X'
 IMPORTING
   RESULT                      BUTTON2
********************OUND              = 1
********************   OUTPUTFIELD_TOO_SHORT       = 2
********************   OTHERS                      = 3 EXCEPTIONS
          .
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

OUTPUT:

                                                LOGIN PAGE


IF YOU ENTER THE RIGHT PASSWORD AND USER NAME THEN YOU CAN LOG IN 
 AND PERFORM ALV , BDC , CREATE SMARTFORM. 

THIS IS SECOND SCREEN CALLED THROUGH CALL TRANSACTION.
NOW IF YOUR PASSWORD IS WRONG THEN YOU WOULD SEE THIS MESSAGE ON SCREEN.

 I HAVE NOT WRITTEN SIGN UP CODE , YOU CAN SIMPLY CREATE IT SAME WAY.
IF YOU WANT TO VALIDATE IT DYNAMICALLY FROM DATABASE THEN SIMPLY MATCH IT WITH VALUES STORED IN DATABASE.