InterviewSolution
| 1. |
Write an ABAP program to display username, date, time, and sum by providing two inputs. |
|
Answer» DATA: lv_result TYPE i.SELECTION-SCREEN BEGIN OF BLOCK bl WITH FRAME TITLE TEXT-001. "Please enter two numbers for calculating the sumPARAMETERS: p_num1 TYPE i, p_num2 TYPE i. "Variable declarationSELECTION-SCREEN END OF BLOCK b1.INITIALIZATION. CLEAR: lv_result. "To clear variablesSTART-OF-SELECTION. "To perform business logicIF p_num1 IS NOT INITIAL AND p_num2 IS NOT INITIAL. "Checking whether values for the variables has been entered or not lv_result= p_num1+p_num2. ELSE. MESSAGE 'Please enter two numbers to perform addition' TYPE 'E'. END IF. END-OF-SELECTION. "To display the outputWRITE :/ 'Hello', sy-uname.WRITE :/ 'Date :', sy-datnum, 'Time :', sy-uzeit.WRITE :/ 'Result : SUM of two numbers is :', lv_result. In the above program code, you need to enter values for two numbers using SELECTION_SCREEN. In START-OF-SELECTION by using the if condition, it will check whether variables are having the values, if it returns true then it will perform the sum, else it will display a message for entering the numbers. In END-OF-SELECTION, the user NAME, date, time, and sum values are displayed. |
|