Professional Documents
Culture Documents
PROG2
REPORT Z7AM_PROG2. data x type i. data y type i. data z type i. x = 10. y = 20. z = x + y. write z.
PROG3
REPORT Z7AM_PROG3. data : x type i, y type i, z type i. x = 10. y = 20. z = x + y. write : x,y,z. write :/ 'result is ',z.
PROG4
REPORT Z7AM_PROG4. * * parameters x type i. parameters y type i. parameters : abc type i, y type i. data m type i. m = abc + y. write :/ 'Result is :',m.
PROG5
REPORT Z7AM_PROG5.
parameters : x type f obligatory default 20, y type f obligatory default 10. data z type f. parameters : r1 radiobutton group g1, r2 radiobutton group g1, r3 radiobutton group g1 default 'X', r4 radiobutton group g1. if r1 = 'X'. z = x + y. write :/ 'sum of two numbers is ',z. elseif r2 = 'X'. z = x - y. if z >= 0. write :/ 'difference is ',z. else. write :/ 'difference is -' no-gap,z no-sign left-justified. endif. elseif r3 = 'X'. z = x * y. write :/ 'product is ',z. elseif r4 = 'X'. z = x / y. write :/ 'Division is ',z. endif.
PROG6
report z7am_prog6. data x type i. write x. data y type c. write y. y = 'gensoft systems'. write / y. data z(10) type c. z = 'gensoft systems'. write / z. data m type string. m = 'gensoft systems'. write / m. data k type i value 10. write / k.
PROG7
REPORT Z7AM_PROG7. parameters : x type i, y type i. data z type i. parameters : c1 as checkbox, c2 as checkbox default 'X', c3 as checkbox, c4 as checkbox, c5 as checkbox. if c1 = 'X'. z = x + y. write :/ 'sum is :',z. endif. if c2 = 'X'. z = x - y. write :/ 'Difference is :',z. endif. if c3 = 'X'. z = x * y. write :/ 'Product is :',z. endif. if c4 = 'X'. z = x / y. write :/ 'Division is :',z. endif. if c5 = 'X'. z = x mod y. write :/ 'Remainder is :',z. endif.
PROG8
REPORT Z7AM_PROG8. parameters : p_x type i, p_y type i, p_ch type i. data lv_z type i. case p_ch.
PROG9
when 1. lv_z = p_x + p_y. write :/ 'sum is ',lv_z. when 2. lv_z = p_x - p_y. write :/ 'Difference is ',lv_z. when 3. lv_z = p_x * p_y. write :/ 'Product is ',lv_z. when 4. lv_z = p_x / p_y. write :/ 'Division is ',lv_z. when others. message 'Please enter 1,2,3,4' type 'I'. endcase.
REPORT Z7AM_PROG9. data x type i. x = '345.67'. write / x. x = '345.21'. write / x. data y type p. y = '345.67'. write / y. data m type p decimals 2. m = '345.67'. write / m.
PROG10
REPORT Z7AM_PROG10. parameters x type i. data y type i value 1. data z type i. while y <= 10. z = x * y. write :/ x,'*',y,'=',z. y = y + 1. endwhile.
PROG11
REPORT Z7AM_PROG11. parameters x type i. data y type i value 1. data z type i. while y <= 10. if y ne 5. z = x * y. write :/ x,'*',y,'=',z. endif. y = y + 1. endwhile.
PROG12
REPORT Z7AM_PROG12. parameters x type i. data y type i value 1. data z type i. while y <= 10. if y eq 5. y = y + 1. continue. endif. z = x * y. write :/ x,'*',y,'=',z. y = y + 1. endwhile.
PROG13
REPORT Z7AM_PROG13. parameters x type i. data y type i value 1. data z type i. while y <= 10. if y eq 5. exit. endif. z = x * y. write :/ x,'*',y,'=',z.
y = y + 1. endwhile.
PROG14
write :/ 'hello'.
PROG16
REPORT Z7AM_PROG16. data x type d. x = '11052012'. "ddmmyyyy write x. "yyyyddmm x = '20120511'. "yyyymmdd write / x. "mmddyyyy x = '20121105'. "yyyyddmm write / x. "ddmmyyyy write :/(10) x. write :/(10) x using edit mask '__/__/____'. data y type t. y = '075544'. "hhmmss write / y. write :/(8) y. write :/(8) y using edit mask '__-__-__'. write :/(5) y using edit mask '__-__'.
PROG17
REPORT Z7AM_PROG17. data : str1 type string value 'Gensoft', str2 type string value 'Systems', str type string.
write :/ 'str is ',str. concatenate str1 str2 into str. write :/ 'str is ',str. clear str. write :/ 'str is ',str. concatenate str1 str2 into str separated by ' '. write :/ 'str is ',str.
PROG18
REPORT Z7AM_PROG18. data str type string value 'Gensoft SysTems'. write str. translate str to upper case. write / str. translate str to lower case. write / str.
PROG19
REPORT Z7AM_PROG19. parameters str type string. data x type i. x = strlen( str ). write :/ 'length of string is :',x.
PROG20
REPORT Z7AM_PROG20. data : str type string value 'Genesis@Software@Systems', str1 type string, str2 type string, str3 type string. write :/ 'str1 is :',str1, / 'str2 is :',str2, / 'str3 is :',str3. uline. split str at '@' into str1 str2. write :/ 'str1 is :',str1, / 'str2 is :',str2, / 'str3 is :',str3. uline. clear : str1,
PROG21
str2, str3. write :/ 'str1 is :',str1, / 'str2 is :',str2, / 'str3 is :',str3. uline. split str at '@' into str1 str2 str3. write :/ 'str1 is :',str1, / 'str2 is :',str2, / 'str3 is :',str3.
REPORT Z7AM_PROG21. data : str1 type string value 'Genesis Software Systems', str2 type string value 'Wipro Technologies'. write :/ 'str1 is :',str1. overlay str1 with str2. write :/ 'str1 is :',str1.
PROG22
REPORT Z7AM_PROG22. data str type string value 'Gensoft Systems'. write :/ str. replace 's' in str with 'k'. write :/ str. str = 'Gensoft Systems'. write :/ str. replace all occurrences of 's' in str with 'k'. write :/ str. str = 'Gensoft Systems'. write :/ str. replace all occurrences of 's' in str with 'k' ignoring case. write :/ str.
PROG23
write str. shift str. write / str. uline. str = 'Gensoft'. write / str. shift str by 2 places. write / str. uline. str = 'Gensoft'. write / str. shift str by 2 places right. write / str. uline. str = 'Gensoft'. write / str. shift str by 2 places circular. write / str.
PROG24
REPORT Z7AM_PROG24. data : x type i value 10, y type i. write :/ x,y. y = x. write :/ x,y. x = 20. write :/ x,y.
PROG25
<abc> = x.
REPORT Z7AM_PROG26.
data : x type i value 10. field-symbols <abc>. assign x to <abc>. write :/ x,<abc>. x = 20. write :/ x,<abc>. <abc> = 30. write :/ x,<abc>. data y(20) type c value 'Gensoft'. assign y to <abc>. write :/ x,y,<abc>.
PROG27
REPORT Z7AM_PROG27. write :/ 'inside program27'. *submit z7am_prog28. submit z7am_prog28 and return. write :/ 'end of program27'.
PROG28
REPORT Z7AM_PROG29. parameters : p_x type i, p_y type i. data lv_z type i. export p_x to memory id 'A1'. export p_y to memory id 'A2'. submit z7am_prog30 and return. import lv_z from memory id 'A3'. write :/ 'sum is :',lv_z.
PROG30
p_y type i, lv_z type i. import p_x from memory id 'A1'. import p_y from memory id 'A2'. lv_z = p_x + p_y. export lv_z to memory id 'A3'. write :/ 'inside program30'.
PROG31
REPORT Z7AM_PROG31. data : begin of emp, empno type i, ename(20) type c, empdesig(30) type c, end of emp. write :/ 'EMP Structure'. write :/ emp-empno, emp-ename, emp-empdesig. emp-empno = 5. emp-ename = 'raju'. emp-empdesig = 'manager'. write :/ 'EMP Structure'. write :/ emp-empno, emp-ename, emp-empdesig.
PROG32
REPORT Z7AM_PROG32. data : begin of emp, empno type i, ename(20) type c, empdesig(30) type c, end of emp. write :/ 'EMP Structure'. write :/ emp-empno,
emp-ename, emp-empdesig. emp-empno = 5. emp-ename = 'raju'. emp-empdesig = 'manager'. write :/ 'EMP Structure'. write :/ emp-empno, emp-ename, emp-empdesig. data emp1 like emp. write :/ 'EMP1 Structure'. write :/ emp1-empno, emp1-ename, emp1-empdesig. "emp1 = emp. write :/ 'EMP1 Structure after assignment'. write :/ emp1-empno, emp1-ename, emp1-empdesig. clear emp1. write :/ 'EMP1 Structure after clear'. write :/ emp1-empno, emp1-ename, emp1-empdesig. move emp to emp1. write :/ 'EMP1 Structure after move'. write :/ emp1-empno, emp1-ename, emp1-empdesig."
PROG33
REPORT Z7AM_PROG33. data : begin of emp, empno type i, ename(20) type c, empdesig(30) type c,
end of emp. emp-empno = 4. emp-ename = 'ravi kumar'. emp-empdesig = 'Manager'. write :/ 'EMP structure'. write :/ emp-empno, emp-ename, emp-empdesig. data : begin of emp1, empno type i, ename(6) type c, end of emp1. move emp to emp1. write :/ 'EMP1 structure'. write :/ emp1-empno, emp1-ename.
PROG34
REPORT Z7AM_PROG34. data : begin of emp, empno type i, ename(20) type c, empdesig(30) type c, end of emp. emp-empno = 4. emp-ename = 'ravi kumar'. emp-empdesig = 'Manager'. write :/ 'EMP structure'. write :/ emp-empno, emp-ename, emp-empdesig. data : begin of emp1, empno type i, dname(6) type c, end of emp1. move emp to emp1. write :/ 'EMP1 structure'. write :/ emp1-empno, emp1-dname.
PROG35
REPORT Z7AM_PROG35. data : begin of emp, ename(20) type c, empno type i, empdesig(30) type c, end of emp. emp-empno = 4. emp-ename = 'ravi kumar'. emp-empdesig = 'Manager'. write :/ 'EMP structure'. write :/ emp-empno, emp-ename, emp-empdesig. data : begin of emp1, empno type i, dname(6) type c, end of emp1. move emp to emp1. write :/ 'EMP1 structure'. write :/ emp1-empno, emp1-dname.
PROG36
REPORT Z7AM_PROG36. data : begin of emp, empno type i, ename(20) type c, empdesig(30) type c, end of emp. emp-empno = 6. emp-ename = 'kiran'. emp-empdesig = 'manager'. write :/ 'EMP structure'. write :/ emp-empno, emp-ename, emp-empdesig. data : begin of emp1,
ename(6) type c, empno type i, deptno type i, end of emp1. move-corresponding emp to emp1. write :/ 'EMP1 structure'. write :/ emp1-ename, emp1-empno, emp1-deptno.
PROG37
REPORT Z7AM_PROG37. data : begin of emp, empno(3) type c, ename(20) type c, empdesig(30) type c, end of emp. emp-empno = 'a16'. emp-ename = 'kiran'. emp-empdesig = 'manager'. write :/ 'EMP structure'. write :/ emp-empno, emp-ename, emp-empdesig. data : begin of emp1, ename(6) type c, empno type i, deptno type i, end of emp1. move-corresponding emp to emp1. write :/ 'EMP1 structure'. write :/ emp1-ename, emp1-empno, emp1-deptno.
PROG38
begin of dept, deptno type i, dname(20) type c, end of dept, empdesig(30) type c, end of emp. emp-empno = 6. emp-ename = 'raju'. emp-dept-deptno = 40. emp-dept-dname = 'sales'. emp-empdesig = 'manager'. write :/ emp-empno, / emp-ename, / emp-dept-deptno, / emp-dept-dname, / emp-empdesig.
PROG39
REPORT Z7AM_PROG39. data : begin of dept, deptno type i, dname(20) type c, end of dept. data : begin of emp, empno type i. include structure dept. data : ename(20) type c, end of emp. emp-empno = 5. emp-deptno = 56. emp-dname = 'sales'. emp-ename = 'raju'. write :/ emp-empno, emp-deptno, emp-dname, emp-ename.
PROG40
empno type i, ename(20) type c, end of emp. write :/ emp-empno, emp-ename. emp-empno = 6. emp-ename = 'raju'. emp-empno = 8. emp-ename = 'ravi'. write :/ emp-empno, emp-ename.
PROG41
REPORT Z7AM_PROG41. data : begin of emp occurs 0, empno type i, ename(20) type c, end of emp. write :/ emp-empno, emp-ename. emp-empno = 6. emp-ename = 'raju'. emp-empno = 8. emp-ename = 'ravi'. write :/ 'Content in header'. write :/ emp-empno, emp-ename. append emp. clear emp. emp-empno = 2. emp-ename = 'mahesh'. append emp. clear emp. emp-empno = 7.
emp-ename = 'kiran'. append emp. write :/ 'Content in header'. write :/ emp-empno, emp-ename. write :/ 'Content in body'. loop at emp. write :/ emp-empno, emp-ename. endloop.
PROG42
REPORT Z7AM_PROG42. data : begin of emp occurs 0, empno type i, ename(20) type c, end of emp. clear emp. "clears header emp-empno = 6. emp-ename = 'raju'. append emp. clear emp. emp-empno = 8. emp-ename = 'ravi'. append emp. clear emp. emp-empno = 2. emp-ename = 'mahesh'. append emp. write :/ 'Content in body'. loop at emp. write :/ emp-empno, emp-ename, sy-tabix. endloop. write :/ 'Content in body from 1 to 2'. loop at emp from 1 to 2. write :/ emp-empno,
emp-ename. endloop.
PROG43
REPORT Z7AM_PROG43. data : begin of emp occurs 0, empno type i, ename(20) type c, end of emp. clear emp. "clears header emp-empno = 6. emp-ename = 'raju'. append emp. clear emp. emp-empno = 8. emp-ename = 'ravi'. append emp. clear emp. emp-empno = 2. emp-ename = 'mahesh'. append emp. clear emp. emp-empno = 3. emp-ename = 'sri'. append emp. write :/ 'Content in body'. loop at emp. write :/ emp-empno, emp-ename. endloop. write :/ 'Records with empno <= 5'. loop at emp where empno <= 5. write :/ emp-empno, emp-ename. endloop.
PROG44
REPORT Z7AM_PROG44.
data : begin of emp occurs 0, empno type i, ename(20) type c, end of emp. clear emp. "clears header emp-empno = 6. emp-ename = 'raju'. append emp. clear emp. emp-empno = 8. emp-ename = 'ravi'. append emp. clear emp. emp-empno = 2. emp-ename = 'mahesh'. append emp. clear emp. emp-empno = 3. emp-ename = 'sri'. append emp. write :/ 'Content in body'. sort emp. loop at emp. write :/ emp-empno, emp-ename. endloop. sort emp by empno descending. write :/ 'Records with empno <= 5'. loop at emp where empno <= 5. write :/ emp-empno, emp-ename. endloop.
PROG45
REPORT Z7AM_PROG45. data : begin of emp occurs 0, empno type i, ename(20) type c,
end of emp. clear emp. "clears header emp-empno = 6. emp-ename = 'raju'. append emp. clear emp. emp-empno = 8. emp-ename = 'ravi'. append emp. clear emp. emp-empno = 2. emp-ename = 'mahesh'. append emp. clear emp. emp-empno = 3. emp-ename = 'sri'. append emp. write :/ 'Content in body'. loop at emp. write :/ emp-empno, emp-ename. endloop. sort emp. write :/ 'Content in body after sort'. loop at emp. write :/ emp-empno, emp-ename. endloop. sort emp by empno descending. write :/ 'Content in body after sorton empno'. loop at emp. write :/ emp-empno, emp-ename. endloop.
PROG46
empno type i, ename(20) type c, end of emp. clear emp. "clears header emp-empno = 6. emp-ename = 'raju'. append emp. clear emp. emp-empno = 8. emp-ename = 'ravi'. append emp. clear emp. emp-empno = 2. emp-ename = 'mahesh'. append emp. clear emp. emp-empno = 3. emp-ename = 'sri'. append emp. write :/ 'Content in emp'. loop at emp. write :/ emp-empno, emp-ename. endloop. data emp1 like emp occurs 0 with header line. write :/ 'Content in emp1'. loop at emp1. write :/ emp1-empno, emp1-ename. endloop. emp1[] = emp[]. write :/ 'Content in emp1 after copy'. loop at emp1. write :/ emp1-empno, emp1-ename. endloop. clear emp1[].
write :/ 'Content in emp1 after clear'. loop at emp1. write :/ emp1-empno, emp1-ename. endloop. append lines of emp to emp1. write :/ 'Content in emp1 after append'. loop at emp1. write :/ emp1-empno, emp1-ename. endloop. refresh emp1. write :/ 'Content in emp1 after refresh'. loop at emp1. write :/ emp1-empno, emp1-ename. endloop. append lines of emp from 2 to 4 to emp1. write :/ 'Content in emp1 after append'. loop at emp1. write :/ emp1-empno, emp1-ename. endloop.
PROG47
REPORT Z7AM_PROG47. data emp like z7pmemp occurs 0 with header line. clear emp. emp-empno = 6. emp-ename = 'raju'. emp-empdesig = 'manager'. append emp. clear emp. emp-empno = 16. emp-ename = 'ravi'. emp-empdesig = 'director'. append emp. clear emp.
emp-empno = 4. emp-ename = 'ramu'. emp-empdesig = 'CA'. append emp. write :/ 'Data in internal table :'. loop at emp. write :/ emp-empno, emp-ename, (30) emp-empdesig. endloop. clear emp. read table emp index 2. if sy-subrc eq 0. write :/ 'Second record is :'. write :/ emp-empno, emp-ename, (30) emp-empdesig. else. write :/ 'Record not found'. endif.
PROG48
REPORT Z7AM_PROG48. data emp like z7pmemp occurs 0 with header line. clear emp. emp-empno = 6. emp-ename = 'raju'. emp-empdesig = 'manager'. append emp. clear emp. emp-empno = 16. emp-ename = 'ravi'. emp-empdesig = 'director'. append emp. clear emp. emp-empno = 4. emp-ename = 'ramu'. emp-empdesig = 'CA'. append emp.
write :/ 'Data in internal table :'. loop at emp. write :/ emp-empno, emp-ename, (30) emp-empdesig. endloop. clear emp. read table emp with key empno = 4. if sy-subrc eq 0. write :/ ' record is :'. write :/ emp-empno, emp-ename, (30) emp-empdesig. else. write :/ 'Record not found'. endif.
PROG49
REPORT Z7AM_PROG49. data emp like z7pmemp occurs 0 with header line. clear emp. emp-empno = 6. emp-ename = 'raju'. emp-empdesig = 'manager'. append emp. clear emp. emp-empno = 16. emp-ename = 'ravi'. emp-empdesig = 'director'. append emp. clear emp. emp-empno = 4. emp-ename = 'ramu'. emp-empdesig = 'CA'. append emp. write :/ 'Data in internal table :'. loop at emp. write :/ emp-empno, emp-ename, (30) emp-empdesig.
endloop. clear emp. sort emp by empno. read table emp with key empno = 4 binary search. if sy-subrc eq 0. write :/ ' record is :'. write :/ emp-empno, emp-ename, (30) emp-empdesig. else. write :/ 'Record not found'. endif.
PROG50
REPORT Z7AM_PROG50. data emp like z7pmemp occurs 0 with header line. clear emp. emp-empno = 6. emp-ename = 'raju'. emp-empdesig = 'manager'. append emp. clear emp. emp-empno = 16. emp-ename = 'ravi'. emp-empdesig = 'director'. append emp. clear emp. emp-empno = 4. emp-ename = 'ramu'. emp-empdesig = 'CA'. append emp. write :/ 'Data in internal table :'. loop at emp. write :/ emp-empno, emp-ename, (30) emp-empdesig. endloop. uline. clear emp.
sort emp by empno. read table emp with key empno = 4. if sy-subrc eq 0. write :/ emp-empno, emp-ename, (20) emp-empdesig. endif. uline. clear emp. read table emp with key empno = 16 transporting ename. if sy-subrc eq 0. write :/ emp-empno, emp-ename, (20) emp-empdesig. endif. uline. clear emp. read table emp with key empno = 16 transporting empno ename. if sy-subrc eq 0. write :/ emp-empno, emp-ename, (20) emp-empdesig. endif. uline. clear emp. read table emp with key empno = 16 transporting no fields. if sy-subrc eq 0. write :/ 'Record found'. write :/ emp-empno, emp-ename, (20) emp-empdesig.
PROG51
endif.
REPORT Z7AM_PROG51. data emp like z7pmemp occurs 0. clear emp. emp-empno = 6.
emp-ename = 'raju'. emp-empdesig = 'manager'. append emp. clear emp. emp-empno = 16. emp-ename = 'ravi'. emp-empdesig = 'director'. append emp. clear emp. emp-empno = 4. emp-ename = 'ramu'. emp-empdesig = 'CA'. append emp.
PROG52
REPORT Z7AM_PROG52. data emp like z7pmemp occurs 0. data wa like z7pmemp. clear wa. wa-empno = 6. wa-ename = 'raju'. wa-empdesig = 'manager'. append wa to emp. clear wa. wa-empno = 16. wa-ename = 'ravi'. wa-empdesig = 'director'. append wa to emp. clear wa. wa-empno = 4. wa-ename = 'ramu'. wa-empdesig = 'CA'. append wa to emp. loop at emp into wa. write :/ wa-empno, wa-ename, (30) wa-empdesig. endloop.
PROG53
REPORT Z7AM_PROG53. data emp like z7pmemp occurs 0. data wa like z7pmemp. clear wa. wa-empno = 6. wa-ename = 'raju'. wa-empdesig = 'manager'. append wa to emp. clear wa. wa-empno = 16. wa-ename = 'ravi'. wa-empdesig = 'director'. append wa to emp. clear wa. wa-empno = 4. wa-ename = 'ramu'. wa-empdesig = 'CA'. append wa to emp. loop at emp into wa. write :/ wa-empno, wa-ename, (30) wa-empdesig. endloop. describe table emp. write :/ 'No of records :',sy-tfill.
PROG54
REPORT Z7AM_PROG54. types : begin of ty_emp. include structure z7pmemp. types end of ty_emp. data : lt_emp type table of ty_emp with header line. clear lt_emp. lt_emp-empno = 5. lt_emp-ename = 'raju'. lt_emp-empdesig = 'manager'. append lt_emp.
clear lt_emp. lt_emp-empno = 14. lt_emp-ename = 'ramu'. lt_emp-empdesig = 'ca'. append lt_emp. clear lt_emp. lt_emp-empno = 11. lt_emp-ename = 'rakesh'. lt_emp-empdesig = 'director'. append lt_emp. clear lt_emp. lt_emp-empno = 9. lt_emp-ename = 'raju'. lt_emp-empdesig = 'supervisor'. append lt_emp. clear lt_emp. lt_emp-empno = 11. lt_emp-ename = 'ramu'. lt_emp-empdesig = 'ceo'. append lt_emp. write :/ 'data in internal table'. loop at lt_emp. write :/ lt_emp-empno, lt_emp-ename, (30) lt_emp-empdesig. endloop.
PROG55
REPORT Z7AM_PROG55. types : begin of ty_emp. include structure z7pmemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. clear ls_emp. ls_emp-empno = 5. ls_emp-ename = 'raju'.
ls_emp-empdesig = 'manager'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 14. ls_emp-ename = 'ramu'. ls_emp-empdesig = 'ca'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 11. ls_emp-ename = 'rakesh'. ls_emp-empdesig = 'director'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 9. ls_emp-ename = 'raju'. ls_emp-empdesig = 'supervisor'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 11. ls_emp-ename = 'ramu'. ls_emp-empdesig = 'ceo'. append ls_emp to lt_emp. write :/ 'data in internal table'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, (30) ls_emp-empdesig. endloop.
PROG56
REPORT Z7AM_PROG56. types : begin of ty_emp. include structure z7pmemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. clear ls_emp.
ls_emp-empno = 5. ls_emp-ename = 'raju'. ls_emp-empdesig = 'manager'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 14. ls_emp-ename = 'ramu'. ls_emp-empdesig = 'ca'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 11. ls_emp-ename = 'rakesh'. ls_emp-empdesig = 'director'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 9. ls_emp-ename = 'raju'. ls_emp-empdesig = 'supervisor'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 11. ls_emp-ename = 'ramu'. ls_emp-empdesig = 'ceo'. append ls_emp to lt_emp. write :/ 'data in internal table'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, (30) ls_emp-empdesig. endloop. sort lt_emp by ename. delete adjacent duplicates from lt_emp comparing ename. uline. write :/ 'data in internal table after deleting duplicate names'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, (30) ls_emp-empdesig.
endloop.
PROG57
REPORT Z7AM_PROG57. types : begin of ty_emp. include structure z7pmemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. clear ls_emp. ls_emp-empno = 5. ls_emp-ename = 'raju'. ls_emp-empdesig = 'manager'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 14. ls_emp-ename = 'ramu'. ls_emp-empdesig = 'ca'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 11. ls_emp-ename = 'rakesh'. ls_emp-empdesig = 'director'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 9. ls_emp-ename = 'raju'. ls_emp-empdesig = 'supervisor'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 11. ls_emp-ename = 'ramu'. ls_emp-empdesig = 'director'. append ls_emp to lt_emp. write :/ 'data in internal table'. loop at lt_emp into ls_emp. write :/ ls_emp-empno,
ls_emp-ename, (30) ls_emp-empdesig. endloop. loop at lt_emp into ls_emp. if ls_emp-empdesig = 'director'. ls_emp-empdesig = 'MD'. modify lt_emp from ls_emp. endif. endloop. uline. write :/ 'data in internal table after modification'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, (30) ls_emp-empdesig. endloop.
PROG58
REPORT Z7AM_PROG58. types : begin of ty_emp. include structure z7pmemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. clear ls_emp. ls_emp-empno = 5. ls_emp-ename = 'raju'. ls_emp-empdesig = 'manager'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 14. ls_emp-ename = 'ramu'. ls_emp-empdesig = 'ca'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 11. ls_emp-ename = 'rakesh'. ls_emp-empdesig = 'director'.
append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 9. ls_emp-ename = 'raju'. ls_emp-empdesig = 'supervisor'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 11. ls_emp-ename = 'ramu'. ls_emp-empdesig = 'director'. append ls_emp to lt_emp. write :/ 'data in internal table'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, (30) ls_emp-empdesig. endloop. loop at lt_emp into ls_emp. if ls_emp-empdesig = 'director'. ls_emp-empdesig = 'MD'. modify lt_emp from ls_emp transporting empdesig. endif. endloop. uline. write :/ 'data in internal table after modification'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, (30) ls_emp-empdesig. endloop.
PROG59
REPORT Z7AM_PROG59. types : begin of ty_emp. include structure z7pmemp. types end of ty_emp. data : lt_emp type table of ty_emp,
ls_emp type ty_emp. clear ls_emp. ls_emp-empno = 5. ls_emp-ename = 'raju'. ls_emp-empdesig = 'manager'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 14. ls_emp-ename = 'ramu'. ls_emp-empdesig = 'ca'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 11. ls_emp-ename = 'rakesh'. ls_emp-empdesig = 'director'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 9. ls_emp-ename = 'raju'. ls_emp-empdesig = 'supervisor'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 11. ls_emp-ename = 'ramu'. ls_emp-empdesig = 'director'. append ls_emp to lt_emp. write :/ 'data in internal table'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, (30) ls_emp-empdesig. endloop. clear ls_emp. ls_emp-empdesig = 'MD'. modify lt_emp from ls_emp transporting empdesig where empdesig = 'director'.
uline. write :/ 'data in internal table after modification'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, (30) ls_emp-empdesig. endloop.
PROG60
REPORT Z7AM_PROG60. types : begin of ty_emp. include structure z7pmemp. types end of ty_emp. data : lt_emp type standard table of ty_emp with non-unique key empno, ls_emp type ty_emp. clear ls_emp. ls_emp-empno = 6. ls_emp-ename = 'raju'. ls_emp-empdesig = 'manager'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 16. ls_emp-ename = 'anil'. ls_emp-empdesig = 'manager'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 16. ls_emp-ename = 'rajesh'. ls_emp-empdesig = 'manager'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 9. ls_emp-ename = 'kiran'. ls_emp-empdesig = 'director'. append ls_emp to lt_emp. write :/ 'Data in internal table :'.
loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, (30) ls_emp-empdesig. endloop. uline. sort lt_emp. write :/ 'Data in internal table after sort:'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, (30) ls_emp-empdesig. endloop.
PROG61
REPORT Z7AM_PROG61. types : begin of ty_emp. include structure z7pmemp. types end of ty_emp. data : lt_emp type sorted table of ty_emp with non-unique key empno, ls_emp type ty_emp. clear ls_emp. ls_emp-empno = 6. ls_emp-ename = 'raju'. ls_emp-empdesig = 'manager'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 16. ls_emp-ename = 'anil'. ls_emp-empdesig = 'manager'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 16. ls_emp-ename = 'rajesh'. ls_emp-empdesig = 'manager'. append ls_emp to lt_emp. write :/ 'Data in internal table :'. loop at lt_emp into ls_emp.
REPORT Z7AM_PROG62. types : begin of ty_emp. include structure z7pmemp. types end of ty_emp. data : lt_emp type sorted table of ty_emp with non-unique key empno, ls_emp type ty_emp. clear ls_emp. ls_emp-empno = 6. ls_emp-ename = 'raju'. ls_emp-empdesig = 'manager'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 16. ls_emp-ename = 'anil'. ls_emp-empdesig = 'manager'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 8. ls_emp-ename = 'rajesh'. ls_emp-empdesig = 'manager'. append ls_emp to lt_emp. write :/ 'Data in internal table :'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, (30) ls_emp-empdesig. endloop.
PROG63
REPORT Z7AM_PROG63. types : begin of ty_emp. include structure z7pmemp. types end of ty_emp.
data : lt_emp type sorted table of ty_emp with non-unique key empno, ls_emp type ty_emp. clear ls_emp. ls_emp-empno = 6. ls_emp-ename = 'raju'. ls_emp-empdesig = 'manager'. insert ls_emp into table lt_emp. clear ls_emp. ls_emp-empno = 16. ls_emp-ename = 'anil'. ls_emp-empdesig = 'manager'. insert ls_emp into table lt_emp. clear ls_emp. ls_emp-empno = 8. ls_emp-ename = 'rajesh'. ls_emp-empdesig = 'manager'. insert ls_emp into table lt_emp. write :/ 'Data in internal table :'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, (30) ls_emp-empdesig. endloop. *sort lt_emp by ename.
PROG64
REPORT Z7AM_PROG64. types : begin of ty_emp. include structure z7pmemp. types end of ty_emp. data : lt_emp type sorted table of ty_emp with unique key empno, ls_emp type ty_emp. clear ls_emp. ls_emp-empno = 6. ls_emp-ename = 'raju'.
ls_emp-empdesig = 'manager'. insert ls_emp into table lt_emp. clear ls_emp. ls_emp-empno = 16. ls_emp-ename = 'anil'. ls_emp-empdesig = 'manager'. insert ls_emp into table lt_emp. clear ls_emp. ls_emp-empno = 8. ls_emp-ename = 'rajesh'. ls_emp-empdesig = 'manager'. insert ls_emp into table lt_emp. clear ls_emp. ls_emp-empno = 16. ls_emp-ename = 'vamshi'. ls_emp-empdesig = 'manager'. insert ls_emp into table lt_emp.
write :/ 'Data in internal table :'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, (30) ls_emp-empdesig. endloop.
PROG65
REPORT Z7AM_PROG65. types : begin of ty_emp. include structure z7pmemp. types end of ty_emp. data : lt_emp type hashed table of ty_emp with unique key empno, ls_emp type ty_emp. clear ls_emp. ls_emp-empno = 6. ls_emp-ename = 'raju'. ls_emp-empdesig = 'manager'. *append ls_emp to lt_emp.
insert ls_emp into table lt_emp. clear ls_emp. ls_emp-empno = 16. ls_emp-ename = 'anil'. ls_emp-empdesig = 'manager'. insert ls_emp into table lt_emp. clear ls_emp. ls_emp-empno = 8. ls_emp-ename = 'rajesh'. ls_emp-empdesig = 'manager'. insert ls_emp into table lt_emp. write :/ 'Data in internal table :'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, (30) ls_emp-empdesig. endloop. sort lt_emp. write :/ 'Data in internal table after sort:'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, (30) ls_emp-empdesig. endloop. clear ls_emp. *read table lt_emp into ls_emp index 2. read table lt_emp into ls_emp with key empno = 6.
PROG66
REPORT Z7AM_PROG66. write :/ 'gensoft'. write :/ 'hello'. write :/ 'welcome'. write :/ 'bye'. write :/ 'ameerpet'. write :/ 'hello'. write :/ 'welcome'.
write :/ 'bye'. write :/ 'SAP training'. write :/ 'hello'. write :/ 'welcome'. write :/ 'bye'. write :/ 'hyderabad'. write :/ 'hello'. write :/ 'welcome'. write :/ 'bye'.
PROG67
REPORT Z7AM_PROG67. write :/ 'gensoft'. perform abc. write :/ 'sap training'. perform abc. write :/ 'hyderabad'. perform abc. form abc. write :/ 'hello'. write :/ 'welcome'. write :/ 'bye'. endform.
PROG68
REPORT Z7AM_PROG68. write :/ 'gensoft'. perform abc. write :/ 'sap training'. perform abc. write :/ 'hyderabad'. perform pqr. perform abc. form abc. write :/ 'hello'. write :/ 'welcome'. write :/ 'bye'. endform.
REPORT Z7AM_PROG69. write :/ 'gensoft'. perform abc. write :/ 'sap training'. perform abc. write :/ 'hyderabad'. perform pqr. perform abc. form abc. write :/ 'hello'. write :/ 'welcome'. write :/ 'bye'. endform. form pqr. write :/ 'inside pqr'. perform lmn. endform. form lmn. write :/ 'inside lmn'. endform.
PROG70
REPORT Z7AM_PROG70. perform abc(z7ampool). PROGRAM Z7AMPOOL. form abc. write :/ 'inside abc'. endform. form pqr. write :/ 'inside pqr'. endform.
PROG71
REPORT Z7AM_PROG71
data : x type i value 10, y type i value 20. break-point. perform abc using x y. "actual parameters x = 30. y = 14. perform abc using x y. form abc using m n. "formal parameters data z type i. "local variable z = m + n. write :/ 'sum is :',z. endform. .
PROG72
REPORT Z7AM_PROG72 data : x type i value 10, y type i value 5, r1 type i, r2 type i. write :/ 'r1 and r2 before sub :',r1,r2. perform abc using x y changing r1 r2. write :/ 'r1 and r2 after sub :',r1,r2. form abc using m n changing t1 t2. t1 = m + n. t2 = m - n. endform.
PROG73
REPORT Z7AM_PROG73 types : begin of ty_emp, empno type i, ename(20) type c, deptno type i, end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp.
clear ls_emp. ls_emp-empno = 5. ls_emp-ename = 'raju'. ls_emp-deptno = 10. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 15. ls_emp-ename = 'ravi'. ls_emp-deptno = 20. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 2. ls_emp-ename = 'ramu'. ls_emp-deptno = 10. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 25. ls_emp-ename = 'rakesh'. ls_emp-deptno = 20. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 17. ls_emp-ename = 'rajesh'. ls_emp-deptno = 30. append ls_emp to lt_emp. perform abc tables lt_emp. form abc tables gt_emp. describe table gt_emp. write :/ 'No of records :',sy-tfill. endform.
PROG74
REPORT Z7AM_PROG74 data : x type i value 10, y type i value 20. write :/ 'X and Y before calling sub :',x,y. perform abc using x y.
write :/ 'X and Y before calling sub :',x,y. form abc using m n. data z type i. z = m. m = n. n = z. endform.
PROG75
REPORT Z7AM_PROG74 data : x type i value 10, y type i value 20. write :/ 'X and Y before calling sub :',x,y. perform abc using x y. write :/ 'X and Y before calling sub :',x,y. form abc using value(m) value(n). data z type i. z = m. m = n. n = z. endform.
PROG76
REPORT Z7AM_PROG76 include z7aminc. x = 10. y = 20. z = x + y. write z. inc code data : x type i, y type i, z type i.
PROG77
REPORT Z7AM_PROG81 define abc. &3 = &1 + &2. &4 = &1 - &2. &5 = &1 * &2. end-of-definition. data : r1 type i, r2 type i, r3 type i. abc 20 10 r1 r2 r3. write :/ 'sum is :',r1, / 'difference is :',r2, / 'product is :',r3. uline. clear : r1,r2,r3. abc 10 5 r1 r2 r3. write :/ 'sum is :',r1, / 'difference is :',r2,
REPORT Z7AM_PROG82 *message 'hello' type 'I'. *message i000(z7ammsg). *message s000(z7ammsg). *message e000(z7ammsg). message a000(z7ammsg).
PROG83
REPORT Z7AM_PROG86. parameters : p_x type i, p_y type i. data lv_z type i. CALL FUNCTION 'Z7AMFM5' EXPORTING I_X = p_x I_Y = p_y IMPORTING E_Z = lv_z. write :/ 'Division is :',lv_z. write :/ 'hello'.
FUNCTION Z7AMFM5. try. e_z = i_x / i_y. *catch cx_sy_zerodivide. catch cx_root. message 'cannot divide by zero' type 'I'. endtry. ENDFUNCTION.
PROG87
REPORT Z7AM_PROG87. parameters : p_x type i, p_y type i. data lv_z type i. CALL FUNCTION 'Z7AMFM6' EXPORTING I_X = p_x
I_Y = p_y IMPORTING E_Z = lv_z EXCEPTIONS DIVIDEERROR = 16 OTHERS = 23. if sy-subrc eq 0. write :/ 'Division is :',lv_z. elseif sy-subrc eq 16. write :/ 'Cannot divide by zero'. elseif sy-subrc eq 23. write :/ 'Unknown error'. endif.
FUNCTION Z7AMFM6. if i_y eq 0. raise divideerror. else. e_z = i_x / i_y. endif. ENDFUNCTION.
PROG88
REPORT Z7AM_PROG88. parameters : p_x type i. data : lv_y(20) type c, lv_z(30) type c. select single ename empdesig from z7pmemp into (lv_y,lv_z) where empno = p_x. if sy-subrc eq 0.
message i000(z7ammsg). write :/ 'Employee name :',lv_y, / 'Employee desig:',lv_z. else. message i001(z7ammsg). endif.
PROG89
REPORT Z7AM_PROG89. parameters : p_x type i. types : begin of ty_emp, lv_y(20) type c, lv_z(30) type c, end of ty_emp. data ls_emp type ty_emp. select single ename empdesig from z7pmemp into ls_emp where empno = p_x. if sy-subrc eq 0. message i000(z7ammsg). write :/ 'Employee name :',ls_emp-lv_y, / 'Employee desig:',ls_emp-lv_z. else. message i001(z7ammsg). endif.
PROG90
REPORT Z7AM_PROG90. *parameters : p_x type zempno. parameters p_x type z7pmemp-empno. types : begin of ty_emp, lv_y type z7pmemp-ename, lv_z type z7pmemp-empdesig, end of ty_emp. data ls_emp type ty_emp. select single ename empdesig from z7pmemp into ls_emp where empno = p_x.
if sy-subrc eq 0. message i000(z7ammsg). write :/ 'Employee name :',ls_emp-lv_y, / 'Employee desig:',ls_emp-lv_z. else. message i001(z7ammsg). endif.
Prog91
REPORT Z7AM_PROG91. parameters p_desig type z7pmemp-empdesig. types : begin of ty_emp, empno type z7pmemp-empno, ename type z7pmemp-ename, end of ty_emp. data ls_emp type ty_emp. select empno ename from z7pmemp into ls_emp where empdesig = p_desig. write :/ ls_emp-empno, ls_emp-ename. endselect.
Prog92
REPORT Z7AMPROG92.
*parameters p_land1(3) type c. parameters p_land1 type kna1-land1. types : begin of ty_kna1, kunnr type kna1-kunnr, land1 type kna1-land1, ort01 type kna1-ort01, end of ty_kna1. data : ls_kna1 type ty_kna1. select kunnr land1 ort01 from kna1 into ls_kna1 where land1 = p_land1. write :/ ls_kna1-kunnr, ls_kna1-land1, ls_kna1-ort01. endselect.
Prog93
REPORT
Z7AMPROG93.
types : begin of ty_kna1, kunnr type kna1-kunnr, land1 type kna1-land1, ort01 type kna1-ort01, end of ty_kna1. data : lt_kna1 type table of ty_kna1, ls_kna1 type ty_kna1. select kunnr land1 ort01 from kna1 into table lt_kna1 where land1 = p_land1. if sy-subrc eq 0. loop at lt_kna1 into ls_kna1. write :/ ls_kna1-kunnr, ls_kna1-land1, ls_kna1-ort01. endloop. else. message 'No data' type 'I'. endif.
Prog94
REPORT
Z7AMPROG94.
types : begin of ty_emp. include structure z7amemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select * from z7amemp into table lt_emp. if sy-subrc eq 0. write :/ 'No of records retrieved :',sy-dbcnt. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-deptno. endloop. else. write :/ 'No data'. endif.
Prog95
REPORT
Z7AMPROG95.
types : begin of ty_emp. include structure z7amemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select empno deptno from z7amemp into corresponding fields of table lt_emp. if sy-subrc eq 0. write :/ 'No of records retrieved :',sy-dbcnt. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-deptno. endloop.
Prog96
REPORT
Z7AMPROG96.
types : begin of ty_emp. include structure z7amemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select * from z7amemp into table lt_emp up to 4 rows. if sy-subrc eq 0. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-deptno. endloop. else. write :/ 'No data'. endif.
Prog97
REPORT
Z7AMPROG97.
types : begin of ty_emp. include structure z7amemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select * from z7amemp into table lt_emp where deptno = 10 or deptno = 20. if sy-subrc eq 0. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-deptno. endloop. else. write :/ 'No data'. endif.
Prog98
REPORT
Z7AMPROG98.
types : begin of ty_emp. include structure z7amemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select * from z7amemp into table lt_emp where deptno in (10,20,30). if sy-subrc eq 0.
loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-deptno. endloop. else. write :/ 'No data'. endif.
Prog99
REPORT
Z7AMPROG99.
types : begin of ty_emp. include structure z7amemp. types end of ty_emp. data : ls_emp type ty_emp. clear ls_emp. ls_emp-empno = 53. ls_emp-ename = 'Rajuk'. ls_emp-deptno = 40. *insert z7amemp from ls_emp. modify z7amemp from ls_emp. if sy-subrc eq 0. write :/ 'No of records affected :',sy-dbcnt. else. write :/ 'Not inserted'. endif.
Prog100
REPORT
Z7AMPROG100.
types : begin of ty_emp. include structure z7amemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. clear ls_emp. ls_emp-empno = 113. ls_emp-ename = 'Rajuk'. ls_emp-deptno = 40. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 123. ls_emp-ename = 'Ramesh'. ls_emp-deptno = 40. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 83. ls_emp-ename = 'abc'. ls_emp-deptno = 40. append ls_emp to lt_emp. *insert z7amemp from table lt_emp. *insert z7amemp from table lt_emp
Prog101
REPORT
Z7AMPROG101.
tables z7amemp. select-options so_empno for z7amemp-empno. types : begin of ty_emp. include structure z7amemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. initialization. so_empno-low = 5. so_empno-high = 28. append so_empno. start-of-selection. perform getemp. if lt_emp[] is not initial. perform displayemp. endif. FORM getemp . select * from z7amemp into table lt_emp where empno in so_empno. ENDFORM. " getemp FORM displayemp . loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-deptno. endloop. ENDFORM. " displayemp
Prog102
REPORT
Z7AMPROG102.
tables z7amemp. select-options so_empno for z7amemp-empno. types : begin of ty_emp. include structure z7amemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. initialization. so_empno-sign = 'E'. so_empno-low = 5. so_empno-high = 28.
append so_empno. start-of-selection. perform getemp. if lt_emp[] is not initial. perform displayemp. endif. FORM getemp . select * from z7amemp into table lt_emp where empno in so_empno. ENDFORM. " getemp FORM displayemp . loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-deptno. endloop. ENDFORM. " displayemp
Prog103
REPORT
Z7AMPROG103.
ranges r_empno for z7amemp-empno. types : begin of ty_emp. include structure z7amemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select * from z7amemp into table lt_emp where empno in r_empno. if sy-subrc eq 0. write :/ 'No of records :',sy-dbcnt. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-deptno. endloop. endif.
Prog104
REPORT
Z7AMPROG104.
ranges r_empno for z7amemp-empno. types : begin of ty_emp. include structure z7amemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. initialization. r_empno-low = 7. r_empno-high = 30. append r_empno.
start-of-selection. select * from z7amemp into table lt_emp where empno in r_empno. if sy-subrc eq 0. write :/ 'No of records :',sy-dbcnt. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-deptno. endloop. endif.
Prog105
REPORT
Z7AMPROG105.
ranges r_empno for z7amemp-empno. types : begin of ty_emp. include structure z7amemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. initialization. r_empno-low = 7. r_empno-high = 30. r_empno-option = 'BT'. append r_empno. start-of-selection. select * from z7amemp into table lt_emp where empno in r_empno. if sy-subrc eq 0. write :/ 'No of records :',sy-dbcnt. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-deptno. endloop. endif.
Prog106
REPORT
Z7AMPROG106.
ranges r_empno for z7amemp-empno. types : begin of ty_emp. include structure z7amemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. initialization. r_empno-low = 7. r_empno-high = 30. r_empno-option = 'BT'. r_empno-sign = 'I'. append r_empno. start-of-selection.
select * from z7amemp into table lt_emp where empno in r_empno. if sy-subrc eq 0. write :/ 'No of records :',sy-dbcnt. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-deptno. endloop. endif.
Prog107
REPORT
Z7AMPROG107.
tables z7amemp. select-options so_empno for z7amemp-empno no-extension no intervals. types : begin of ty_emp. include structure z7amemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. start-of-selection. perform getemp. if lt_emp[] is not initial. perform displayemp. endif. FORM getemp . select * from z7amemp into table lt_emp where empno in so_empno. ENDFORM. " getemp FORM displayemp . loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-deptno. endloop. ENDFORM. " displayemp
Prog108
REPORT
Z7AMPROG108.
type-pools zabc. write :/ zabc_x. data : lt_emp type table of zabc_emp, ls_emp type zabc_emp.
Prog109
REPORT
Z7AMPROG109.
ENAME TYPE Z7AMEMP-ENAME, END OF TY_F4. DATA : LT_F4 TYPE TABLE OF TY_F4, LS_F4 TYPE TY_F4. TYPES : BEGIN OF TY_EMP. INCLUDE STRUCTURE Z7AMEMP. TYPES END OF TY_EMP. DATA : LS_EMP TYPE TY_EMP. SELECTION-SCREEN BEGIN OF BLOCK BK1 WITH FRAME TITLE ABC. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 12(15) LB1. PARAMETERS P_EMPNO TYPE Z7AMEMP-EMPNO. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 12(15) LB2. PARAMETERS P_ENAME TYPE Z7AMEMP-ENAME. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 12(15) LB3. PARAMETERS P_DEPTNO TYPE Z7AMEMP-DEPTNO. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN END OF BLOCK BK1. SELECTION-SCREEN BEGIN OF BLOCK BK2 WITH FRAME TITLE XYZ. SELECTION-SCREEN PUSHBUTTON 5(10) B1 USER-COMMAND P1. SELECTION-SCREEN PUSHBUTTON 18(10) B2 USER-COMMAND P2. SELECTION-SCREEN PUSHBUTTON 31(10) B3 USER-COMMAND P3. SELECTION-SCREEN SKIP 2. SELECTION-SCREEN PUSHBUTTON 5(10) B4 USER-COMMAND P4. SELECTION-SCREEN PUSHBUTTON 18(10) B5 USER-COMMAND P5. SELECTION-SCREEN PUSHBUTTON 31(10) B6 USER-COMMAND P6. SELECTION-SCREEN END OF BLOCK BK2. INITIALIZATION. ABC = 'Employee'. XYZ = 'Operations'. LB1 = 'Employee No'. LB2 = 'Employee Name'. LB3 = 'Department no'. B1 = 'Search'. B2 = 'Insert'. B3 = 'Delete'. B4 = 'Modify'. B5 = 'Clear'. B6 = 'Exit'. AT SELECTION-SCREEN OUTPUT. IF FLAG EQ 0. PERFORM INVISIBLE. ELSEIF FLAG EQ 1.
PERFORM VISIBLE. ENDIF. AT SELECTION-SCREEN. CASE SY-UCOMM. WHEN 'P6'. LEAVE PROGRAM. WHEN 'P1'. IF P_EMPNO IS NOT INITIAL. SELECT SINGLE ENAME DEPTNO FROM Z7AMEMP INTO (P_ENAME,P_DEPTNO) WHERE EMPNO = P_EMPNO. IF SY-SUBRC NE 0. MESSAGE 'Record not found' TYPE 'I'. ELSE. FLAG = 1. ENDIF. ELSE. MESSAGE 'Please enter empno' TYPE 'I'. ENDIF. WHEN 'P5'. CLEAR : P_EMPNO, P_ENAME, P_DEPTNO. WHEN 'P2'. IF P_EMPNO IS NOT INITIAL. CLEAR LS_EMP. LS_EMP-EMPNO = P_EMPNO. LS_EMP-ENAME = P_ENAME. LS_EMP-DEPTNO = P_DEPTNO. INSERT Z7AMEMP FROM LS_EMP. IF SY-SUBRC EQ 0. MESSAGE 'Record inserted' TYPE 'I'. ELSE. MESSAGE 'Not inserted' TYPE 'I'. ENDIF. ELSE. MESSAGE 'Please enter empno before insert' TYPE 'I'. ENDIF. WHEN 'P4'. IF P_EMPNO IS NOT INITIAL. UPDATE Z7AMEMP SET ENAME = P_ENAME DEPTNO = P_DEPTNO WHERE EMPNO = P_EMPNO. ELSE. MESSAGE 'Please enter empno before update' TYPE 'I'. ENDIF. WHEN 'P3'. IF P_EMPNO IS NOT INITIAL. DELETE FROM Z7AMEMP WHERE EMPNO = P_EMPNO. ELSE. MESSAGE 'Please enter empno before delete' TYPE 'I'. ENDIF. ENDCASE. AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_EMPNO. PERFORM GETF4DATA. IF LT_F4[] IS NOT INITIAL. PERFORM DISPLAYF4. ENDIF. AT SELECTION-SCREEN ON HELP-REQUEST FOR P_EMPNO. CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING TITEL = 'Custom F1 Help' TXT1 = 'Z7AMEMP Table' TXT2 = 'Employee No (EMPNO Field)'. *&---------------------------------------------------------------------* *& Form invisible *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM INVISIBLE . LOOP AT SCREEN. IF SCREEN-NAME = 'LB2' OR SCREEN-NAME = 'P_ENAME' OR SCREEN-NAME = 'LB3' OR SCREEN-NAME = 'P_DEPTNO'. SCREEN-INVISIBLE = '1'. SCREEN-INPUT = '0'. MODIFY SCREEN. ENDIF. ENDLOOP. ENDFORM. " invisible *&---------------------------------------------------------------------* *& Form getf4data *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM GETF4DATA . SELECT EMPNO ENAME FROM Z7AMEMP INTO TABLE LT_F4. ENDFORM. " getf4data *&---------------------------------------------------------------------* *& Form displayf4 *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM DISPLAYF4 . CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING RETFIELD = 'EMPNO' DYNPPROG = SY-REPID DYNPNR = SY-DYNNR DYNPROFIELD = 'P_EMPNO' VALUE_ORG = 'S' TABLES VALUE_TAB = LT_F4[]. ENDFORM. " displayf4
*&---------------------------------------------------------------------* *& Form visible *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM VISIBLE . LOOP AT SCREEN. IF SCREEN-NAME = 'LB2' OR SCREEN-NAME = 'P_ENAME' OR SCREEN-NAME = 'LB3' OR SCREEN-NAME = 'P_DEPTNO'.
SCREEN-INVISIBLE = '0'. SCREEN-INPUT = '1'. MODIFY SCREEN. ENDIF. ENDLOOP. ENDFORM. " visible
Prog110
REPORT
Z7AMPROG110.
tables sscrfields. parameters x type i. selection-screen function selection-screen function selection-screen function selection-screen function selection-screen function initialization. sscrfields-functxt_01 sscrfields-functxt_02 sscrfields-functxt_03 sscrfields-functxt_04 sscrfields-functxt_05 = = = = =
1. 2. 3. 4. 5.
at selection-screen. case sy-ucomm. when 'FC01'. call transaction 'SE38'. when 'FC02'. call transaction 'SE11'. when 'FC03'. call transaction 'SE80'. endcase.
Prog111
REPORT
Z7AMPROG111.
set pf-status 'ABC'. write 'hello'. at user-command. case sy-ucomm. when 'R1'. leave program. when 'MI1'. call transaction 'SE38'. when 'MP4'. call transaction 'SE24'. endcase.
Prog112
REPORT
Z7AMPROG112.
selection-screen begin of tabbed block tb1 for 6 lines. selection-screen tab (10) t1 user-command p1. selection-screen tab (10) t2 user-command p2. selection-screen end of block tb1. selection-screen pushbutton 5(10) b1 user-command r1. selection-screen pushbutton 18(10) b2 user-command r2.
selection-screen begin of screen 200 as subscreen. parameters p_deptno type z7amemp-deptno. selection-screen end of screen 200. selection-screen begin of screen 100 as subscreen. parameters : p_empno type z7amemp-empno, p_ename type z7amemp-ename. selection-screen end of screen 100. initialization. b1 = 'Insert'. b2 = 'Exit'. t1 = 'Tab1'. t2 = 'Tab2'. tb1-activetab = 'P2'. tb1-dynnr = '200'. tb1-prog = sy-repid. at selection-screen. case sy-ucomm. when 'P1'. tb1-activetab = 'P1'. tb1-dynnr = '100'. tb1-prog = sy-repid. when 'P2'. tb1-activetab = 'P2'. tb1-dynnr = '200'. tb1-prog = sy-repid. when 'R2'. leave program. endcase.
Prog113
REPORT
Z7AMPROG113.
type-pools vrm. types : begin of ty_values. include type vrm_value. types end of ty_values. data : lt_values type table of ty_values, ls_values type ty_values. data xyz(20) type c. parameters abc like xyz as listbox visible length 10 user-command P1. selection-screen begin of block b1 with title parameters : c1 as checkbox modif id c2 as checkbox modif id c3 as checkbox modif id selection-screen end of block b1. selection-screen begin of block b2 with title parameters : r1 radiobutton group g1 r2 radiobutton group g1 r3 radiobutton group g1 frame t1. i1, i1, i1. frame t2. modif id i2, modif id i2, modif id i2.
selection-screen end of block b2. data flag type i. initialization. t1 = 'Courses'. perform values. if lt_values[] is not initial. perform associatevalues. endif. at selection-screen output. if flag = 0. perform invisibleblocks. elseif flag = 1. perform visibleblock1. elseif flag = 2. perform visibleblock2. endif. at selection-screen. case sy-ucomm. when 'P1'. if abc = 'K1'. flag = 1. elseif abc = 'K2'. flag = 2. elseif abc = 'K3'. flag = 3. endif. endcase. form values . clear ls_values. ls_values-key = 'K1'. ls_values-text = 'Courses'. append ls_values to lt_values. clear ls_values. ls_values-key = 'K2'. ls_values-text = 'Institutes'. append ls_values to lt_values. clear ls_values. ls_values-key = 'K3'. ls_values-text = 'Locations'. append ls_values to lt_values. endform. " values form associatevalues . CALL FUNCTION 'VRM_SET_VALUES' EXPORTING id = 'ABC' values = lt_values[]. endform. " associatevalues
FORM visibleblock1 . loop at screen. if screen-group1 = 'I1'. screen-invisible = '0'. modify screen. endif. if screen-group1 = 'I2'. screen-invisible = '1'. modify screen. endif. endloop. ENDFORM. " visibleblock1
FORM visibleblock2 . loop at screen. if screen-group1 = 'I2'. screen-invisible = '0'. modify screen. endif. if screen-group1 = 'I1'. screen-invisible = '1'. modify screen. endif. endloop. ENDFORM. " visibleblock2
Prog114
REPORT
Z7AMPROG114.
data : lv_vbeln type vbak-vbeln. select-options so_vbeln for lv_vbeln. types : begin of ty_vbak. include structure zmyvbak. types end of ty_vbak. data : lt_vbak type table of ty_vbak, ls_vbak type ty_vbak. types : begin of ty_vbap. include structure zmyvbap. types end of ty_vbap. data : lt_vbap type table of ty_vbap, ls_vbap type ty_vbap. initialization. so_vbeln-low = '4970'. so_vbeln-high = '4975'. append so_vbeln. start-of-selection. perform getvbak. if lt_vbak[] is not initial.
perform getvbap. perform display. endif. FORM getvbak . select vbeln erdat erzet ernam from vbak into table lt_vbak where vbeln in so_vbeln. ENDFORM. " getvbak FORM getvbap . loop at lt_vbak into ls_vbak. select vbeln posnr matnr from vbap into table lt_vbap where vbeln = ls_vbak-vbeln. endloop. ENDFORM. " getvbap FORM display . loop at lt_vbak into ls_vbak. write :/ ls_vbak-vbeln, ls_vbak-erdat, ls_vbak-erzet, ls_vbak-ernam. loop at lt_vbap into ls_vbap where vbeln = ls_vbak-vbeln. write:/5 ls_vbap-vbeln, ls_vbap-posnr, ls_vbap-matnr. endloop. endloop. ENDFORM. " display
Prog115
REPORT
Z7AMPROG115.
data : lv_vbeln type vbak-vbeln. select-options so_vbeln for lv_vbeln. types : begin of ty_vbak. include structure zmyvbak. types end of ty_vbak. data : lt_vbak type table of ty_vbak, ls_vbak type ty_vbak. types : begin of ty_vbap. include structure zmyvbap. types end of ty_vbap. data : lt_vbap type table of ty_vbap, ls_vbap type ty_vbap. initialization. so_vbeln-low = '4970'. so_vbeln-high = '4975'. append so_vbeln. start-of-selection. perform getvbak. if lt_vbak[] is not initial. perform getvbap.
perform display. endif. FORM getvbak . select vbeln erdat erzet ernam from vbak into table lt_vbak where vbeln in so_vbeln. ENDFORM. " getvbak FORM getvbap . loop at lt_vbak into ls_vbak. select vbeln posnr matnr appending corresponding fields of table lt_vbap from vbap where vbeln = ls_vbak-vbeln. endloop. ENDFORM. " getvbap FORM display . loop at lt_vbak into ls_vbak. write :/ ls_vbak-vbeln, ls_vbak-erdat, ls_vbak-erzet, ls_vbak-ernam. loop at lt_vbap into ls_vbap where vbeln = ls_vbak-vbeln. write:/5 ls_vbap-vbeln, ls_vbap-posnr, ls_vbap-matnr. endloop. endloop. ENDFORM. " display
Prog116
REPORT
Z7AMPROG116.
data : lv_vbeln type vbak-vbeln. select-options so_vbeln for lv_vbeln. types : begin of ty_vbak. include structure zmyvbak. types end of ty_vbak. data : lt_vbak type table of ty_vbak, ls_vbak type ty_vbak. types : begin of ty_vbap. include structure zmyvbap. types end of ty_vbap. data : lt_vbap type table of ty_vbap, ls_vbap type ty_vbap. initialization. so_vbeln-low = '4970'. so_vbeln-high = '4975'. append so_vbeln. start-of-selection. perform getvbak. if lt_vbak[] is not initial. perform getvbap.
perform display. endif. FORM getvbak . select vbeln erdat erzet ernam from vbak into table lt_vbak where vbeln in so_vbeln. ENDFORM. " getvbak FORM getvbap . select vbeln posnr matnr from vbap into table lt_vbap for all entries in lt_vbak where vbeln = lt_vbak-vbeln. ENDFORM. " getvbap FORM display . loop at lt_vbak into ls_vbak. format color 5. write :/ ls_vbak-vbeln, ls_vbak-erdat, ls_vbak-erzet, ls_vbak-ernam. format color off. loop at lt_vbap into ls_vbap where vbeln = ls_vbak-vbeln. format color 6. write:/5 ls_vbap-vbeln, ls_vbap-posnr, ls_vbap-matnr. format color off. endloop. endloop. ENDFORM. " display
Prog117
REPORT
Z7AMPROG117.
TYPES : BEGIN OF TY_EMP, DEPTNO TYPE Z7AMEMPLOYEE-DEPTNO, CNT TYPE I, SAL TYPE I, END OF TY_EMP. DATA : LT_EMP TYPE TABLE OF TY_EMP, LS_EMP TYPE TY_EMP. SELECT DEPTNO COUNT(*) SUM( EMPSAL ) FROM Z7AMEMPLOYEE INTO TABLE LT_EMP GROUP BY DEPTNO. IF SY-SUBRC EQ 0. LOOP AT LT_EMP INTO LS_EMP. WRITE :/ LS_EMP-DEPTNO, LS_EMP-CNT, LS_EMP-SAL. ENDLOOP. ENDIF.
Prog118
REPORT
Z7AMPROG118.
types : begin of ty_emp, deptno type z7amemployee-deptno, cnt type i, sal type i, end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select deptno count(*) sum( empsal ) from z7amemployee into table lt_emp group by deptno having deptno ne 30. if sy-subrc eq 0. loop at lt_emp into ls_emp. write :/ ls_emp-deptno, ls_emp-cnt, ls_emp-sal. endloop. endif.
Prog119
REPORT
data lv_vbeln type vbap-vbeln. select-options so_vbeln for lv_vbeln. types : begin of ty_vbap, vbeln type vbap-vbeln, posnr type vbap-posnr, matnr type vbap-matnr, netwr type vbap-netwr, end of ty_vbap. data : lt_vbap type table of ty_vbap, ls_vbap type ty_vbap. initialization. so_vbeln-low = '4970'. so_vbeln-high = '4975'. append so_vbeln. start-of-selection. perform getvbap. if lt_vbap[] is not initial. perform displayvbap. endif. FORM getvbap . select vbeln posnr matnr netwr from vbap into table lt_vbap where vbeln in so_vbeln. ENDFORM. " getvbap FORM displayvbap . loop at lt_vbap into ls_vbap. at first. write :/8 'SALES DOCUMENT ITEM DATA WITH PRICES'. endat.
at new vbeln. write :/ 'SALES DOCUMENT :',ls_vbap-vbeln color 3. endat. write :/5 ls_vbap-posnr, ls_vbap-matnr, ls_vbap-netwr. at end of vbeln. sum. write :/ 'Total value of :',ls_vbap-vbeln, ' is:',ls_vbap-netwr color 4. endat. at last. sum. write :/ 'Total value is :',ls_vbap-netwr color 3. endat. endloop. ENDFORM.
Prog120
REPORT
" displayvbap
data lv_vbeln type vbap-vbeln. select-options so_vbeln for lv_vbeln. types : begin of ty_vbap, posnr type vbap-posnr, vbeln type vbap-vbeln, matnr type vbap-matnr, netwr type vbap-netwr, end of ty_vbap. data : lt_vbap type table of ty_vbap, ls_vbap type ty_vbap. initialization. so_vbeln-low = '4970'. so_vbeln-high = '4975'. append so_vbeln. start-of-selection. perform getvbap. if lt_vbap[] is not initial. perform displayvbap. endif. FORM getvbap . select vbeln posnr matnr netwr from vbap into corresponding fields of table lt_vbap where vbeln in so_vbeln. ENDFORM. " getvbap FORM displayvbap . loop at lt_vbap into ls_vbap. at first. write :/8 'SALES DOCUMENT ITEM DATA WITH PRICES'. endat.
at new vbeln. write :/ 'SALES DOCUMENT :',ls_vbap-vbeln color 3. endat. write :/5 ls_vbap-posnr, ls_vbap-matnr, ls_vbap-netwr. at end of vbeln. sum. write :/ 'Total value of :',ls_vbap-vbeln, ' is:',ls_vbap-netwr color 4. endat. at last. sum. write :/ 'Total value is :',ls_vbap-netwr color 3. endat. endloop. ENDFORM.
Prog121
REPORT
" displayvbap
data lv_vbeln type vbap-vbeln. select-options so_vbeln for lv_vbeln. types : begin of ty_vbap, vbeln type vbap-vbeln, posnr type vbap-posnr, matnr type vbap-matnr, netwr type vbap-netwr, end of ty_vbap. data : lt_vbap type table of ty_vbap, ls_vbap type ty_vbap. initialization. so_vbeln-low = '4970'. so_vbeln-high = '4975'. append so_vbeln. start-of-selection. perform getvbap. if lt_vbap[] is not initial. perform displayvbap. endif. FORM getvbap . select vbeln posnr matnr netwr from vbap into table lt_vbap where vbeln in so_vbeln. ENDFORM. " getvbap FORM displayvbap . loop at lt_vbap into ls_vbap. at first. write :/8 'SALES DOCUMENT ITEM DATA WITH PRICES'. endat. * at new vbeln.
on change of ls_vbap-vbeln. write :/ 'SALES DOCUMENT :',ls_vbap-vbeln color 3. endon. endat. write :/5 ls_vbap-posnr, ls_vbap-matnr, ls_vbap-netwr. at end of vbeln. sum. write :/ 'Total value of :',ls_vbap-vbeln, ' is:',ls_vbap-netwr color 4. endat. at last. sum. write :/ 'Total value is :',ls_vbap-netwr color 3. endat.
endloop. ENDFORM.
Prog122
REPORT
" displayvbap
Z7AMPROG122.
data : y type i value 1. while y <= 10. at new y. on change of y. write :/ 'hello'. * endat. endon. y = y + 1. endwhile. *
Prog123
REPORT
data lv_kunnr type kna1-kunnr. select-options so_kunnr for lv_kunnr. types : begin of ty_kna1, kunnr type kna1-kunnr, land1 type kna1-land1, name1 type kna1-name1, end of ty_kna1. data : lt_kna1 type table of ty_kna1, ls_kna1 type ty_kna1. types : begin of ty_vbak. include structure zmyvbak. types end of ty_vbak. data : lt_vbak type table of ty_vbak, ls_vbak type ty_vbak. types : begin of ty_vbap. include structure zmyvbap.
types end of ty_vbap. data : lt_vbap type table of ty_vbap, ls_vbap type ty_vbap. initialization. so_kunnr-low = '1000'. so_kunnr-high = '1020'. append so_kunnr. start-of-selection. perform getcustomers. if lt_kna1[] is not initial. perform displaycustomers. endif. top-of-page. uline. write :/8 'CUSTOMER MASTER DATA' color 1. uline. top-of-page during line-selection. case sy-lsind. when 1. uline. write :/8 'SALES DOCUMENTS OF CUSTOMERS' color 7. uline. when 2. uline. write :/8 'SALES DOCUMENT ITEMS' color 6. uline. endcase. at line-selection. case sy-lsind. when 1. clear lv_kunnr. lv_kunnr = sy-lisel+0(10). perform convertkunnr. if lv_kunnr is not initial. perform salesorders. if lt_vbak[] is not initial. perform displaysalesorders. else. message 'No sales orders' type 'I'. endif. endif. when 2. perform getsalesitems. if lt_vbap[] is not initial. perform displaysalesitems. else. message 'No items' type 'I'. endif. endcase. FORM getcustomers . select kunnr land1 name1 from kna1 into table lt_kna1 where kunnr in so_kunnr. ENDFORM. " getcustomers
FORM displaycustomers . uline. format color 5. write :/(12) 'CUSTOMER',sy-vline,'COUNTRY',sy-vline,'CUSTOMER NAME'. format color off. uline. format color 6. loop at lt_kna1 into ls_kna1. write :/(12) ls_kna1-kunnr,sy-vline, (6) ls_kna1-land1,sy-vline, ls_kna1-name1,sy-vline. endloop. format color off. ENDFORM. " displaycustomers FORM salesorders . select vbeln erdat erzet ernam from vbak into table lt_vbak where kunnr = lv_kunnr. ENDFORM. " salesorders FORM displaysalesorders . uline. format color 3. write :/(11) 'SALES DOC',(10) 'DATE',(8) 'TIME','PERSON'. format color off. uline. format color 7. loop at lt_vbak into ls_vbak. write :/ ls_vbak-vbeln, ls_vbak-erdat, ls_vbak-erzet, ls_vbak-ernam. hide ls_vbak-vbeln. endloop. format color off. ENDFORM. " displaysalesorders FORM convertkunnr . CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING INPUT = lv_kunnr IMPORTING OUTPUT = lv_kunnr. ENDFORM. " convertkunnr
FORM getsalesitems . select vbeln posnr matnr from vbap into table lt_vbap where vbeln = ls_vbak-vbeln. ENDFORM. " getsalesitems FORM displaysalesitems . uline. format color 2. write :/(11) 'SALES DOC',(7) 'ITEM NO',(10) 'MATERIAL'. format color off. uline. format color 3. loop at lt_vbap into ls_vbap.
Prog124
REPORT
" displaysalesitems
Z7AMPROG124.
types : begin of ty_dept_emp. include structure z7amdept. include structure z7amemp. types end of ty_dept_emp. data : lt_dept_emp type table of ty_dept_emp, ls_dept_emp type ty_dept_emp. select * from z7amdept inner join z7amemp on z7amdept~dno = z7amemp~deptno into table lt_dept_emp. if sy-subrc eq 0. sort lt_dept_emp by dno. loop at lt_dept_emp into ls_dept_emp. write :/ ls_dept_emp-dno, (15) ls_dept_emp-dname, ls_dept_emp-loc, ls_dept_emp-empno, ls_dept_emp-deptno, (15) ls_dept_emp-ename. endloop. else. write :/ 'No data'. endif.
Prog125
REPORT Z7AMPROG125.
types : begin of ty_dept_emp. include structure z7amdept. include structure z7amemp. types end of ty_dept_emp. data : lt_dept_emp type table of ty_dept_emp, ls_dept_emp type ty_dept_emp. select * from z7amdept left outer join z7amemp on z7amdept~dno = z7amemp~deptno into table lt_dept_emp. if sy-subrc eq 0.
sort lt_dept_emp by dno. loop at lt_dept_emp into ls_dept_emp. write :/ ls_dept_emp-dno, (15) ls_dept_emp-dname, ls_dept_emp-loc, ls_dept_emp-empno, ls_dept_emp-deptno, (15) ls_dept_emp-ename. endloop. else. write :/ 'No data'. endif.
Prog126
REPORT Z7AMPROG126.
types : begin of ty_dept_emp, dno type z7amdept-dno, dname type z7amdept-dname. include structure z7amemp. types end of ty_dept_emp. data : lt_dept_emp type table of ty_dept_emp, ls_dept_emp type ty_dept_emp. select dno dname empno deptno ename from z7amdept as x left outer join z7amemp as y on x~dno = y~deptno into table lt_dept_emp. if sy-subrc eq 0. sort lt_dept_emp by dno. loop at lt_dept_emp into ls_dept_emp. write :/ ls_dept_emp-dno, (15) ls_dept_emp-dname, ls_dept_emp-empno, ls_dept_emp-deptno, (15) ls_dept_emp-ename. endloop. else. write :/ 'No data'. endif.
Prog127
REPORT Z7AMPROG127.
kunnr type kna1-kunnr, land1 type kna1-land1, vbeln type vbak-vbeln, ernam type vbak-ernam, lv_kunnr type vbak-kunnr, lv_vbeln type vbap-vbeln, posnr type vbap-posnr, matnr type vbap-matnr, end of ty_sales. data : lt_sales type table of ty_sales, ls_sales type ty_sales. select kna1~kunnr land1 vbak~vbeln vbak~ernam vbak~kunnr vbap~vbeln posnr matnr from kna1 inner join vbak on kna1~kunnr = vbak~kunnr inner join vbap on vbak~vbeln = vbap~vbeln into table lt_sales where kna1~kunnr = p_kunnr. if sy-subrc eq 0. loop at lt_sales into ls_sales. write :/ ls_sales-kunnr, ls_sales-land1, ls_sales-vbeln, (15) ls_sales-ernam, ls_sales-lv_kunnr, ls_sales-lv_vbeln, ls_sales-posnr, (10) ls_sales-matnr. endloop. else. write :/ 'No data'. endif.
Prog128
PROGRAM
Z7AMPROG128.
*data : io1 type i, * io2 type i, * io3 type i. MODULE ABC INPUT. CASE SY-UCOMM. WHEN 'P2'. LEAVE PROGRAM. * when 'P1'. * io3 = io1 + io2. ENDCASE. ENDMODULE.
Prog129
" abc
INPUT
PROGRAM
Z7AMPROG129.
CONTROLS TBSTR TYPE TABSTRIP. MODULE USER_COMMAND_0100 INPUT. CASE SY-UCOMM. WHEN 'P4'. LEAVE PROGRAM. ENDCASE. ENDMODULE.
Prog130
" USER_COMMAND_0100
INPUT
PROGRAM Z7AMPROG130. TABLES : VBAK,VBAP. TYPES : BEGIN OF TY_VBAP. INCLUDE STRUCTURE ZMYVBAP. TYPES END OF TY_VBAP. DATA : LT_VBAP TYPE TABLE OF TY_VBAP, LS_VBAP TYPE TY_VBAP. CONTROLS TBCTRL TYPE TABLEVIEW USING SCREEN 100. MODULE USER_COMMAND_0100 INPUT. IF VBAK-VBELN IS NOT INITIAL. PERFORM GETITEMS. ELSE. MESSAGE 'Please enter sales doc' TYPE 'I'. ENDIF. CASE SY-UCOMM. WHEN 'P1'.
" USER_COMMAND_0100
INPUT
FORM GETITEMS . SELECT VBELN POSNR MATNR FROM VBAP INTO TABLE LT_VBAP WHERE VBELN = VBAK-VBELN. IF SY-SUBRC EQ 0. DESCRIBE TABLE LT_VBAP. TBCTRL-LINES = SY-TFILL. ENDIF. ENDFORM. " getitems MODULE ABC OUTPUT. VBAP-VBELN = LS_VBAP-VBELN. VBAP-POSNR = LS_VBAP-POSNR. VBAP-MATNR = LS_VBAP-MATNR. ENDMODULE. " abc
OUTPUT
Prog131
PROGRAM
Z7AMPROG131.
MODULE USER_COMMAND_0100 INPUT. CASE SY-UCOMM. WHEN 'P1'. LEAVE PROGRAM. WHEN 'BACK'. LEAVE PROGRAM. WHEN 'CANCEL'. LEAVE PROGRAM. ENDCASE. ENDMODULE. MODULE STATUS_0100 OUTPUT. SET PF-STATUS 'ABC'. ENDMODULE. MODULE ABC INPUT. CASE SY-UCOMM. " STATUS_0100 OUTPUT
" USER_COMMAND_0100
INPUT
" abc
INPUT
Prog132
PROGRAM
Z7AMPROG132.
MODULE USER_COMMAND_0100 INPUT. CASE SY-UCOMM. WHEN 'P1'. LEAVE PROGRAM. ENDCASE. ENDMODULE. " USER_COMMAND_0100
INPUT
Prog133
PROGRAM
Z7AMPROG133.
TABLES KNA1. MODULE USER_COMMAND_0100 INPUT. CASE SY-UCOMM. WHEN 'P1'. LEAVE PROGRAM. ENDCASE. ENDMODULE. " USER_COMMAND_0100 MODULE ABC INPUT. IF KNA1-LAND1 NE 'AF' AND KNA1-LAND1 NE 'AR'.
INPUT
MESSAGE 'Please enter either AF or AR' TYPE 'E'. ENDIF. ENDMODULE. " abc INPUT
Prog134
PROGRAM Z7AMPROG134. TYPE-POOLS VRM. DATA FLAG TYPE I. DATA IO1(10) TYPE C. TYPES : BEGIN OF TY_VALUES. INCLUDE TYPE VRM_VALUE. TYPES END OF TY_VALUES. DATA : LT_VALUES TYPE TABLE OF TY_VALUES, LS_VALUES TYPE TY_VALUES. MODULE STATUS_0100 OUTPUT. SET PF-STATUS 'ABC'. IF FLAG EQ 0. PERFORM INVISIBLEBLOCKS. PERFORM PREPAREVALUES. FLAG = 1. ELSEIF FLAG EQ 2. PERFORM VISIBIEBLOCK1. ELSEIF FLAG EQ 3. PERFORM VISIBLEBLOCK2. ENDIF. ENDMODULE. " STATUS_0100 OUTPUT
MODULE USER_COMMAND_0100 INPUT. CASE SY-UCOMM. WHEN 'BACK'. LEAVE PROGRAM. WHEN 'P1'. IF IO1 = 'K1'. FLAG = 2. ELSEIF IO1 = 'K2'. FLAG = 3. ELSEIF IO1 = 'K3'. FLAG = 4. ENDIF. ENDCASE. ENDMODULE. " USER_COMMAND_0100 FORM INVISIBLEBLOCKS . LOOP AT SCREEN. IF SCREEN-GROUP1 = 'G1' OR SCREEN-GROUP1 = 'G2'. SCREEN-INVISIBLE = '1'. MODIFY SCREEN. ENDIF. ENDLOOP. ENDFORM. " invisibleblocks FORM PREPAREVALUES . CLEAR LS_VALUES. LS_VALUES-KEY = 'K1'. LS_VALUES-TEXT = 'Courses'. APPEND LS_VALUES TO LT_VALUES. CLEAR LS_VALUES. LS_VALUES-KEY = 'K2'. LS_VALUES-TEXT = 'Institutes'. APPEND LS_VALUES TO LT_VALUES. CLEAR LS_VALUES. LS_VALUES-KEY = 'K3'. LS_VALUES-TEXT = 'Locations'. APPEND LS_VALUES TO LT_VALUES. CALL FUNCTION 'VRM_SET_VALUES' EXPORTING ID = 'IO1' VALUES = LT_VALUES[]. ENDFORM. " preparevalues FORM VISIBIEBLOCK1 . LOOP AT SCREEN. IF SCREEN-GROUP1 = 'G1'. SCREEN-INVISIBLE = '0'. ELSEIF SCREEN-GROUP1 = 'G2'. SCREEN-INVISIBLE = '1'. ENDIF. MODIFY SCREEN. ENDLOOP. ENDFORM. " visibieblock1 FORM VISIBLEBLOCK2 . LOOP AT SCREEN. IF SCREEN-GROUP1 = 'G1'. SCREEN-INVISIBLE = '1'.
INPUT
ELSEIF SCREEN-GROUP1 = 'G2'. SCREEN-INVISIBLE = '0'. ENDIF. MODIFY SCREEN. ENDLOOP. ENDFORM. " visibleblock2 MODULE ABC INPUT. CALL FUNCTION 'POPUP_TO_INFORM' EXPORTING TITEL = 'Custom F1 Help' TXT1 = 'Dropdown' TXT2 = 'List of Values'. ENDMODULE.
Prog135
REPORT
" abc
INPUT
Z7AMPROG135.
parameters : p_land1 type kna1-land1. types : begin of ty_kna1, kunnr type kna1-kunnr, land1 type kna1-land1, end of ty_kna1. data ls_kna1 type ty_kna1. data abc type cursor. open cursor abc for select kunnr land1 from kna1 where land1 = p_land1. do. fetch next cursor abc into :ls_kna1. if sy-subrc eq 0. write :/ ls_kna1-kunnr, ls_kna1-land1. else. exit. endif. enddo.
Prog136
REPORT
Z7AMPROG136.
parameters : p_land1 type kna1-land1. data : lv_kunnr type kna1-kunnr, lv_land1 type kna1-land1. exec sql. open abc for select kunnr, land1 from kna1 where land1 = :p_land1 endexec. do. exec sql. fetch next abc into :lv_kunnr, :lv_land1 endexec.
if sy-subrc eq 0. write :/ lv_kunnr, lv_land1. else. exit. endif. enddo. exec sql. close abc endexec.
Prog137
REPORT
Z7AMPROG137.
types : begin of ty_legacy, str(100) type c, end of ty_legacy. data : lt_legacy type table of ty_legacy, ls_legacy type ty_legacy. types : begin of ty_kna1. include structure kna1. types end of ty_kna1. data : lt_kna1 type table of ty_kna1, ls_kna1 type ty_kna1. * Read data from local file CALL FUNCTION 'GUI_UPLOAD' EXPORTING FILENAME TABLES DATA_TAB
= 'c:\customer.txt' = lt_legacy[].
if lt_legacy[] is not initial. loop at lt_legacy into ls_legacy. split ls_legacy-str at ',' into ls_kna1-kunnr ls_kna1-land1 ls_kna1-name1. append ls_kna1 to lt_kna1. endloop. endif. if lt_kna1[] is not initial. modify kna1 from table lt_kna1. endif.
Prog138
TYPES : BEGIN OF TY_LEGACY, STR(100) TYPE C, END OF TY_LEGACY. DATA : LT_LEGACY TYPE TABLE OF TY_LEGACY, LS_LEGACY TYPE TY_LEGACY. TYPES : BEGIN OF TY_KNA1, KUNNR TYPE KNA1-KUNNR, LAND1 TYPE KNA1-LAND1, NAME1 TYPE KNA1-NAME1, END OF TY_KNA1. DATA : LT_KNA1 TYPE TABLE OF TY_KNA1, LS_KNA1 TYPE TY_KNA1. TYPES : BEGIN OF TY_BDCDATA. INCLUDE STRUCTURE BDCDATA. TYPES END OF TY_BDCDATA. DATA : LT_BDCDATA TYPE TABLE OF TY_BDCDATA, LS_BDCDATA TYPE TY_BDCDATA. * Read data from file CALL FUNCTION 'GUI_UPLOAD' EXPORTING FILENAME = 'c:\customer.txt' TABLES DATA_TAB = LT_LEGACY[]. IF LT_LEGACY[] IS NOT INITIAL. LOOP AT LT_LEGACY INTO LS_LEGACY. SPLIT LS_LEGACY-STR AT ',' INTO LS_KNA1-KUNNR LS_KNA1-LAND1 LS_KNA1-NAME1. APPEND LS_KNA1 TO LT_KNA1. ENDLOOP. ENDIF.
IF LT_KNA1[] IS NOT INITIAL. LOOP AT LT_KNA1 INTO LS_KNA1. PERFORM PRGINFO USING 'Z7AMPROG149' '100'. PERFORM FLDINFO USING 'KNA1-KUNNR' LS_KNA1-KUNNR. PERFORM FLDINFO USING 'KNA1-LAND1' LS_KNA1-LAND1. PERFORM FLDINFO USING 'KNA1-NAME1' LS_KNA1-NAME1. CALL TRANSACTION 'ZT149' USING LT_BDCDATA MODE 'E'. ENDLOOP. ENDIF. FORM PRGINFO USING PRGNAME SCRNO. REFRESH LT_BDCDATA. CLEAR LS_BDCDATA. LS_BDCDATA-PROGRAM = PRGNAME. LS_BDCDATA-DYNPRO = SCRNO. LS_BDCDATA-DYNBEGIN = 'X'. APPEND LS_BDCDATA TO LT_BDCDATA. ENDFORM. FORM FLDINFO USING CLEAR LS_BDCDATA. LS_BDCDATA-FNAM = LS_BDCDATA-FVAL = APPEND LS_BDCDATA ENDFORM. FNAME FVALUE. FNAME. FVALUE. TO LT_BDCDATA.
Prog149
*&---------------------------------------------------------------------* *& Include Z7AM149TOP Module Pool Z7AMPROG149 *& *&---------------------------------------------------------------------* PROGRAM Z7AMPROG149.
TABLES KNA1. MODULE USER_COMMAND_0100 INPUT. CASE SY-UCOMM. WHEN 'P1'. INSERT KNA1. IF SY-SUBRC EQ 0. MESSAGE 'Inserted' TYPE 'I'. ELSE. MESSAGE 'Not inserted' TYPE 'I'. ENDIF. LEAVE PROGRAM. WHEN 'P2'.
LEAVE PROGRAM. ENDCASE. ENDMODULE. MODULE ABC INPUT. CASE SY-UCOMM. WHEN 'p3'. LEAVE PROGRAM. ENDCASE. ENDMODULE.
" USER_COMMAND_0100
INPUT
" abc
INPUT
Prog150
REPORT Z7AMPROG150.
types : begin of ty_legacy, str(100) type c, end of ty_legacy. data : lt_legacy type table of ty_legacy, ls_legacy type ty_legacy. types : begin of ty_kna1, kunnr type kna1-kunnr, land1 type kna1-land1, name1 type kna1-name1, end of ty_kna1. data : lt_kna1 type table of ty_kna1, ls_kna1 type ty_kna1. types : begin of ty_bdcdata. include structure bdcdata. types end of ty_bdcdata. data : lt_bdcdata type table of ty_bdcdata, ls_bdcdata type ty_bdcdata. * Read data from local system file CALL FUNCTION 'GUI_UPLOAD' EXPORTING FILENAME = 'c:\customer.txt' TABLES DATA_TAB = lt_legacy[]. if lt_legacy[] is not initial. loop at lt_legacy into ls_legacy. split ls_legacy-str at ',' into ls_kna1-kunnr ls_kna1-land1
ls_kna1-name1. append ls_kna1 to lt_kna1. endloop. endif. * Create the session object CALL FUNCTION 'BDC_OPEN_GROUP' EXPORTING CLIENT = SY-MANDT GROUP = 'S1' * HOLDDATE = '20120712' KEEP = 'X' USER = sy-uname. * Map the internal table data to BDCDATA loop at lt_kna1 into ls_kna1. perform prginfo using 'Z7AMPROG149' '100'. perform fldinfo using 'KNA1-KUNNR' ls_kna1-kunnr. perform fldinfo using 'KNA1-LAND1' ls_kna1-land1. perform fldinfo using 'KNA1-NAME1' ls_kna1-name1. * Map the BDCDATA internal table to session object CALL FUNCTION 'BDC_INSERT' EXPORTING TCODE = 'ZT149' TABLES DYNPROTAB = lt_bdcdata[]. ENDLOOP. * Close the session object CALL FUNCTION 'BDC_CLOSE_GROUP'. form prginfo using prgname scrno. refresh lt_bdcdata. clear ls_bdcdata. ls_bdcdata-program = prgname. ls_bdcdata-dynpro = scrno. ls_bdcdata-dynbegin = 'X'. append ls_bdcdata to lt_bdcdata. endform. form fldinfo using clear ls_bdcdata. ls_bdcdata-fnam = ls_bdcdata-fval = append ls_bdcdata endform. fname fvalue. fname. fvalue. to lt_bdcdata.
Prog151
report Z7AMPROG151 no standard page heading line-size 255. include bdcrecx1. parameters: dataset(132) lower case. *** DO NOT CHANGE - the generated data section - DO NOT CHANGE * * If it is nessesary to change the data section use the rules: * 1.) Each definition of a field exists of two lines * 2.) The first line shows exactly the comment * '* data element: ' followed with the data element * which describes the field. * If you don't have a data element use the * comment without a data element name * 3.) The second line shows the fieldname of the * structure, the fieldname must consist of * a fieldname and optional the character '_' and * three numbers and the field length in brackets * 4.) Each field must be type C. * *** Generated data section with specific formatting - DO NOT CHANGE data: begin of record, * data element: KUNNR KUNNR_001(010), * data element: LAND1_GP LAND1_002(003), * data element: NAME1_GP NAME1_003(035), end of record. *** End generated data section *** * Begin of custom changes types : begin of ty_legacy, str(100) type c, end of ty_legacy. DATA : LT_LEGACY TYPE TABLE OF TY_LEGACY, LS_LEGACY TYPE TY_LEGACY. TYPES : BEGIN OF TY_KNA1, KUNNR TYPE KNA1-KUNNR, LAND1 TYPE KNA1-LAND1, NAME1 TYPE KNA1-NAME1, END OF TY_KNA1. DATA : LT_KNA1 TYPE TABLE OF TY_KNA1, LS_KNA1 TYPE TY_KNA1.
***
***
start-of-selection. * Begin of custom changes * Read data from local system file CALL FUNCTION 'GUI_UPLOAD' EXPORTING FILENAME = 'c:\customer.txt' TABLES DATA_TAB = LT_LEGACY[]. IF LT_LEGACY[] IS NOT INITIAL. LOOP AT LT_LEGACY INTO LS_LEGACY. SPLIT LS_LEGACY-STR AT ',' INTO LS_KNA1-KUNNR LS_KNA1-LAND1 LS_KNA1-NAME1. APPEND LS_KNA1 TO LT_KNA1. ENDLOOP. ENDIF. * End of custom changes *perform open_dataset using dataset. perform open_group. *do. loop at lt_kna1 into ls_kna1. *read dataset dataset into record. *if sy-subrc <> 0. exit. endif. perform bdc_dynpro perform bdc_field perform bdc_field perform * perform * perform * perform *enddo. endloop. bdc_field using bdc_field using bdc_field using bdc_transaction using 'Z7AMPROG149' '0100'. using 'BDC_OKCODE' '=P1'. using 'BDC_CURSOR' 'KNA1-NAME1'. 'KNA1-KUNNR' ls_kna1-kunnr. record-KUNNR_001. 'KNA1-LAND1' ls_kna1-land1. record-LAND1_002. 'KNA1-NAME1' ls_kna1-name1. record-NAME1_003. using 'ZT149'.
Prog152