Sunteți pe pagina 1din 147

FEB2012-7AMCOREABAP Program1

REPORT Z730PROG1. write 'welcome to abap'.

Program2
REPORT Z730PROG2. *data x type i. *data y type i. *data z type i. data : x type i, y type i, z type i. x = 10. y = 20. z = x + y. write z. write :/ 'sum of two numbers is :',z. write :/ 'sum of two numbers is :',z left-justified. write :/ 'sum of two numbers is :',z centered.

Program3
REPORT Z730PROG3. data : x type i value 10, "declaration and initialization y type i value 20, z type i. z = x + y. write z. x = 20. y = 45. z = x + y. write / z. constants m type i value 60. write / m. * m = 56.

Program4
REPORT Z730PROG4. *parameters x type i. *parameters y type i. parameters : x type i default 50 obligatory, y type i default 60. data m type i. m = x + y. write m.

Program5
REPORT Z730PROG4. *parameters x type i. *parameters y type i. parameters : x type i default 50 obligatory, y type i default 60. data m type i.

m = x + y. write m.

Program6
REPORT Z730PROG6. data x type c. write x. x = 'Gensoft'. write / x. data y(10) type c. y = 'Gensoft Systems'. write / y. data z type string. z = 'Gensoft Systems'. write / z.

Program7
REPORT Z730PROG7. parameters : x type i, y type i. data z type i. parameters : r1 radiobutton group abc, r2 radiobutton group abc, r3 radiobutton group abc default 'X', r4 radiobutton group abc. if r1 = 'X'. z = x + y. write :/ 'Addition is ',z. elseif r2 = 'X'. z = x - y. if z >= 0. write :/ 'Difference is ',z. else. write :/ 'Difference is -' no-gap,z no-sign. endif. elseif r3 = 'X'. z = x * y. write :/ 'Product is ',z. elseif r4 = 'X'. z = x / y. write :/ 'Division is ',z. endif.

Program8
REPORT Z730PROG8. parameters : x type i, y type i. data z type i. parameters : c1 as checkbox, c2 as checkbox, c3 as checkbox, c4 as checkbox. if c1 = 'X'. z = x + y.

write :/ 'Addition 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.

Program9
REPORT Z730PROG9. parameters : x type i, y type i, ch type i. data z type i. case ch. when 1. z = x + y. write :/ 'Sum is ',z. when 2. z = x - y. write :/ 'Difference is ',z. when 3. z = x * y. write :/ 'Product is ',z. when 4. z = x / y. write :/ 'Division is ',z. when others. message 'Please enter 1,2,3,4' type 'I'. endcase.

Program10
REPORT Z730PROG10. write :/ 'applicaion server date :',sy-datum, / 'applicaion server time :',sy-uzeit, / 'current program :',sy-repid.

Program11
REPORT Z730PROG11. data x type i. x = '123.45'. write :/ x. x = '123.56'. write :/ x. data z type p. z = '123.45'. write :/ z.

data m type p decimals 2. m = '123.45'. write :/ m.

Program12
REPORT Z730PROG12. data : x type i value 10, y type i. write :/ x,y. y = x. write :/ x,y. x = 20. write :/ x,y.

Program13
REPORT Z730PROG13. data x type i value 10. field-symbols <fs>. assign x to <fs>. write :/ x,<fs>. x = 20. write :/ x,<fs>. <fs> = 30. write :/ x,<fs>. data y(20) type c value 'Gensoft'. assign y to <fs>. write :/ x,y,<fs>.

Program14
REPORT Z730PROG14. write :/ 'inside program 14'. *submit z730prog15. submit z730prog15 and return. write :/ 'end of program 14'.

Program15
REPORT Z730PROG15. write :/ 'inside program15'.

Program16
REPORT Z730PROG16. parameters : x type i, y type i. data z type i. export x to memory id 'A1'. export y to memory id 'A2'. submit z730prog17 and return.

import z from memory id 'A3'. write :/ z.

Program17
REPORT Z730PROG16. parameters : x type i, y type i. data z type i. export x to memory id 'A1'. export y to memory id 'A2'. submit z730prog17 and return. import z from memory id 'A3'. write :/ z.

Program18
REPORT Z730PROG18. data x type d. x = '07032012'. "ddmmyyyy write :/ x. x = '20120307'. "yyyymmdd write :/ x. "ddmmyyyy write :/(10) x. write :/(10) x using edit mask '__/__/____'. data y type t. y = '084532'. write :/ y. write :/(8) y. write :/(8) y using edit mask '__-__-__'.

Program19
REPORT Z730PROG18. data x type d. x = '07032012'. "ddmmyyyy write :/ x. x = '20120307'. "yyyymmdd write :/ x. "ddmmyyyy write :/(10) x. write :/(10) x using edit mask '__/__/____'. data y type t. y = '084532'. write :/ y. write :/(8) y. write :/(8) y using edit mask '__-__-__'.

Program20
REPORT Z730PROG20. parameters x type i. data : y type i. y = x mod 2. check y eq 0. write :/ 'Even no'. write :/ 'End of program'.

Program21 REPORT Z730PROG21. parameters x type i. data : y type i value 1, z type i. while y <= 10. z = x * y. write :/ x,'*',y,'=',z. y = y + 1. endwhile. Program22 REPORT Z730PROG22. parameters x type i. data : y type i value 1, z type i. while y <= 10. if y ne 3. z = x * y. write :/ x,'*',y,'=',z. endif. y = y + 1. endwhile. Program23 REPORT Z730PROG23. parameters x type i. data : y type i value 1, z type i. while y <= 10. if y eq 3. continue. endif. z = x * y. write :/ x,'*',y,'=',z. y = y + 1. endwhile. write :/ 'End of program'. Program24

REPORT

Z730PROG24.

parameters x type i. data : y type i value 1, z type i. while y <= 10. if y eq 3. y = y + 1. continue. endif. z = x * y. write :/ x,'*',y,'=',z. y = y + 1. endwhile. write :/ 'End of program'. Program25 REPORT Z730PROG25. parameters x type i. data : y type i value 1, z type i. while y <= 10. if y eq 3. exit. endif. z = x * y. write :/ x,'*',y,'=',z. y = y + 1. endwhile. write :/ 'End of program'. Program26 REPORT Z730PROG26. data x(10) type c value 'gensoft'. write : / x. Program27 REPORT Z730PROG27. parameters x(30) type c. data k type i.

k = strlen( x ). write :/ 'Length of string is :',k. Program28 REPORT Z730PROG28. data x(10) type c value 'Gensoft'. write :/ x. translate x to upper case. write :/ x. translate x to lower case. write :/ x. Program29 REPORT Z730PROG29 no standard page heading. data : str1 type string value 'Genesis', str2 type string value 'Software', str3 type string value 'Systems', str type string. write :/ str. concatenate str1 str2 str3 into str. write :/ str. clear str. write :/ 'str is ',str. concatenate str1 str2 str3 into str separated by ' '. write :/ 'str is ',str. Program30 REPORT Z730PROG30. 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. split str at '@' into str1 str2. write :/ '********************'. write :/ 'str1 is :',str1, / 'str2 is :',str2,

'str3 is :',str3.

clear : str1,str2,str3. write :/ '********************'. write :/ 'str1 is :',str1, / 'str2 is :',str2, / 'str3 is :',str3. split str at '@' into str1 str2 str3. write :/ '********************'. write :/ 'str1 is :',str1, / 'str2 is :',str2, / 'str3 is :',str3. Program31 REPORT Z730PROG31. data : str1 type string value 'Wipro', str2 type string value 'Genesis software '. write :/ str2. overlay str2 with str1. write :/ str2. Program32 REPORT Z730PROG32. data str type string value 'Genesis Software Systems'. write :/ str. replace 's' in str with 'r'. write :/ str. str = 'Genesis Software Systems'. write :/ str. replace all occurrences of 's' in str with 'r'. write :/ str. str = 'Genesis Software Systems'. write :/ str. replace all occurrences of 's' in str with 'r' ignoring case. write :/ str. Program33 REPORT Z730PROG33. data str type string value 'Gensoft Systems'.

write :/ str. data str1 type string. str1 = str+3(4). write :/ str1. str = 'gensoft systems'. write :/ str. str1 = str+4(3). write :/ str1. Program34 REPORT Z730PROG34. parameters x(30) type c lower case. data : str1 type string, str2 type string. data k type i. data r type i. k = strlen( x ). r = k - 1. str1 = x+0(1). str2 = x+1(r). translate str1 to upper case. translate str2 to lower case. clear x. concatenate str1 str2 into x. write :/ x. Program35 REPORT Z730PROG35. data : begin of emp, empno type i, ename(20) type c, end of emp. write :/ emp-empno, emp-ename. emp-empno = 5. emp-ename = 'xyz'. write :/ emp-empno, emp-ename.

Program36 REPORT Z730PROG36. data : begin of emp, empno type i, ename(20) type c, end of emp. write :/ emp-empno, emp-ename. emp-empno = 5. emp-ename = 'xyz'. write :/ emp-empno, emp-ename. data emp1 like emp. write :/ 'EMP1 structure'. write :/ emp1-empno, emp1-ename. emp1 = emp. write :/ 'EMP1 structure after assignment'. write :/ emp1-empno, emp1-ename. clear emp1. write :/ 'EMP1 structure after clear'. write :/ emp1-empno, emp1-ename. move emp to emp1. write :/ 'EMP1 structure after move'. write :/ emp1-empno, emp1-ename. Program37 REPORT Z730PROG37. data : begin of emp, empno type i, ename(20) type c, empdesig(30) type c, end of emp. emp-empno = 5.

emp-ename = 'xyz'. emp-empdesig = 'Manager'. write :/ emp-empno, emp-ename, emp-empdesig. data : begin of emp1, empno type i, ename(20) type c, end of emp1. move emp to emp1. write :/ 'EMP1 structure'. write :/ emp1-empno, emp1-ename. Program38 REPORT Z730PROG38. data : begin of emp, empno type i, ename(20) type c, empdesig(30) type c, end of emp. emp-empno = 5. emp-ename = 'xyz'. emp-empdesig = 'Manager'. write :/ emp-empno, emp-ename, emp-empdesig. data : begin of emp1, dname(20) type c, deptno type i, ename(20) type c, end of emp1. move-corresponding emp to emp1. write :/ 'EMP1 structure'. write :/ emp1-deptno, emp1-dname, emp1-ename. Program39 REPORT Z730PROG39. data : begin of emp, empno(3) type c,

ename(20) type c, empdesig(30) type c, end of emp. emp-empno = '15'. emp-ename = 'xyz'. emp-empdesig = 'Manager'. write :/ emp-empno, emp-ename, emp-empdesig. data : begin of emp1, dname(20) type c, empno type i, ename(20) type c, end of emp1. move-corresponding emp to emp1. write :/ 'EMP1 structure'. write :/ emp1-empno, emp1-dname, emp1-ename. Program40 REPORT Z730PROG40. data : begin of emp, empno type i, ename(20) type c, begin of dept, deptno type i, dname(20) type c, end of dept, empdesig(20) type c, end of emp. emp-empno = 6. emp-ename = 'xyz'. emp-dept-deptno = 10. emp-dept-dname = 'Sales'. emp-empdesig = 'Manager'. write :/7 emp-empno, (10) emp-ename, emp-dept-deptno, emp-dept-dname, emp-empdesig. Program41

REPORT

Z730PROG41.

data : begin of dept, deptno type i, dname(20) type c, end of dept. data : begin of emp, empno type i, ename(20) type c. include structure dept. data : empdesig(20) type c, end of emp. emp-empno = 6. emp-ename = 'abc'. emp-deptno = 10. emp-dname = 'sales'. write :/ emp-empno, / emp-ename, / emp-deptno, / emp-dname, / emp-empdesig. Program42 REPORT Z730PROG42. type-pools z730t. write :/ z730t_y. *data m type z730t_x. * *m = 20. *write :/ m. *m = 30. *write :/ m. Typepoolcode TYPE-POOL Z730T . types z730t_x type i. constants z730t_y type i value 10. Program43 REPORT Z730PROG43. 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 = 'ravi'. emp-empno = 4. emp-ename = 'ramesh'. append emp. emp-empno = 7. emp-ename = 'vamshi'. append emp. emp-empno = 3. emp-ename = 'raju'. append emp. write :/ 'Data in internal table..'. loop at emp. write :/ emp-empno, emp-ename. endloop. Program44 REPORT Z730PROG44. data : begin of emp occurs 0, empno type i, ename(20) type c, end of emp. emp-empno = 4. emp-ename = 'ramesh'. append emp. emp-empno = 7. emp-ename = 'vamshi'. append emp. emp-empno = 3. emp-ename = 'raju'. append emp.

emp-empno = 2. emp-ename = 'vamshi kumar'. append emp. write :/ 'Data in internal table..'. loop at emp. write :/ emp-empno, emp-ename. endloop. sort emp. write :/ 'Data in internal table after sort..'. loop at emp. write :/ emp-empno, emp-ename. endloop. sort emp by empno. write :/ 'Data in internal table after sort on empno..'. loop at emp. write :/ emp-empno, emp-ename. endloop. sort emp by empno descending. write :/ 'Data in internal table after sort on empno descending..'. loop at emp. write :/ emp-empno, emp-ename. endloop. describe table emp. write :/ 'No of records :',sy-tfill. Program45 REPORT Z730PROG45. data : begin of emp occurs 0, empno type i, ename(20) type c, end of emp. emp-empno = 4. emp-ename = 'ramesh'. append emp.

emp-empno = 7. emp-ename = 'vamshi'. append emp. emp-empno = 3. emp-ename = 'raju'. append emp. emp-empno = 2. emp-ename = 'vamshi kumar'. append emp. write :/ 'Data in internal table..'. loop at emp. write :/ emp-empno, emp-ename. endloop. data emp1 like emp occurs 0. append lines of emp to emp1. describe table emp1. write :/ 'No of records in emp1 after append:',sy-tfill. refresh emp1. describe table emp1. write :/ 'No of records in emp1 after refresh:',sy-tfill. append lines of emp from 1 to 3 to emp1. describe table emp1. write :/ 'No of records in emp1 after append:',sy-tfill. refresh emp1. describe table emp1. write :/ 'No of records in emp1 after refresh:',sy-tfill. loop at emp. append emp to emp1. endloop. describe table emp1. write :/ 'No of records in emp1 after append:',sy-tfill. Program46 REPORT Z730PROG46. types : begin of ty_emp, empno type i, ename(20) type c,

end of ty_emp. data lt_emp type standard table of ty_emp with header line. clear lt_emp. lt_emp-empno = 7. lt_emp-ename = 'vamshi'. append lt_emp. clear lt_emp. lt_emp-empno = 17. lt_emp-ename = 'kiran'. append lt_emp. clear lt_emp. lt_emp-empno = 3. lt_emp-ename = 'praneeth'. append lt_emp. write :/ 'internal table data'. loop at lt_emp. write :/ lt_emp-empno, lt_emp-ename. endloop. write :/ 'Second record is :'. read table lt_emp index 2. if sy-subrc eq 0. write :/ lt_emp-empno, lt_emp-ename. else. write :/ 'Read failed'. endif. write :/ 'Read based on condition'. sort lt_emp by empno. read table lt_emp binary search with key empno = 17. if sy-subrc eq 0. write :/ lt_emp-empno, lt_emp-ename. else. write :/ 'Read failed'. endif. Program47 REPORT Z730PROG47.

types : begin of ty_emp, empno type i, ename(20) type c, empdesig(30) type c, end of ty_emp. data lt_emp type standard table of ty_emp with header line. clear lt_emp. lt_emp-empno = 7. lt_emp-ename = 'vamshi'. lt_emp-empdesig = 'Manager'. append lt_emp. clear lt_emp. lt_emp-empno = 17. lt_emp-ename = 'kiran'. lt_emp-empdesig = 'Director'. append lt_emp. clear lt_emp. lt_emp-empno = 3. lt_emp-ename = 'praneeth'. lt_emp-empdesig = 'Consultant'. append lt_emp. write :/ 'internal table data'. loop at lt_emp. write :/ lt_emp-empno, lt_emp-ename, lt_emp-empdesig. endloop. sort lt_emp by empno. write :/ 'Empno = 3:'. read table lt_emp with key empno = 3. if sy-subrc eq 0. write :/ lt_emp-empno, lt_emp-ename, lt_emp-empdesig. endif. write :/ 'Empno = 17:'. clear lt_emp. read table lt_emp with key empno = 17 transporting empdesig.

if sy-subrc eq 0. write :/ lt_emp-empno, lt_emp-ename, lt_emp-empdesig. endif. Program48 REPORT Z730PROG48. types : begin of ty_emp. include structure z9amemp. types end of ty_emp. data ls_emp type ty_emp. ls_emp-empno = 43. ls_emp-ename = 'Rajesh Khanna'. ls_emp-empdesig = 'Manager'. *insert z9amemp from ls_emp. modify z9amemp from ls_emp. if sy-subrc eq 0. message 'Record Inserted' type 'I'. else. message 'Unable to Insert' type 'I'. endif. Program49 REPORT Z730PROG49. types : begin of ty_emp. include structure z9amemp. types end of ty_emp. data lt_emp type standard table of ty_emp. data ls_emp type ty_emp. ls_emp-empno = 80. ls_emp-ename = 'vamshi'. ls_emp-empdesig = 'manager'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 90. ls_emp-ename = 'kiran'. ls_emp-empdesig = 'manager'. append ls_emp to lt_emp.

ls_emp-empno = 50. ls_emp-ename = 'Rathod'. ls_emp-empdesig = 'Director'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 91. ls_emp-ename = 'kirana'. ls_emp-empdesig = 'manager'. append ls_emp to lt_emp.

*insert z9amemp from table lt_emp. *insert z9amemp from table lt_emp accepting duplicate keys. modify z9amemp from table lt_emp. if sy-subrc eq 0. write :/ 'No of records affected :',sy-dbcnt. else. message 'Unable to insert' type 'I'. endif. Program50 REPORT Z730PROG50. types : begin of ty_emp, empno type i, ename(20) type c, empdesig(30) type c, 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 = 15. ls_emp-ename = 'ravi'. ls_emp-empdesig = 'Director'. append ls_emp to lt_emp.

clear ls_emp. ls_emp-empno = 2. ls_emp-ename = 'ramu'. ls_emp-empdesig = 'Consultant'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 4. ls_emp-ename = 'rakesh'. 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, ls_emp-empdesig. endloop. loop at lt_emp into ls_emp. if ls_emp-empdesig = 'Manager'. ls_emp-empdesig = 'Supervisor'. * modify lt_emp from ls_emp. modify lt_emp from ls_emp transporting empdesig. endif. endloop. write :/ 'Data in internal table after modification'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-empdesig. endloop. Program51 REPORT Z730PROG51. types : begin of ty_emp, empno type i, ename(20) type c, empdesig(30) type c, end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. field-symbols <fs> like line of lt_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 = 15. ls_emp-ename = 'ravi'. ls_emp-empdesig = 'Director'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 2. ls_emp-ename = 'ramu'. ls_emp-empdesig = 'Consultant'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 4. ls_emp-ename = 'rakesh'. 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, ls_emp-empdesig. endloop. loop at lt_emp assigning <fs>. if <fs>-empdesig = 'Manager'. <fs>-empdesig = 'Supervisor'. endif. endloop. write :/ 'Data in internal table after modification'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-empdesig. endloop. Program52

REPORT Z730PROG52. types : begin of ty_emp, empno type i, ename(20) type c, empdesig(30) type c, 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 = 15. ls_emp-ename = 'ravi'. ls_emp-empdesig = 'Director'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 2. ls_emp-ename = 'ramu'. ls_emp-empdesig = 'Consultant'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 4. ls_emp-ename = 'rakesh'. 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, ls_emp-empdesig. endloop. sort lt_emp by empdesig. write :/ 'Data in internal table after sort'. loop at lt_emp into ls_emp. write :/ ls_emp-empno,

ls_emp-ename, ls_emp-empdesig. endloop. delete adjacent duplicates from lt_emp comparing empdesig. write :/ 'Data in internal table after deleting consultant'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-empdesig. endloop. Program53 REPORT Z730PROG53. types : begin of ty_emp, empno type i, ename(20) type c, empdesig(30) type c, 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 = 15. ls_emp-ename = 'ravi'. ls_emp-empdesig = 'Director'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 2. ls_emp-ename = 'ramu'. ls_emp-empdesig = 'Consultant'. append ls_emp to lt_emp. clear ls_emp. ls_emp-empno = 4. ls_emp-ename = 'rakesh'. 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, ls_emp-empdesig. endloop. sort lt_emp by empno. clear ls_emp. read table lt_emp into ls_emp with key empno = 15 transporting no fields. if sy-subrc eq 0. write :/ 'Record found'. write :/ ls_emp-empno, ls_emp-ename, ls_emp-empdesig. else. write :/ 'No record'. endif. Program54
REPORT Z730PROG54. types : begin of ty_emp, f1(3) type c, f2 type i, f3(30) type c, f4(30) type c, f5 type d, f6 type t, end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select * from y730amemp 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-f1, ls_emp-f2, ls_emp-f5. endloop. else. message 'No data' type 'I'. endif.

Program55
REPORT Z730PROG55. types : begin of ty_emp, f1 type y730amemp-mandt, f2 type y730amemp-empno, f3 type y730amemp-ename, f4 type y730amemp-empdesig, f5 type y730amemp-jdate,

f6 type y730amemp-jtime, end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select * from y730amemp 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-f1, ls_emp-f2, ls_emp-f5. endloop. else. message 'No data' type 'I'. endif.

Program56
REPORT Z730PROG56. types : begin of ty_emp, mandt type y730amemp-mandt, empno type y730amemp-empno, ename type zemp_name, empdesig type zemp_desig, jdate type y730amemp-jdate, jtime type y730amemp-jtime, end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select * from y730amemp 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-mandt, ls_emp-empno, ls_emp-jtime. endloop. else. message 'No data' type 'I'. endif.

Program57
REPORT Z730PROG57. types : begin of ty_emp. include structure y730amemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select * from y730amemp 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-mandt, ls_emp-empno, ls_emp-jtime. endloop. else.

message 'No data' type 'I'. endif.

Program58
REPORT Z730PROG58. types : begin of ty_emp. include structure y730amemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select empno ename from y730amemp 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. endloop. else. message 'No data' type 'I'. endif.

Program59
REPORT Z730PROG59. types : begin of ty_emp. include structure y730amemp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select empno ename from y730amemp 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. endloop. else. message 'No data' type 'I'. endif.

Program60
REPORT Z730PROG60. types : begin of ty_emp, empno type y730amemp-empno, ename type y730amemp-ename, end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select empno ename from y730amemp 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. endloop.

else. message 'No data' type 'I'. endif.

Program61
REPORT Z730PROG61. types : begin of ty_emp, empno type y730amemp-empno, ename type y730amemp-ename, end of ty_emp. data : ls_emp type ty_emp. select empno ename from y730amemp into ls_emp. write :/ ls_emp-empno, ls_emp-ename. endselect.

Program62
REPORT Z730PROG62. parameters p_kunnr type kna1-kunnr. types : begin of ty_kna1, land1 type kna1-land1, name1 type kna1-name1, end of ty_kna1. data ls_kna1 type ty_kna1. select single land1 name1 from kna1 into ls_kna1 where kunnr = p_kunnr. if sy-subrc eq 0. write :/ ls_kna1-land1, ls_kna1-name1. else. write :/ 'No data'. endif.

Program63
REPORT Z730PROG63. parameters p_kunnr type kna1-kunnr. types : begin of ty_kna1, name1 type kna1-name1, land1 type kna1-land1, end of ty_kna1. data ls_kna1 type ty_kna1. select single land1 name1 from kna1 into corresponding fields of ls_kna1 if sy-subrc eq 0. write :/ ls_kna1-land1, ls_kna1-name1. else. write :/ 'No data'. endif. where kunnr = p_kunnr.

Program64
REPORT Z730PROG64. parameters p_kunnr type kna1-kunnr.

types : begin of ty_kna1, land1 type kna1-land1, name1 type kna1-name1, end of ty_kna1. data ls_kna1 type ty_kna1. * not recommended as sequence doesn't match * with table fields sequemnce select single name1 land1 from kna1 into corresponding fields of ls_kna1 if sy-subrc eq 0. write :/ ls_kna1-land1, ls_kna1-name1. else. write :/ 'No data'. endif.

where kunnr = p_kunnr.

Program65
REPORT Z730PROG65. types : begin of ty_emp, empno type y730amemp-empno, ename type y730amemp-ename, end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select empno ename from y730amemp into table lt_emp. if sy-subrc eq 0. sort lt_emp by empno. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename. endloop. else. message 'No data' type 'I'. endif.

Program66
REPORT Z730PROG66. types : begin of ty_emp, empno type y730amemp-empno, ename type y730amemp-ename, end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select empno ename from y730amemp into table lt_emp order by empno. * into table lt_emp order by empno descending. if sy-subrc eq 0. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename. endloop. else. message 'No data' type 'I'.

endif.

Program67
REPORT Z730PROG67. types : begin of ty_emp, deptno type z730dept-deptno, total type i, end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select deptno sum( empsal ) from z730dept 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-total. endloop. else. write :/ 'No data'. endif.

Program68
REPORT Z730PROG68. types : begin of ty_emp, deptno type z730dept-deptno, total type i, end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select deptno sum( empsal ) from z730dept into table lt_emp group by deptno having deptno ne 20. if sy-subrc eq 0. loop at lt_emp into ls_emp. write :/ ls_emp-deptno, ls_emp-total. endloop. else. write :/ 'No data'. endif.

Program69
REPORT Z730PROG69. parameters p_kunnr type kna1-kunnr. data : lv_land1 type kna1-land1, lv_name1 type kna1-name1.

select single land1 name1 from kna1 into (lv_land1,lv_name1) where kunnr = p_kunnr. if sy-subrc eq 0. write :/ lv_land1, lv_name1. else. write :/ 'No data'. endif.

Program70
REPORT Z730PROG70. parameters p_kunnr type kna1-kunnr. data : lv_land1 type kna1-land1, lv_name1 type kna1-name1.

exec sql. select land1,name1 from kna1 into :lv_land1, :lv_name1 where kunnr = :p_kunnr endexec. if sy-subrc eq 0. write :/ lv_land1, lv_name1. else. write :/ 'No data'. endif.

Program71
REPORT Z730PROG71. parameters p_kunnr type kna1-kunnr. data : lv_land1 type kna1-land1, lv_name1 type kna1-name1.

exec sql. select land1, name1 from kna1 into :lv_land1,:lv_name1 where kunnr = :p_kunnr endexec. if sy-subrc eq 0. write :/ lv_land1, lv_name1. else. write :/ 'No data'. endif.

Program72
REPORT Z730PROG72. parameters : p_land1 type kna1-land1. types : begin of ty_kna1, kunnr type kna1-kunnr, name1 type kna1-name1, end of ty_kna1. data : ls_kna1 type ty_kna1. data abc type cursor. open cursor abc for select kunnr name1 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-name1. else.

exit. endif. enddo. close cursor abc.

Program73
REPORT Z730PROG73. parameters : p_land1 type kna1-land1. data : lv_kunnr type kna1-kunnr, lv_name1 type kna1-name1. exec sql. open abc for select kunnr, name1 from kna1 where land1 = :p_land1 endexec. do. exec sql. fetch next abc into :lv_kunnr, :lv_name1 endexec. if sy-subrc eq 0. write :/ lv_kunnr,lv_name1. else. exit. endif. enddo. exec sql. close abc endexec.

Program74
REPORT write write write write write write write write write write write write REPORT :/ :/ :/ :/ :/ :/ :/ :/ :/ :/ :/ :/ Z730PROG74. 'hello'. 'welcome'. 'hi'. 'GENSOFT'. 'hello'. 'welcome'. 'hi'. 'GENTECH'. 'hello'. 'welcome'. 'hi'. 'GENESIS'. Z730PROG75.

Program75
write :/ 'GENSOFT'. perform abc. write :/ 'GENTECH'. perform abc. write :/ 'GENESIS'. perform abc. form abc. write :/ 'hello'. write :/ 'welcome'. write :/ 'hi'.

endform.

Program76
REPORT Z730PROG76. data : p_x type i, p_y type i. perform abc using p_x p_y. "actual parameters perform abc using 40 50. form abc using lv_x lv_y. data lv_z type i. "local variables lv_z = lv_x + lv_y. write :/ 'Result is ',lv_z. endform.

Program77
REPORT Z730PROG77. data : lv_x type i value 10, lv_y type i value 5, lv_r1 type i, lv_r2 type i. write :/ lv_r1,lv_r2. perform abc using lv_x lv_y changing lv_r1 lv_r2. write :/ lv_r1,lv_r2. form abc using m n changing r1 r2. r1 = m + n. r2 = m - n. endform.

Program78
REPORT ZSUBPOOL. data lv_z type i. form 123. write : / 'inside the 123'. endform. form sub1 using x y. lv_z = x + y. write :/ 'sum is ',lv_z. endform. form sub2 using x y changing m. m = x + y. endform. REPORT Z730PROG78.

perform 123(zsubpool). write :/ 'hello'. *data lv_z type i. * *perform sub2(zsubpool) using 30 40 changing lv_z. *write :/ 'sum is ',lv_z. *parameters : p_x type i, * p_y type i. * *perform sub2(zsubpool) using p_x p_y changing lv_z.

Program79
REPORT Z730PROG79. data : x type i value 10, y type i value 20. write :/ 'X and Y before calling subroutine :',x,y. perform abc using x y. write :/ 'X and Y after calling subroutine :',x,y. form abc using m n. data z type i. z = m. m = n. n = z. endform.

Program80
REPORT Z730PROG80. data : x type i value 10, y type i value 20. write :/ 'X and Y before calling subroutine :',x,y. perform abc using x y. write :/ 'X and Y after calling subroutine :',x,y. form abc using value(m) value(n). data z type i. z = m. m = n. n = z. endform.

Program81
REPORT Z730PROG81. 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. select kunnr land1 name1 from kna1 into table lt_kna1 where land1 in ('AR','IN'). perform abc tables lt_kna1. if sy-subrc = 0. endif. form abc tables gt_kna1. describe table gt_kna1. write :/ 'No of records :',sy-tfill. endform.

Program82
REPORT Z730PROG82. 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. select kunnr land1 name1 from kna1 into table lt_kna1 where land1 in ('AR','IN'). if sy-subrc eq 0. perform abc tables lt_kna1. describe table lt_kna1. write :/ 'No of records in actual inttable:',sy-tfill. endif. form abc tables gt_kna1 structure ls_kna1. describe table gt_kna1. write :/ 'No of records :',sy-tfill. delete table gt_kna1. endform.

Program83
REPORT Z730PROG83. write :/ 'welcome'. include z730inc1. x = 10. y = 20. z = x + y. write :/ z. includecoding data : x type i, y type i, z type i.

Program84
REPORT Z730PROG84. *include z730inc2. write :/ 'welcome'. perform abc. include z730inc2.

includecoding
data x type i. form abc. write :/ 'inside abc'. endform.

Program85
REPORT Z730PROG85. write :/ 'welcome'. perform abc. include z730inc2.

Program86
REPORT Z730PROG86. x = 45. write :/ 'welcome'. perform abc.

include z730inc2.

Program87
REPORT Z730PROG87. include z730inc2. start-of-selection. x = 45. write :/ 'welcome'. perform abc.

Program88
REPORT Z730PROG88. define abc. &3 = &1 + &2. &4 = &1 - &2. end-of-definition. data : lv_r1 type i, lv_r2 type i. abc 20 10 lv_r1 lv_r2. write :/ 'sum is ',lv_r1, 'difference is ',lv_r2. clear : lv_r1,lv_r2. abc 200 109 lv_r1 lv_r2. write :/ 'sum is ',lv_r1, 'difference is',lv_r2.

Program89
REPORT Z730PROG89. parameters : p_x type i, p_y type i. data : lv_r1 type i, lv_r2 type i. CALL FUNCTION 'Z730FM1' EXPORTING I_X = p_x i_y = p_y IMPORTING E_R1 = lv_r1 E_R2 = lv_r2. write : / lv_r1,lv_r2.

Program90
REPORT Z730PROG90. parameters : p_x type i, p_y type i. CALL FUNCTION 'Z730FM2' EXPORTING i_x = p_x changing c_y = p_y. write :/ p_y.

Program91
REPORT Z730PROG91. parameters p_land1 type kna1-land1. types : begin of ty_kna1. include structure kna1. types end of ty_kna1. data : lt_kna1 type table of ty_kna1. CALL FUNCTION 'Z730FM3' EXPORTING i_land1 = p_land1 tables t_kna1 = lt_kna1. if lt_kna1[] is not initial. describe table lt_kna1. write :/ 'No of records :',sy-tfill. endif.

Program92
REPORT Z730PROG92. parameters p_land1 type kna1-land1. types : begin of ty_kna1. include structure z730kna1. types end of ty_kna1. data : lt_kna1 type table of ty_kna1, ls_kna1 type ty_kna1. CALL FUNCTION 'Z730FM4' EXPORTING i_land1 = p_land1 tables t_kna1 = lt_kna1[]. if lt_kna1[] is not initial. loop at lt_kna1 into ls_kna1. write :/ ls_kna1-kunnr, ls_kna1-land1, ls_kna1-name1. endloop. else. write :/ 'No data'.

endif.

Program93
REPORT Z730PROG93. types : begin of ty_kna1. include structure z730kna1. types end of ty_kna1. data : lt_kna1 type table of ty_kna1. select kunnr land1 name1 from kna1 into table lt_kna1 where land1 in ('AR','IN'). if sy-subrc eq 0. describe table lt_kna1. write :/ sy-tfill. CALL FUNCTION 'Z730FM6' TABLES t_kna1 = lt_kna1[]. describe table lt_kna1. write :/ sy-tfill. endif.

Program94
REPORT Z730PROG94. parameters : p_x type i, p_y type i. data lv_z type i. CALL FUNCTION 'Z730FM7' EXPORTING i_x = p_x i_y = p_y IMPORTING E_Z = lv_z. write :/ 'Division is :',lv_z. write :/ 'end of program'.

Program95
REPORT Z730PROG95. parameters : p_x type i, p_y type i. data lv_z type i. CALL FUNCTION 'Z730FM8' EXPORTING i_x = p_x i_y = p_y IMPORTING E_Z = lv_z EXCEPTIONS MYEXCEPTION = 1 OTHERS = 2. if sy-subrc eq 0. write :/ 'result is ',lv_z. elseif sy-subrc eq 1. * write :/ 'Cannnot divide by zero'. * message i004(z730msg). * message s004(z730msg). message a004(z730msg). elseif sy-subrc eq 2.

write :/ 'unknown error'. endif.

Program96 Program97
REPORT Z730PROG97. *tables y730amemp. *select-options so_empno for y730amemp-empno. data lv_empno type y730amemp-empno. select-options so_empno for lv_empno. types : begin of ty_emp, empno type y730amemp-empno, ename type y730amemp-ename, empdesig type y730amemp-empdesig, 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. select empno ename empdesig

from y730amemp into table lt_emp where empno in so_empno. if sy-subrc eq 0. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-empdesig. endloop. endif.

Program98
REPORT Z730PROG98. data lv_empno type y730amemp-empno. select-options so_empno for lv_empno. types : begin of ty_emp, empno type y730amemp-empno, ename type y730amemp-ename, empdesig type y730amemp-empdesig, 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. select empno ename empdesig from y730amemp into table lt_emp where empno in so_empno. if sy-subrc eq 0. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-empdesig. endloop. endif.

Program99
REPORT Z730PROG99. data flag type i. selection-screen begin of block b1 with frame title abc. selection-screen begin of line. selection-screen comment 7(15) lb1. parameters : p_empno type z9amemp-empno. selection-screen end of line. selection-screen begin of line. selection-screen comment 7(15) lb2. parameters : p_ename type z9amemp-ename. selection-screen end of line. selection-screen begin of line. selection-screen comment 7(15) lb3. parameters p_desig type z9amemp-empdesig.

selection-screen end of line. selection-screen end of block b1. selection-screen begin of block b2 with frame title pqr. selection-screen pushbutton 5(10) bt1 user-command p1. selection-screen pushbutton 18(10) bt2 user-command p2. selection-screen pushbutton 31(10) bt3 user-command p3. selection-screen skip 2. selection-screen pushbutton 5(10) bt4 user-command p4. selection-screen pushbutton 18(10) bt5 user-command p5. selection-screen pushbutton 31(10) bt6 user-command p6. selection-screen end of block b2. initialization. abc = 'Employee'. pqr = 'Operations'. lb1 = 'Employee No'. lb2 = 'Employee Name'. lb3 = 'Designation'. bt1 = 'Insert'. bt2 = 'Modify'. bt3 = 'Search'. bt4 = 'Exit'. bt5 = 'Clear'. bt6 = 'Clear All'. at selection-screen. case sy-ucomm. when 'P4'. leave program. when 'P6'. perform clearfields. endcase. at selection-screen output. if flag eq 0. loop at screen. if screen-name = 'LB2' or screen-name = 'P_ENAME' or screen-name = 'LB3' or screen-name = 'P_DESIG'. screen-invisible = '1'. screen-input = '0'. modify screen. endif. endloop. flag = 1. endif. form clearfields . clear : p_empno, p_ename, p_desig. endform. " clearfields

Program100
REPORT Z730PROG100. data flag type i. types : begin of ty_f4, empno type z9amemp-empno, ename type z9amemp-ename, end of ty_f4.

data : lt_f4 type table of ty_f4, ls_f4 type ty_f4. selection-screen begin of block b1 with frame title abc. selection-screen begin of line. selection-screen comment 7(15) lb1. parameters : p_empno type z9amemp-empno. selection-screen end of line. selection-screen begin of line. selection-screen comment 7(15) lb2 modif id a1. parameters : p_ename type z9amemp-ename modif id a1. selection-screen end of line. selection-screen begin of line. selection-screen comment 7(15) lb3 modif id a1. parameters p_desig type z9amemp-empdesig modif id a1. selection-screen end of line. selection-screen end of block b1. selection-screen begin of block b2 with frame title pqr. selection-screen pushbutton 5(10) bt1 user-command p1. selection-screen pushbutton 18(10) bt2 user-command p2. selection-screen pushbutton 31(10) bt3 user-command p3. selection-screen skip 2. selection-screen pushbutton 5(10) bt4 user-command p4. selection-screen pushbutton 18(10) bt5 user-command p5. selection-screen pushbutton 31(10) bt6 user-command p6. selection-screen end of block b2. initialization. abc = 'Employee'. pqr = 'Operations'. lb1 = 'Employee No'. lb2 = 'Employee Name'. lb3 = 'Designation'. bt1 = 'Insert'. bt2 = 'Modify'. bt3 = 'Search'. bt4 = 'Exit'. bt5 = 'Clear'. bt6 = 'Clear All'. at selection-screen. case sy-ucomm. when 'P4'. leave program. when 'P6'. perform clearfields. when 'P3'. perform checkempno. when 'P2'. update z9amemp set ename = p_ename empdesig = p_desig where empno = p_empno. if sy-subrc eq 0. flag = 3. perform clearfields. endif. endcase. at selection-screen output.

if flag eq 0. loop at screen. if screen-group1 = 'A1'. screen-invisible = '1'. screen-input = '0'. modify screen. endif. endloop. flag = 1. elseif flag eq 2. loop at screen. if screen-name = 'P_EMPNO'. screen-input = '0'. modify screen. endif. endloop. elseif flag eq 3. loop at screen. if screen-name = 'P_EMPNO'. screen-input = '1'. modify screen. endif. endloop. endif. at selection-screen on p_empno. perform checkempno. at selection-screen on value-request for p_empno. perform f4help. form clearfields . clear : p_empno, p_ename, p_desig. endform.

" clearfields

form f4help . select empno ename from z9amemp into table lt_f4. if sy-subrc eq 0. 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[]. endif. endform. " f4help form checkempno . if p_empno is not initial. select single ename empdesig from z9amemp into (p_ename,p_desig) where empno = p_empno. if sy-subrc ne 0. message 'Employee Not found' type 'I'. flag = 0. else.

flag = 2. endif. else. message 'Please enter empno before enter' type 'I'. endif. endform. " checkempno Z730PROG101.

Program101
REPORT types : begin of ty_kna1. include structure kna1. types end of ty_kna1. data ls_kna1 type ty_kna1. 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 p3. selection-screen pushbutton 16(10) b2 user-command p4. selection-screen begin of screen 100 as subscreen. parameters : p_kunnr type kna1-kunnr, p_land1 type kna1-land1. selection-screen end of screen 100. selection-screen begin of screen 200 as subscreen. parameters : p_name1 type kna1-name1, p_name2 type kna1-name2. selection-screen end of screen 200. initialization. t1 = 'Tab1'. t2 = 'Tab2'. b1 = 'Insert'. b2 = 'Exit'. 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 'P4'. leave program. when 'P3'. ls_kna1-kunnr = p_kunnr. ls_kna1-land1 = p_land1. ls_kna1-name1 = p_name1. ls_kna1-name2 = p_name2. insert kna1 from ls_kna1. endcase.

at selection-screen on help-request for p_kunnr. CALL FUNCTION 'POPUP_TO_INFORM' EXPORTING titel = 'Custom F1 Help' txt1 = 'KNA1 TABLE' txt2 = 'KUNNR Field'.

Program102
REPORT Z730PROG102. 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 lv_abc(20) type c. parameters abc like lv_abc as listbox visible length 10 user-command p1. data flag type i. selection-screen begin of block b1 with frame title bk1. parameters : c1 as checkbox modif id gp1, c2 as checkbox modif id gp1, c3 as checkbox modif id gp1. selection-screen end of block b1. selection-screen begin of block b2 with frame title bk2. parameters : r1 radiobutton group g1 modif id gp2, r2 radiobutton group g1 modif id gp2, r3 radiobutton group g1 modif id gp2. selection-screen end of block b2. initialization. bk1 = 'Courses'. bk2 = 'Institutes'. perform values. at selection-screen output. if flag eq 0. loop at screen. if screen-group1 = 'GP1' or screen-group1 = 'GP2'. screen-invisible = '1'. modify screen. endif. endloop. flag = 1. elseif flag eq 2. loop at screen. if screen-group1 = 'GP1'. screen-invisible = '0'. modify screen. endif. if screen-group1 = 'GP2'. screen-invisible = '1'. modify screen.

endif. endloop. elseif flag eq 3. loop at screen. if screen-group1 = 'GP1'. screen-invisible = '1'. modify screen. endif. if screen-group1 = 'GP2'. screen-invisible = '0'. modify screen. endif. endloop. endif. at selection-screen. case sy-ucomm. when 'P1'. if abc = 'K1'. flag = 2. elseif abc = 'K2'. 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 = 'Addresses'. append ls_values to lt_values. CALL FUNCTION 'VRM_SET_VALUES' EXPORTING id = 'ABC' values = lt_values[]. endform. " values

Program103
REPORT Z730PROG103. *tables sscrfields. parameters x type i. selection-screen selection-screen selection-screen selection-screen selection-screen function function function function function = = = = key key key key key 1. 2. 3. 4. 5. 1'. 2'. 3'. 4'.

initialization. sscrfields-FUNCTXT_01 sscrfields-FUNCTXT_02 sscrfields-FUNCTXT_03 sscrfields-FUNCTXT_04

'Button 'Button 'Button 'Button

sscrfields-FUNCTXT_05 = 'Button 5'. at selection-screen. case sy-ucomm. when 'FC01'. call transaction 'SE38'. when 'FC02'. call transaction 'SE37'. endcase.

Program104

PROGRAM

Z730PROG104.

controls tbstr type tabstrip. module abc input. case sy-ucomm. when 'P4'. leave program. endcase. endmodule. " abc

INPUT

Program105

PROGRAM

Z730PROG105.

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 io1(10) type c. data r2 type c. data flag type i. module USER_COMMAND_0100 input. case sy-ucomm. when 'P1'. leave program. when 'P2'. if io1 = 'K1'. flag = 2. elseif io1 = 'K2'. flag = 3. endif. endcase. endmodule. " USER_COMMAND_0100

INPUT

module STATUS_0100 output. if flag eq 0. r2 = 'X'. perform invisible_blocks. clear ls_values. ls_values-key = 'K1'. ls_values-text = 'KNA1'. append ls_values to lt_values. clear ls_values. ls_values-key = 'K2'. ls_values-text = 'MARA'. append ls_values to lt_values. ls_values-key = 'K3'. ls_values-text = 'VBAK'. append ls_values to lt_values. CALL FUNCTION 'VRM_SET_VALUES' EXPORTING id = 'IO1' values = lt_values[]. flag = 1. elseif flag eq 2. loop at screen. if screen-group1 = 'G1'. screen-invisible = '0'. screen-input = '1'. modify screen. endif. if screen-group1 = 'G2'. screen-invisible = '1'. screen-input = '0'. modify screen. endif. endloop. elseif flag eq 3. loop at screen. if screen-group1 = 'G1'. screen-invisible = '1'. screen-input = '0'. modify screen. endif. if screen-group1 = 'G2'. screen-invisible = '0'. screen-input = '1'. modify screen. endif. endloop. endif. endmodule. " STATUS_0100 form invisible_blocks . loop at screen. if screen-group1 = 'G1' or screen-group1 = 'G2'. screen-invisible = '1'. screen-input = '0'.

OUTPUT

modify screen. endif. endloop. endform.

" invisible_blocks

Program106

PROGRAM Z730PROG106. module USER_COMMAND_0100 input. case sy-ucomm. when 'P1'. leave program. endcase. endmodule. " USER_COMMAND_0100 INPUT module abc input. case sy-ucomm. when 'P2'. leave program. endcase. endmodule.
Program107

" abc INPUT

PROGRAM Z730PROG107. module USER_COMMAND_0100 input. case sy-ucomm. when 'P1'. leave program. endcase. endmodule. " USER_COMMAND_0100

INPUT

Program108

PROGRAM Z730PROG108. tables kna1. module USER_COMMAND_0100 input. case sy-ucomm. when 'P1'. leave program. endcase. endmodule. " USER_COMMAND_0100

INPUT

module abc input. select single kunnr land1 name1 from kna1 into corresponding fields of kna1 where land1 = kna1-land1. if sy-subrc ne 0. message 'Please choose other country' type 'E'. endif. endmodule. " abc INPUT module pqr input. CALL FUNCTION 'POPUP_TO_INFORM' EXPORTING titel = 'Custom F1 help' txt1 = 'KNA1 Table' txt2 = 'KUNNR FIELD'. endmodule. " pqr INPUT

module lmn input. CALL FUNCTION 'POPUP_TO_INFORM' EXPORTING titel = 'Custom F1 help' txt1 = 'KNA1 Table' txt2 = 'LAND1 FIELD'. endmodule. " lmn INPUT

Program109

PROGRAM

Z730PROG109.

*data vbak-vbeln type vbeln. tables : vbak,vbap. controls tbctrl type tableview using screen 100. types : begin of ty_vbap, vbeln type vbap-vbeln, posnr type vbap-posnr, matnr type vbap-matnr, end of ty_vbap. data : lt_vbap type table of ty_vbap, ls_vbap type ty_vbap. types : begin of ty_f4, vbeln type vbak-vbeln, ernam type vbak-ernam, end of ty_f4. data lt_f4 type table of ty_f4. 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'. leave program. endcase. endmodule.

" 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. tbctrl-lines = sy-dbcnt. endif. endform. " getitems module abc output. vbap-vbeln = ls_vbap-vbeln. vbap-posnr = ls_vbap-posnr. vbap-matnr = ls_vbap-matnr. endmodule. " abc

OUTPUT

module getvalues input. select vbeln ernam from vbak into table lt_f4. if sy-subrc eq 0. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING retfield = 'VBELN' DYNPPROG = sy-repid DYNPNR = '100' DYNPROFIELD = 'VBAK-VBELN' VALUE_ORG = 'S' tables value_tab = lt_f4[]. endif. endmodule. " getvalues INPUT module USER_COMMAND_0100 input. endmodule. " USER_COMMAND_0100 INPUT

Program110

Program111

Program112

Program113

PROGRAM

Z730PROG113.

controls tbstr type tabstrip. controls tbctrl type tableview using screen '300'. data scrno type sy-dynnr value '200'. module USER_COMMAND_0100 input. case sy-ucomm. when 'P3'. leave program. when 'P2'. tbstr-activetab = 'P2'. scrno = '300'. when 'P1'. tbstr-activetab = 'P1'. scrno = '200'. endcase. endmodule. " USER_COMMAND_0100

INPUT

Program114

PROGRAM

Z730PROG114.

module USER_COMMAND_0100 input. case sy-ucomm. when 'P2'. leave program. when 'P1'. call screen 200. endcase. endmodule. " USER_COMMAND_0100 module USER_COMMAND_0200 input. case sy-ucomm. when 'P1'. set screen 300. when 'P2'. * leave to screen 100. leave to screen 0. when 'P3'. leave program. endcase. endmodule. " USER_COMMAND_0200 module USER_COMMAND_0300 input. CASE sy-ucomm. when 'P1'. * leave to screen 200.

INPUT

INPUT

leave to screen 0. when 'P2'. leave to screen 100. when 'P3'. leave program. endcase. endmodule. " USER_COMMAND_0300

INPUT

Program115
REPORT Z730PROG115. types : begin of ty_emp. include structure z11am_emp. types end of ty_emp. data : lt_emp type sorted table of ty_emp with non-unique key empno, ls_emp type ty_emp. select * from z11am_emp into table lt_emp. if lt_emp[] is not initial. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename. endloop. endif. clear ls_emp. ls_emp-empno = 15. ls_emp-ename = 'Raju'. append ls_emp to lt_emp. write :/ 'Internal table after append:'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename. endloop. clear ls_emp. ls_emp-empno = 13. ls_emp-ename = 'Mahesh'. *append ls_emp to lt_emp. insert ls_emp into table lt_emp. write :/ 'Internal table after insert:'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename. endloop. * *clear ls_emp. *ls_emp-empno = 4. *ls_emp-ename = 'Gensoft'. *insert ls_emp into table lt_emp. * *write :/ 'Internal table after inserting empno 4:'. * loop at lt_emp into ls_emp. * write :/ ls_emp-empno, * ls_emp-ename. * endloop. * * *read table lt_emp into ls_emp index 7. *if sy-subrc eq 0.

* write :/ 'Seventh record is :'. * write :/ ls_emp-empno, * ls_emp-ename. *else. * write :/ 'No data'. *endif. * *read table lt_emp into ls_emp with key empno = 13 binary search. *if sy-subrc eq 0. * write :/ 'Emp record with empno 13 is :'. * write :/ ls_emp-empno, * ls_emp-ename. *else. * write :/ 'No data'. *endif.

Program116
REPORT Z730PROG116. types : begin of ty_emp. include structure z11am_emp. types end of ty_emp. data : lt_emp type standard table of ty_emp with non-unique key deptno, ls_emp type ty_emp. select * from z11am_emp into table lt_emp. if lt_emp[] is not initial. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-deptno. endloop. endif. sort lt_emp. if lt_emp[] is not initial. write :/ 'After default sort...'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-deptno. endloop. endif.

Program117
REPORT Z730PROG117. types : begin of ty_emp. include structure z11am_emp. types end of ty_emp. data : lt_emp type hashed table of ty_emp with unique key ename, ls_emp type ty_emp. select * from z11am_emp into table lt_emp. if lt_emp[] is not initial. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-deptno. endloop. endif.

sort lt_emp. write :/ 'After sort...'. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, ls_emp-deptno. endloop. *read table lt_emp into ls_emp with key empno = 3 binary search. read table lt_emp into ls_emp with key empno = 3. if sy-subrc eq 0. write :/ 'empno 3 :'. write :/ ls_emp-empno, ls_emp-ename. else. write :/ 'No data'. endif.

Program118
REPORT Z730PROG118. types : begin of ty_itab, f1(3) type c, f2(2) type n, f3 type i, end of ty_itab. data : lt_itab type standard table of ty_itab with non-unique key f1 f2, ls_itab type ty_itab. clear ls_itab. ls_itab-f1 = 'abc'. ls_itab-f2 = '10'. ls_itab-f3 = 5. append ls_itab to lt_itab. write :/ sy-tabix. clear ls_itab. ls_itab-f1 = 'pqr'. ls_itab-f2 = '20'. ls_itab-f3 = 8. append ls_itab to lt_itab. write :/ sy-tabix. clear ls_itab. ls_itab-f1 = 'abc'. ls_itab-f2 = '10'. ls_itab-f3 = 18. append ls_itab to lt_itab. write :/ sy-tabix. write :/ 'Data in internal table'. loop at lt_itab into ls_itab. write :/ ls_itab-f1, ls_itab-f2, ls_itab-f3. endloop.

Program119
REPORT Z730PROG119. types : begin of ty_itab,

f1(3) type c, f2(2) type n, f3 type i, end of ty_itab. data : lt_itab type standard table of ty_itab with non-unique key f1 f2, ls_itab type ty_itab. clear ls_itab. ls_itab-f1 = 'abc'. ls_itab-f2 = '10'. ls_itab-f3 = 5. collect ls_itab into lt_itab. write :/ sy-tabix. clear ls_itab. ls_itab-f1 = 'pqr'. ls_itab-f2 = '20'. ls_itab-f3 = 8. collect ls_itab into lt_itab. write :/ sy-tabix. clear ls_itab. ls_itab-f1 = 'abc'. ls_itab-f2 = '10'. ls_itab-f3 = 18. collect ls_itab into lt_itab. write :/ sy-tabix. write :/ 'Data in internal table'. loop at lt_itab into ls_itab. write :/ ls_itab-f1, ls_itab-f2, ls_itab-f3. endloop.

Program120
REPORT Z730PROG120. types : begin of ty_emp. include structure z11am_emp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select * from z11am_emp into table lt_emp. if sy-subrc eq 0. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, (15) ls_emp-empdesig, (20) ls_emp-address, ls_emp-deptno. endloop. endif.

Program121
REPORT Z730PROG121. PARAMETERS p_deptno type z11am_emp-deptno. types : begin of ty_emp.

include structure z11am_emp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. select * from z11am_emp into table lt_emp where deptno = p_deptno. if sy-subrc eq 0. loop at lt_emp into ls_emp. write :/ ls_emp-empno, ls_emp-ename, (15) ls_emp-empdesig, (20) ls_emp-address, ls_emp-deptno. endloop. endif.

Program122
REPORT Z730PROG122. CALL FUNCTION 'BP_EVENT_RAISE' EXPORTING eventid

= 'ZMYEVENT'.

Program123
REPORT Z730PROG123. parameters : p_jname type TBTCJOB-JOBNAME. data lv_jid type TBTCJOB-JOBCOUNT. *data lv_uname type TBTCJOB-AUTHCKNAM value sy-uname. data lv_rep type sy-repid value 'Z730PROG121'. data lv_var type RALDB-VARIANT value 'V1'. * open the job CALL FUNCTION 'JOB_OPEN' EXPORTING jobname IMPORTING JOBCOUNT if lv_jid is not initial. * submit the job CALL FUNCTION 'JOB_SUBMIT' EXPORTING authcknam jobcount jobname REPORT VARIANT * Release the job DAta lv_status type c. CALL FUNCTION 'JOB_CLOSE' EXPORTING jobcount jobname STRTIMMED IMPORTING JOB_WAS_RELEASED

= p_jname = lv_jid.

= = = = =

sy-uname lv_jid p_jname lv_rep lv_var.

= lv_jid = p_jname = 'X' = lv_status.

WRITE :/ lv_status. endif.

Program124
REPORT Z730PROG124. data lv_matnr type matnr value 'M100'. set parameter id 'MAT' field lv_matnr. call transaction 'MM03'.

Program125
data lv_vbeln type vbrk-vbeln. select-options so_vbeln for lv_vbeln. data lv_matnr type matnr. types : begin of ty_vbrk, vbeln type vbrk-vbeln, fkart type vbrk-fkart, fkdat type vbrk-fkdat, end of ty_vbrk. data : lt_vbrk type table of ty_vbrk, ls_vbrk type ty_vbrk. types : begin of ty_vbrp, vbeln type vbrp-vbeln, posnr type vbrp-posnr, matnr type vbrp-matnr, end of ty_vbrp. data : lt_vbrp type table of ty_vbrp, ls_vbrp type ty_vbrp. types : begin of ty_mara, matnr type mara-matnr, mtart type mara-mtart, matkl type mara-matkl, end of ty_mara. data ls_mara type ty_mara. form getvbrk . select vbeln fkart fkdat from vbrk into table lt_vbrk where vbeln in so_vbeln. endform. " getvbrk form displayvbrk . uline. format color 5. write :/8(12) 'VBRK',(7) 'FKART',(8) 'FKDAT'. format color off. uline. format color 3. loop at lt_vbrk into ls_vbrk. write :/8 ls_vbrk-vbeln hotspot on,sy-vline, (5) ls_vbrk-fkart,sy-vline, ls_vbrk-fkdat,sy-vline. endloop. format color off. uline.

endform.

" displayvbrk

form getvbrp . select vbeln posnr matnr from vbrp into table lt_vbrp where vbeln = lv_vbeln. endform. " getvbrp form displayvbrp . uline. format color 4. loop at lt_vbrp into ls_vbrp. write :/ ls_vbrp-vbeln,sy-vline, ls_vbrp-posnr,sy-vline, ls_vbrp-matnr,sy-vline. hide ls_vbrp-matnr. endloop. format color off. uline. endform. " displayvbrp form getmaterial . select single matnr mtart matkl from mara into ls_mara where matnr = ls_vbrp-matnr. endform. " getmaterial form displaymaterial . format color 7. write :/ ls_mara-matnr, ls_mara-mtart, ls_mara-matkl. format color off. endform.

" displaymaterial

Program126
REPORT Z730PROG126 no standard page heading. include z730intinc. initialization. so_vbeln-low = '90005177'. so_vbeln-high = '90005185'. append so_vbeln. start-of-selection. if so_vbeln[] is not initial. perform getvbrk. if lt_vbrk[] is not initial. perform displayvbrk. else. message 'No billing docs' type 'I'. endif. else. message 'Please enter range of billing docs' type 'I'. endif. top-of-page. uline.

write :/13 'BILLING DOCUMENT HEADER DATA' color 6. uline. top-of-page during line-selection. case sy-lsind. when 1. uline. write :/12 'BILLING DOCUMENT ITEM DATA' color 1. uline. when 2. uline. write :/12 'MATERIAL DATA' color 1. uline. endcase. at line-selection. case sy-lsind. when 1. clear lv_vbeln. lv_vbeln = sy-lisel+7(10). unpack lv_vbeln to lv_vbeln. perform getvbrp. if lt_vbrp[] is not initial. perform displayvbrp. else. message 'No item data' type 'I'. endif. when 2. perform getmaterial. if ls_mara is not initial. perform displaymaterial. endif. when 3. get cursor field ls_mara-matnr value lv_matnr. set parameter id 'MAT' field lv_matnr. call transaction 'MM03'. endcase.

Program127
REPORT Z730PROG127. types : begin of ty_emp_dept, empno type z11am_emp-empno, ename type z11am_emp-ename, deptno type z11am_emp-deptno, dno type z11am_dept-dno, dname type z11am_dept-dname, loc type z11am_dept-loc, end of ty_emp_dept. data : lt_emp_dept type table of ty_emp_dept, ls_emp_dept type ty_emp_dept. select empno ename deptno dno dname loc from z11am_emp inner join z11am_dept on z11am_emp~deptno = z11am_dept~dno into table lt_emp_dept. if sy-subrc eq 0. loop at lt_emp_dept into ls_emp_dept. write :/ ls_emp_dept-empno, (10) ls_emp_dept-ename, ls_emp_dept-deptno, ls_emp_dept-dno,

ls_emp_dept-dname, (16) ls_emp_dept-loc. skip 1. endloop. endif.

Program128
REPORT Z730PROG128. types : begin of ty_emp_dept, empno type z11am_emp-empno, ename type z11am_emp-ename, deptno type z11am_emp-deptno, dno type z11am_dept-dno, dname type z11am_dept-dname, loc type z11am_dept-loc, end of ty_emp_dept. data : lt_emp_dept type table of ty_emp_dept, ls_emp_dept type ty_emp_dept. select empno ename deptno dno dname loc from z11am_emp left outer join z11am_dept on z11am_emp~deptno = z11am_dept~dno into table lt_emp_dept. if sy-subrc eq 0. loop at lt_emp_dept into ls_emp_dept. write :/ ls_emp_dept-empno, (10) ls_emp_dept-ename, ls_emp_dept-deptno, ls_emp_dept-dno, ls_emp_dept-dname, (16) ls_emp_dept-loc. skip 1. endloop. endif.

Program129
REPORT Z730PROG129. types : begin of ty_emp_dept, empno type z11am_emp-empno, ename type z11am_emp-ename, deptno type z11am_emp-deptno, dno type z11am_dept-dno, dname type z11am_dept-dname, loc type z11am_dept-loc, end of ty_emp_dept. data : lt_emp_dept type table of ty_emp_dept, ls_emp_dept type ty_emp_dept. select empno ename deptno dno dname loc from z11am_emp as x left outer join z11am_dept as y on x~deptno = y~dno into table lt_emp_dept. if sy-subrc eq 0. loop at lt_emp_dept into ls_emp_dept. write :/ ls_emp_dept-empno, (10) ls_emp_dept-ename, ls_emp_dept-deptno, ls_emp_dept-dno,

ls_emp_dept-dname, (16) ls_emp_dept-loc. skip 1. endloop. endif.

Program130
REPORT Z730PROG130 no standard page heading. 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. ranges r_vbeln for vbap-vbeln. start-of-selection. r_vbeln-low = '0000004970'. r_vbeln-high = '0000004975'. r_vbeln-option = 'BT'. r_vbeln-sign = 'I'. append r_vbeln. select vbeln posnr matnr netwr from vbap into table lt_vbap where vbeln in r_vbeln. if sy-subrc eq 0. sort lt_vbap by vbeln. loop at lt_vbap into ls_vbap. at first. write :/15 'SALES DOCUMENT ITEM DATA WITH PRICES' COLOR 4. endat. at new vbeln. write :/ 'Sales Document :',ls_vbap-vbeln color 5. endat. write :/10 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 2 under ls_vbap-netwr. endat. at last. sum. write :/ 'Total net value is :', ls_vbap-netwr color 7 under ls_vbap-netwr. endat. endloop. endif.

Program131
REPORT Z730PROG131 no standard page heading. types : begin of ty_vbap, posnr type vbap-posnr,

matnr type vbap-matnr, netwr type vbap-netwr, vbeln type vbap-vbeln, end of ty_vbap. data : lt_vbap type table of ty_vbap, ls_vbap type ty_vbap. ranges r_vbeln for vbap-vbeln. start-of-selection. r_vbeln-low = '0000004970'. r_vbeln-high = '0000004975'. r_vbeln-option = 'BT'. r_vbeln-sign = 'I'. append r_vbeln. select vbeln posnr matnr netwr from vbap into corresponding fields of table lt_vbap where vbeln in r_vbeln. if sy-subrc eq 0. loop at lt_vbap into ls_vbap. at first. write :/15 'SALES DOCUMENT ITEM DATA WITH PRICES' COLOR 4. endat. at new vbeln. write :/ 'Sales Document :',ls_vbap-vbeln color 5. endat. write :/10 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 2 under ls_vbap-netwr. endat. at last. sum. write :/ 'Total net value is :', ls_vbap-netwr color 7 under ls_vbap-netwr. endat. endloop. endif.

Program132
REPORT Z730PROG132. data lv_vbeln type vbeln. select-options so_vbeln for lv_vbeln. types : begin of ty_vbak, vbeln type vbak-vbeln, erdat type vbak-erdat, erzet type vbak-erzet, end of ty_vbak. data : lt_vbak type table of ty_vbak, ls_vbak type ty_vbak. types : begin of ty_vbap, vbeln type vbap-vbeln,

posnr type vbap-posnr, matnr type vbap-matnr, 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. endif. if lt_vbap[] is not initial. loop at lt_vbak into ls_vbak. write :/ ls_vbak-vbeln, ls_vbak-erdat, ls_vbak-erzet. loop at lt_vbap into ls_vbap where vbeln = ls_vbak-vbeln. write :/6 ls_vbap-vbeln, ls_vbap-posnr, ls_vbap-matnr. endloop. endloop. endif. form getvbak . select vbeln erdat erzet 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

Program133
REPORT Z730PROG133. data lv_vbeln type vbeln. select-options so_vbeln for lv_vbeln. types : begin of ty_vbak, vbeln type vbak-vbeln, erdat type vbak-erdat, erzet type vbak-erzet, end of ty_vbak. data : lt_vbak type table of ty_vbak, ls_vbak type ty_vbak. types : begin of ty_vbap, vbeln type vbap-vbeln, posnr type vbap-posnr, matnr type vbap-matnr,

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. endif. if lt_vbap[] is not initial. loop at lt_vbak into ls_vbak. write :/ ls_vbak-vbeln, ls_vbak-erdat, ls_vbak-erzet. loop at lt_vbap into ls_vbap where vbeln = ls_vbak-vbeln. write :/6 ls_vbap-vbeln, ls_vbap-posnr, ls_vbap-matnr. endloop. endloop. endif. form getvbak . select vbeln erdat erzet 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 appending corresponding fields of table lt_vbap where vbeln = ls_vbak-vbeln. endloop. endform. " getvbap

Program134
REPORT Z730PROG134. data lv_vbeln type vbeln. select-options so_vbeln for lv_vbeln. types : begin of ty_vbak, vbeln type vbak-vbeln, erdat type vbak-erdat, erzet type vbak-erzet, end of ty_vbak. data : lt_vbak type table of ty_vbak, ls_vbak type ty_vbak. types : begin of ty_vbap, vbeln type vbap-vbeln, posnr type vbap-posnr, matnr type vbap-matnr, 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. endif. if lt_vbap[] is not initial. loop at lt_vbak into ls_vbak. write :/ ls_vbak-vbeln, ls_vbak-erdat, ls_vbak-erzet. loop at lt_vbap into ls_vbap where vbeln = ls_vbak-vbeln. write :/6 ls_vbap-vbeln, ls_vbap-posnr, ls_vbap-matnr. endloop. endloop. endif. form getvbak . select vbeln erdat erzet from vbak into table lt_vbak where vbeln in so_vbeln. endform. " getvbak form getvbap . if lt_vbak[] is not initial. select vbeln posnr matnr from vbap into table lt_vbap for all entries in lt_vbak where vbeln = lt_vbak-vbeln. endif. endform. " getvbap

Program135
REPORT Z730PROG135 no standard page heading. 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. ranges r_vbeln for vbap-vbeln. start-of-selection. r_vbeln-low = '0000004970'. r_vbeln-high = '0000004975'. r_vbeln-option = 'BT'. r_vbeln-sign = 'I'. append r_vbeln.

select vbeln posnr matnr netwr from vbap into table lt_vbap where vbeln in r_vbeln. if sy-subrc eq 0. sort lt_vbap by vbeln. loop at lt_vbap into ls_vbap. at first. write :/15 'SALES DOCUMENT ITEM DATA WITH PRICES' COLOR 4. endat. * at new vbeln. on change of ls_vbap-vbeln. write :/ 'Sales Document :',ls_vbap-vbeln color 5. endon. endat. write :/10 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 2 under ls_vbap-netwr. endat. at last. sum. write :/ 'Total net value is :', ls_vbap-netwr color 7 under ls_vbap-netwr. endat. endloop. endif.

Program136
REPORT Z730PROG136. data lv_Vbeln type 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, end of ty_vbap. data : ls_vbap type ty_vbap. initialization. so_vbeln-low = '4970'. so_vbeln-high = '4975'. append so_vbeln. start-of-selection. perform getvbap. form getvbap . select vbeln posnr matnr from vbap into ls_vbap where vbeln in so_vbeln. on change of ls_vbap-vbeln. write :/ 'Sales Document :',ls_vbap-vbeln color 5. write :/5 ls_vbap-posnr, ls_vbap-matnr.

else. write :/5 ls_vbap-posnr, ls_vbap-matnr. endon. endselect. endform. " getvbap

Program137
REPORT Z730PROG137. data x type i. start-of-selection. write :/ 'inside start-of-selection'. end-of-selection. write :/ 'inside end-of-selection'. load-of-program. x = 10. write :/ 'inside load-of-program'. initialization. write :/ 'inside initialization'. top-of-page. write :/ x. write :/ 'inside top of page'.

Program138
REPORT Z730PROG138. parameters x type i. initialization. x = 10. start-of-selection. write :/ 'start'. load-of-program. write :/ 'load'. end-of-selection. write :/ 'end of sel'. top-of-page. write :/ 'Top'.

Program139
REPORT Z730PROG139. parameters x type i. initialization. x = 10. write :/ 'inside initialization'. start-of-selection. write :/ 'start'. load-of-program. write :/ 'load'.

end-of-selection. write :/ 'end of sel'. top-of-page. write :/ 'Top'.

Program140
REPORT Z730PROG140. parameters x type i. data z type i. start-of-selection. z = x mod 2. if z ne 0. write :/ 'before stop'. stop. write :/ 'After stop'. else. write :/ 'even no'. endif. end-of-selection. write :/ 'inside end of selection'.

Program141
REPORT Z730PROG141. types : begin of ty_legacy, str(100) type c, end of ty_legacy. data : lt_legacy type standard 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 system file CALL FUNCTION 'GUI_UPLOAD' EXPORTING filename = 'c:/customer1.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.

modify kna1 from table lt_kna1. endif.

Program142
REPORT Z730PROG142. 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 system file CALL FUNCTION 'GUI_UPLOAD' EXPORTING filename = 'C:\CUSTOMER1.TXT' HAS_FIELD_SEPARATOR = 'X' tables data_tab = lt_kna1[]. if lt_kna1[] is not initial. modify kna1 from table lt_kna1. endif.

Program143
REPORT Z730PROG143. data dsn(30) type c value '\\200.200.200.20\c$\abc.txt'. data str type string value 'ACCENTURE'. open dataset dsn for output in text mode encoding default. if sy-subrc eq 0. transfer str to dsn. else. write :/ 'File not openend'. endif. close dataset dsn.

Program144
REPORT

Z730PROG143.

data dsn(30) type c value '\\200.200.200.20\c$\abc1.txt'. data str type string. open dataset dsn for input in text mode encoding default. if sy-subrc eq 0. do. read dataset dsn into str. if sy-subrc eq 0. write :/ str. else. exit. endif. enddo. close dataset dsn. else. write :/ 'File not opened'.

endif.

Program145
REPORT

Z730PROG143.

data dsn(30) type c value '\\200.200.200.20\c$\abc1.txt'. data str type string. open dataset dsn for input in text mode encoding default message str. if sy-subrc eq 0. close dataset dsn. else. write :/ str. endif.

Program146
REPORT Z730PROG143. data dsn(30) type c value '\\200.200.200.20\c$\abc2.txt'. data str type string value 'CMC LTD'. data msg type string. open dataset dsn for appending in text mode encoding default message msg . if sy-subrc eq 0. transfer str to dsn. close dataset dsn. else. write :/ msg. endif.

Program147
REPORT Z730PROG143. data dsn(30) type c value '\\200.200.200.20\c$\abc2.txt'. data str type string value 'TCS'. data msg type string. open dataset dsn for update in text mode encoding default message msg . if sy-subrc eq 0. transfer str to dsn. close dataset dsn. else. write :/ msg. endif.

Program148
REPORT Z730PROG143. data dsn(30) type c value '\\200.200.200.20\c$\abc2.txt'. data str type string. data msg type string. open dataset dsn for update in text mode encoding default message msg . if sy-subrc eq 0. read dataset dsn into str. if sy-subrc eq 0. write :/ str.

else. write :/ 'Read failed'. endif. close dataset dsn. else. write :/ msg. endif.

Program149
REPORT data data data data

Z730PROG143.

dsn(30) type c value '\\200.200.200.20\c$\narra1.txt'. str type string. msg type string. pos type i.

open dataset dsn for input in text mode encoding default message msg . if sy-subrc eq 0. read dataset dsn into str. if sy-subrc eq 0. write :/ str. get dataset dsn position pos. write :/ 'Position is :',pos. pos = pos + 6. set dataset dsn position pos. read dataset dsn into str. if sy-subrc eq 0. write :/ str. endif. else. write :/ 'Read failed'. endif. close dataset dsn. else. write :/ msg. endif.

Program150
REPORT

Z730PROG143.

data dsn(30) type c value '\\200.200.200.20\c$\san2.txt'. data str type string. data msg type string. open dataset dsn for input in text mode encoding default message msg. if sy-subrc eq 0. delete dataset dsn. else. write :/ msg. endif.

Program151
REPORT

Z730PROG143.

data dsn(30) type c value '\\200.200.200.20\c$\abc5.txt'. data str type i value 10. data msg type string.

open dataset dsn for output in text mode encoding default message msg. if sy-subrc eq 0. transfer str to dsn. else. write :/ msg. endif.

Program152
REPORT Z730PROG143. data dsn(30) type c value '\\200.200.200.20\c$\abc1.txt'. data str type string. data msg type string. open dataset dsn for input in binary mode message msg. if sy-subrc eq 0. read dataset dsn into str. if sy-subrc eq 0. write :/ str. endif. else. write :/ msg. endif.

Program153
REPORT

Z730PROG153.

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. types : begin of ty_bdcmsgcoll. include structure bdcmsgcoll. types end of ty_bdcmsgcoll. data lt_bdcmsgcoll type table of ty_bdcmsgcoll. data ls_bdcmsgcoll type ty_bdcmsgcoll. types: begin of ty_msg, messages type string,

end of ty_msg. data lt_msg type table of ty_msg. data ls_msg type ty_msg. * Read data from file CALL FUNCTION 'GUI_UPLOAD' EXPORTING filename tables data_tab

= 'c:\CUSTOMER.txt' = lt_legacy[].

* Transfer data to final internal table 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. else. write :/ 'No data'. endif. if lt_kna1[] is not initial. loop at lt_kna1 into ls_kna1. * Map Program info perform prginfo using 'Z730PROG154' '100'. * Map Each Field info 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 BDCDATA internal table to transaction call transaction 'Z154' USING lt_bdcdata mode 'E' messages into lt_bdcmsgcoll. endloop. endif.

if lt_bdcmsgcoll is not initial. loop at lt_bdcmsgcoll into ls_bdcmsgcoll. CALL FUNCTION 'FORMAT_MESSAGE' EXPORTING ID = ls_bdcmessage-msgid NO = ls_bdcmsgcoll-msgnr V1 = ls_bdcmsgcoll-msgv1 V2 = ls_bdcmsgcoll-msgv2 V3 = ls_bdcmsgcoll-msgv3 V4 = ls_bdcmsgcoll-msgv4 IMPORTING MSG = ls_messages-msg.

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 fname fvalue. clear ls_bdcdata. ls_bdcdata-fnam = fname. ls_bdcdata-fval = fvalue. append ls_bdcdata to lt_bdcdata. endform.

Program154

program

z730prog154.

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 'P3'. leave program. endcase. endmodule. " USER_COMMAND_0100 INPUT

Program155
REPORT Z730PROG155. 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. data msg type string. * open the file in input mode data dsn(40) type c value '\\200.200.200.50\c$\customer.txt'. open dataset dsn for input in text mode encoding default message msg. if sy-subrc eq 0. do. read dataset dsn into ls_legacy-str. if sy-subrc eq 0. append ls_legacy to lt_legacy. else. exit. endif. enddo. else. write :/ msg. endif. 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. * Create the session object CALL FUNCTION 'BDC_OPEN_GROUP' EXPORTING GROUP = 'S5' * HOLDDATE = '20120429' KEEP = 'X'

USER

= sy-uname.

loop at lt_kna1 into ls_kna1. perform prginfo using 'Z730PROG154' '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 to session object CALL FUNCTION 'BDC_INSERT' EXPORTING TCODE = 'Z154' TABLES dynprotab = lt_bdcdata[]. endloop. * Close the session object CALL FUNCTION 'BDC_CLOSE_GROUP'. 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 fname fvalue. clear ls_bdcdata. ls_bdcdata-fnam = fname. ls_bdcdata-fval = fvalue. append ls_bdcdata to lt_bdcdata. endform.

Program156
report Z730PROG156 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. data lv_fname type string. * end of custom changes parameters : p_path type ibipparms-path. at selection-screen on value-request for p_path. CALL FUNCTION 'F4_FILENAME' IMPORTING FILE_NAME = p_path. if p_path is not initial. lv_fname = p_path. endif. start-of-selection. *perform open_dataset using dataset. * Begin of custom changes CALL FUNCTION 'GUI_UPLOAD' EXPORTING filename tables data_tab

***

= lv_fname = 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_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 perform * perform * perform * perform *enddo. endloop. perform close_group. *perform close_dataset using dataset. using 'Z730PROG154' '0100'. using 'BDC_OKCODE' '=P1'. bdc_field using 'BDC_CURSOR' 'KNA1-NAME1'. bdc_field using 'KNA1-KUNNR' ls_kna1-kunnr. record-KUNNR_001. bdc_field using 'KNA1-LAND1' ls_kna1-land1. record-LAND1_002. bdc_field using 'KNA1-NAME1' ls_kna1-name1. record-NAME1_003. bdc_transaction using 'Z154'.

Program157

report Z730PROG157 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: MATNR MATNR_001(018), * data element: MBRSH MBRSH_002(001), * data element: MTART MTART_003(004), * data element: XFELD KZSEL_01_004(001), * data element: MAKTX MAKTX_005(040), * data element: MEINS MEINS_006(003), 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_material, matnr type mara-matnr, mbrsh type mara-mbrsh, mtart type mara-mtart, maktx type makt-maktx, meins type mara-meins, end of ty_material. data : lt_material type table of ty_material, ls_material type ty_material. * End of custom changes start-of-selection. * Begin of changes CALL FUNCTION 'GUI_UPLOAD' EXPORTING filename tables data_tab

= 'c:\material.txt' = lt_legacy[].

if lt_legacy[] is not initial. loop at lt_legacy into ls_legacy. split ls_legacy-str at ',' into ls_material-matnr ls_material-mbrsh ls_material-mtart ls_material-maktx ls_material-meins. append ls_material to lt_material. endloop. endif.

* end of changes *perform open_dataset using dataset. perform open_group. *do. loop at lt_material into ls_material. *read dataset dataset into record. *if sy-subrc <> 0. exit. endif. perform bdc_dynpro perform bdc_field perform perform * perform * perform * perform perform perform perform perform perform perform * perform perform * perform *enddo. endloop. perform close_group. *perform close_dataset using dataset. using 'SAPLMGMM' '0060'. using 'BDC_CURSOR' 'RMMG1-MTART'. bdc_field using 'BDC_OKCODE' '/00'. bdc_field using 'RMMG1-MATNR' ls_material-matnr. record-MATNR_001. bdc_field using 'RMMG1-MBRSH' ls_material-mbrsh. record-MBRSH_002. bdc_field using 'RMMG1-MTART' ls_material-mtart. record-MTART_003. bdc_dynpro using 'SAPLMGMM' '0070'. bdc_field using 'BDC_CURSOR' 'MSICHTAUSW-DYTXT(01)'. bdc_field using 'BDC_OKCODE' '=ENTR'. bdc_field using 'MSICHTAUSW-KZSEL(01)' record-KZSEL_01_004. bdc_dynpro using 'SAPLMGMM' '4004'. bdc_field using 'BDC_OKCODE' '=BU'. bdc_field using 'MAKT-MAKTX' ls_material-maktx. record-MAKTX_005. bdc_field using 'BDC_CURSOR' 'MARA-MEINS'. bdc_field using 'MARA-MEINS' ls_material-meins. record-MEINS_006. bdc_transaction using 'MM01'.

Program158
REPORT

Z730PROG158.

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. types : begin of ty_bdcmsgcoll. include structure bdcmsgcoll. types end of ty_bdcmsgcoll. data : lt_bdcmsgcoll type table of ty_bdcmsgcoll, ls_bdcmsgcoll type ty_bdcmsgcoll. types : begin of ty_messages, msg type string, end of ty_messages. data : lt_messages type table of ty_messages, ls_messages type ty_messages. * Read data from file CALL FUNCTION 'GUI_UPLOAD' EXPORTING filename tables data_tab

= 'c:\CUSTOMER.txt' = lt_legacy[].

* Transfer data to final internal table 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. else. write :/ 'No data'. endif. if lt_kna1[] is not initial. loop at lt_kna1 into ls_kna1. * Map Program info perform prginfo using 'Z730PROG154' '100'. * Map Each Field info 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 BDCDATA internal table to transaction call transaction 'Z154' USING lt_bdcdata mode 'A' messages into lt_bdcmsgcoll. endloop. endif. if lt_bdcmsgcoll[] is not initial. loop at lt_bdcmsgcoll into ls_bdcmsgcoll. CALL FUNCTION 'FORMAT_MESSAGE' EXPORTING ID = ls_bdcmsgcoll-msgid NO = ls_bdcmsgcoll-msgnr V1 = ls_bdcmsgcoll-msgv1 V2 = ls_bdcmsgcoll-msgv2 V3 = ls_bdcmsgcoll-msgv3 V4 = ls_bdcmsgcoll-msgv4 IMPORTING MSG = ls_messages-msg. if ls_messages-msg is not initial. append ls_messages to lt_messages. endif. endloop. if lt_messages[] is not initial. CALL FUNCTION 'GUI_DOWNLOAD' EXPORTING filename FILETYPE APPEND WRITE_FIELD_SEPARATOR tables data_tab endif. 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 fname fvalue. clear ls_bdcdata. ls_bdcdata-fnam = fname. ls_bdcdata-fval = fvalue. append ls_bdcdata to lt_bdcdata. endform.

= 'c:\830errors.txt' = 'ASC' = 'X' = 'X' = lt_messages[].

Program159

report Z730PROG159 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: KUN16 KUNNR_001(016), * data element: KTOKD KTOKD_002(004), * data element: NAME1_GP NAME1_003(035), * data element: SORTL SORTL_004(010), * data element: STRAS_GP STRAS_005(035), * data element: LAND1_GP LAND1_006(003), * data element: SPRAS SPRAS_007(002), * data element: BANKS BANKS_01_008(003), * data element: BANKK BANKL_01_009(015), * data element: BANKN BANKN_01_010(018), 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, name1 type kna1-name1, sortl type kna1-sortl, ***

***

stras type kna1-stras, land1 type kna1-land1, spras type kna1-spras, end of ty_kna1. data : lt_kna1 type table of ty_kna1, ls_kna1 type ty_kna1. types : begin of ty_knbk, kunnr type knbk-kunnr, banks type knbk-banks, bankl type knbk-bankl, bankn type knbk-bankn, end of ty_knbk. data : lt_knbk type table of ty_knbk, ls_knbk type ty_knbk. data lv_id(3) type c. data lv_rowid(2) type n. data lv_fname type bdcdata-fnam. * End of Custom changes start-of-selection. * begin of custom changes CALL FUNCTION 'GUI_UPLOAD' EXPORTING filename tables data_tab

= 'c:\cstbank.txt' = lt_legacy[].

if lt_legacy[] is not initial. loop at lt_legacy into ls_legacy. lv_id = ls_legacy-str+0(3). if lv_id = 'CST'. split ls_legacy-str at ',' into lv_id ls_kna1-kunnr ls_kna1-name1 ls_kna1-sortl ls_kna1-stras ls_kna1-land1 ls_kna1-spras. append ls_kna1 to lt_kna1. elseif lv_id = 'BNK'. split ls_legacy-str at ',' into lv_id ls_knbk-kunnr ls_knbk-banks ls_knbk-bankl ls_knbk-bankn. append ls_knbk to lt_knbk. endif. 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 bdc_field bdc_field bdc_dynpro bdc_field using 'SAPMF02D' '0100'. using 'BDC_CURSOR' 'RF02D-KTOKD'. using 'BDC_OKCODE' '/00'. using 'RF02D-KUNNR' ls_kna1-kunnr. record-KUNNR_001. using 'RF02D-KTOKD' '0004'. record-KTOKD_002. using 'SAPMF02D' '0110'. using 'BDC_CURSOR' 'KNA1-SPRAS'. using 'BDC_OKCODE' '/00'. using 'KNA1-NAME1' ls_kna1-name1. record-NAME1_003. using 'KNA1-SORTL' ls_kna1-sortl. record-SORTL_004. using 'KNA1-STRAS' ls_kna1-stras. record-STRAS_005. using 'KNA1-LAND1' ls_kna1-land1. record-LAND1_006. using 'KNA1-SPRAS' ls_kna1-spras. record-SPRAS_007. using 'SAPMF02D' '0120'. using 'BDC_CURSOR' 'KNA1-LIFNR'. using 'BDC_OKCODE' '/00'. using 'SAPMF02D' '0125'. using 'BDC_CURSOR' 'KNA1-NIELS'. using 'BDC_OKCODE' '/00'. using 'SAPMF02D' '0130'. using 'BDC_CURSOR' 'KNBK-BANKN(01)'. using 'BDC_OKCODE' '=ENTR'.

perform bdc_field perform * perform * perform * perform * perform * perform perform bdc_field bdc_field bdc_field bdc_field bdc_field bdc_dynpro bdc_field

perform bdc_field perform bdc_dynpro perform bdc_field perform bdc_field perform bdc_dynpro perform bdc_field perform bdc_field

clear lv_rowid. loop at lt_knbk into ls_knbk where kunnr = ls_kna1-kunnr. lv_rowid = lv_rowid + 1.

clear lv_fname. concatenate 'KNBK-BANKS(' LV_ROWID ')' into lv_fname. *perform bdc_field using 'KNBK-BANKS(01)' * record-BANKS_01_008. perform bdc_field using lv_fname ls_knbk-banks. clear lv_fname. concatenate 'KNBK-BANKL(' LV_ROWID ')' into lv_fname. *perform bdc_field using 'KNBK-BANKL(01)' * record-BANKL_01_009. perform bdc_field using lv_fname ls_knbk-bankl. clear lv_fname. concatenate 'KNBK-BANKN(' LV_ROWID ')' into lv_fname. *perform bdc_field using 'KNBK-BANKN(01)' * record-BANKN_01_010. perform bdc_field using lv_fname ls_knbk-bankn. endloop. perform bdc_dynpro perform bdc_field using 'SAPMF02D' '0130'. using 'BDC_CURSOR' 'KNBK-BANKS(01)'. perform bdc_field using 'BDC_OKCODE' '=UPDA'. perform bdc_transaction using 'XD01'. *enddo. endloop. perform close_group. *perform close_dataset using dataset.

Program160
REPORT

Z730PROG160.

type-pools truxs. types : begin of ty_excel, matnr type mara-matnr, mbrsh type mara-mbrsh, mtart type mara-mtart, maktx type makt-maktx, meins type mara-meins, end of ty_excel. data : lt_excel type table of ty_excel, ls_excel type ty_excel. data lt_truxs type TRUXS_T_TEXT_DATA. CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP' EXPORTING I_FIELD_SEPERATOR = 'X' I_LINE_HEADER = 'X' i_tab_raw_data = lt_truxs[] i_filename = 'c:\material.xls' tables

i_tab_converted_data

= lt_excel.

if lt_excel[] is not initial. describe table lt_excel. write :/ 'Records :',sy-tfill. loop at lt_excel into ls_excel. write :/ ls_excel-matnr, ls_excel-mbrsh, ls_excel-mtart, ls_excel-maktx, ls_excel-meins. endloop. endif.

Program161
REPORT

Z730PROG161.

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_dept. include structure z830_dept. types end of ty_dept. data : lt_dept type table of ty_dept, ls_dept type ty_dept. types : begin of ty_emp. include structure z830_emp. types end of ty_emp. data : lt_emp type table of ty_emp, ls_emp type ty_emp. 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. * Processing of first transaction * Read data from dept file CALL FUNCTION 'GUI_UPLOAD' EXPORTING filename = 'c:\dept.txt' tables data_tab = lt_legacy[]. * Transfer dept data to final internal table loop at lt_legacy into ls_legacy. split ls_legacy-str at ',' into

ls_dept-deptno ls_dept-dname ls_dept-loc. append ls_dept to lt_dept. endloop. * Create the session object CALL FUNCTION 'BDC_OPEN_GROUP' EXPORTING CLIENT = GROUP = KEEP = USER =

SY-MANDT 'S50' 'X' sy-uname.

* Map the dept to BDCDATA internal table loop at lt_dept into ls_dept. * Map program infor perform prginfo using 'Z730PROG162' '100'. * Map each field info perform fldinfo using 'Z830_DEPT-DEPTNO' ls_dept-deptno. perform fldinfo using 'Z830_DEPT-DNAME' ls_dept-dname. perform fldinfo using 'Z830_DEPT-LOC' ls_dept-loc. * Map BDCDATA to session object CALL FUNCTION 'BDC_INSERT' EXPORTING TCODE = 'Z162' TABLES dynprotab = lt_bdcdata[]. endloop. * Processing of second transaction * Read data from emp file refresh lt_legacy. CALL FUNCTION 'GUI_UPLOAD' EXPORTING filename = 'c:\emp.txt' tables data_tab = lt_legacy[]. * Transfer emp data to final internal table loop at lt_legacy into ls_legacy. split ls_legacy-str at ',' into ls_emp-empno ls_emp-ename ls_emp-empdesig ls_emp-deptno. append ls_emp to lt_emp. endloop. * Map the emp data to BDCDATA internal table refresh lt_bdcdata. loop at lt_emp into ls_emp. * Map program info perform prginfo using 'Z730PROG163' '200'. * Map each field info perform fldinfo using 'Z830_EMP-EMPNO' ls_emp-empno. perform fldinfo using 'Z830_EMP-ENAME' ls_emp-ename.

perform fldinfo using 'Z830_EMP-EMPDESIG' ls_emp-empdesig. perform fldinfo using 'Z830_EMP-DEPTNO' ls_emp-deptno. * Map BDCDATA to session object CALL FUNCTION 'BDC_INSERT' EXPORTING TCODE = 'Z163' 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 fname fvalue. clear ls_bdcdata. ls_bdcdata-fnam = fname. ls_bdcdata-fval = fvalue. append ls_bdcdata to lt_bdcdata. endform.

Program162

program z730prog162. tables z830_dept. module user_command_0100 input. case sy-ucomm. when 'P1'. insert z830_dept. if sy-subrc eq 0. message 'Inserted' type 'I'. else. message 'Not inserted' type 'I'. endif. leave program. when 'P2'. leave program. endcase. endmodule. " USER_COMMAND_0100

INPUT

Program163

program z730prog163. tables : z830_emp. module user_command_0200 input. case sy-ucomm. when 'P1'. insert z830_emp. if sy-subrc eq 0. message 'Inserted' type 'I'. else. message 'Not inserted' type 'I'. endif. leave program. when 'P2'. leave program. endcase. endmodule. " USER_COMMAND_0200

INPUT

Program164
REPORT

Z730PROG164.

types : begin of ty_emp. include structure z830_emp. types end of ty_emp.

data ls_emp type ty_emp. ls_emp-empno = 45. ls_emp-ename = 'Ramesh Kiran'. ls_emp-empdesig = 'CEO'. ls_emp-deptno = 90. insert z830_emp from ls_emp.

Program165
REPORT Z730PROG165.

CALL FUNCTION 'OPEN_FORM' EXPORTING FORM LANGUAGE CALL FUNCTION 'WRITE_FORM' EXPORTING WINDOW

= 'Z830FORM1' = SY-LANGU.

= 'MAIN'.

Program166
REPORT

Z730PROG166.

CALL FUNCTION 'OPEN_FORM' EXPORTING FORM LANGUAGE CALL FUNCTION 'WRITE_FORM' EXPORTING WINDOW CALL FUNCTION 'CLOSE_FORM'.

= 'Z830FORM1' = SY-LANGU.

= 'MAIN'.

Program167
REPORT Z730PROG167.

CALL FUNCTION 'OPEN_FORM' EXPORTING FORM LANGUAGE CALL FUNCTION 'WRITE_FORM' EXPORTING WINDOW CALL FUNCTION 'CLOSE_FORM'.

= 'Z830FORM2' = SY-LANGU.

= 'MAIN'.

Program168
REPORT

Z730PROG168.

CALL FUNCTION 'OPEN_FORM' EXPORTING FORM LANGUAGE

= 'Z830FORM2' = SY-LANGU.

CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT WINDOW CALL FUNCTION 'CLOSE_FORM'.

= 'E1' = 'MAIN'.

Program169
REPORT

Z730PROG169.

CALL FUNCTION 'OPEN_FORM' EXPORTING FORM LANGUAGE CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT WINDOW CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT WINDOW CALL FUNCTION 'CLOSE_FORM'.

= 'Z830FORM2' = SY-LANGU.

= 'E2' = 'MAIN'.

= 'E1' = 'MAIN'.

Program170
REPORT

Z730PROG170.

CALL FUNCTION 'OPEN_FORM'. CALL FUNCTION 'START_FORM' EXPORTING FORM = 'Z830FORM1' LANGUAGE = sy-langu. CALL FUNCTION 'WRITE_FORM' EXPORTING WINDOW CALL FUNCTION 'END_FORM'. CALL FUNCTION 'START_FORM' EXPORTING FORM = 'Z830FORM2' LANGUAGE = sy-langu. CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT WINDOW CALL FUNCTION 'WRITE_FORM' EXPORTING

= 'MAIN'.

= 'E1' = 'MAIN'.

ELEMENT WINDOW CALL FUNCTION 'END_FORM'. CALL FUNCTION 'CLOSE_FORM'.

= 'E2' = 'MAIN'.

Program171
REPORT Z730PROG171. parameters p_lang type t002-spras. CALL FUNCTION 'OPEN_FORM' EXPORTING FORM LANGUAGE CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT WINDOW CALL FUNCTION 'CLOSE_FORM'.

= 'Z830FORM3' = p_lang.

= 'E1' = 'MAIN'.

Program172

REPORT

Z730PROG172.

types : begin of ty_kna1, name1 type kna1-name1, end of ty_kna1. data : lt_kna1 type table of ty_kna1, ls_kna1 type ty_kna1. CALL FUNCTION 'OPEN_FORM' EXPORTING FORM LANGUAGE CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT WINDOW CALL FUNCTION 'WRITE_FORM'

= 'Z830FORM4' = SY-LANGU.

= 'E1' = 'WINDOW2'.

EXPORTING ELEMENT WINDOW

= 'E1' = 'WINDOW1'.

select name1 from kna1 into table lt_kna1. if sy-subrc eq 0. loop at lt_kna1 into ls_kna1. CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT = 'E1' WINDOW = 'MAIN'. endloop. endif. CALL FUNCTION 'CLOSE_FORM'.
Program173
REPORT Z730PROG173. types : begin of ty_lines. include structure tline. types end of ty_lines. data : lt_lines type table of ty_lines, ls_lines type ty_lines. types : begin of ty_kna1, kunnr type kna1-kunnr, 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_head. include structure thead. types end of ty_head. data ls_head type ty_head. * Read the standard text CALL FUNCTION 'READ_TEXT' EXPORTING CLIENT id language name object

= = = = =

SY-MANDT 'ST' sy-langu 'Z830TEXT' 'TEXT'

tables lines

= lt_lines[].

if lt_lines[] is not initial. select kunnr name1 from kna1 into table lt_kna1 where land1 = 'IN'. endif. if lt_kna1[] is not initial. loop at lt_kna1 into ls_kna1. clear : ls_lines. ls_lines-tdformat = '*'. concatenate ls_kna1-kunnr ls_kna1-name1 into ls_lines-tdline separated by '@'. append ls_lines to lt_lines. clear ls_kna1. endloop. * Prepare header info. clear ls_head. ls_head-tdobject = 'TEXT'. ls_head-tdname = 'Z830TEXT'. ls_head-tdid = 'ST'. ls_head-tdspras = sy-langu. * WRITE THE TEXT to standard text CALL FUNCTION 'SAVE_TEXT' EXPORTING CLIENT = SY-MANDT header = ls_head tables lines = lt_lines[]. endif.

Program174
REPORT

Z730PROG174.

CALL FUNCTION 'OPEN_FORM' EXPORTING FORM LANGUAGE CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT WINDOW CALL FUNCTION 'CLOSE_FORM'.

= 'Z830FORM5' = SY-LANGU.

= 'E1' = 'MAIN'.

Program175

report z730prog175. call function '/1BCDWB/SF00000567'.


Program176
report z730prog176.

data lv_fname type rs38l_fnam. call function 'SSF_FUNCTION_MODULE_NAME' exporting formname = 'Z830SFORM1' importing fm_name = lv_fname. call function lv_fname.

Program177
report z730prog177. data lv_fname type rs38l_fnam. call function 'SSF_FUNCTION_MODULE_NAME' exporting formname = 'Z830SFORM2' importing fm_name = lv_fname. call function lv_fname.

Program178
report z730prog178. data lv_fname type rs38l_fnam. parameters p_vbeln type vbap-vbeln. call function 'SSF_FUNCTION_MODULE_NAME' exporting formname = 'Z830SFORM2' importing fm_name = lv_fname. call function lv_fname exporting i_vbeln = p_vbeln.

Program179
report

z730prog179.

data lv_vbeln type vbeln. select-options so_vbeln for lv_vbeln. data lv_fname type rs38l_fnam. 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. select vbeln posnr matnr from vbap into table lt_vbap

where vbeln in so_vbeln. if sy-subrc eq 0. call function 'SSF_FUNCTION_MODULE_NAME' exporting formname = 'Z830SFORM3' importing fm_name = lv_fname. call function lv_fname tables t_vbap = lt_vbap[]. endif.

Program180
REPORT Z730PROG180. * Get the smartform function module data lv_fname type rs38l_fnam. call function 'SSF_FUNCTION_MODULE_NAME' exporting formname = 'Z830SFORM5' importing fm_name = lv_fname. * Prepare control parameters to supress display of smartform data ls_ctrl_param type SSFCTRLOP. ls_ctrl_param-no_dialog = 'X'. *ls_ctrl_param-preview = ' '. ls_ctrl_param-getotf = 'X'. * structure for holding otf data data ls_job_out_info type SSFCRESCL. * Call the smartform function module call function lv_fname exporting CONTROL_PARAMETERS = ls_ctrl_param importing JOB_OUTPUT_INFO = ls_job_out_info. * Extract the OTF data types : begin of ty_itcoo. include structure itcoo. types end of ty_itcoo. data : lt_itcoo type table of ty_itcoo. lt_itcoo[] = ls_job_out_info-otfdata[]. * call the function module convert_otf data lv_binfilesize type i. types : begin of ty_lines. include structure tline. types end of ty_lines.

data : lt_lines type table of ty_lines. call function 'CONVERT_OTF' exporting format max_linewidth importing bin_filesize tables otf lines

= 'PDF' = 132 = lv_binfilesize = lt_itcoo[] = lt_lines[].

* Call the function module gui_download * to convert otf format to PDF file call function 'GUI_DOWNLOAD' exporting bin_filesize = lv_binfilesize filename = 'c:\8.pdf filetype = 'BIN'. tables data_tab = lt_lines[].

Program181
REPORT Z730PROG181. data lv_fname type rs38l_fnam. parameters : p_vbeln type vbak-vbeln, p_flag type c. CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING formname = 'Z830SFORM8' IMPORTING FM_NAME = lv_fname. call function lv_fname exporting i_vbeln = p_vbeln i_flag = p_flag.

Program182
report

z730prog182.

parameters : p_vbeln type vbrk-vbeln. types : begin of ty_vbrk. include structure zmyvbrk. types end of ty_vbrk. data gs_vbrk type ty_vbrk. types : begin of ty_vbrp. include structure zmyvbrp. types end of ty_vbrp. data : gt_vbrp type table of ty_vbrp.

data lv_fname type rs38l_fnam. select single vbeln vkorg fkdat from vbrk into gs_vbrk where vbeln = p_vbeln. if sy-subrc eq 0. select posnr arktx fkimg netwr from vbrp into table gt_vbrp where vbeln = p_vbeln. endif. if gt_vbrp[] is not initial. call function 'SSF_FUNCTION_MODULE_NAME' exporting formname = 'Z830SFORM10' importing fm_name = lv_fname. call function lv_fname exporting ls_vbrk = gs_vbrk tables lt_vbrp = gt_vbrp[]. endif.

Program183
REPORT

Z730PROG183.

data lv_vbeln type vbak-vbeln. select-options so_vbeln for lv_vbeln. data lv_fname type rs38l_fnam. start-of-selection. CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING formname = 'Z830SFORM13' IMPORTING FM_NAME = lv_fname. call function lv_fname tables lt_vbeln = so_vbeln.

Program184
REPORT Z730PROG184. parameters name(20) type c. CALL FUNCTION 'OPEN_FORM' EXPORTING FORM LANGUAGE CALL FUNCTION 'WRITE_FORM'

= 'Z830FORM6' = SY-LANGU.

EXPORTING ELEMENT WINDOW CALL FUNCTION 'CLOSE_FORM'.

= 'E1' = 'MAIN'.

Program185

S-ar putea să vă placă și