Monday 21 August 2017

Chain-End Chain


  • Description – Generally in  input screen, when the user gives the input and their is no record present in the database, the user input is restricted by a error message. This error message disables the input screen and now the user can not provide correct values in the input field as it is disabled by the error message. To overcome this problem Chain And EndChain Statement is used in the Flow Logic of the screen where Input fields are validated.




  • Step 1. Go to SE38, Provide Program name and click on Create Button.

  • Step 2.  Declare some variables and tables statement in the program. Activate the program and then Right Click on the Program name, Go to Create and then click on Screen.
  • Step 3. Provide the Screen Number ‘0001’ and then click on the Okay button.
  • Step 4. Provide The Description, choose Normal Screen and then click on the Layout button.
  • Step 5. Create two input fields with one push button as per shown below.
  • Step 6. Let’s create another screen for displaying the result.
  • Step 7 : Click on Goto -> Secondary window -> Dictionary/Program fields.
  • Enter table name ‘VBRP’ and click on Get from Dictionary.
  • Step 8. The selected fields are shown on the screen and now create a push button ‘Back’ with the properties as shown.
  • Step 9 . Go to the flow logic of the screen ‘ 9000’, ‘ 9001’ and define the modules under PBO & PAI.

PROCESS BEFORE OUTPUT.
MODULE STATUS_9001.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_9001. 
PROCESS BEFORE OUTPUT.
MODULE STATUS_9000.
*
PROCESS AFTER INPUT.
 MODULE USER_COMMAND_9000.

  • Step 10. Provide the below code in the PAI modules of both screens as per shown below.



TABLES : VBRP.

DATA :P_VBELN TYPE VBRP-VBELN,
      P_POSNR TYPE VBRP-POSNR.

module STATUS_9000 output.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.

endmodule.                 " STATUS_9000  OUTPUT

module USER_COMMAND_9000 input.

  CASE SY-UCOMM.
    WHEN ‘SHOW'.
     SELECT SINGLE * FROM VBRP WHERE VBELN = P_VBELN AND POSNR = P_POSNR.
     CALL SCREEN 9001.

  ENDCASE.

endmodule.                 " USER_COMMAND_9000  INPUT

module STATUS_9001 output.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.

endmodule.                 " STATUS_9001  OUTPUT

module USER_COMMAND_9001 input.

  CASE SY-UCOMM.
    WHEN 'BACK'.
     LEAVE TO SCREEN 0.
  ENDCASE.

endmodule.                 " USER_COMMAND_9001  INPUT

  • Step 11. Lets Create A T-Code for the Module pool Program.

Output Analysis:



  • Step 12. Let's open a new session, provide the program t-code and run it. Please check the database table ‘VBRP’ and provide the p_vbeln and p_posnr and then click on the Show button.
  • Step 13. Based on the input one record is selected and displayed in the next screen ‘0002’ . At last click on the Back button to go the input screen.
  • Step 14. Provide some vbeln and posnr value for which no database record exists in the database table ‘vbrp’ and click on the show button.
  • Step 15. Though No record is selected for the given Input still we are navigated to the next screen.
  • Click on the Back button.
  • Step 16. Let's validate the input fields. If for the user input no record is selected, the control should not pass to the Next screen. Go to the Flow logic of the screen ‘9000’. Add a new module ‘Input_Validation’ in the PAI and define it.
  • Step 17. Provide input field values and if based on the input fields no record is selected then as per the program validation an error message is displayed which restricts the navigation to the next screen but also at the same time all input fields are disabled. To avoid this problem we use chain and endchain statement in the flow logic of the screen.

  • Step 18. In the flow logic of the first screen, add chain and endchain statement and inside it put all the fields that you want to enable again if they are disabled with validation error within the module.
PROCESS BEFORE OUTPUT.
MODULE STATUS_9000.
*
PROCESS AFTER INPUT.
CHAIN.
FIELD : P_VBELN , P_POSNR
MODULE INPUT_VALIDATION.

ENDCHAIN.
 MODULE USER_COMMAND_9000. 
  • Step 19. Lets again provide some input values and we got a validation error and due to the addition of the chain and endchain statement in the flow logic of the screen the input fields are again in the input mode to accept the user input again.


 

No comments:

Post a Comment