You are on page 1of 14

Simple Write program: Write:/ 'Name','Address','Dob','Age','Degree','Subject Title'. Using with colors.

Write:/ 'Name' Color 5, / 'Address' Color 6, / 'Dob' Color 4, / 'Age' Color 7.

Using No Standard Page Heading: Write:/ 'Name' Color 5 inverse on, /5 'Address', / 'Dob', / 'Age'. Using fore color backround. Write:/ 'Name' Color 5 inverse on, / 'Address' Color 4 inverse on, / 'Dob' Color 2 inverse on, / 'Age' Color 1 inverse on. Using underline: Write:/ 'Name:','Muthuraj' Color 5 inverse on. uline. Write:/ 'Address:','No.10,Bangalore' Color 4 inverse on. uline. Write:/ 'Dob' Color 2 inverse on. uline. Write:/ 'Age' Color 1 inverse on. uline. Using Underline-sy-uline Hand cursor move: Format hotspot on. Write: /5 'Name','Muthuraj M' Color 5 inverse on. Write: /(105) sy-uline. Write: /6 'Address','No.10,5th cross,Indranagar,Bangalore' Color 3 inverse on. Write: / sy-uline. Write: /7 'Dob','01.01.1982' Color 6 inverse on. Write: / sy-uline. Write: /8'Age','26' Color 7 inverse on. Write: / sy-uline. Write: /9 'Sex','Male' Color 2 inverse on. Write: / sy-uline. Write: /10 'Degree','MCA' Color 1 inverse on. Write: / sy-uline. Format hotspot off. REPORT YDEMO_PROG No Standard Page Heading.

Format hotspot on. Write: /5 'Name','Muthuraj M' Color 5 inverse on. Write: / sy-uline. Write: /6 'Address','No.10,5th cross,Indranagar,Bangalore' Color 3 inverse on. Write: / sy-uline. Write: /7 'Dob','01.01.1982' Color 6 inverse on. Write: / sy-uline. Write: /8'Age','26' Color 7 inverse on. Write: / sy-uline. Write: /9 'Sex','Male' Color 2 inverse on. Write: / sy-uline. Write: /10 'Degree','MCA' Color 1 inverse on. Write: / sy-uline. Format hotspot off. ASSIGNMENT ON 23.07.2009. Using With Data Format. Data Data Data Data V_Name(20) type c. V_roll(3) type n. V_age type i. V_Per(5) type p decimals 2.

V_Name = 'Muthuraj'. V_roll = '45'. V_age = '25'. V_per = '78.12'. Write: / V_name,V_roll,V_age,V_per. Using with data Format Sequentially(Serialy). Data: V_Name(20) type c, V_roll(3) type n, V_age type i, V_Per(5) type p decimals 2. p decimals 2. V_Name = 'Muthuraj'. V_roll = '45'. V_age = '25'. V_per = '78.12'. Write: / V_name,V_roll,V_age,V_per. Disply Box in the selection screen using Parameter type: Parameters: P_Name(20) type c, P_roll(3) type n, P_age type i, P_Per(5) type p decimals 3. Write: / P_name,/ P_roll,/ P_age,/ P_per. Display box in the selection screen using Parameters type: Selection-screen Begin of Block blk with Frame Title text-000. Parameters: P_Name(20) type c. P_roll(3) type n, P_age type i,

P_Per(5) type p decimals 2. Selection-screen End of Block blk. Write: / P_name,P_roll,P_age,P_per. Display with obligatory in the selection scrn using Parameters type: Selection-screen Begin of Block blk with Frame Title text-000. Parameters: P_Name(20) type c Lower case, P_roll(3) type n Obligatory, P_age type i. Selection-screen End of Block blk. Parameters: P_Per(5) type p decimals 2 Obligatory. Write: / P_name,/ P_roll,/ P_age,/ P_per.

Display Multiple boxes in the selection scrn using Parameters type: Selection-screen Begin of Block blk with Frame Title text-000. Parameters: P_Name(20) type c Lower case Obligatory, P_roll(3) type n Obligatory, P_age type i, P_Per(5) type p decimals 2 Obligatory. Selection-screen End of Block blk. Write: / P_name,P_roll,P_age,P_per. REPORT YDEMO_PROG No Standard Page Heading. Selection-screen Begin of Block blk with Frame Title text-000. Parameters: P_id(6) type n Obligatory, P_name(25) type c Lower case. Selection-screen End of Block blk. Selection-screen Begin of Block blk1 with Frame Title text-000. Parameters: P_dob(12) type c, P_addrs(56) type c Lower case. Selection-screen End of Block blk1. Selection-screen Begin of Block blk2 with Frame Title text-000. Parameters: P_dept(10) type c Lower case, P_desgn(15) type c Lower Case. Selection-screen End of Block blk2. Selection-screen Begin of Block blk3 with Frame Title text-000. Parameters: P_wds(2) type n, P_sal(6) type n. Selection-screen End of Block blk3. Write: / P_id color 7 inverse on,/ P_name color 6 inverse on, / P_dob color 4 inverse on,/ P_addrs color 2 inverse on, / P_dept color 1 inverse on,/ P_desgn color 5 inverse on, / P_wds color 3 inverse on,/ P_sal color 5 inverse on. Using IF......ENDIF Statements. Parameters P_sal type i. if P_sal > 20000. Write:/ 'Devloper'. endif. if P_sal <= 20000. Write:/ 'Supporting'. endif.

Using IF......ELSE....ENDIF Statements: Parameters P_Studt type i. if P_studt > 75. Write:/ 'Pass'. else. Write:/ 'Fail'. endif. Using IF......ELSE....ENDIF Statements: Parameters: P_Name(20) type c Lower case, P_age type i, Data: salary type i value 20000, bonus type i value 2000, result type i. result = salary + bonus. if P_age > 30. Write:/ P_name,P_age,P_salary,result. else. Data: salary1 type i value 30000, bonus1 type i value 3000, result1 type i. result1 = salary1 + bonus1. Write:/ P_name,P_age,P_salary,result1. endif.

Using IF......ELSEIF.......ELSE....ENDIF Statements: Parameters: P_per(5) type p decimals 2. if P_per >= 75. Write:/ 'Grade A'. elseif P_per >= 60 and P_per < 75. Write:/ 'Grade B'. elseif P_per >= 45 and P_per < 60. Write:/ 'Grade C'. else. Write:/ 'Fail'. endif. Using IF......ELSEIF.......ELSE....ENDIF Statements: Parameters: P_name(20) type c Lower case, P_age type i, P_exp type i, P_sal(6) type n. if P_exp > 15. Data: salary type i value 35000, increment type i value 10000, resal type i. resal = salary + increment. Write:/ P_name,P_age,P_exp,P_sal,resal.

elseif P_exp >= 10 and P_exp < 15. Data: Salary1 type i value 25000, increment1 type i value 7000, resal1 type i. resal1 = salary1 + increment1. Write:/ P_name,P_age,P_exp,P_sal,resal1. elseif P_exp >= 5 and P_exp < 10. Data: Salary2 type i value 3000, increment2 type i value 7000, resal2 type i. resal2 = salary2 + increment2. Write:/ P_name,P_age,P_exp,P_sal,resal2. else. Data: Salary3 type i value 15000. Write:/ P_name,P_age,P_exp,salary3. endif.

Desending order using while......Endwhile: Parameters no type i. while no >= 0. no = no - 1. Write:/ no. endwhile. Using CASE......ENDCASE Statemet: Parameters clr type i. case clr. when '1'. Write:/ 'Green'. when '2'. Write:/ 'Red'. when '3'. Write:/ 'Blue'. When others. Write:/ 'Enter valid clr'. endcase.

Addition of two variables using Parameters: Parameters: P_a type i, P_b type i. Data result type i. result = P_a * P_b. Write: result. Displaying Date: Write sy-Datum dd/mm/yy. Transferring date with specified format: Data: w-date(8) type c value '122680',

w-date2(8) type c. write w-date to w-date2 date 'mm/dd/yy'. write w-date2. Displaying decending order using data type: Parameters: v type i. Data res type i. do 10 times. res = v - sy-index. write:/ res. enddo. Nested do statements: Parameters: v type i. Data: res type i, res2 type i. do 10 times. res = v * sy-index. write:/ res. enddo. do 5 times. res2 = v - sy-index. write:/ res2. enddo. Assingning values to variables through Move Keyword: Data: V_field(20) type c, V_field2(12) type c. Move 'Muthu' to V_field. Move 'Manish' to V_field2. Write:/ V_field,V_field2. Assignment:27.07.08 decending order: Parameters no type i. while no >= 1. Write:/ no. no = no - 1. endwhile.

Assending order using Parameters type : break-point. Parameters: P_no type i. do P_no times. Write:/ sy-index. enddo. Desending order using Data type : Parameters: P_no type i. data desc type i.

desc = P_no. do P_no times. Write:/ desc. desc = desc - 1. enddo. Transferring data with a specified format. Data: w_date(8) type c value '50/12/25', w_date2(8) type c. write w_date to w_date2 mm/dd/yy. write:/ w_date2. Displaying radio button using Parameters type : Parameters: P1(15) type c, P2 like P1 obligatory lower case, P3 like sy-datum, Cb1 as checkbox, rb1 radiobutton group g1, rb2 radiobutton group g1. Write:/ ' P1 =', P1, / ' P2 =', P2, / ' P3 =', P3, / ' cb1 =', cb1, / ' rb1 =', rb1, / ' rb2 =', rb2. Reverse display output: break-point. . Parameters:P_no type i. Data:Digit type i, rev type i. While P_no <> 0. digit = P_no mod 10. rev = rev * 10 + digit. P_no = P_no div 10. endwhile. Write:/ rev. Assending order. Parameters:P_no type i. do P_no times. write:/ sy-index. enddo.

Desending order using data types : Parameters:P_no type i. data desc type i. desc = P_no. do P_no times. write:/ desc. desc = desc - 1.

enddo. Desending order using while_Endwhile: Parameters: P_no type i. While P_no >= 1. Write:/ P_no. P_no = P_no - 1. endwhile. Changing the color backround vs foreground. Format INVERSE ON. Write: 'WORD' color 6. Format INVERSE OFF. Displaying String Name like assending Order. Parameters:P_name(20) type c. data:length type i. length = strlen( P_name ). do length times. write:/ P_name+0(sy-index). enddo. String off set operations. Data: V_name1(15) type c, V_name2(20) type c, result(20) type c. V_name1 = 'IBM'. V_name2 = 'Welcome india'. Move V_name1 to result. Move V_name2+0(3) to result+9(3). Write:/ result. Parameters: P_name1(15) type c lower case, P_name2(20) type c lower case. Data result(20) type c. * V_name1 = 'IBM'. * V_name2 = 'Welcome india'. Translate P_name1+0(1) to upper case. Move P_name1 to result. Move P_name2+0(3) to result+9(3). Move P_name2+8(3) to result+13(3). Write:/ result.

Displaying String like desending order. Parameters: P_name(10) type c. data:len type i, temp type i. len = strlen( P_name ). temp = len.

do len times. write:/ P_name+0(temp). temp = temp - 1. enddo. Displaying numbers like desending order. Parameters: P_no(10) type c. data:len type i, temp type i. len = strlen( P_no ). temp = len. do len times. write:/ P_no+0(temp),P_no+0(sy-index). temp = temp - 1. enddo.

Contains String(CS): data W_field(4) type c. Move 'ABCD' to W_field. if W_field cp '*A++*'. write 'field contains those letters!'. Endif. Nested if statements: Data: Answer(10) Type c. Parameters:Gift(15) type c. if answer = 'yes'. CASE GIFT. When 'Toy'. Write 'You want a toy'. When 'Bike'. Write 'You want a bike'. When 'Others'. Write 'I dont know what you want'. ENDCASE. Else. Write: 'BAH HUMBUG'. Endif. Continue statement: Do 10 times. if sy-index = 7. continue. endif. write:/ sy-index. enddo. Exit inside the Statement: Do 10 times. if sy-index = 7. Exit. endif.

write:/ sy-index. enddo. Exit statement outside the loop: Do 10 times. if sy-index = 7. endif. write:/ sy-index. Exit. enddo. Working with date variables: Data Today type D. Today = sy-datum. Write:/ Today, / Today+2(2), / Today+4(2), / Today+6(2). Tranfering data from WA To IT. Data: begin of it occurs 3, f1(1), f2(2), end of it. it-f1 = 'A'. it-f2 = 'xx'. append it. write:/ 'sy-tabix =',sy-tabix. it-f1 = 'B'. it-f2 = 'YY'. append it. write:/ 'sy-tabix =',sy-tabix. it-f1 = 'C'. it-f2 = 'ZZ'. append it. write:/ 'sy-tabix =',sy-tabix. it-f1 = 'D'. it-f2 = 'MM'. append it. write:/ 'sy-tabix =',sy-tabix. Using append sorted by: Data: begin of it occurs 3, orderno(4) type n, name(10), sales type p decimals 2, end of it. it-orderno = 5000. it-sales = 100. it-name = 'Muthu'. append it." sorted by sales. it-orderno = 5001. it-sales = 150. it-name = 'Mally'. append it." sorted by sales.

it-orderno = 5002. it-sales = 170. it-name = 'Manish'. append it." sorted by sales. it-orderno = 5003. it-sales = 250. it-name = 'Amit'. append it." sorted by sales. it-orderno = 5004. it-sales = 350. it-name = 'Anu'. append it." sorted by sales. Delete it index 1. loop at it. write:/ it-orderno,it-sales,it-name. endloop. Filling internal table using Collect: Data: begin of it occurs 3, Date type d, tot_sales type p decimals 2, name(10), num_sales type i value 1, end of it. it-date = '20080120'. it-name = 'Muthu'. it-tot_sales = 200. Collect it. it-date = '20080120'. it-name = 'Mally'. it-tot_sales = 300. Collect it. it-date = '20080120'. it-name = 'Muthu'. it-tot_sales = 400. Collect it. it-date = '20080130'. it-name = 'Manish'. it-tot_sales = 100. Collect it. it-date = '20090120'. it-name = 'Muthu'. it-tot_sales = 700. Collect it. it-date = '20090120'. it-name = 'Malli'. it-tot_sales = 300. Collect it.

it-date = '20090120'. it-name = 'Manish'. it-tot_sales = 200. Collect it. loop at it. write:/ it-date,it-tot_sales,it-name,it-num_sales. endloop. PARAMETERS: p_auart TYPE vbak-auart. DATA it_vbak TYPE TABLE OF vbak WITH HEADER LINE. SELECT * FROM vbak INTO TABLE it_vbak WHERE auart = p_auart. WRITE:/ sy-dbcnt. Loop at it_vbak. Write:/ it_vbak-vbeln,it_vbak-ernam,it_vbak-auart. ENDLOOP. PARAMETERS: p_mtart TYPE Mara-mtart. DATA it_mara TYPE TABLE OF mara WITH HEADER LINE. SELECT * FROM mara INTO TABLE it_Mara WHERE mtart = p_mtart. WRITE:/ sy-dbcnt,sy-subrc. LOOP AT it_mara. WRITE:/ sy-tabix, it_mara-matnr,it_Mara-mtart.. ENDLOOP. PARAMETERS: p_lfart TYPE likp-lfart. DATA it_likp TYPE TABLE OF Likp WITH HEADER LINE. SELECT * FROM Likp INTO TABLE it_Likp WHERE LFart = p_lfart. WRITE:/ sy-dbcnt,sy-subrc. LOOP AT it_likp. WRITE:/ sy-tabix, it_Likp-vbeln,it_likp-lfdat,it_likp-lfart. ENDLOOP. Tables vbrk. *Parameters: P_pltyp type vbrk-pltyp. Data it_vbrk type table of vbrk with header line. Select-options s_pltyp FOR vbrk-pltyp. select * from vbrk into table it_vbrk where pltyp in s_pltyp. *Write:/ sy-dbcnt,sy-subrc. loop at it_vbrk. Write:/ it_vbrk-fkart,it_vbrk-fktyp,it_vbrk-pltyp. endloop.

Parameters: P_PINCR type ekko-Pincr. Data it_ekko type table of ekko with Header line. Select * from ekko into table it_ekko where pincr = P_pincr. write:/ sy-dbcnt,sy-subrc. loop at it_ekko. Write:/ it_ekko-ebeln,it_ekko-bukrs,it_ekko-wkurs,it_ekko-pincr. endloop. Displaying ascending order by string. Parameters: P_name(10) type c. data:len type i. len = strlen( P_name ). do len times. write:/ P_name+0(sy-index). enddo. Displaying ascending order by number. Parameters: P_no(10) type C. Data: len type i. len = strlen( P_no ). do len times. write:/ P_no+0(sy-index). enddo. * displaying radiobutton and checkboxes. SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text-100. PARAMETERS:p_rad1 RADIOBUTTON GROUP gr1 DEFAULT 'X', p_rad2 RADIOBUTTON GROUP gr1. SELECTION-SCREEN END OF BLOCK blk. SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-101. PARAMETERS: p_chk1 AS CHECKBOX, p_chk2 AS CHECKBOX. SELECTION-SCREEN END OF BLOCK blk1.

Passing Parameters to subroutines: Parameters: P type i. "call by value. break-point. Write:/ 'Before P =',P. Perform manipulate-P using P. Write:/ 'After P =',P. Form manipulate-P using value(P). P = P + 1. Write:/ 'Inside P =',P. Endform. Data M type i. " Call by refrence. M = 10. Write:/ 'Before M =',M. Perform manipulate-M using M. Write:/ 'After M =',M.

Form manipulate-M using M. M = M + 1. Write:/ 'Inside M =',M. Endform. Data A type i. A = 10. Write:/ 'before A =',A. Perform manipulate-A using A. End-of-selection. Write:/ 'after A =',A. Form manipulate-A changing value(A). A = A + 10. Write:/ 'Inside A =',A. if A = 21. stop. endif.

write:/ '2''s mul table'. write:/ '3''s mul table'. at line-selection. write:/ sy-lsind, sy-lisel.

You might also like