Escolar Documentos
Profissional Documentos
Cultura Documentos
Title:
Author:
Date:
Version:
SAP Version:
Introduction.
This document details the procedures available within a series of include files called YRBINC, YREPINC,
YBDCINC and YGRAPH. They are common utilities for Reporting utilities, BDC utilities and Graphing utilities
respectively.
These routines are written so that the maintenance aspect of using them within any program is minimal. Parameters
are passed to and from the routines using arguments to the procedure call. This eliminates the need to know the
internal structure of the various routines providing Black Box programming.
The following pages of this document detail one routine per page.
Table Of Contents
1. ABOUT THIS DOCUMENT...........................................................................................................20
1.1. PROCEDURE FORMAT..................................................................................................................20
1.2. RUNNING THE MACRO.................................................................................................................22
2. USING THE ROUTINES.................................................................................................................23
3. DEPENDANCIES..............................................................................................................................27
4. BDC OPERATIONS.........................................................................................................................28
4.1. MANDT................................................................................................................................28
4.2. FUNCNAME.........................................................................................................................28
4.3. BDCMODE. .........................................................................................................................28
4.4. BDCUPMODE......................................................................................................................28
4.5. CRBATCH............................................................................................................................28
4.6. INHIBITCHK........................................................................................................................28
4.7. DUMPBDC...........................................................................................................................29
4.8. DUMPMSG...........................................................................................................................29
4.9. GENMAIL............................................................................................................................29
4.10. MAILPROG........................................................................................................................29
5. MACROS AND FORMS..................................................................................................................30
5.1. AN EXAMPLE............................................................................................................................30
6. DRILL DOWN REPORTS...............................................................................................................32
7. ARRAYS.............................................................................................................................................33
7.1. TABLES WITHIN TABLES .............................................................................................................33
7.1.1. Defining An Array.................................................................................................................33
7.1.2. Accessing An Array...............................................................................................................33
8. SELECT-OPTIONS..........................................................................................................................35
9. AUTHORISATION CHECKS.........................................................................................................36
10. SUB-TOTALS..................................................................................................................................37
11. REAL-TIME DISPLAYS...............................................................................................................38
11.1. PUSHING KEYS IN ABAP........................................................................................................38
12. INFORMATION SOURCES........................................................................................................39
Page 1
Page 2
16.11. SOURCECODE........................................................................................................................47
16.12. SEE ALSO............................................................................................................................47
17. RADIOLEFT, RADIORIGHT - MACRO....................................................................................48
17.1. LOCATION..............................................................................................................................48
17.2. PURPOSE................................................................................................................................48
17.3. ENTRY...................................................................................................................................48
17.3.1. Position...............................................................................................................................48
17.3.2. Title Length.........................................................................................................................48
17.3.3. Title.....................................................................................................................................48
17.3.4. Parameter............................................................................................................................48
17.3.5. Group.................................................................................................................................48
17.4. EXIT.....................................................................................................................................48
17.5. CALLED BY............................................................................................................................48
17.6. CALLS ...................................................................................................................................48
17.7. TABLES ..................................................................................................................................48
17.8. SYSTEM VARIABLES .................................................................................................................48
17.9. DESCRIPTION...........................................................................................................................48
17.10. EXAMPLES ............................................................................................................................48
17.11. SOURCECODE........................................................................................................................49
17.12. SEE ALSO............................................................................................................................49
18. COPYBOOK - MACRO.................................................................................................................50
18.1. LOCATION..............................................................................................................................50
18.2. PURPOSE................................................................................................................................50
18.3. ENTRY...................................................................................................................................50
18.3.1. Table name to use..............................................................................................................50
18.4. EXIT.....................................................................................................................................50
18.5. CALLED BY............................................................................................................................50
18.6. CALLS ...................................................................................................................................50
18.7. TABLES ..................................................................................................................................50
18.8. SYSTEM VARIABLES .................................................................................................................50
18.9. DESCRIPTION...........................................................................................................................50
18.10. EXAMPLES ............................................................................................................................50
18.11. SOURCECODE........................................................................................................................50
18.12. SEE ALSO............................................................................................................................51
19. COPY_STRUCTURE - MACRO..................................................................................................52
19.1. LOCATION..............................................................................................................................52
19.2. PURPOSE................................................................................................................................52
19.3. ENTRY...................................................................................................................................52
19.3.1. Structure Name to extract from the data dictionary..........................................................52
19.3.2. Internal table name to copy strcuture to............................................................................52
19.4. EXIT.....................................................................................................................................52
19.5. CALLED BY............................................................................................................................52
19.6. CALLS ...................................................................................................................................52
19.7. TABLES ..................................................................................................................................52
19.8. SYSTEM VARIABLES .................................................................................................................52
19.9. DESCRIPTION...........................................................................................................................52
19.10. EXAMPLES ............................................................................................................................52
19.11. SOURCECODE........................................................................................................................52
19.12. SEE ALSO............................................................................................................................53
20. END_OF_REPORT - MACRO.....................................................................................................54
20.1. LOCATION..............................................................................................................................54
20.2. PURPOSE................................................................................................................................54
20.3. ENTRY...................................................................................................................................54
20.3.1. Select option table to use....................................................................................................54
20.3.2. Title for this selection block...............................................................................................54
20.4. EXIT.....................................................................................................................................54
20.4.1. Report Footer printed.........................................................................................................54
20.5. CALLED BY............................................................................................................................54
Page 3
Page 4
Page 5
28.4. EXIT.....................................................................................................................................77
28.5. CALLED BY............................................................................................................................77
28.6. CALLS ...................................................................................................................................77
28.7. TABLES ..................................................................................................................................77
28.8. SYSTEM VARIABLES .................................................................................................................77
28.9. DESCRIPTION...........................................................................................................................77
28.10. EXAMPLES ............................................................................................................................78
28.11. SOURCECODE........................................................................................................................78
28.12. SEE ALSO............................................................................................................................80
31. CENTREREPORT..........................................................................................................................81
31.1. LOCATION..............................................................................................................................81
31.2. PURPOSE................................................................................................................................81
31.3. ENTRY...................................................................................................................................81
31.3.1. True or False.......................................................................................................................81
31.4. EXIT.....................................................................................................................................81
31.5. CALLED BY............................................................................................................................81
31.6. CALLS ...................................................................................................................................81
31.7. TABLES ..................................................................................................................................81
31.8. SYSTEM VARIABLES .................................................................................................................81
31.9. DESCRIPTION...........................................................................................................................81
31.10. EXAMPLES ............................................................................................................................81
31.11. SOURCECODE........................................................................................................................81
31.12. SEE ALSO............................................................................................................................82
32. CHECKBOX....................................................................................................................................83
32.1. LOCATION..............................................................................................................................83
32.2. PURPOSE................................................................................................................................83
32.3. ENTRY...................................................................................................................................83
32.3.1. Data-field table...................................................................................................................83
32.3.2. Data field title.....................................................................................................................83
32.3.3. Data field length.................................................................................................................83
32.4. EXIT.....................................................................................................................................83
32.5. CALLED BY............................................................................................................................83
32.6. CALLS ...................................................................................................................................83
32.7. TABLES ..................................................................................................................................83
32.8. SYSTEM VARIABLES .................................................................................................................83
32.9. DESCRIPTION...........................................................................................................................84
32.10. EXAMPLES ............................................................................................................................84
32.11. SOURCECODE........................................................................................................................84
32.12. SEE ALSO............................................................................................................................85
33. CHECKBREAKS............................................................................................................................86
33.1. LOCATION..............................................................................................................................86
33.2. PURPOSE................................................................................................................................86
33.3. ENTRY...................................................................................................................................86
33.4. EXIT.....................................................................................................................................86
33.5. CALLED BY............................................................................................................................86
33.6. CALLS ...................................................................................................................................86
33.7. TABLES ..................................................................................................................................86
33.8. SYSTEM VARIABLES .................................................................................................................86
33.9. DESCRIPTION...........................................................................................................................86
33.10. EXAMPLES ............................................................................................................................86
33.11. SOURCECODE........................................................................................................................86
33.12. SEE ALSO............................................................................................................................88
34. CHECK_DOMAIN_VALUES.......................................................................................................89
34.1. LOCATION..............................................................................................................................89
34.2. PURPOSE................................................................................................................................89
34.3. ENTRY...................................................................................................................................89
34.3.1. Domain Name To Check....................................................................................................89
34.3.2. Value To Check..................................................................................................................89
Page 6
34.4. EXIT.....................................................................................................................................89
34.5. CALLED BY............................................................................................................................89
34.6. CALLS ...................................................................................................................................89
34.7. TABLES ..................................................................................................................................89
34.8. SYSTEM VARIABLES .................................................................................................................89
34.9. DESCRIPTION...........................................................................................................................89
34.10. EXAMPLES ............................................................................................................................89
34.11. SOURCECODE........................................................................................................................89
34.12. SEE ALSO............................................................................................................................90
35. COLUMN_COLOUR.....................................................................................................................91
35.1. LOCATION..............................................................................................................................91
35.2. PURPOSE................................................................................................................................91
35.3. ENTRY...................................................................................................................................91
35.3.1. Column width......................................................................................................................91
35.3.2. Colour to set........................................................................................................................91
35.3.3. Value to write......................................................................................................................91
35.3.4. Actual colour code to use...................................................................................................91
35.4. EXIT.....................................................................................................................................91
35.5. CALLED BY............................................................................................................................91
35.6. CALLS ...................................................................................................................................91
35.7. TABLES ..................................................................................................................................91
35.8. SYSTEM VARIABLES .................................................................................................................91
35.9. DESCRIPTION...........................................................................................................................91
35.10. EXAMPLES ............................................................................................................................91
35.11. SOURCECODE........................................................................................................................91
35.12. SEE ALSO............................................................................................................................92
36. DUMP_TABLE................................................................................................................................93
36.1. LOCATION..............................................................................................................................93
36.2. PURPOSE................................................................................................................................93
36.3. ENTRY...................................................................................................................................93
36.3.1. None....................................................................................................................................93
36.3.2. Tables:
Unstructured table for dump........................................................................93
36.4. EXIT.....................................................................................................................................93
36.4.1. None....................................................................................................................................93
36.5. CALLED BY............................................................................................................................93
36.6. CALLS ...................................................................................................................................93
36.7. TABLES ..................................................................................................................................93
36.8. SYSTEM VARIABLES .................................................................................................................93
36.9. DESCRIPTION...........................................................................................................................93
36.10. EXAMPLES ............................................................................................................................93
36.11. SOURCECODE........................................................................................................................93
36.12. SEE ALSO............................................................................................................................94
37. FIRSTCOL.......................................................................................................................................95
37.1. LOCATION..............................................................................................................................95
37.2. PURPOSE................................................................................................................................95
37.3. ENTRY...................................................................................................................................95
37.3.1. Direction to move the first column of the report..............................................................95
37.4. EXIT.....................................................................................................................................95
37.5. CALLED BY............................................................................................................................95
37.6. CALLS ...................................................................................................................................95
37.7. TABLES ..................................................................................................................................95
37.8. SYSTEM VARIABLES .................................................................................................................95
37.9. DESCRIPTION...........................................................................................................................95
37.10. EXAMPLES ............................................................................................................................95
37.11. SOURCECODE........................................................................................................................95
37.12. SEE ALSO............................................................................................................................96
38. FORMATKEY.................................................................................................................................97
38.1. LOCATION..............................................................................................................................97
Page 7
38.2. PURPOSE................................................................................................................................97
38.3. ENTRY...................................................................................................................................97
38.3.1. Value to format...................................................................................................................97
38.4. EXIT.....................................................................................................................................97
38.4.1. Formatted value..................................................................................................................97
38.5. CALLED BY............................................................................................................................97
38.6. CALLS ...................................................................................................................................97
38.7. TABLES ..................................................................................................................................97
38.8. SYSTEM VARIABLES .................................................................................................................97
38.9. DESCRIPTION...........................................................................................................................97
38.10. EXAMPLES ............................................................................................................................97
38.11. SOURCECODE........................................................................................................................97
38.12. SEE ALSO............................................................................................................................98
39. FORMATREPORT.........................................................................................................................99
39.1. LOCATION..............................................................................................................................99
39.2. PURPOSE................................................................................................................................99
39.3. ENTRY...................................................................................................................................99
39.4. EXIT.....................................................................................................................................99
39.5. CALLED BY............................................................................................................................99
39.6. CALLS ...................................................................................................................................99
39.7. TABLES ..................................................................................................................................99
39.8. SYSTEM VARIABLES .................................................................................................................99
39.9. DESCRIPTION...........................................................................................................................99
39.10. EXAMPLES ............................................................................................................................99
39.11. SOURCECODE........................................................................................................................99
39.12. SEE ALSO..........................................................................................................................100
40. GETMASK.....................................................................................................................................102
40.1. LOCATION............................................................................................................................102
40.2. PURPOSE..............................................................................................................................102
40.3. ENTRY.................................................................................................................................102
40.3.1. Variable or literal mask....................................................................................................102
40.4. EXIT....................................................................................................................................102
40.4.1. Actual mask to use............................................................................................................102
40.5. CALLED BY..........................................................................................................................102
40.6. CALLS .................................................................................................................................102
40.7. TABLES ................................................................................................................................102
40.8. SYSTEM VARIABLES ...............................................................................................................102
40.9. DESCRIPTION.........................................................................................................................102
40.10. EXAMPLES ..........................................................................................................................102
40.11. SOURCECODE......................................................................................................................103
40.12. SEE ALSO..........................................................................................................................103
41. GET_LOCAL_HOST...................................................................................................................104
41.1. LOCATION............................................................................................................................104
41.2. PURPOSE..............................................................................................................................104
41.3. ENTRY.................................................................................................................................104
41.4. EXIT....................................................................................................................................104
41.4.1. Host Name.........................................................................................................................104
41.4.2. Server Name......................................................................................................................104
41.5. CALLED BY..........................................................................................................................104
41.6. CALLS .................................................................................................................................104
41.7. TABLES ................................................................................................................................104
41.8. SYSTEM VARIABLES ...............................................................................................................104
41.9. DESCRIPTION.........................................................................................................................104
41.10. EXAMPLES ..........................................................................................................................104
41.11. SOURCECODE......................................................................................................................104
41.12. SEE ALSO..........................................................................................................................105
42. GIVELINE.....................................................................................................................................106
42.1. LOCATION............................................................................................................................106
Page 8
42.2. PURPOSE..............................................................................................................................106
42.3. ENTRY.................................................................................................................................106
42.3.1. Line Number of required line in text................................................................................106
42.3.2. Width of column................................................................................................................106
42.3.3. Text to split........................................................................................................................106
42.4. EXIT....................................................................................................................................106
42.4.1. Line N ...............................................................................................................................106
42.5. CALLED BY..........................................................................................................................106
42.6. CALLS .................................................................................................................................106
42.7. TABLES ................................................................................................................................106
42.8. SYSTEM VARIABLES ...............................................................................................................106
42.9. DESCRIPTION.........................................................................................................................106
42.10. EXAMPLES ..........................................................................................................................106
42.11. SOURCECODE......................................................................................................................106
42.12. SEE ALSO..........................................................................................................................107
43. ICON, SYMBOL OR GRAPHIC...............................................................................................108
43.1. LOCATION............................................................................................................................108
43.2. PURPOSE..............................................................................................................................108
43.3. ENTRY.................................................................................................................................108
43.3.1. Icon: Icon Name to print................................................................................................108
43.3.2. Symbol: Symbol Name to print.......................................................................................108
43.3.3. Graphic: Icon/symbol name, name type........................................................................108
43.4. EXIT....................................................................................................................................108
43.4.1. None..................................................................................................................................108
43.5. CALLED BY..........................................................................................................................108
43.6. CALLS .................................................................................................................................108
43.7. TABLES ................................................................................................................................108
43.8. SYSTEM VARIABLES ...............................................................................................................108
43.9. DESCRIPTION.........................................................................................................................108
43.10. EXAMPLES ..........................................................................................................................109
43.11. SOURCECODE......................................................................................................................109
43.12. SEE ALSO..........................................................................................................................110
44. GROUPHEADER..........................................................................................................................111
44.1. LOCATION............................................................................................................................111
44.2. PURPOSE..............................................................................................................................111
44.3. ENTRY.................................................................................................................................111
44.3.1. Group Header Title..........................................................................................................111
44.3.2. Group Header Value........................................................................................................111
44.4. EXIT....................................................................................................................................111
44.5. CALLED BY..........................................................................................................................111
44.6. CALLS .................................................................................................................................111
44.7. TABLES ................................................................................................................................111
44.8. SYSTEM VARIABLES ...............................................................................................................111
44.9. DESCRIPTION.........................................................................................................................111
44.10. EXAMPLES ..........................................................................................................................112
44.11. SOURCECODE......................................................................................................................112
44.12. SEE ALSO..........................................................................................................................113
45. INITBREAK...................................................................................................................................114
45.1. LOCATION............................................................................................................................114
45.2. PURPOSE..............................................................................................................................114
45.3. ENTRY.................................................................................................................................114
45.3.1. Field to break on...............................................................................................................114
45.3.2. Title of field.......................................................................................................................114
45.4. EXIT....................................................................................................................................114
45.5. CALLED BY..........................................................................................................................114
45.6. CALLS .................................................................................................................................114
45.7. TABLES ................................................................................................................................114
45.8. SYSTEM VARIABLES ...............................................................................................................114
45.9. DESCRIPTION.........................................................................................................................114
Page 9
Page 10
Page 11
54. REPHEADER................................................................................................................................135
54.1. LOCATION............................................................................................................................135
54.2. PURPOSE..............................................................................................................................135
54.3. ENTRY.................................................................................................................................135
54.3.1. Company Code..................................................................................................................135
54.3.2. Report Title.......................................................................................................................135
54.4. EXIT....................................................................................................................................135
54.4.1. Report header produced for current report.....................................................................135
54.5. CALLED BY..........................................................................................................................135
54.6. CALLS .................................................................................................................................135
54.7. TABLES ................................................................................................................................135
54.8. SYSTEM VARIABLES ...............................................................................................................135
54.9. DESCRIPTION.........................................................................................................................135
54.10. EXAMPLES ..........................................................................................................................135
54.11. SOURCECODE......................................................................................................................136
54.12. SEE ALSO..........................................................................................................................137
55. RUNTOTALS................................................................................................................................138
55.1. LOCATION............................................................................................................................138
55.2. PURPOSE..............................................................................................................................138
55.3. ENTRY.................................................................................................................................138
55.4. EXIT....................................................................................................................................138
55.5. CALLED BY..........................................................................................................................138
55.6. CALLS .................................................................................................................................138
55.7. TABLES ................................................................................................................................138
55.8. SYSTEM VARIABLES ...............................................................................................................138
55.9. DESCRIPTION.........................................................................................................................138
55.10. EXAMPLES ..........................................................................................................................138
55.11. SOURCECODE......................................................................................................................138
55.12. SEE ALSO..........................................................................................................................139
56. SAVEREPORT..............................................................................................................................140
56.1. LOCATION............................................................................................................................140
56.2. PURPOSE..............................................................................................................................140
56.3. ENTRY.................................................................................................................................140
56.3.1. Report Name.....................................................................................................................140
56.4. EXIT....................................................................................................................................140
56.5. CALLED BY..........................................................................................................................140
56.6. CALLS .................................................................................................................................140
56.7. TABLES ................................................................................................................................140
56.8. SYSTEM VARIABLES ...............................................................................................................140
56.9. DESCRIPTION.........................................................................................................................140
56.10. EXAMPLES ..........................................................................................................................140
56.11. SOURCECODE......................................................................................................................140
56.12. SEE ALSO..........................................................................................................................141
57. SETCOLOUR................................................................................................................................142
57.1. LOCATION............................................................................................................................142
57.2. PURPOSE..............................................................................................................................142
57.3. ENTRY.................................................................................................................................142
57.3.1. Colour to set......................................................................................................................142
57.4. EXIT....................................................................................................................................142
57.5. CALLED BY..........................................................................................................................142
57.6. CALLS .................................................................................................................................142
57.7. TABLES ................................................................................................................................142
57.8. SYSTEM VARIABLES ...............................................................................................................142
57.9. DESCRIPTION.........................................................................................................................142
57.10. EXAMPLES ..........................................................................................................................142
57.11. SOURCECODE......................................................................................................................142
57.12. SEE ALSO..........................................................................................................................143
58. SHOW_PROGRESS.....................................................................................................................144
Page 12
58.1. LOCATION............................................................................................................................144
58.2. PURPOSE..............................................................................................................................144
58.3. ENTRY.................................................................................................................................144
58.3.1. Message to display............................................................................................................144
58.4. EXIT....................................................................................................................................144
58.5. CALLED BY..........................................................................................................................144
58.6. CALLS .................................................................................................................................144
58.7. TABLES ................................................................................................................................144
58.8. SYSTEM VARIABLES ...............................................................................................................144
58.9. DESCRIPTION.........................................................................................................................144
58.10. EXAMPLES ..........................................................................................................................144
58.11. SOURCECODE......................................................................................................................144
58.12. SEE ALSO..........................................................................................................................145
59. SORTREP......................................................................................................................................146
59.1. LOCATION............................................................................................................................146
59.2. PURPOSE..............................................................................................................................146
59.3. ENTRY.................................................................................................................................146
59.3.1. Table to sort......................................................................................................................146
59.4. EXIT....................................................................................................................................146
59.4.1. Table Sorted......................................................................................................................146
59.4.2. Report column table sorted on..........................................................................................146
59.4.3. Sort direction 'A' or 'D'.....................................................................................................146
59.5. CALLED BY..........................................................................................................................146
59.6. CALLS .................................................................................................................................146
59.7. TABLES ................................................................................................................................146
59.8. SYSTEM VARIABLES ...............................................................................................................146
59.9. DESCRIPTION.........................................................................................................................146
59.10. EXAMPLES ..........................................................................................................................146
59.11. SOURCECODE......................................................................................................................147
59.12. SEE ALSO..........................................................................................................................148
60. STRIPSTRING..............................................................................................................................149
60.1. LOCATION............................................................................................................................149
60.2. PURPOSE..............................................................................................................................149
60.3. ENTRY.................................................................................................................................149
60.3.1. String to remove characters from.....................................................................................149
60.3.2. String of characters to remove.........................................................................................149
60.4. EXIT....................................................................................................................................149
60.4.1. Entry string with strip chars removed..............................................................................149
60.5. CALLED BY..........................................................................................................................149
60.6. CALLS .................................................................................................................................149
60.7. TABLES ................................................................................................................................149
60.8. SYSTEM VARIABLES ...............................................................................................................149
60.9. DESCRIPTION.........................................................................................................................149
60.10. EXAMPLES ..........................................................................................................................149
60.11. SOURCECODE......................................................................................................................149
60.12. SEE ALSO..........................................................................................................................150
61. SUBTITLES...................................................................................................................................151
61.1. LOCATION............................................................................................................................151
61.2. PURPOSE..............................................................................................................................151
61.3. ENTRY.................................................................................................................................151
61.4. EXIT....................................................................................................................................151
61.5. CALLED BY..........................................................................................................................151
61.6. CALLS .................................................................................................................................151
61.7. TABLES ................................................................................................................................151
61.8. SYSTEM VARIABLES ...............................................................................................................151
61.9. DESCRIPTION.........................................................................................................................151
61.10. EXAMPLES ..........................................................................................................................151
61.11. SOURCECODE......................................................................................................................151
61.12. SEE ALSO..........................................................................................................................152
Page 13
62. TABLELINE..................................................................................................................................153
62.1. LOCATION............................................................................................................................153
62.2. PURPOSE..............................................................................................................................153
62.3. ENTRY.................................................................................................................................153
62.4. EXIT....................................................................................................................................153
62.4.1. Global flag w__line printed set to true............................................................................153
62.5. CALLED BY..........................................................................................................................153
62.6. CALLS .................................................................................................................................153
62.7. TABLES ................................................................................................................................153
62.8. SYSTEM VARIABLES ...............................................................................................................153
62.9. DESCRIPTION.........................................................................................................................153
62.10. EXAMPLES ..........................................................................................................................153
62.11. SOURCECODE......................................................................................................................153
62.12. SEE ALSO..........................................................................................................................154
63. UNDERLINE.................................................................................................................................155
63.1. LOCATION............................................................................................................................155
63.2. PURPOSE..............................................................................................................................155
63.3. ENTRY.................................................................................................................................155
63.3.1. Start position.....................................................................................................................155
63.3.2. Width.................................................................................................................................155
63.4. EXIT....................................................................................................................................155
63.4.1. Global flag w__line printed set to true............................................................................155
63.5. CALLED BY..........................................................................................................................155
63.6. CALLS .................................................................................................................................155
63.7. TABLES ................................................................................................................................155
63.8. SYSTEM VARIABLES ...............................................................................................................155
63.9. DESCRIPTION.........................................................................................................................155
63.10. EXAMPLES ..........................................................................................................................155
63.11. SOURCECODE......................................................................................................................155
63.12. SEE ALSO..........................................................................................................................156
64. USEREPORT.................................................................................................................................157
64.1. LOCATION............................................................................................................................157
64.2. PURPOSE..............................................................................................................................157
64.3. ENTRY.................................................................................................................................157
64.3.1. Report Name.....................................................................................................................157
64.4. EXIT....................................................................................................................................157
64.5. CALLED BY..........................................................................................................................157
64.6. CALLS .................................................................................................................................157
64.7. TABLES ................................................................................................................................157
64.8. SYSTEM VARIABLES ...............................................................................................................157
64.9. DESCRIPTION.........................................................................................................................157
64.10. EXAMPLES ..........................................................................................................................157
64.11. SOURCECODE......................................................................................................................157
64.12. SEE ALSO..........................................................................................................................158
65. WLINE............................................................................................................................................159
65.1. LOCATION............................................................................................................................159
65.2. PURPOSE..............................................................................................................................159
65.3. ENTRY.................................................................................................................................159
65.3.1. Dataline to print................................................................................................................159
65.3.2. Colour of line....................................................................................................................159
65.4. EXIT....................................................................................................................................160
65.5. CALLED BY..........................................................................................................................160
65.6. CALLS .................................................................................................................................160
65.7. TABLES ................................................................................................................................160
65.8. SYSTEM VARIABLES ...............................................................................................................160
65.9. DESCRIPTION.........................................................................................................................160
65.10. EXAMPLES ..........................................................................................................................160
65.11. SOURCECODE......................................................................................................................160
65.12. SEE ALSO..........................................................................................................................161
Page 14
66. WRITECENTRE...........................................................................................................................162
66.1. LOCATION............................................................................................................................162
66.2. PURPOSE..............................................................................................................................162
66.3. ENTRY.................................................................................................................................162
66.3.1. Text to centre....................................................................................................................162
66.4. EXIT....................................................................................................................................162
66.5. CALLED BY..........................................................................................................................162
66.6. CALLS .................................................................................................................................162
66.7. TABLES ................................................................................................................................162
66.8. SYSTEM VARIABLES ...............................................................................................................162
66.9. DESCRIPTION.........................................................................................................................162
66.10. EXAMPLES ..........................................................................................................................162
66.11. SOURCECODE......................................................................................................................162
66.12. SEE ALSO..........................................................................................................................163
67. WRITECOL...................................................................................................................................164
67.1. LOCATION............................................................................................................................164
67.2. PURPOSE..............................................................................................................................164
67.3. ENTRY.................................................................................................................................164
67.3.1. Data line and column to print..........................................................................................164
67.3.2. Column to use...................................................................................................................164
67.4. EXIT....................................................................................................................................164
67.5. CALLED BY..........................................................................................................................164
67.6. CALLS .................................................................................................................................164
67.7. TABLES ................................................................................................................................164
67.8. SYSTEM VARIABLES ...............................................................................................................164
67.9. DESCRIPTION.........................................................................................................................164
67.10. EXAMPLES ..........................................................................................................................164
67.11. SOURCECODE......................................................................................................................164
67.12. SEE ALSO..........................................................................................................................165
68. WRITELINE..................................................................................................................................166
68.1. LOCATION............................................................................................................................166
68.2. PURPOSE..............................................................................................................................166
68.3. ENTRY.................................................................................................................................166
68.3.1. Table work area containing report data..........................................................................166
68.3.2. Colour to use to print the data in.....................................................................................166
68.4. EXIT....................................................................................................................................166
68.5. CALLED BY..........................................................................................................................166
68.6. CALLS .................................................................................................................................166
68.7. TABLES ................................................................................................................................166
68.8. SYSTEM VARIABLES ...............................................................................................................166
68.9. DESCRIPTION.........................................................................................................................166
68.10. EXAMPLES ..........................................................................................................................167
68.11. SOURCECODE......................................................................................................................167
68.12. SEE ALSO..........................................................................................................................169
69. WRITESYMBOL..........................................................................................................................170
69.1. LOCATION............................................................................................................................170
69.2. PURPOSE..............................................................................................................................170
69.3. ENTRY.................................................................................................................................170
69.3.1. Symbol name to use...........................................................................................................170
69.3.2. Hotspot flag.......................................................................................................................170
69.4. EXIT....................................................................................................................................170
69.5. CALLED BY..........................................................................................................................170
69.6. CALLS .................................................................................................................................170
69.7. TABLES ................................................................................................................................170
69.8. SYSTEM VARIABLES ...............................................................................................................170
69.9. DESCRIPTION.........................................................................................................................170
69.10. EXAMPLES ..........................................................................................................................170
69.11. SOURCECODE......................................................................................................................170
69.12. SEE ALSO..........................................................................................................................171
Page 15
70. WRITEVALUE..............................................................................................................................172
70.1. LOCATION............................................................................................................................172
70.2. PURPOSE..............................................................................................................................172
70.3. ENTRY.................................................................................................................................172
70.3.1. Width of output field.........................................................................................................172
70.3.2. Value to write....................................................................................................................172
70.3.3. Conversion exit routine.....................................................................................................172
70.3.4. Currency Field..................................................................................................................172
70.3.5. Unit field...........................................................................................................................172
70.3.6. Other Format field............................................................................................................172
70.4. EXIT....................................................................................................................................172
70.5. CALLED BY..........................................................................................................................172
70.6. CALLS .................................................................................................................................172
70.7. TABLES ................................................................................................................................173
70.8. SYSTEM VARIABLES ...............................................................................................................173
70.9. DESCRIPTION.........................................................................................................................173
70.10. EXAMPLES ..........................................................................................................................173
70.11. SOURCECODE......................................................................................................................173
70.12. SEE ALSO..........................................................................................................................174
71. ZBDC_BATCH_ON......................................................................................................................175
71.1. LOCATION............................................................................................................................175
71.2. PURPOSE..............................................................................................................................175
71.3. ENTRY.................................................................................................................................175
71.4. EXIT....................................................................................................................................175
71.5. CALLED BY..........................................................................................................................175
71.6. CALLS .................................................................................................................................175
71.7. TABLES ................................................................................................................................175
71.8. SYSTEM VARIABLES ...............................................................................................................175
71.9. DESCRIPTION.........................................................................................................................175
71.10. EXAMPLES ..........................................................................................................................175
71.11. SOURCECODE......................................................................................................................175
71.12. SEE ALSO..........................................................................................................................175
72. ZBDC_CLOSE_GROUP..............................................................................................................177
72.1. LOCATION............................................................................................................................177
72.2. PURPOSE..............................................................................................................................177
72.3. ENTRY.................................................................................................................................177
72.3.1. None..................................................................................................................................177
72.4. EXIT....................................................................................................................................177
72.4.1. Status 0 - Ok.....................................................................................................................177
72.5. CALLED BY..........................................................................................................................177
72.6. CALLS .................................................................................................................................177
72.7. TABLES ................................................................................................................................177
72.8. SYSTEM VARIABLES ...............................................................................................................177
72.9. DESCRIPTION.........................................................................................................................177
72.10. EXAMPLES ..........................................................................................................................177
72.11. SOURCECODE......................................................................................................................177
72.12. SEE ALSO..........................................................................................................................178
73. ZBDC_DUMP_ON........................................................................................................................179
73.1. LOCATION............................................................................................................................179
73.2. PURPOSE..............................................................................................................................179
73.3. ENTRY.................................................................................................................................179
73.3.1. None..................................................................................................................................179
73.4. EXIT....................................................................................................................................179
73.4.1. None..................................................................................................................................179
73.5. CALLED BY..........................................................................................................................179
73.6. CALLS .................................................................................................................................179
73.7. TABLES ................................................................................................................................179
73.8. SYSTEM VARIABLES ...............................................................................................................179
73.9. DESCRIPTION.........................................................................................................................179
Page 16
Page 17
Page 18
81.1. LOCATION............................................................................................................................199
81.2. PURPOSE..............................................................................................................................199
81.3. ENTRY.................................................................................................................................199
81.3.1. Transaction Code..............................................................................................................199
81.3.2. Mode..................................................................................................................................199
81.3.3. Update Type......................................................................................................................199
81.3.4. Table - p_messages - contains batch msgs.......................................................................199
81.4. EXIT....................................................................................................................................199
81.4.1. MsgId, Error and message if failed.................................................................................199
81.5. CALLED BY..........................................................................................................................199
81.6. CALLS .................................................................................................................................199
81.7. TABLES ................................................................................................................................199
81.8. SYSTEM VARIABLES ...............................................................................................................199
81.9. DESCRIPTION.........................................................................................................................200
81.10. EXAMPLES ..........................................................................................................................200
81.11. SOURCECODE......................................................................................................................200
81.12. SEE ALSO..........................................................................................................................202
82. Z_CALL_BDC...............................................................................................................................203
82.1. LOCATION............................................................................................................................203
82.2. PURPOSE..............................................................................................................................203
82.3. ENTRY.................................................................................................................................203
82.3.1. Message Table...................................................................................................................203
82.3.2. Transaction to use.............................................................................................................203
82.3.3. Table - p_messages - contains batch msgs.......................................................................203
82.4. EXIT....................................................................................................................................203
82.4.1. Table p_messages filled with BDC Messages..................................................................203
82.5. CALLED BY..........................................................................................................................203
82.6. CALLS .................................................................................................................................203
82.7. TABLES ................................................................................................................................203
82.8. SYSTEM VARIABLES ...............................................................................................................203
82.9. DESCRIPTION.........................................................................................................................203
82.10. EXAMPLES ..........................................................................................................................203
82.11. SOURCECODE......................................................................................................................203
82.12. SEE ALSO..........................................................................................................................204
List Of Tables
TABLE 1 - LIST OF ROUTINES........................................................................................................24
TABLE 2 -YDCSET TABLE STRUCTURE......................................................................................28
TABLE 3 - SYSTEM VARIABLES AFFECTED BY DRILL DOWN REPORTS.......................32
TABLE 4 - CUSTOM AUTHORISATION OBJECTS.....................................................................36
TABLE 5 COMMON BDC OK CODES..........................................................................................182
Changes Pending.
Page 19
1.1.
Procedure Format.
These routines rely on the SAP routines conforming to the following constraints:
Each routine has a header that is as follows:
*EJECT
********************************************************************
*
*
Procedure:
*
*
Purpose:
*
*
Entry:
*
*
Exit:
*
*
Called By:
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
The macros search for various keywords and extract the relevant text from the header. The sections
can be formatted as follows:
1.1.1.1.
Procedure.
The procedure heading can only occupy one line, and is used as a trigger for the
start of all routines that require to search the procedure. This should be the same
as the name specified in the Forms Statement.
1.1.1.2.
Purpose.
The Purpose header can extend across multiple lines up to the first 'Entry'
statement.. The text 'Purpose:' and all comment markers up to this line are
removed and the remaining texts concatenated into a single string. This string is
then output as a single paragraph under the 'Purpose' Sub heading.
1.1.1.3.
Entry.
There must be an 'Entry:' heading for each 'TABLE' or 'USING' parameter defined
on the form. These have the comment markers stripped and the word 'Entry:'
removed from them and are used as the Level 3 sub headings under the heading
'Entry'.
Any text below the line containing the word 'Entry:', up until the next 'Entry:', or
the first 'Exit:' line will be concatenated together, minus the comment markers and
extra spaces to form an explanation for the parameter that has just been specified.
Page 20
1.1.1.4.
Exit.
There must be an 'Exit:' heading for each 'CHANGING' defined on the form.
These have the comment markers stripped and the word 'Exit:' removed from them
and are used as the Level 3 sub headings under the heading 'Exit'.
Any text below the line containing the word 'Exit:', up until the next 'Exit:', or the
first 'Called By:' line will be concatenated together, minus the comment markers
and extra spaces to form an explanation for the parameter that has just been
specified.
1.1.1.5.
Called By.
The Called by line contains all the procedures that are dependant on the current
procedure being documentented. However... the macros DO NOT take any entries
in the 'Called By' lines as gospel, but scans the supplied source file for references
to the procedure and enters these references into the documentation instead. The
documentation also contains a 'model' procedure call for the the form being called,
however this 'model' call needs manual formating.
1.1.1.6.
Calls.
The Calls Line again is not used by the macros, but can be updated by the results
of the macros if you wish. The macros scan the source code and extract and
'PERFORM' calls between the Form Declaration and the next 'ENDFORM'.
These are then output under a Level 2 heading 'CALLS'.
1.1.1.7.
Other Entries.
Other entries appear in the documentation that are not required in the header.
These are:
Tables
System Variables
Description
Example
Source Code
See Also
1.1.1.7.1.
Tables:
The macros will scan the source code for the routine and parse any tables
statements between the FORM...ENDFORM statements into a comma seperated
list as a Level 2 paragraph.
1.1.1.7.2.
System Variables.
The next heading in the document is 'System variables'. This contains a list of all
system variables, and a truncated description, or all system variables referenced
in the form.
1.1.1.7.3.
Description.
This entry in the documentation should describe the routine, how and why it
works, any funnies or occasions when it will not work. The level 2 header is
entered, but no text. This is for you to do.
1.1.1.7.4.
Examples.
The example is taken from the file that you specify for example files. In my own
copy, I have the routine run Grep, searching all directories for occurances below
the main directory, and then read the file produced to retrieve the file name. The
routine then scans this file and extracts the source code 7 lines either side of the
reference to the routine and inserts it into the document.
Page 21
The number of lines that are extracted for the example can be modified by
changing the subscript in the line:
Dim SourceBuffer(7) As String
In subroutine 'Examples'.
1.1.1.7.5.
Source Code.
The macro then extracts the source code from the source file and inserts it into the
document.
1.1.1.7.6.
See Also.
A place where you can insert references to other similarly minded forms.
1.2.
Enter the routine name to document. Clickng the cancel button, or leaving the input field blank will
cause the routine to exit.
Enter the name of the file containing the routine. This does not have to be the only routine in the
file.
Enter the name of the file containing the example that you wish to use for the usage of the routine.
Ta-dahhhh....
Page 22
Allhdrs
Buildreport
CentreReport
Checkbox
Checkbreaks
Firstcol
Formatreport
Getmask
Giveline
Graphic
Groupheader
Icon
Initbreak
Printtitles
Printtotals
Psub
Repheader
Runtotals
Savereport
Setcolour
Sortrep
Stripstring
Subtitle.
YBDCINC
Page 23
Symbol
Tableline.
Underline
Usereport
Wline
Writecol
Writecentre
Writeline
WriteSymbol
Writevalue
Get_Local_Host
Function
Various constants defined here. The ones with single underscores can
be used in your own programs.
Prints all group headers for a report
Adds columns to a report definition, locates column titles and format
from data dictionary.
Centres a report or leaves it left justified
Prints a report element as a check box
Checks column breaks and prints totals if required
Sets the first column displayed
Takes a defined report and calculates the required spacing.
Gets a Unit or Currency mask
Returns the Nth line of a string of text to fit a column M characters
wide.
Inserts an icon or symbol graphic on a report
Prints out group headers.
Inserts an Icon on a report
Initialises Report breaks.
Prints the column titles on a report
Prints break totals
Macro. Prints select option sub titles
Prints a Report Header
Prints the run totals for a report
Saves report format on report stack
Sets the output colour
Sorts a report by a specified column
Removes specified characters from a string
Called by PSUB to print subtitles containing selection criteria for a
report
Inserts a symbol on a report
Draws a line across the current report.
Draws a line of specified width from a specified startpoint
Uses a previously stacked report
Outputs a line to the report
Writes to a specific column on the report
Prints the specified text centrally on a defined report.
Outputs a line of data onto the report
Writes a symbol to the report
Writes a single value to a report
Gets the name of the local SAP host
Include File
YGRAPH
Routine Name
Function
Init_Global
Is_Service_Active
Newbdc
Read_YDCSET
Zbdc_Batch_On
Zbdc_Close_Group
Zbdc_Dump_On
Zbdc_Field
ZBDC_Fillscreen
Zbdc_Insert
Zbdc_Open_Group
Zbdc_Screen
Zbdc_Scroll
Zdo_BDC
Z_Call_BDC
Curve_Category
Curve_Colour
Curve_Type
Curve_Width
Legend_Text
Next_Curve
Page 24
*
*
*
Zap ReportTable.
Perform BuildReport using 'VBELN0' Text-019 10 '' ''.
Perform BuildReport using 'ERDAT0' Text-020 8 'DD/MM/YY' ''.
Perform BuildReport using 'CREDT0' Text-021 11 '' ''.
Perform BuildReport using 'DEBIT0' Text-022 11 '' ''.
Perform BuildReport using 'VBELN1' Text-019 10 '' ''.
Perform BuildReport using 'ERDAT1' Text-020 8 'DD/MM/YY' ''.
Perform BuildReport using 'CREDT1' Text-021 11 '' ''.
Perform BuildReport using 'DEBIT1' Text-022 11 '' ''.
Perform BuildReport using 'VBELN2' Text-019 10 '' ''.
Perform BuildReport using 'ERDAT2' Text-020 8 'DD/MM/YY' ''.
Perform BuildReport using 'CREDT2' Text-021 11 '' ''.
Perform BuildReport using 'DEBIT2' Text-022 11 '' ''.
Perform FormatReport.
Perform SaveReport using c_billing_rep.
EndForm.
*Eject
***********************************************************************
*
*
Procedure:
Print_Revenue_Report
*
*
Purpose:
Prints the standard revenue report.
*
*
Entry:
*
*
Exit:
*
*
Called By:
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form Print_Revenue_Report.
*
Data: w_lines type i,
w_prted type i,
w_vbeln like vbak-vbeln.
*
Read Table t_revenue index 1.
*
* Initial group headers.
*
Set pf-status '001'.
Perform UseReport using c_main_report.
Perform GroupHeader using Text-009 T_REVENUE-KTEXT.
Perform GroupHeader using Text-008 T_REVENUE-ABTEI.
Perform GroupHeader using Text-007 T_REVENUE-ENAME.
Perform GroupHeader using Text-006 T_REVENUE-VB.
Perform GroupHeader using Text-015 T_REVENUE-CENDNG.
Move t_revenue-vbeln to w_vbeln.
*
Loop at t_revenue.
*
*
Change in Vbeln ?? Check if there are any unprinted billing
*
docs.
*
If w_vbeln <> t_revenue-vbeln.
Perform billing_rep using 0 changing w_prted.
Move t_revenue-vbeln to w_vbeln.
EndIf.
Page 25
*
*
*
Page 26
3. Dependancies
Should it be required to track all uses of routines defined in ZBOSSINC, open a program containing
references to the routines and place the cursor on the Perform calling the routine.
Click the Where Used
and display it.
Page 27
button. This will locate all occurances of that routine in any ABAP program
4. BDC Operations.
The BDC routines have the ability to modify their behaviour without changing any code. This enables such
operations as debugging, or e-mail notification to be carried out. Note that at the present time some options
are not operation.
In order to support this, a table called YDCSET has to be built and populated. The structure of this table is
as follows:
Field Name
Key Data Element
MANDT
X
MANDT
FUNCNAME
X
RS38L_FNAM
BDCMODE
BDCMODE
BDCUPMODE
BDCUPMODE
CRBATCH
INHIBITCHK
DUMPBDC
DUMPMSG
GENMAIL
MAILPROG
PNAME
Type Length
CHAR
3
CHAR
30
CHAR
1
CHAR
1
CHAR
1
CHAR
1
CHAR
1
CHAR
1
CHAR
64
CHAR
8
4.1.
MANDT.
Client, the standard client field for SAP
4.2.
FUNCNAME
This is the function name of the RFC that this record applies to.
4.3.
BDCMODE.
The BDC Mode is the standard screen mode that you wish the BDC to run in. This can be:
4.4.
'A'. Display all screens and wait for <enter> between each screen
'E'. Display only erroneous screens.
'N'. Display no screens.
BDCUPMODE.
This is the standard BDC database update mode for the function. This can be either:
4.5.
CRBATCH.
The CRBATCH field is a single character field, and can have two values, 'X' or ' '. If the field
contains an X, the BDC routines will create an SM35 batch session should the BDC fail.
4.6.
INHIBITCHK.
In some cases, it can be helpful to inhibit validation checks within a BDC, for example where the
validation becomes too long or is not required in certain circumstances. This field is again a single
character field with a value of 'X' or ''. If the field has a value of 'X', then data validation can be
controlled using the following type of code:
If W__Ydcset-Inhibitchk = False.
Select Lgnum From T320 Into W_Lgnm1
Up To 1 Rows
Where Werks = W_Werks And
Lgnum = W_Lgnum.
Page 28
Endselect.
If Sy-Subrc <> 0.
Move C_Invalid_Warehouse To Pc_Status.
Endif.
Endif.
4.7.
DUMPBDC.
During the development of BDC sessions, it can be useful to see what is actually in the BDC table
itself prior to the call. Again, a single character field, this field determines whether a rudimentary
report detailing the contents of the BDC table should be printed out. 'X' causes the system to print
the table, '' not.
4.8.
DUMPMSG.
In the same manner that DUMPBDC causes the BDC table to be dumped to the nearest printer, this
flag causes the message table to be dumped to the printer should the BDC fail. 'X' causes the system
to dump the table, '' not.
4.9.
GENMAIL.
This field contains a procedure name. This procedure name coupled with the MailProg field is used
to call a specified procedure, passing as parameters the transaction code, the error message and the
user name. The Procedure call is error trapped so that if the procedure cannot be found, the
program still continues.
4.10. MAILPROG.
This field contains the name of the file which holds the procedure used to send mail.
Page 29
Macros have to be defined in the same way that Performs have to be with Define and End-Of-Definition.
They are generally used for short pieces of code that cannot be called using a perform.
5.1.
An Example.
The subroutine Subtitles prints the report criteria based upon the values passed to in by the caller.
The caller has to loop around the select-options table and pass the relevant data. This is due to the
fact that although Select-Options tables have the same field names, the field definitions differ
depending on the table you have set the select options up for. As you have to specify the structure in
the Perform definition, this makes the writing of a generic routine using Performs impossible:
Form Subtitles Tables p_selects structure s_vkorg using p_title.
This requires the calling program to loop around the relevant select options table:
Loop at s_vkorg.
Perform Subtitles using Title Text
s_vkorg-sign s_vkorg-option
s_vkorg-low s_vkorg-high.
EndLoop.
Obviously when this occurs once, the few extra lines of code are no problem, however, eight or
nine selection options can become a bore.
By using a macro, this problem can be alleviated by expanding the code in-line so that all variables
etc are available as normal.
Define PSub.
Loop at &1.
Perform Subtitles using &2
&1-Sign &1-option
Page 30
&1-low &1-high.
EndLoop.
End-Of-Definition.
The macro expands any arguments by replacing the &n parameter with the relevant parameter
passed by the calling program.
Therefore, the lines of code above become:
Psub s_vkorg Text-021.
Page 31
Contents
The title of the report
The current column in the list.
Page length in lines
Current line in list
Page width in columns
Current page in list
Number of columns in window
Number of lines in window
Current Page Number
Cursor column position on screen.
Cursor Row position on screen.
Number of selected list line
Contents of the selected line as a string
Index of selected list (0 = base, 1=detail 1 etc)
Index of displayed list (0=base, 1=detail 1 etc)
Status information for each list level
Contents of the message line
Number of first displayed column
Number of first displayed line on this page
Command field function entry.
Page 32
7. Arrays.
Arrays are available in ABAP disguised as internal tables. However, the problem occurs when you try to
define an Array within an existing table.
This is handy when you are dealing series of data that are identical but perhaps are part of a time series for
instance. By using an array the amount of program code can be cut down quite considerably.
As a simple example, the psuedo code below shows how the invoice totals for each month can be totalled.
Assume that a record has a customer number, an invoice total and a month number.
For Each Record In The File
Do
InvoiceTotal(MonthNumber):=InvoiceTotal(MonthNumber)+This Invoice
EndDo
This Invoice
This Invoice
This Invoice
+ This Invoice
As you can see, the amount of code increases dramatically without arrays.
Arrays (or tables) can be referenced like so:
Read Table t_mytab index w_index.
This will place the w_indexth record from t_mytab in the tables header line so that the information can be
accessed directly.
7.1.
Page 33
Loop at MyTab.
*
* Get at the data in the array
*
Refresh i_totals.
Move MyTab-Totals[] to i_totals[].
*
Write: / MyTab-kunnr, MyTab-Count, at 50 .
Loop At i_totals
Write i_totals.
Write /50 .
EndLoop.
EndLoop.
Page 34
8. Select-Options.
Select Options provide a very flexible method of defining the report search criteria. Select Options are
available on any field where this icon is displayed:
The user can then select a wide range of criteria. By using these criteria, reports can be produced that can
contain contiguous ranges, discrete records, exclusions and even pattern matched results.
Selection criteria are stored in a table created when the program runs. There can be many seperate selection
criteria within one selection option table.
Due to this, reports should have the selection criteria printed at the top of each page so that the user can see
what selection criteria were used to produce the report.
In order to do this, a routine called Subtitle should be used. This will print out in plain language what the
report criteria for a specific record in the selection criteria table has.
It is not possible to actually pass the table to the routine as the structure has to be declared as a separate
statement. Each selection criteria table, although having the same field names has a different definition.
For more information on Selection criteria see below.
Page 35
9. Authorisation Checks.
SAP has the ability to provide authorisation checks for users to enable them to access differing parts of
programs or reports based upon their access code.
To carry out an authorisation check, use the following code:
Authority-Check Object 'AuthorisationObject'
ID Authorisation-id' Field 'Authorisation Field'.
if sy-subrc = 0.
*
*
User has authorised access to this object
*
Else.
*
*
User is not authorised for this object.
*
endif.
If the user has authorisation for this object, SY-SUBRC will be 0. Any other value means that the user is not
authorised. (Some values mean that the object is not present, but if you are protecting sensitive data then
treating that as unauthorised as well is good practice).
There are a huge number of predefined Authorisation Objects, so before creating one of your own, check in
Tools->Administration->Maintain Users->Authorization to see if an appropriate object exists. If one does
not exist there, create your authorisation object and complete the table below which details in house
authorisations:
Authorisation
Check
Is the user a dealer ?
Object Class
Object
Dealer Authorisation
Technical
Name
ZDEALER
Authorisation
ID
USR10_1
Page 36
Field
V:ZDEAL+DI
JSB
Aware
Y
10.
Sub-Totals.
The majority of reports require totals at certain places. ABAP provides the AT NEW commands which are
difficult, if not exasperatingly impossible to use. YREPINC implements a set of routines that will provide
sub-totals for columnar style reports.
After formatting the report using BuildReport and FormatReport, a list of break points is setup using
InitBreak. Break points are listed in reverse order - ie the lowest break point first working up to a report
total. As the report is printed, calling CheckBreaks before the printing of each line causes the break points
to be checked and updated, with sub-totals and new group headings being printed as required.
Once the report has been printed, calling RunTotals prints the final set of totals for the report.
All numeric columns on the report will be sub-totalled.
implemented:
Perform
Perform
Perform
Perform
Perform
Page 37
11.
Real-Time Displays.
There may be occasions where a report is showing real time data (for example the status of a queue). If the
operator used the data displayed on the screen, invalid decisions may be made due to the data not being up
to date.
This can be alleviated by having a Refresh button on the button bar which the operator must remember to
press if they require the latest information.
This however places the onus for getting the correct information on the operator.
There is however, a way to provide an Auto-Refresh capability within a report, which can be expanded to
include other functions.
Primarily, a timer is set running as a totally separate task, even in a different processor. SAP provides the
ability to notify the calling program when this Remote Function Call (RFC) completes.
Function Z_WAIT_X_SECS has been written as an RFC capable function which waits a defined number of
seconds before it exits. As this is a remote function call, the original program continues rather than waiting
for the RFC to complete.
The call to Z_WAIT_X_SECS looks like this:
Call Function 'Z_WAIT_X_SECS'
Starting New Task 'IF'
Performing Start_Refresh On End Of Task
Exporting
WAIT_TIME = w_pollrate
Exceptions
COMMUNICATION_FAILURE = 1 Message w_RFCText
SYSTEM_FAILURE
= 2 Message w_RFCText
OTHERS
= 3.
Will cause the button RFSH to be pushed. By including this statement in the On End Of Task
call causes the program to automatically carry out whatever action is specified by the function code.
Thanks to Ted Hoffman [hoffmantt@hotmail.com] for this information
Page 38
12.
Information Sources.
http://www.sapfans.com/sapfans/
http://src.thehub.com.au/
http://207.105.30.51/simpweb/index.html
Ted Hoffman
Page 39
13.
13.2. Purpose.
Adds entries to a Range table
13.3. Entry.
13.3.1. Item To Add.
This is the range value that you wish to add to the range table. Applicable to AddRange,
AddDiscrete and AddConsec.
13.4. Exit.
13.5. Called By.
AddDiscrete 'ABC' r_mara.
AddConsec 'A' 'Z' r_range.
13.6. Calls.
13.7. Tables.
13.8. System Variables.
13.9. Description.
These three macros add records to a select option table. The Macro AddRange is obsolete, replaced
by AddDiscrete, however, it has been left in the code for backwards compatability.
AddDiscrete adds single entries to a range table.
AddConsec adds a consecutive Range to a range table.
13.10. Examples.
Move i_matnr to w_matnr.
Move c_ok to w_status.
Move ''
to e_text.
Move ''
to e_xchpf.
Zap t_ekpo.
*
* Document types to include in the search:
*
Addrange: 'NB' r_fbsart,
'UB' r_fbsart,
'ZUB' r_fbsart,
'LP' r_lbsart.
*
Page 40
* Check Valid material, and that the material has been provided.
*
13.11. Source.
*Eject
***********************************************************************
*
*
macro:
AddRange, AddDiscrete, AddConsec.
*
*
Purpose:
Adds an 'EQ' entry to a range table
*
AddDiscrete - copied version of addrange for
*
backwards compatability.
*
AddConsec - adds a 'BT' entry to a range table
*
*
Entry:
Value to add,
*
Range table to use
*
*
Exit:
*
*
*
Called By:
AddRange r_value r_table.
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Define AddRange.
Move 'I' to &2-sign.
Move 'EQ' to &2-option.
Move &1 to &2-low.
Append &2.
End-Of-Definition.
*
Define AddDiscrete.
Move 'I' to &2-sign.
Move 'EQ' to &2-option.
Move &1 to &2-low.
Append &2.
End-Of-Definition.
*
Define AddConsec.
Move 'I' to &3-sign.
Move 'BT' to &3-option.
Move &1 to &3-low.
Move &2 to &3-high.
Append &3.
End-Of-Definition.
Page 41
14.
14.2. Purpose
Simplifies the typing when constructing Selection screen blocks. Note these macros are used by
SAP-AG (Well.that's where I got them from.)
14.3. Entry
14.3.1.Begin_Of_Block - Block name and Frame title.
These are the standard parameters that you would use when you write the 'Selection Screen
Begin Of Block' statement in full.
14.3.2.End_Of_Block
- Block name
These are the standard parameters that you would use when you write the 'Selection Screen
End Of Block' statement in full.
14.4. Exit
14.5. Called By
Begin_Of_Block BlockName Text-012
14.6. Calls
None
14.7. Tables.
None
14.9. Description.
These two macros simplify the coding required to set up block structures within a selection screen.
14.10. Examples.
Begin_of_block PARAMS Text-001.
Selection-Screen Comment 1(17) Text-016.
Select-options: s_kdgrp for vbkd-kdgrp,
s_kostl for pa0001-kostl no-extension,
s_pernr for pa0001-pernr no-extension,
s_vbeln for vbak-vbeln no-extension,
s_wdate for catsdb-workdate obligatory.
BlankLine.
Selection-Screen Comment 1(17) Text-017.
CheckLeft 1 19 Text-018 p_summry.
End_Of_Block PARAMS.
14.11. Source.
*Eject
***********************************************************************
*
*
macro:
Various Macros for Selection Screens.
*
*
Macro
Arguments
Function
Page 42
*
Begin_Of_Block, Block Name
Simplifies creation of
*
Block Title
Screen blocks
*
*
BlankLine
None
Puts a line on a screen
*
*
End_Of_Block Block Name
Simplifies creation of
*
Screen blocks
*
*
RadioLeft
Position
Places a radio button
*
Title Length
on a selection screen
*
Title
with comment to left.
*
Parameter
*
Group.
*
*
RadioRight
Position
Places a radio button
*
Title Length
on a selection screen
*
Title
with comment to right
*
Parameter
*
Group.
*
*
CheckLeft
Position
Places a check box
*
Title Length
on a selection screen
*
Title
with comment to left.
*
Parameter
*
*
CheckRight
Position
Places a check box
*
Title Length
on a selection screen
*
Title
with comment to right
*
Parameter
Define Begin_Of_Block.
Selection-Screen Begin Of Block &1 With Frame Title &2.
End-Of-Definition.
*
Define BlankLine.
Selection-Screen Uline.
Selection-Screen Skip 1.
End-Of-Definition.
*
Define End_Of_Block.
Selection-Screen End Of Block &1.
End-Of-Definition.
*
Define RadioLeft.
Selection-Screen Begin Of Line.
Selection-Screen Position &1.
Selection-Screen Comment (&2) &3
Parameter &4 as RadioButton Group &5.
Selection-Screen End Of Line.
End-Of-Definition.
*
Define RadioRight.
Selection-Screen Begin Of Line.
Selection-Screen Position &1.
Parameter &4 RadioButton Group &5.
Selection-Screen Comment (&2) &3.
Selection-Screen End Of Line.
End-Of-Definition.
*
Define CheckLeft.
Selection-Screen Begin Of Line.
Selection-Screen Position &1.
Selection-Screen Comment (&2) &3.
Parameter &4 as CheckBox.
Selection-Screen End Of Line.
End-Of-Definition.
*
Define CheckRight.
Selection-Screen Begin Of Line.
Selection-Screen Position &1.
Parameter &4 as checkbox.
Selection-Screen Comment (&2) &3.
Selection-Screen End Of Line.
End-Of-Definition.
Page 43
Page 44
15.
BLANKLINE - Macro
15.1. Location.
YREPINC.
15.2. Purpose.
Inserts a line across a selection screen.
15.3. Entry.
15.4. Exit.
15.5. Called By.
BlankLine
15.6. Calls.
15.7. Tables.
15.8. System Variables.
15.9. Description.
This macro simplifies report screen generation by removing cimbersome commands. Itis used to
place a line on the screen.
15.10. Examples.
15.11. SourceCode.
See Begin_Of_Block.
Page 45
16.
16.2. Purpose.
This macro inserts a check box into a selection screen with the text to the left or right of the check
box.
16.3. Entry.
16.3.1.Position.
The position in characters to the start of the comment or check box from the left edge of the
screen or block.
16.3.2.Title Length.
The length of the title in characters
16.3.3.Title
The Title or comment to be applied to the check box
16.3.4.Parameter
The parameter name for the check box.
16.4. Exit.
16.5. Called By.
CheckLeft 40 15 Text-015 p_check.
16.6. Calls.
16.7. Tables.
16.8. System Variables.
16.9. Description.
This macro handles the required screen statements to place a check box on a selection screen with
the text to the left of the check box.
16.10. Examples.
Begin_of_block PARAMS Text-001.
Selection-Screen Comment 1(17) Text-016.
Select-options: s_kdgrp for vbkd-kdgrp,
s_kostl for pa0001-kostl no-extension,
s_pernr for pa0001-pernr no-extension,
s_vbeln for vbak-vbeln no-extension,
s_wdate for catsdb-workdate obligatory.
BlankLine.
Selection-Screen Comment 1(17) Text-017.
CheckLeft 1 19 Text-018 p_summry.
End_Of_Block PARAMS.
Page 46
16.11. SourceCode.
See Begin_Of_Block
Page 47
17.
17.2. Purpose.
This macro inserts a radio button into a selection screen with the text to the left or right of the check
box.
17.3. Entry.
17.3.1.Position.
The position in characters to the start of the comment or radio button from the left edge of
the screen or block.
17.3.2.Title Length.
The length of the title in characters
17.3.3.Title
The Title or comment to be applied to the radio button
17.3.4.Parameter
The parameter name for the radio button
17.3.5. Group.
The group that the radio button belongs to.
17.4. Exit.
17.5. Called By.
RadioLeft 40 15 Text-015 p_check Group_One.
17.6. Calls.
17.7. Tables.
17.8. System Variables.
17.9. Description.
This macro handles the required screen statements to place a radio button on a selection screen with
the text to the left of the check box.
17.10. Examples.
Begin_of_block PARAMS Text-001.
Selection-Screen Comment 1(17) Text-016.
Select-options: s_kdgrp for vbkd-kdgrp,
s_kostl for pa0001-kostl no-extension,
s_pernr for pa0001-pernr no-extension,
s_vbeln for vbak-vbeln no-extension,
s_wdate for catsdb-workdate obligatory.
BlankLine.
Selection-Screen Comment 1(17) Text-017.
RadioLeft 1 19 Text-018 p_summry group_1.
RadioLeft 1 19 text-019 p_detail group_1.
Page 48
End_Of_Block PARAMS.
17.11. SourceCode.
See Begin_Of_Block
Page 49
18.
COPYBOOK - Macro
18.1. Location.
YRBINC.
18.2. Purpose.
This macro copys the structure of an SAP table into an internal table of the same name prefixed by
tb_.
18.3. Entry.
18.3.1. Table name to use.
This is the table name that should be copied from the data dictionary
18.4. Exit.
18.5. Called By.
CopyBook Lqua.
18.6. Calls.
18.7. Tables.
18.8. System Variables.
18.9. Description.
This macro takes the repetitiveness out of creating an internal table for a dictionary structure.
18.10. Examples.
Form Unload_Docs Using Pu_Funcname Pu_Outdir Pu_Program.
*
CopyBook: dokhl,
doktl.
18.11. SourceCode.
*eject
***********************************************************************
*
*
macro:
CopyBook
*
*
Purpose:
Copies the structure of a specified table into
*
an internal table of the same name prefixed with
*
t_
*
*
Entry:
Table name to copy
*
*
Exit:
Declaration for table t_nnnnnn
*
*
Called By:
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Define CopyBook.
Copy_Structure &1 &1.
Page 50
End-Of-Definition.
Page 51
19.
COPY_STRUCTURE - Macro
19.1. Location.
YRBINC.
19.2. Purpose.
Copies a data dictionary structure into a specified internal table
19.3. Entry.
19.3.1.Structure Name to extract from the data dictionary.
19.3.2.Internal table name to copy strcuture to.
19.4. Exit.
19.5. Called By.
Copy_Structure Lqua Lqua_Copy.
19.6. Calls.
19.7. Tables.
19.8. System Variables.
19.9. Description.
19.10. Examples.
19.11. SourceCode.
*eject
***********************************************************************
*
*
macro:
Copy_Structure
*
*
Purpose:
Copies the structure of a specified table into
*
an internal table of a specified name prefixed
*
with a t_
*
*
Entry:
Table name to copy
*
Internal declaration name minus t_ prefix
*
*
Exit:
Declaration for table t_nnnnnn
*
*
Called By:
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Define Copy_Structure.
Data Begin of t_&1 occurs 0.
Include Structure &2.
Data End Of t_&1.
End-Of-Definition.
Page 52
Page 53
20.
END_OF_REPORT - Macro
20.1. Location.
YREPINC.
20.2. Purpose.
Performs End of Report Processing.
20.3. Entry.
20.3.1.Select option table to use
This parameter is the select option table the code is to process.
arguments that are used in PSUB.
20.4. Exit.
20.4.1.Report Footer printed
20.5. Called By.
End_Of_Report s_selopt t_title.
20.6. Calls.
RUNTOTALS
TABLELINE
SUBTITLES
WRITECENTRE
20.7. Tables.
20.8. System Variables.
SY-SUBRC
20.9. Description.
This macro performs all end of report processing, including the printing of select option values that
have more than 5 entries. This prevents a recursive call to the page heading routines due to the
subtitles filling complete pages.
20.10. Examples.
*
20.11. SourceCode.
*EJECT
Define End_Of_Report.
*
*
If there are any totals to print then reportbrreaks record count
Page 54
*
*
*
*
*
Page 55
21.
Format_Selects - Macro
21.1. Location.
YREPINC.
21.2. Purpose.
Formats a select table using 'FormatKey'.
21.3. Entry.
21.3.1.Select Option Tables to use.
21.4. Exit.
All select options for that specified table formatted
21.6. Calls.
FormatKey
21.7. Tables.
21.8. System Variables.
21.9. Description.
Select Options tables although they have the same field names, have a structure dependant on the
table specified in the select options statement and therefore cannot be passed to a generic subroutine
as the structure of the passed table has to be specified.
Format_Selects provides the loop to call FormatKey so that the programmer does not have to be
concerned with this.
21.10. Examples.
21.11. SourceCode.
*Eject
***********************************************************************
*
*
macro:
Format_Selects
*
*
Purpose:
Formats Select options using fornmat key
*
*
Entry:
Select option to format
*
*
Exit:
Select options formatted as per format key
*
*
Called By:
Format_Selects s_options
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Define Format_Selects.
Loop at &1.
Perform formatkey using &1-low changing &1-low.
Page 56
Page 57
22.
INIT_FUNC - Macro
22.1. Location.
YBDCINC.
22.2. Purpose.
Initialises a function's parameters when called via RFC from a different language other than SAP.
22.3. Entry.
The Function name to be initialised in Quotes
22.4. Exit.
Entry parameters to the function that are optional, have a proposed value and are passed in empty
are set to the proposed value. Entry parameters that are strings are changed to upper case. Exit
parameters are cleared to their initial state. Global parameters are initialised.
22.6. Calls.
22.6.1.Functions:
Function_Get.
22.6.2.Forms:
Init_Global
Read_YDCSet
22.7. Tables.
22.8. System Variables.
SY-UNAME CHAR C
12
22.9. Description.
Functions can be called with a variety of parameters. These parameters can be optional, they can
also have a proposal or default associated with them, so that if they are not provided by the calling
routine, then SAP provides them with the value defined in the proposal.
However, when functions are called as RFC's, from another language, more often than not, the
languages do not support named parameters, rather they support positional parameters in which the
meaning of the parameter is defined by it's position in the argument list rather than the name.
As all the parameters must be specified in the call to the RFC, SAP does not carry out the default
processing correctly.
This macro will carry out that default processing and also, initailise any exported parameters with
INITIAL.
Many thanks to John Campbell, (John.campbell@54marine-avenue.freeserve.co.uk) for the
Ascii/Char translation.
22.10. Examples.
FUNCTION Y_CHECK_PO_AND_RETURN_SPLR_RFC.
*"---------------------------------------------------------------------*"*"Local interface:
Page 58
*"
IMPORTING
*"
VALUE(I_EBELN) LIKE YFIBER-EBELN
*"
EXPORTING
*"
VALUE(E_LIFNR) LIKE YFIBER-LIFNR
*"
EXCEPTIONS
*"
X_NO_PO_NUMBER
*"
X_PO_NOT_FOUND
*"---------------------------------------------------------------------*
*
Data: w_status type status_code,
" RFC Status
w_ebeln like i_ebeln,
" P/O Number
w_lifnr like e_lifnr,
" Supplier code
w_text type status_text.
*
Init_func 'Y_CHECK_PO_AND_RETURN_SPLR_RFC'.
*
Move c_ok
to w_status.
Move i_ebeln to w_ebeln.
Move ''
to w_lifnr.
*
22.11. SourceCode.
*Eject
***********************************************************************
*
*
macro:
Init_Func
*
*
Purpose:
Initialises a function where it is called by
*
an RFC that uses positional parameters.
*
*
ABAP uses named parameters when communicating
*
with a function. If any of these parameters are
*
specified as optional they do not need to be
*
passed. If these parameters also have a
*
Proposal, then the value of the parameter that
*
has not been passed is set to the value of the
*
proposal.
*
*
However, when calling RFC's, many languages
*
do not have named parameters. As such these
*
languages which use positional parameters cannot
*
exclude any parameters at all.
*
*
This then causes SAP to think that the parameter
*
has been passed (which it has), and that it is
*
blank (which it is), and not substitute the
*
proposal.
*
*
This macro will collect the various optional
*
parameters and if the parameter passed is initial
*
will set it to the default.
*
*
Additionally all export variables are initialised
*
*
Entry:
'Function Name'
*
*
Exit:
*
*
Called By:
Init_Func 'FUNCTION_NAME'
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Define Init_Func.
*
Constants: c_param_import
like catfu-paramtype value '1', "Import parameter flag
c_param_export
like catfu-paramtype value '2', "Export parameter flag.
Page 59
*
*
*
*
*
*
*
*
*
Field-Symbols: <f_param>.
Data: Begin of t__prmtab occurs 0.
Include Structure CatFu.
Data: End Of t__prmtab,
w__impdefault like catfu-impdefault,
w__name
like catfu-name,
w__dump(30) type c,
w__apost
like c_apostrophe,
w__fname
like tfdir-funcname.
Perform Init_Global.
Move &1 to w__fname.
Translate w__fname to upper case.
Perform Read_YDCSET using w__fname sy-uname changing w__ydcset.
Zap t_bdcmsg.
Get the function details and loop through the parameter list. If
the variable is an export variable then initialise it. If it is an
import variable that is optional with a proposal, set the variable
to the value of the proposal if the value passed is blank.
Call Function 'FUNCTION_GET'
Exporting
Funcname
= W__Fname
Tables
Prmtab
= T__Prmtab
Exceptions
Fm_Not_Found
=1
Nametab_Fault
=2
Ref_Field_Missing = 3
Ref_Structure_Missing = 4
Others
= 5.
If sy-subrc <> 0.
Message E000 with 'FUNCTION_GET Failure ' &1 '' ''.
Exit.
EndIf.
Loop at t__prmtab.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
Page 60
Proposal here ??
Assign (t__prmtab-name) to <f_param>.
If not t__prmtab-impdefault is initial.
If <f_param> is initial.
Is this a quote ? (The start of a string)
Perform AscChar using t__prmtab-impdefault+0(1)
changing w__apost.
If w__apost = c_apostrophe.
This is a string. Get rid of the quotes...
Move t__prmtab-impdefault+1 to w__impdefault.
Split w__impdefault
at t__prmtab-impdefault+0(1)
into <f_param> w__dump.
Else.
Move t__prmtab-impdefault to <f_param>.
EndIf.
EndIf.
EndIf.
If this parameter has a character component then
*
*
Page 61
23.
PSUB - Macro
23.1. Location.
YREPINC.
23.2. Purpose.
Prints all select options for a given select-options table.
23.3. Entry.
23.3.1.Select Option Tables to use.
23.3.2.Description of data held in select options table.
23.4. Exit.
All select options for that specified table printed.
23.6. Calls.
SubTitles
23.7. Tables.
23.8. System Variables.
23.9. Description.
Select Options tables although they have the same field names, have a structure dependant on the
table specified in the select options statement and therefore cannot be passed to a generic subroutine
as the structure of the passed table has to be specified.
Psub provides the loop to call Subtitles so that the programmer does not have to be concerned with
this. Psub will not print select options with more than 5 entries. (See End_Of_Report).
23.10. Examples.
*eject
**********************************************************************
*
*
Procedure:
RHeader
*
*
Purpose:
Prints report header/sub titles etc
*
*
Entry:
*
*
Exit:
*
*
Called By:
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form RHeader using p_sortby p_sortdir.
*
Data: w_sutitle(50) type c,
" Sub title string.
Page 62
*
*
*
*
*
w_srttitle(50) type c,
w_textno(3) type n,
w_srtfld(10) type c.
Field-Symbols <F_ColText>.
" Sorted by
" Sort field text no
" Sort by text field
" Sort text pointer.
*
*
*
*
*
*
Exceptions.
If Not p_prat9 is Initial.
Perform WriteCentre using text-011.
Endif.
If Not p_prata is Initial.
Perform WriteCentre using Text-012.
EndIf.
If Not p_nil is Initial.
Perform WriteCentre using Text-013.
EndIf.
Sorted By ...
23.11. SourceCode.
*Eject
***********************************************************************
*
*
macro:
Psub.
*
*
Purpose:
Prints a set of sub titles.
*
*
Entry:
Select option table to use
*
Entry:
Title for this selection block.
*
*
Exit:
Report header produced for current report
*
*
*
Called By:
Psub s_vkorg text-021
*
*
Calls:
Subtitles.
*
*
Modification History:
*
Page 63
* Date Reason
Version Who
*
Define PSub.
*
* Note that these are normally printed in the top of page event.
*
* In some cases where there are loads of criteria (more than a page
* length then this will cause a top of page longer than one page
* which means that the top of page is called again... and so on and
* so forth.
*
* Check how many lines there are and if there are more than a
* pages worth then display them at the end of the report.
*
Describe table &1 lines w__sublines.
If w__sublines < 5.
Loop at &1.
Perform Subtitles using &2
&1-Sign &1-option
&1-low &1-high
False.
EndLoop.
Else.
*
*
Too many options here - print them at the end of the report.
*
Perform Param_Subtitle using &2
'See option list at end of report'
.
EndIf.
End-Of-Definition.
Page 64
24.
WRITETABLE - Macro
24.1. Location.
YREPINC.
24.2. Purpose.
Writes an entire table to a specified column on a report
24.3. Entry.
24.3.1.Table to use
24.3.2. Field name of column to put text in..
24.4. Exit.
24.5. Called By.
WriteTable TableName fieldname.
24.6. Calls.
WriteCol
24.7. Tables.
24.8. System Variables.
24.9. Description.
This Macro will write a sub-table to a defined column on a report. The macro loops around the table
calling WriteCol for each entry.
24.10. Examples.
24.11. SourceCode.
*eject
**********************************************************************
*
*
Procedure:
WriteTable
*
*
Purpose:
Writes a table into asingle column
*
*
Entry:
Table to print
*
Column to use.
*
Exit:
*
*
Called By:
WriteTable t_table 'vbeln'.
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Define WriteTable.
Loop at &1.
Perform WriteCol using &1 &2.
EndLoop.
End-Of-Definition.
Page 65
Page 66
25.
ZAP - Macro
25.1. Location.
YREPINC.
25.2. Purpose.
Clears the header area and the table area of an internal user defined table.
25.3. Entry.
25.3.1.Table to clear
25.4. Exit.
25.5. Called By.
Zap internal_table.
25.6. Calls.
25.7. Tables.
25.8. System Variables.
25.9. Description.
Two statements are required completely clear an internal table. These are Clear (for the header
area) and refresh for the main table. Zap allows these to be specified in one go.
25.10. Examples.
Zap t_vbbp.
25.11. SourceCode.
*Eject
***********************************************************************
*
*
macro:
Zap.
*
*
Purpose:
Clears and refreshes a table
*
*
Entry:
Table to clear
*
*
Exit:
Table header cleared
*
Table contents deleted
*
*
Called By:
Zap t_table
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Define Zap.
Clear &1.
Refresh &1.
End-Of-Definition.
Page 67
26.
ALLHDRS
26.1. Location.
YREPINC.
26.2. Purpose.
Prints all group headers
26.3. Entry.
26.4. Exit.
26.5. Called By.
26.6. Calls.
GROUPHEADER
26.7. Tables.
26.8. System Variables.
26.9. Description.
Prints any group headers defined by InitBreak
26.10. Examples.
26.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
AllHdrs.
*
*
Purpose:
Prints all group headers
*
*
Entry:
*
*
Exit:
*
*
Called By:
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
FORM AllHdrs.
*
Data w__lines type i.
Describe Table ReportBreaks Lines w__lines.
*
* Don't print run totals here.
*
While w__lines > 0.
Read table ReportBreaks Index w__lines.
Perform GroupHeader
Using ReportBreaks-Title ReportBreaks-Value.
Compute w__lines = w__lines - 1.
EndWhile.
EndForm.
Page 68
Page 69
27.
ASCCHAR
27.1. Location.
YRBINC.
27.2. Purpose.
Ascii(C$) or Chr$(N)
27.3. Entry.
27.3.1.Character to return Ascii code for
Or Number to return character for
27.4. Exit.
Opposite of above
27.10. Examples.
*
*
*
*
*
*
*
27.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
AscChar
Page 70
*
*
Purpose:
Ascii(C$) or Chr$(N)
*
*
Entry:
Character to return Ascii code for
*
Or Number to return character for
*
*
Exit:
Opposite of above
*
*
*
Called By:
Perform AscChar using 98 changing w_char
*
Perform AscChar using 'A' changing w_num.
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form AscChar Using pu_in changing pc_out.
*
Data: Begin of t__chr,
"ASCII/CHR Converter
asc type x,
End of t__chr,
*
w__len
type i,
w__type(1) type c.
*
* If pu_in is a character, return the ascii value, if it's
* a value return the character.
*
Move 0 to pc_out.
Describe field pu_in type w__type.
Case w__type.
When 'C'.
Compute w__len = strlen( pu_in ).
If w__len = 1.
Move pu_in to t__chr.
Move t__chr-asc to pc_out.
EndIf.
When Others.
If pu_in > 0
and pu_in < 256.
Move pu_in to t__chr-asc.
Move t__chr to pc_out.
EndIf.
EndCase.
EndForm.
Page 71
28.
BUILDREPORT
28.1. Location.
YREPINC.
28.2. Purpose.
Adds report data field to table
28.3. Entry.
28.3.1.Data-field name.
This is the name of the table field that should be included in the report. If you include a
valid SAP table name as part of the field name, the routine matches up the field with the
corresponding field in the data table, but at the same time obtains default values from the
Data Dictionary for the full Table-Field combination. If the field does not occur anywhere
other than in the internal table, then the only specification required is the field name
28.3.4.1.
NO-ZERO
NO-SIGN
DD/MM/YY
MM/DD/YY
DD/MM/YYYY
MM/DD/YYYY
DDMMYY
MMDDYY
YYMMDD
CURRENCY w
DECIMALS d
ROUND r
UNIT u
EXPONENT e
... LEFT-JUSTIFIED
... CENTERED
... RIGHT-JUSTIFIED
Page 72
Note
Option
... NO-ZERO
Effect
Option
... NO-SIGN
Effect
Option
Option
... DD/MM/YY
... MM/DD/YY
Effect
Option
Option
... DD/MM/YYYY
... MM/DD/YYYY
Effect
Option
Option
... DDMMYY
... MMDDYY
Effect
Option
... YYMMDD
Effect
Option
... CURRENCY w
Effect
Option
... DECIMALS d
Effect
Example
DECIMALS
DECIMALS
DECIMALS
DECIMALS
DECIMALS
DECIMALS
0,
2,
5,
1,
5,
20.
"output:
"output:
"output:
"output:
"output:
"output:
1
1.27
1.26700
1.3E+04
1.25456E+04
1.25456000000000E+04
Option
... ROUND r
Effect
ROUND -2,
ROUND 0,
ROUND 2,
ROUND 5,
"output: 1,249,397.00
"output:
12,493,97
"output:
124.94
"output:
0.12
Option
... UNIT u
Effect
Example
Page 73
Option
... EXPONENT e
Effect
EXPONENT
EXPONENT
EXPONENT
EXPONENT
EXPONENT
EXPONENT
DECIMALS
0,
0,
3,
-3,
9,
2
4.
"output:
"output:
"output:
"output:
"output:
12345678900,000000
1,235E+10
12345678,90000000E+03
12345678900000,00E-03
12,34567890000000E+09
"output:
123456789,0000E+02
Option
Effect
'_'
'V'
'LL'
at beginning of template:
left justify (standard)
'RR'
at beginning of template:
right justify
'==conv'
':', ...
separator
Example
"Output: 15:46:33
If the output length "(8)" was not specified here, the output
would be "15:46:" because the implicit output length for the
type T is 6.
Option
Effect
Option
... UNDER g
Effect
Output of the field f begins at the column from which the field
g was output. If this happens in the same output line, the
output of the field g is overwritten.
Note
Example
Page 74
First Name
Ron
RoomNo
5.1
Age
24
Option
... NO-GAP
Effect
Suppresses the blank after the field f. Fields output one after
the other are then displayed without gaps.
Example
"Output: ABC
If NO-GAP was not specified here, the output would have been "A
B C" because one blank is always implicitly generated between
consecutive output fields.
Option
... LEFT-JUSTIFIED
... CENTERED
... RIGHT-JUSTIFIED
Effect
Left-justified, centered or
For number fields (types I,
standard output format, but
other types, as well as for
Examples
right-justified output.
P and F), RIGHT-JUSTIFIED is the
LEFT-JUSTIFIED is used for all
templates.
Notes
Page 75
2,5
246,3
TDM
TLira
TDM
TLira
DM
DM
Runtime errors:
-
Return ->
ABAP/4 Editor
Other additional formats are available. These are generally colour specifications. The
following colours can be used by specifying the text shown:
28.3.5.Format field.
This field is used in conjunction with the Format Type field see 28.3.4above. If the Format
type field contains the words 'Unit' or 'Currency', then this field should contain either a
valid Unit or Currency Code, or a variable that contains one of these codes. The variable
may either be a field in the same record of the internal table that holds the data being
reported on, or a variable defined within the report itself.
Page 76
28.3.5.1.
... UNIT u
Effect
Example
28.3.5.2.
... CURRENCY w
Effect
28.4. Exit.
None
28.6. Calls.
28.7. Tables.
dd01l
dd03l
dd04t
Domains
Table Fields
R/3 DD: Data element texts
4
1
28.9. Description.
BuildReport populates an internal table prior to using the data stored in the table to format a report.
Field and table names are converted to upper case before being stored in the table. The Table name
if present and the field name are then used to locate the field entry in the SAP Data dictionary.
The Data dictionary provides a Domain name for the variable which is used to access the Domains
table. The domains table provides the physical attributes of the field such as print width and
conversion routines.
The routine also uses information obtained from the Data dictionary to locate the field title. If the
title parameter passed to the routine is blank, then the title retrieved is stored for use.
In any case, the print parameters (Width and conversion routines) are stored in the table.
The routine then examines the title of the field (either that passed, or that retrieved) to make sure
that the column width is at least wide enough to accommodate the longest word in the title.
Page 77
The table used by this routine must be initialised before adding the first entry by using:
Refresh ReportTable.
There must be one call to this routine for each column of information in the report.
28.10. Examples.
Form Report_BadData Tables t_zisid Structure t_zisid.
*
Data: w_ermsg like t_zisid-ermsg,
" Group heading....
w_matnr like t_zisid-matnr,
w_text like dd04t-ddtext.
" Concatenate Group hdr
*
Zap ReportTable.
Perform BuildReport using 'ZISID-ZZSHIPNO' '' 0 '' ''.
Perform BuildReport using 'ZISID-PRONU' '' 0 '' ''.
Perform BuildReport using 'ZISID-EBELN' '' 0 '' ''.
Perform BuildReport using 'ZISID-EBELP' '' 0 '' ''.
Perform BuildReport using 'EKBE-MENGE' '' 0 '' ''.
Perform BuildReport using 'MSEG-MBLNR' '' 0 '' ''.
Perform BuildReport using 'MSEG-MJAHR' '' 0 '' ''.
Perform BuildReport using 'MSEG-ZEILE' '' 0 '' ''.
28.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
BuildReport.
*
*
Purpose:
Adds report data field to table
*
*
Entry:
Data-field name
*
Data field title
*
Data field length
*
FormatType. 'Unit' or 'Currency' or format mask
*
Format field
*
*
Exit:
None
*
*
Called By:
Perform BuildReport
*
using field title format field
*
Format-field
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
FORM BUILDREPORT using p_field
p_title
like dd04t-ddtext
p_len
like dd03l-leng
p_formattype like datatype-char0016
p_formatfield like dd03l-fieldname.
*
Tables: dd01l, dd03l, dd04t.
Data: Begin Of t_dd01l occurs 0,
DataType like dd01l-datatype,
Convexit like dd01l-convexit,
End Of t_dd01l,
*
Begin of t_dd03l occurs 0,
Domname like dd03l-domname,
As4local like dd03l-as4local,
As4vers like dd03l-as4vers,
Rollname like dd03l-rollname,
leng like dd03l-leng,
End Of t_dd03l,
*
Begin Of SplitTab occurs 0,
word(50) type c,
Page 78
*
*
*
*
End Of SplitTab,
w__table
like dd03l-tabname,
w__field
like dd03l-fieldname,
w__fmask(30) type c,
w__ffield(30) type c,
w__tlen
type i.
clear ReportTable.
Check for table-field name or just field name.....
Search p_field for '-'.
If sy-subrc = 0.
Split p_field at '-' into w__table w__field.
Else.
Move p_field to w__field.
EndIf.
Translate w__table to upper case.
Translate w__field to upper case.
*
*
*
*
*
*
*
*
*
Page 79
*
*
*
endif.
if p_len = 0.
Move t_dd03l-leng to ReportTable-ColWidth.
else.
Move p_len
to ReportTable-ColWidth.
EndIf.
If not t_dd01l-convexit is initial.
Concatenate '==' t_dd01l-convexit into ReportTable-Convexit.
EndIf.
Move t_dd01l-datatype to ReportTable-DataType.
endif.
Is column width less than an individual word in the title ?
Clear SplitTab.
Split ReportTable-Title at ' ' into table SplitTab.
Loop at SplitTab.
Compute w__tlen = strlen( SplitTab-Word ).
if w__tlen >= ReportTable-ColWidth.
ReportTable-ColWidth = w__tlen + 2.
endif.
endloop.
Append ReportTable.
ENDFORM.
"BUILDREPORT.
29.
30.
Page 80
31.
CENTREREPORT
31.1. Location.
YREPINC.
31.2. Purpose.
Sets a flag to tell formatreport to centre the report on the page or not.
31.3. Entry.
31.3.1.True or False
31.4. Exit.
31.5. Called By.
NEWREPORT.
Perform CentreReport using True.
31.6. Calls.
31.7. Tables.
31.8. System Variables.
31.9. Description.
31.10. Examples.
*
Modification History:
*
* Date Reason
Version Who
*
Form NewReport.
Zap ReportTable.
Zap ReportBreaks.
Perform CentreReport using True.
Move True to w__runtotal.
Move False to w__grouphdr.
Move False to w__lineprinted.
EndForm.
*Eject
***********************************************************************
*
31.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
CentreReport.
*
*
Purpose:
Sets a flag to tell formatreport to centre the
*
report on the page or not.
*
*
Entry:
True or False
*
*
Exit:
*
*
Called By:
Perform CentreReport using True
Page 81
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
*
Form CentreReport using pu_centre like true.
Move pu_centre to w__centre.
EndForm.
Page 82
32.
CHECKBOX
32.1. Location.
YREPINC.
32.2. Purpose.
Adds report data field to table as a check box .
32.3. Entry.
32.3.1.Data-field table.
This is the name of the table field that should be included in the report. If you include a
valid SAP table name as part of the field name, the routine matches up the field with the
corresponding field in the data table, but at the same time obtains default values from the
Data Dictionary for the full Table-Field combination. If the field does not occur anywhere
other than in the internal table, then the only specification required is the field name
32.4. Exit.
None
32.7. Tables.
32.8. System Variables.
SY-SUBRC INT4 X
SY-TABIX INT4 X
Page 83
4
4
32.9. Description.
CheckBox inserts a check box onto a report. The check box will appear in a column with a
minimum width of three spaces. The check box can be used to allow end-users to select multiple
lines from a report.
32.10. Examples.
EndIf.
Psub s_bname 'Developer'.
Perform PrintTitles.
EndForm.
*
Form UserRep.
Zap ReportTable.
Perform CheckBox using 'Selct' 'Process' 3.
Perform BuildReport using 'usr01-bname' '' 0 '' ''.
Perform BuildReport using 'Fulln' 'Full Name' 40 '' ''.
Perform FormatReport.
Set Pf-Status 'ZDLARTHR'.
Move '0' to w_state.
Loop at t_users.
Perform WriteLine using t_users col_normal.
32.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
CheckBox.
*
*
Purpose:
Adds report data field to table as a check box
*
*
Entry:
Data-field table
*
Data field title
*
Data field length
*
*
Exit:
None
*
*
Called By:
Perform CheckBox
*
using table name title length
*
*
Calls:
BuildReport
*
*
Modification History:
*
* Date Reason
Version Who
*
Form CheckBox using p_name like dd03l-fieldname
p_title like dd04t-ddtext
p_length like dd03l-leng.
*
Constants: c__cboxwidth type i value 3.
*
Data: w__table(20) type c,
w__name(20) type c.
*
Perform BuildReport using p_name p_title p_length '' ''.
*
* Locate this record and set the check box flag.
*
Search p_name for '-'.
If sy-subrc = 0.
Split p_name at '-' into w__table w__name.
Else.
Move p_name to w__name.
EndIf.
Translate w__table to upper case.
Translate w__name to upper case.
Read Table ReportTable with key Table = w__table
FieldName = w__name.
if sy-subrc = 0.
Move True to ReportTable-CheckBox.
Page 84
Page 85
33.
CHECKBREAKS
33.1. Location.
YREPINC.
33.2. Purpose.
Checks and prints total breaks
33.3. Entry.
ReportData Table.
33.4. Exit.
33.5. Called By.
Perform CheckBreaks tables datatable.
33.6. Calls.
TABLELINE
GROUPHEADER
33.7. Tables.
33.8. System Variables.
SY-TABIX INT4 X
SY-INDEX INT4 X
SY-SUBRC INT4 X
4
4
4
33.9. Description.
CheckBreaks examines the table initialised by sequential calls to InitBreak. The values stored
against the various break levels are checked. If these are the same as the current data line the
numeric values on the data line are accumulated against the relevant break level.
If a value in the break table is different from the corresponding value in the data line, the search
terminates and all sub totals up to and including the subtotal check value that has changed are
printed and the variables reset.
The initial call to CheckBreaks also prints any group headers required.
If any subtotals are printed, the corresponding group headers are then printed.
33.10. Examples.
*
*
*
*
if w_repid = c_zso0620.
Perform CheckBreaks tables t_repdata.
Endif.
Perform Writeline tables t_repdata using Col_Normal.
EndLoop.
Final totals.
Perform RunTotals Tables t_repdata.
33.11. SourceCode.
*Eject
***********************************************************************
*
*
Procedure:
Checkbreaks
*
Page 86
*
Purpose:
Checks and prints total breaks
*
*
Entry:
breakTotals table established
*
Entry
ReportData Table.
*
*
Exit:
*
*
Called By:
Perform CheckBreaks using p_datatable.
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form Checkbreaks using p_datatable.
*
Field-Symbols: <F_Group>.
Data: t__coltotals type Decimal_Value occurs 0 with header line,
t__carry
type Decimal_Value occurs 0 with header line,
w__breaklevel type i value -1,
w__totprint type i,
W__Pos
Type i,
W__Ffeed
like c_yes,
w__datatable(2000) type c.
*
Move p_datatable to w__datatable.
If w__allhdr_done = False.
Perform AllHdrs.
Move True to w__allhdr_done.
EndIf.
Loop at ReportBreaks.
*
*
Any value from a lower sub total ?
*
Don't do run totals here....
*
if ReportBreaks-Title <> 'Run Total:'.
Assign (ReportBreaks-field) to <F_Group>.
if <F_group> <> ReportBreaks-value.
*
*
Print a group total.
*
Move sy-tabix to w__breaklevel.
*
*
Form Feed ?
*
If ReportBreaks-Ffeed = c_yes.
Move c_yes to w__ffeed.
Endif.
Endif.
Endif.
EndLoop.
*
* Break at what level ?
*
If w__breaklevel <> -1.
Zap t__carry.
Compute w__totprint = w__breaklevel + 1.
do w__totprint times.
*
*
Add the totals from the previous level.
*
Read Table ReportBreaks Index sy-index.
Move Reportbreaks-Totals[] to t__coltotals[].
Loop at t__coltotals.
Move sy-tabix to w__pos.
Read Table t__carry index w__pos.
if sy-subrc = 0.
Compute t__coltotals = t__coltotals + t__carry.
Modify t__coltotals index w__pos.
Move t__coltotals to t__carry.
Modify t__carry index w__pos.
else.
Clear t__carry.
Page 87
*
*
*
*
*
*
*
*
*
Group Headers.
Page 88
34.
CHECK_DOMAIN_VALUES
34.1. Location.
YRBINC.
34.2. Purpose.
This routine checks a domains entities to see if the specified value exists is one of those entities.
34.3. Entry.
34.3.1. Domain Name To Check
34.3.2. Value To Check
34.4. Exit.
One parameter is returned by this routine and can have the following values:
True:
False:
34.9. Description.
This routine can be used to check values passed into functionns and forms via RFC's and so forth,
rather than the more normal method of entry via a screen.
34.10. Examples.
34.11. SourceCode.
*Exit
**********************************************************************
*
*
Procedure:
Check_Domain_Values
*
*
Purpose:
Checks that a value exists in the
*
specified domain
*
*
Entry:
Domain name to use
*
Value to check
*
*
Exit:
True - domain contains value
*
False - domain does not contain value
*
*
Called By:
Perform Check_Domain_Values
*
using w_domain w_value
*
changing w_valid.
*
*
Calls:
*
*
Modification History:
Page 89
*
* Date Reason
Version Who
*
Form check_domain_values using pu_domain like dd07l-domname
pu_value like dd07l-domvalue_l
Changing pc_valid like true.
*
Call Function 'CHECK_DOMAIN_VALUES'
Exporting
domname
= pu_domain
value
= pu_value
Exceptions
no_domname = 1
wrong_value = 2
dom_not_found = 3
Others
= 4.
If sy-subrc = 0.
Move true To pc_valid.
Else.
Move false To pc_valid.
Endif.
Endform.
Page 90
35.
COLUMN_COLOUR
35.1. Location.
YREPINC.
35.2. Purpose.
Sets the colour of a specific column
35.3. Entry.
35.3.1.Column width
35.3.2.Colour to set
35.3.3.Value to write
35.3.4.Actual colour code to use.
35.4. Exit.
35.5. Called By.
WRITEVALUE
Perform Column_Colour using p_width p_value p_format col_heading.
35.6. Calls.
SETCOLOUR
35.7. Tables.
35.8. System Variables.
35.9. Description.
This procedure sets the back ground colour for the currently selected column.
35.10. Examples.
*
*
Colours....
When 'COL_BACKGROUND' or 'GREY'.
Perform Setcolour using Col_background.
Write at (p_width) p_value no-gap.
Perform SetColour using w__last_colour.
When 'COL_HEADING' or 'BLUE' or 'DARK_BLUE'.
Perform Column_Colour using p_width
p_value
p_format
col_heading.
When 'COL_NORMAL' or 'WHITE' or 'BEIGE'.
If p_format <> 'BEIGE'.
Perform Column_Colour using p_width
p_value
35.11. SourceCode.
*EJECT
***********************************************************************
Page 91
*
*
Procedure:
Column_Colour
*
*
Purpose:
Sets the colour of a specific column
*
*
Entry:
Column width
*
Entry:
Colour to set
*
Entry:
Value to write
*
Entry:
Actual colour code to use.
*
*
Exit:
Actual mask to use.
*
*
Called By:
Perform Getmask using mask_in changing mask_out
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form Column_Colour using p_width p_value p_format p_colour.
*
* Need to set intensified on for dark colours ??
*
Data w__format(20) type c.
*
Move p_format to w__format.
If w__format+0(4) = 'DARK'.
Format Intensified on.
Else.
Format Intensified off.
EndIf.
*
Perform Setcolour using p_colour.
Write at (p_width) p_value no-gap.
*
* Ok, put intensity back to what it should be.....
*
*
w__intense_flag is the NEXT not the CURRENT intensity setting
*
for the line....so if it's False, intensity is already on,
*
If it's True then intensity is off.....
*
*
oh my gawd.....
*
If w__format+0(4) = 'DARK'.
If w__intense_flag = True.
Format Intensified off.
EndIf.
Else.
If w__intense_flag = False.
Format Intensified on.
EndIf.
EndIf.
Perform SetColour using w__last_colour.
EndForm.
Page 92
36.
DUMP_TABLE
36.1. Location.
YREPINC.
36.2. Purpose.
This routine dumps the specified table one full record at a time.
36.3. Entry.
36.3.1.None
36.3.2. Tables:
36.4. Exit.
36.4.1.None
36.5. Called By.
36.6. Calls.
SAVEREPORT
NEWREPORT
BUILDREPORT
36.7. Tables.
36.8. System Variables.
SY-LINSZ
SY-INDEX
SY-SUBRC
SY-LSIND
INT4 X
INT4 X
INT4 X
INT4 X
4
4
4
4
36.9. Description.
A debugging tool that will dump as much of the table as possible to the screen.
36.10. Examples.
SELECT SINGLE WRKST
FROM MARA
INTO T_COLOR_LIST-WRKST
WHERE MATNR = TB_RESERVE-PMTNR.
APPEND T_COLOR_LIST.
ENDIF.
ENDLOOP.
PERFORM DUMP_TABLE TABLES TB_RESERVE.
EXIT.
*
*
Send any non-coloured fiber to the colouring shop.
*
*
Find the coloring shop order first. Take the first shop order
*
that has an order type of CLOR and the dates are this month.
*
36.11. SourceCode.
*EJECT
***********************************************************************
Page 93
*
*
Procedure:
Dump_Table
*
*
Purpose:
This routine dumps the specified table
*
one full record at a time.
*
*
Entry:
None
*
*
Tables:
Unstructured table for dump
*
*
Exit:
None
*
*
Called By:
Perform DumpTable Tables t_tabname.
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form Dump_Table tables t_dumptable.
*
Field-Symbols <f_table_field>.
*
Data: w__fwidth like dd03l-leng,
w__twidth like w__fwidth,
w__nwidth like w__fwidth,
w__linsz like sy-linsz.
*
Move sy-linsz to w__linsz.
Perform SaveReport using 'DumpTab'.
Perform NewReport.
*
* Get the table field details.
*
Read Table t_dumptable index 1.
Do.
Assign component sy-index
of structure t_dumptable
to <f_table_field>.
If sy-subrc = 0.
Describe field <f_table_field> output-length w__fwidth.
Compute w__nwidth = w__twidth + w__fwidth + 2.
If w__nwidth < 255.
Perform BuildReport using sy-index '' w__fwidth '' ''.
Move w__nwidth to w__twidth.
Else.
Exit.
EndIf.
Else.
Exit.
EndIf.
EndDo.
New-page line-size 255.
Perform FormatReport.
*
Loop at t_dumptable.
Perform WriteLine using t_dumptable col_normal.
EndLoop.
Move 1 to sy-lsind.
New-Page line-size w__linsz.
EndForm.
Page 94
37.
FIRSTCOL
37.1. Location.
YREPINC.
37.2. Purpose.
Sets the first column of the report
37.3. Entry.
37.3.1. Direction to move the first column of the report.
The first column displayed for the report is set in a relative fashion. Either the first or last
column on the report, or plus or minus one column. These movements are decided upon
by the value of this parameter:
37.4. Exit.
37.5. Called By.
37.6. Calls.
37.7. Tables.
37.8. System Variables.
37.9. Description.
This routine sets the first column displayed at the left edge of the screen. This is the Report
Column, rather than the column of characters. If for example the 2 nd column of the report starts at
physical column 20 of the display, then perfoming Firstcol once with a value of '>' will display the
19th actual column as the first column of the display.
37.10. Examples.
Case w_ucomm.
When 'PROCESS'. Perform Process_Selections using w_mode.
Perform Message_Report.
Perform Setup_Proposal.
When 'PICK'.
Break-Point.
When 'SELECT'. Perform Chngall using 'X'.
When 'DESELECT'. Perform Chngall using ' '.
When 'LEFTMARGIN'. Perform FirstCol using '<<'.
When 'ONEL'.
Perform FirstCol using '<'.
When 'ONER'.
Perform FirstCol using '>'.
When 'RIGHTMARGI'. Perform FirstCol using '>>'.
EndCase.
*
Start-Of-Selection.
*
37.11. SourceCode.
*EJECT
***********************************************************************
*
Page 95
*
Procedure:
FirstCol.
*
*
Purpose:
Sets the first column of the report
*
*
Entry:
'<<' - Move to the left margin.
*
'<' - Move Left 0ne column
*
'>' - Move Right one column.
*
'>>' - Move to Right margin.
*
*
Exit:
*
*
Called By:
Perform FirstCol using '>>'.
*
*
Calls:
*
*
Modification History:
*
Form FirstCol using p_action.
*
Statics: w__macol like sy-macol,
" Current Margin
w__Cols type i.
" Number of columns
*
Data: w__newm like sy-macol.
" New column
*
Move 0 to w__newm.
if w__macol is Initial.
Move 1 to w__macol.
Describe Table reportTable lines w__cols.
EndIf.
Case p_action.
When '<<'. Move 0 to w__macol.
" Left Margin
When '<'. If w__macol > 0.
Subtract 1 from w__macol.
EndIf.
When '>'. If w__macol < w__cols.
Add 1 to w__macol.
EndIf.
When '>>'. Move w__cols to w__macol.
" Right Margin
EndCase.
If w__macol <> 0.
Read Table ReportTable Index w__macol.
Compute w__newm = ReportTable-StartPos + 2.
Scroll List To Column w__newm.
Else.
Scroll List to Column 0.
EndIf.
EndForm.
Page 96
38.
FORMATKEY
38.1. Location.
YRBINC.
38.2. Purpose.
Formats a key. If it is all zeroes, then it is right justfied and padded with zeroes If it is alphanumeric then it is left justified and padded with spaces
38.3. Entry.
38.3.1.Value to format
38.4. Exit.
38.4.1.Formatted value
38.5. Called By.
38.6. Calls.
38.7. Tables.
38.8. System Variables.
38.9. Description.
When reading rows from SAP tables, it can happen that even though you specifiy a valid key, the
relevant rows are not returned. This is due to the formatting of the key, and primarily happens with
numeric type variables that are prefixed with zeroes.
Having checked if the string contains only numbers, the routine then puts the key in an N type
variable, and then takes the rightmost number of characters upto the key length. If the key contains
alpha characters then it is placed in a C type variable and the left most keylength characters will be
taken.
38.10. Examples.
Move text-020 to t_zisid-ermsg.
Modify t_zisid.
Move True to w_baddata.
Else.
*
*
*
38.11. SourceCode.
*EJECT
**********************************************************************
*
Page 97
*
Procedure:
FormatKey
*
*
Purpose:
Formats a key. If it is all zeroes, then
*
it is right justfied and padded with
*
zeroes
*
*
If it is alpha-numeric then it is left
*
justified and padded with spaces
*
*
Entry:
Value to format
*
*
Exit:
Formatted value
*
*
Called By:
Perform FormatKey using w_key changing
*
w_newkey.
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form FormatKey using pu_key changing pc_key.
*
Data: w_flen
type i,
" Field Length
w_nkey(132) type n,
" Numeric Key
w_ckey(132) type c,
" Character
w_start
type i.
" Read key from
*
Describe field pu_key length w_flen.
If pu_key co c_numbers.
Move pu_key to w_nkey.
*
*
This is right justified.....
*
Compute w_start = 132 - w_flen.
Move w_nkey+w_start(w_flen) to pc_key.
Else.
Move pu_key to w_ckey.
Move W_Ckey+0(w_flen) to pc_key.
Translate pc_key to upper case.
EndIf.
EndForm.
Page 98
39.
FORMATREPORT
39.1. Location.
YREPINC.
39.2. Purpose.
Calculates the positions of the report columns specified in table reptab.
39.3. Entry.
39.4. Exit.
39.5. Called By.
39.6. Calls.
39.7. Tables.
39.8. System Variables.
SY-TABIX INT4 X
SY-LINSZ INT4 X
4
4
39.9. Description.
This routine calculates the positioning of columns of information based upon column widths
retrieved from the SAP Data dictionary or passed during calls to BuildReport.
Having calculated the maximum width of the report, the routine then checks that width against the
current report width, aborting with an error if the calculated report width is larger.
If the report will fit in the currently defined report width, the system then calculates the offsets
required to provide a columnar report centralised on the page.
The FormatReport should be called once all the BuildReport calls for the columns have been
processed.
39.10. Examples.
Perform
Perform
Perform
Perform
Perform
Perform
Perform
Perform
*
39.11. SourceCode.
*Eject
***********************************************************************
*
*
Procedure:
FormatReport.
*
Page 99
*
Purpose:
Calculates the positions of the report columns
*
specified in table reptab.
*
*
Entry:
None Reptable is global
*
*
Exit:
None
*
*
Called By:
Perform FormatReport.
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
FORM FORMATREPORT.
Data: w__maxlen type i,
w__numcols type i,
w__prevpos type i,
w__width type i,
w__gap type i,
w__first type i.
*
* Find the maximum width of the report. Allow for vertical lines
*
Move 0 to w__maxlen.
Move 1 to w__numcols.
*
* Centralise the report or not ??
*
Loop At ReportTable.
if sy-tabix = 1.
Compute ReportTable-StartPos = 1.
else.
Compute ReportTable-StartPos = w__prevpos + w__Width + 1.
endif.
Modify ReportTable.
w__prevpos = ReportTable-StartPos.
w__width = ReportTable-ColWidth.
Compute w__maxlen = w__maxlen + ReportTable-ColWidth + 1.
Endloop.
*
if w__maxlen > sy-linsz.
Message id 'SU' type 'E' number 0
with 'Report Width > Defined Width:'
w__maxlen
sy-linsz.
endif.
*
* Centralise the report
*
Compute w__numcols = w__numcols + 1.
Compute w__gap = ( sy-linsz - w__maxlen ) / 2.
Read Table ReportTable Index 1.
If w__centre = True.
Move w__gap to w__first.
Else.
Move 1 to w__first.
EndIf.
Loop at ReportTable.
If w__centre = True.
Compute ReportTable-StartPos
= ReportTable-StartPos + w__gap.
EndIf.
Move w__first to ReportTable-First.
Move w__maxlen to ReportTable-Maxwidth.
Modify ReportTable.
Endloop.
ENDFORM.
"FORMATREPORT
Page 100
CentreReport
CheckBox
CheckBreaks
InitBreaks
WriteLine
PrintTotals
Page 101
40.
GETMASK
40.1. Location.
YREPINC.
40.2. Purpose.
Locates a currency or unit mask
40.3. Entry.
40.3.1.Variable or literal mask
This parameter can be either a literal mask - a string defining the mask directly, or a
variable (in both cases these are strings) which contains a mask string.
40.4. Exit.
40.4.1.Actual mask to use.
40.5. Called By.
WRITEVALUE
Perform GetMask using p_currency changing w__fcode.
40.6. Calls.
40.7. Tables.
40.8. System Variables.
SY-SUBRC INT4 X
40.9. Description.
Unit and Currency values have a format mask applied to them prior to output. The reporting
routines can accept either literal masks, or variables containing a mask. This routine attempts to
assign the passed variable to a field symbol. If an error occurs then this means that the value passed
must be a literal. In that case the literal is passed straight back to the calling routine, otherwise the
contents of the variable are passed back to the caller.
40.10. Examples.
*
*
Page 102
40.11. SourceCode.
***********************************************************************
*
*
Procedure:
GetMask
*
*
Purpose:
Locates a currency or unit mask
*
*
Entry:
Variable or literal mask
*
*
Exit:
Actual mask to use.
*
*
Called By:
Perform Getmask using mask_in changing mask_out
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form getMask using p_mvin changing p_mvout.
*
Field-Symbols <f_fcode>.
*
Move '' to p_mvout.
If not p_mvin is initial.
Assign (p_mvin) to <f_Fcode>.
*
*
Is this a variable or a literal...
*
If sy-subrc = 0.
Move <F_Fcode> to p_mvout.
" Is a variable.
Else.
Move p_mvin to p_mvout.
" Is a literal.
EndIf.
EndIf.
EndForm.
Page 103
41.
GET_LOCAL_HOST
41.1. Location.
YBDCINC.
41.2. Purpose.
Gets / returns the current local host
41.3. Entry.
41.4. Exit.
41.4.1.Host Name
41.4.2.Server Name
41.5. Called By.
IS_SERVICE_ACTIVE
Perform Get_Local_Host Changing W__Local_Host W__Local_Serv.
41.6. Calls.
GWY_READ-CONNECTIONS
41.7. Tables.
41.8. System Variables.
SY-SUBRC INT4 X
41.9. Description.
This function returns the local server hosting the SAP system.
41.10. Examples.
*
41.11. SourceCode.
*EJECT
**********************************************************************
*
*
Procedure:
Get_Local_Host
*
*
Purpose:
Gets / returns the current local host
Page 104
*
*
Entry:
*
*
Exit:
Host Name
*
Server Name
*
*
Called By:
Perform Get_Local_Host
*
changing w_host w_server
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form Get_Local_Host Changing Pc_Local_Host Like Gwy_Struct-Gwhost
Pc_Local_Serv Like Gwy_Struct-Gwserv.
Data: W__Sapsys(2).
Call 'C_Sapgparam' Id 'NAME' Field 'SAPLOCALHOST'
Id 'VALUE' Field Pc_Local_Host.
Call 'C_Sapgparam' Id 'NAME' Field 'SAPSYSTEM'
Id 'VALUE' Field W__Sapsys.
Pc_Local_Serv = 'SAPGW'.
Pc_Local_Serv+5 = W__Sapsys.
Endform.
Page 105
42.
GIVELINE
42.1. Location.
YRBINC.
42.2. Purpose.
Provides text on line number 'N' from a line of text within a specified column width
42.3. Entry.
42.3.1.Line Number of required line in text.
This is the logical line number that you require. The lines are made up of the text split into
the column width specified below.
42.3.2.Width of column.
This is the width of the column that the line has to fit into.
42.3.3.Text to split
This is the string of text that has to be split into lines of the specified width.
42.4. Exit.
42.4.1.Line N
Line Nof specified text within a specified column width
42.6. Calls.
42.7. Tables.
42.8. System Variables.
42.9. Description.
42.10. Examples.
*
*
*
42.11. SourceCode.
*EJECT
Page 106
***********************************************************************
*
*
Procedure:
GiveLine.
*
*
Purpose:
Provides text on line number 'N' from a line of
*
text within a specified column width
*
*
Entry:
Line Number of required line in text
*
Width of column
*
Text to split
*
*
Exit:
Line N of specified text within a specified
*
Line width
*
*
Called By:
Perform GiveLine
*
Using LineNo ColWidth FullText
*
Changing Text
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form GiveLine using p_lineno type i
p_colwidth type i
p_fulltext
changing p_text.
Data: Begin of w__TextTable occurs 0,
Word(20) type c,
End Of w__TextTable,
w__linecount type i,
w__linelen type i,
w__wordlen type i,
w__totallen type i.
*
* Split the incoming text into seperate words.
*
Clear w__Texttable.
split p_fulltext at ' ' into table w__TextTable.
Move 1 to w__linecount.
Move Space to p_text.
Loop at w__TextTable.
Compute w__linelen = Strlen( p_text ).
Compute w__wordlen = Strlen( w__TextTable-Word ).
Compute w__totallen = w__linelen + w__wordlen + 1.
*
*
Space to add this word onto the line ?
*
if w__Totallen < p_colwidth.
if w__linelen <> 0.
Compute w__linelen = w__linelen + 1.
endif.
Move w__TextTable-Word to p_text+w__linelen.
else.
Compute w__linecount = w__linecount + 1.
if w__linecount > p_lineno.
Exit.
else.
Move w__TextTable-Word to p_text.
endif.
endif.
endloop.
*
* End of the table ?
*
if w__linecount < p_lineno.
move space to p_text.
endif.
Endform.
Page 107
43.
43.2. Purpose.
Adds an icon or a symbol to a report
43.3. Entry.
43.3.1.Icon: Icon Name to print
43.3.2.Symbol: Symbol Name to print
43.3.3.Graphic: Icon/symbol name, name type
Not callable directly by user
43.4. Exit.
43.4.1.None
43.5. Called By.
ICON
SYMBOL
Perform Graphic using p_iconname True.
43.6. Calls.
43.7. Tables.
43.8. System Variables.
43.9. Description.
The routine makes an entry into the internal report definition table ReportTable and flags the entry
as either an icon or a symbol. When the report is printed, Writeline prints the data using the correct
formatting process.
The graphics can be also described as hot spots or check boxes. Hot spots are items in a report that
can be activated by the click of a mouse button and are standard SAP items.
However, Checkboxes are limited in that you cannot cause an 'At Line Selection' event using them.
The best way is to use hot spot graphics.
Additional files need to be included in your program before you can use this facility. If you wish to
print only icons, include the following line in your program:
Include <icon>.
If you wish to use just symbols, insert Include <Symbol>. In your program.
comprehensive set, substitute <list> in the include statement.
Below is an example report using icons.
Page 108
For a more
43.10. Examples.
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form Icon using p_iconname p_hotspot.
Perform Graphic using p_iconname True.
EndForm.
*
Form Symbol using p_symbolname.
Perform Graphic Using p_symbolname False.
EndForm.
*
Form Graphic using p_name p_icon.
43.11. SourceCode.
*Eject
***********************************************************************
*
*
Procedure:
Icon, Symbol, Graphic
*
*
Purpose:
Adds an icon or a symbol to a report
*
*
Entry:
Icon: Icon Name to print
*
Entry:
Symbol: Symbol Name to print when check field
*
is true.
*
Entry:
Graphic: Icon/symbol name, name type
*
Not callable directly by user
*
*
Entry:
Hotspot - True or False
*
Entry:
Symbol: Field for symbol value check
*
Entry:
Symbol: Symbol Name to print when check fld is
*
false.
*
Exit:
None
*
*
Called By:
Perform Icon using ICON_CHANGE.
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form Icon using p_iconname
p_hotspot like true.
Perform Graphic using p_iconname
True
p_hotspot
''
''.
EndForm.
*
Form Symbol using p_True_symbol
p_hotspot like True
p_check_field
p_False_symbol.
Page 109
Page 110
44.
GROUPHEADER
44.1. Location.
YREPINC.
44.2. Purpose.
Prints a Group Header line. The group header line is the purple line shown on the report extract
below:
44.3. Entry.
44.3.1. Group Header Title.
This is the title of the header. Normally a column title, this is printed to the left of the
group header.
44.4. Exit.
44.5. Called By.
ALLHDRS
CHECKBREAKS
Perform GroupHeader using ReportBreaks-Title ReportBreaks-Value.
44.6. Calls.
TABLELINE
WLINE
44.7. Tables.
44.8. System Variables.
SY-VLINE CHAR C
44.9. Description.
The SAP GUI performs various actions when scrolling based upon the colour of the line. Using
Group headings will cause all the data lines under that group heading to scroll up, keeping the
existing group heading in view until it is superseded by another group header.
This routine formats a data line with the relevant information and vertical lines to enable it to be
integrated into the current report format then outputs that line using the Col_Group colour.
Page 111
44.10. Examples.
*
*
*
*
*
Single field....
Compute w_textno = 16 + p_sortby.
Concatenate 'TEXT-' w_textno into w_hdrt.
Assign (w_hdrt) to <f_hdrtext>.
Assign Component p_sortby of Structure t_repdata to <f_hdrval>.
Perform GroupHeader using <F_Hdrtext> <F_HdrVal>.
Else.
Material...
if p_sortby = 1.
Concatenate text-017 t_repdata-matnr '(' t_repdata-maktx ')'
into w_hdrtitle separated by ' '.
44.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
GroupHdr.
*
*
Purpose:
Prints a Group Header line
*
*
Entry:
Group Header Title
*
Entry:
Group Header value
*
*
Exit:
None
*
*
Called By:
Perform GroupHeader using Title Value.
*
*
Calls:
wline
*
PrintTitles
*
*
Modification History:
*
* Date Reason
Version Who
*
FORM GROUPHEADER using p_title
p_value.
Data: w__repline(255) type c,
w__offset
type i,
w__required
type i.
*
If w__lineprinted = True.
Perform TableLine.
EndIf.
*
* Have we enough room to print this plus column titles
*
*
* If MaxTline is 0, then the titles have not been printed, and
* we must be at the top of the page so we don't really care anyway.
*
* However, if MaxTline<>0 then the titles have been printed at
* least once and we can be anywhere on the page....
*
if w__grouphdr = False.
Read Table ReportTable Index 1.
Move True to w__grouphdr.
If ReportTable-MaxTline <> 0.
Compute w__Required = ReportTable-MaxTLine + 3.
Reserve w__Required Lines.
Endif.
Move space to w__repline.
Compute w__offset = ReportTable-StartPos.
Move sy-vline to w__repline+w__offset.
Compute w__offset = w__offset + 1.
Move p_title to w__repline+w__offset.
Compute w__offset = w__offset + Strlen( p_title ) + 1.
Move p_value to w__repline+w__offset.
Page 112
Page 113
45.
INITBREAK
45.1. Location.
YREPINC.
45.2. Purpose.
Initialises report breaks table
45.3. Entry.
45.3.1.Field to break on.
45.3.2.Title of field.
45.4. Exit.
45.5. Called By.
WRITELINE
Perform Initbreak using '*' 'Run Total:' c_no c_yes.
45.6. Calls.
45.7. Tables.
45.8. System Variables.
45.9. Description.
The routine makes an entry in an internal tables containing the field name of the report break, its
title and initial value. The routine then scans the report data table and provides an entry for each
numeric column in the report so that totals can be stored at each break level.
45.10. Examples.
Perform BuildReport using 'SELLTOTAL' text-005 15
'CURRENCY' 'WAERK'.
Perform BuildReport using 'NETWR' text-014 15
'CURRENCY' 'WAERK'.
Perform BuildReport using 'WAERK' Text-012 0 '' ''.
Perform FormatReport.
Read Table t_revenue Index 1.
Perform InitBreak using 'T_REVENUE-CENDNG' Text-015 c_no c_yes.
Perform InitBreak using 'T_REVENUE-VB'
Text-006 c_no c_yes.
Perform InitBreak using 'T_REVENUE-ENAME' Text-007 c_no c_yes.
Perform InitBreak using 'T_REVENUE-ABTEI' Text-008 c_no c_yes.
Perform InitBreak using 'T_REVENUE-KTEXT' Text-009 c_no c_yes.
Perform SaveReport using c_main_report.
*
*
45.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
InitBreak
*
*
Purpose:
Initialises report breaks table
*
Page 114
*
Entry:
Field to break on.
*
Entry:
Title of field.
*
*
Exit:
*
*
Called By:
Perform InitBreak using 'fieldname'
*
'title'
*
FormFeed Yes/No
*
Print Break Yes/No
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
*
* Initialise a report break.
*
Form InitBreak Using p_field p_title p_formfeed p_print.
Field-Symbols <TField>.
*
Data: t__cols like vbak-netwr occurs 0 with header line.
*
* Get access to the field value to set the initial break value
*
clear ReportBreaks.
*
* Get the table name....
*
Move p_field to ReportBreaks-field.
Move p_title to ReportBreaks-title.
Move p_formfeed to ReportBreaks-Ffeed.
Move p_print to ReportBreaks-Print.
If p_field <> '*'.
Assign (p_field) to <TField>.
Move <TField> to ReportBreaks-value.
Else.
Move '*' to ReportBreaks-Value.
EndIf.
*
* Set up the totals columns.
*
Zap T__Cols.
Loop at ReportTable.
Clear T__Cols.
Move 0 to t__cols.
Append t__cols.
EndLoop.
Move t__cols[] to ReportBreaks-Totals[].
Append ReportBreaks.
EndForm.
Page 115
46.
INIT_GLOBAL
46.1. Location.
YBDCINC.
46.2. Purpose.
Initialises all globally declared variables
46.3. Entry.
46.4. Exit.
Global variables (with some exceptions) set to Initial values
46.6. Calls.
46.7. Tables.
46.8. System Variables.
SY-SUBRC INT4 X
46.9. Description.
This routine scans the current SAP Instance's memory space for variables that are defined at a global
level. If these variable names are not found in the list of exceptions defined in the routine, then
these variables are cleared.
The reason behind this occured when a large group of programmers were working on a project. One
of the programmers insisted on using global variables, which the others did not. Instead of having
to keep track of what this one programmer was upto, this routine was written so that he could be
forgotten.....
46.10. Examples.
*
Perform Init_Global.
Move &1 to w__fname.
Translate w__fname to upper case.
Perform Read_YDCSET using w__fname sy-uname changing w__ydcset.
Zap t_bdcmsg.
*
* Get the function details and loop through the parameter list. If
* the variable is an export variable then initialise it. If it is an
46.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
Init_Global
*
Page 116
*
Purpose:
Initialises all globally declared variables
*
*
Entry:
*
*
Exit:
Global variables (with some exceptions) set to
*
Initial values
*
*
Called By:
Perform Init_Global
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form INIT_GLOBAL.
*
Field-Symbols: <F_GLOBAL>,
<F_LITL>.
" This occurs in 40A and above it
" specifies that a field is a
" fixed literal. For systems <40a
" assign it to a dummy var
" that is always false.
*
Data: Begin Of T_Fieldlist Occurs 0.
Include Structure Rfieldlist.
Data: End Of T_Fieldlist,
*
W_Clearit(1) Type C,
W_Strlen Type I,
W_First2(2) Type C,
W_Flitl(18) Type C.
*
* Get A List Of Global Variables For The Zabaco Function Module.
* The Program Name For This Is Saplzabaco
*
Call Function 'GET_GLOBAL_SYMBOLS'
Exporting
Program = C_Main_Program
Tables
Fieldlist = T_Fieldlist
Exceptions
Others = 1.
If Sy-Subrc = 0.
*
*
Set Up The Fixed Literal Field Symbol.
*
If Sy-Saprl+0(2) < '40'.
Move 'False' To W_Flitl.
Else.
Move 'T_Fieldlist-Flitl' To W_Flitl.
Endif.
Assign (W_Flitl) To <F_Litl>.
*
Loop At T_Fieldlist.
*
*
Only Look At W_ Or Wt_ Style Variables, Or Tables.
*
Move True To W_Clearit.
Move T_Fieldlist-Name+0(2) To W_First2.
*
*
If The Variable Is A Fixed Literal Ignore It (A Constant)
*
If <F_Litl> Is Initial.
*
*
Clear It Unless.....
*
Case W_First2.
When '$$'. Clear W_Clearit.
When '%_'. Clear W_Clearit.
When '<%'. Clear W_Clearit.
When 'C_'. Clear W_Clearit.
When 'RE'. Clear W_Clearit.
When 'RS'. Clear W_Clearit.
Page 117
*
*
*
*
*
Page 118
47.
IS_SERVICE_ACTIVE
47.1. Location.
YBDCINC.
47.2. Purpose.
Check to see if a specified service is Active.
NOTE: This routine checks to see if the specified service is active. If that service is loaded but
currently stopped then it is still considered active by SAP (RSMONGWY) However, if the service
is unloaded then this function returns false.
47.3. Entry.
47.3.1.Service Name to Check
47.4. Exit.
47.4.1.True - Service Active
47.4.2.False - Service not available
47.5. Called By.
47.6. Calls.
GWY_READ_CONNECTIONS
GET_LOCAL_HOST
47.7. Tables.
47.8. System Variables.
SY-SUBRC INT4 X
47.9. Description.
This procedure verifies if a given system is active or not.
47.10. Examples.
FUNCTION Z_IS_ABACO_ACTIVE.
*"---------------------------------------------------------------------*"*"Local interface:
*"
EXPORTING
*"
VALUE(E_ACTIVE) LIKE DATATYPE-CHAR0001
*"---------------------------------------------------------------------*
PERFORM IS_SERVICE_ACTIVE USING 'ABACO' CHANGING E_ACTIVE.
ENDFUNCTION.
47.11. SourceCode.
*EJECT
**********************************************************************
*
*
Procedure:
Is_Service_Active
*
*
Purpose:
Check to see if a specified service is
*
Active.
Page 119
*
*
NOTE: This routine checks to see if the
*
specified service is active. If
*
that service is loaded but
*
currently stopped then it is still
*
considered active by SAP (RSMONGWY)
*
However, if the service is
*
unloaded then this function returns
*
false.
*
*
Entry:
Service Name to Check
*
*
Exit:
True - Service Active
*
false - Service not available
*
*
Called By:
Perform Is_Service_Active using 'ABACO'
*
changing w_active.
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form Is_Service_Active Using Pu_Tp Like Gwy_Conn-Tp
Changing Pc_Active Like True.
*
Data: Begin Of T__Conn Occurs 0.
Include Structure Gwy_Conn.
Data: End Of T__Conn,
*
W__Local_Host Like Gwy_Struct-Gwhost,
W__Local_Serv Like Gwy_Struct-Gwserv,
W__Tp
Like Pu_Tp.
*
Move False To Pc_Active.
Perform Get_Local_Host Changing W__Local_Host W__Local_Serv.
Call Function 'GWY_READ_CONNECTIONS'
Exporting
Gwhost
= W__Local_Host
Gwserv
= W__Local_Serv
Tables
Connections
= T__Conn
Exceptions
Gwy_Unknown_Opcode
= 01
Gwy_Communication_Failure = 02
Gwy_Get_Tab_Failed
= 03
Gwy_Newline_Failed
= 04
Gwy_Tablen_Too_Short
= 05
Gwy_Get_Opcode_Failed = 06
Gwy_Get_Gwhost_Failed = 07
Gwy_Get_Gwserv_Failed = 08.
If Sy-Subrc = 0.
Move Pu_Tp To W__Tp.
Translate W__Tp To Upper Case.
Loop At T__Conn
Where Tp = W__Tp And
State = 'CONNECTED'.
Move True To Pc_Active.
Endloop.
Endif.
Endform.
Page 120
48.
NEWBDC
48.1. Location.
YBDCINC.
48.2. Purpose.
Starts a new BDC session
48.3. Entry.
48.3.1.None
48.4. Exit.
48.5. Called By.
48.6. Calls.
48.7. Tables.
48.8. System Variables.
48.9. Description.
Just sets a flag.....
48.10. Examples.
*
48.11. SourceCode.
**********************************************************************
*
*
Procedure:
NewBDC
*
*
Purpose:
Starts a new BDC session
*
*
Entry:
None
*
*
Exit:
*
*
Called By:
Perform NewBDC
*
*
Calls:
*
*
Modification History:
*
Page 121
* Date Reason
*
Form NewBDC.
Move False to w__BDCOpen.
EndForm.
Page 122
Version Who
49.
PRINTTITLES
49.1. Location.
YREPINC.
49.2. Purpose.
Prints titles for the columns of the report
49.3. Entry.
49.4. Exit.
49.5. Called By.
49.6. Calls.
TABLELINE
GIVELINE
WLINE
49.7. Tables.
49.8. System Variables.
SY-VLINE CHAR C
49.9. Description.
Using data previously built up from calls to BuildReport and FormatReport, this routine loops
through the table constructed by these calls, printing one line of each column title.
This process continues until nothing is printed across all columns.
PrintTitles should only be called after all calls to BuildReport and FormatReport have been
processed.
49.10. Examples.
Perform WriteCentre using w_title.
EndIf.
*
49.11. SourceCode.
*EJECT
***********************************************************************
*
Page 123
*
Procedure:
PrintTitles.
*
*
Purpose:
Prints titles for the columns of the report
*
*
Entry:
*
*
Exit:
None
*
*
Called By:
Perform PrintTitles
*
*
Calls:
wline
*
GiveLine
*
*
Modification History:
*
* Date Reason
Version Who
*
FORM PRINTTITLES.
data: w__repline(255) type c,
" Data line to print
w__title like dd04t-ddtext,
" Column title
w__offset
type i,
" Offset to start of column
w__hdrline
type i,
" Number of title line
w__lastpos
type i,
" Last column of report
w__more
like
" More to print ?
datatype-char0001.
*
Perform TableLine.
Move 1 to w__hdrline.
*
* Get the last report column position
*
Read Table ReportTable Index 1.
Compute w__LastPos = ReportTable-StartPos + ReportTable-MaxWidth.
do.
Move Space to w__repline.
Move False to w__more.
Loop At ReportTable.
Move Space to w__title.
*
*
Get a title for this column
*
Perform GiveLine
using w__hdrline
ReportTable-ColWidth
ReportTable-Title
changing w__title.
Compute w__offset = ReportTable-StartPos.
Move Sy-Vline to w__repline+w__offset.
if w__title <> ' '.
Compute w__offset = w__offset + 1.
Move w__title to w__repline+w__offset.
Move True to w__more.
endif.
EndLoop.
*
*
Anything to print ?
*
if w__more = True.
Compute w__hdrline = w__hdrline + 1.
Move sy-vline to w__repline+w__lastpos.
Perform WLine Using w__repline Col_Heading.
else.
exit.
endif.
enddo.
*
* Update the max title line field ?
*
Read Table ReportTable Index 1.
if ReportTable-MaxTline = 0.
Loop At ReportTable.
Compute ReportTable-MaxTline = w__hdrline + 1.
Modify ReportTable.
EndLoop.
Page 124
Endif.
Perform TableLine.
ENDFORM.
" PrintTitles
Page 125
50.
PRINTTOTALS
50.1. Location.
YREPINC.
50.2. Purpose.
Prints break level totals.
50.3. Entry.
50.3.1.Data tables to print totals for
50.3.2.Current total level
50.4. Exit.
50.5. Called By.
CHECKBREAKS
RUNTOTALS.
Perform PrintTotals using sy-index.
50.6. Calls.
TABLELINE
SETCOLOUR WRITEVALUE
50.7. Tables.
50.8. System Variables.
SY-VLINE CHAR C
SY-TABIX INT4 X
1
4
50.9. Description.
PrintTotals prints the totals accumulated during calls to Checkbreaks upto and including the break
level passed.
50.10. Examples.
*
*
*
*
50.11. SourceCode.
*EJECT
***********************************************************************
*
Page 126
*
Procedure:
PrintTotals
*
*
Purpose:
Prints break level totals.
*
*
Entry:
Data tables to print totals for
*
Entry:
Current total level
*
*
Exit:
*
*
Called By:
Perform PrintTotals
*
using p_totallevel
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form PrintTotals using p_totallevel.
*
Data: t__coltotals like vbak-netwr occurs 0 with header line,
w__pos
type i,
w__pos1
type i,
w__title(50) type c.
*
* Loop around the totals tables at the specified level.
*
Read table ReportBreaks index p_totallevel.
*
* Print this Break ?
*
If ReportBreaks-Print = c_yes.
If w__lineprinted = True.
Perform TableLine.
EndIf.
Write /001 ''.
Read table ReportTable index 1.
Compute w__pos = ReportTable-StartPos + 1.
Compute w__pos1 = ReportTable-First + ReportTable-MaxWidth + 1.
If ReportBreaks-Title <> 'Run Total:'.
Concatenate ReportBreaks-Title
ReportBreaks-Value
'Total:' into w__title separated by ' '.
Else.
Move ReportBreaks-Title to w__title.
EndIf.
Write: At w__pos sy-vline no-gap,
w__title no-gap,
at w__pos1 sy-vline no-gap.
Move ReportBreaks-Totals[] to t__coltotals[].
Loop at t__coltotals.
If not t__coltotals is initial.
*
*
Get the column positions to print at and also the
*
decimal places.
*
Read table ReportTable index sy-tabix.
Compute w__pos = ReportTable-StartPos + 1.
Write At w__pos sy-vline no-gap.
Perform SetColour using Col_Total.
Perform WriteValue using ReportTable-ColWidth
t__coltotals
ReportTable-ConvExit
ReportTable-Currency
ReportTable-Unit
ReportTable-Format.
Write sy-vline no-gap.
Format Color Off.
Endif.
EndLoop.
Position w__pos1.
Write sy-vline.
EndIf.
EndForm.
Page 127
Page 128
51.
PRG_DOC_HELP
51.1. Location.
YRBINC.
51.2. Purpose.
Displays help for current program
51.3. Entry.
51.4. Exit.
51.5. Called By.
51.6. Calls.
51.7. Tables.
TTCDS
4
8
51.9. Description.
This procedure displays the help associated with a program in a pop up window.
51.10. Examples.
WHEN 'FUN8'.
IF IT_STAT-STATUS = C_FINISHED.
SUBMIT YUPDSEQ AND RETURN WITH P_JOBNO = JOBNO.
ELSE.
MESSAGE W000 WITH TEXT-401.
ENDIF.
WHEN 'FUN9'.
PERFORM PRG_DOC_HELP.
* Update current job
ENDCASE.
*
* If a user double clicks a line and the line status is failed, drill
* down to the log report.
*
AT LINE-SELECTION.
51.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
Prg_Doc_Help
*
*
Purpose:
Displays help for current program
*
*
Entry:
*
*
Exit:
*
*
Called By:
Perform Prg_Doc_Help
*
*
Calls:
*
Page 129
*
Modification History:
*
* Date Reason
Version Who
*
form prg_doc_help.
*
Tables: ttcds.
*
Data: w_abapname like dokhl-object,
w_pf15
type c,
w_hometext like dsygh-doktitle,
*
begin of t_pline occurs 100,
text(80),
end of t_pline.
*
Select single * from ttcds where
progname = sy-repid .
If sy-subrc = 0.
Call function 'DSYS_SHOW'
Exporting
dokclass
= ttcds-dokclass
doklangu
= space
dokname
= ttcds-dokname
doktitle
=''
hometext
= w_hometext
outline
= ttcds-dsysgldrg
Importing
pf15 = w_pf15
Exceptions
class_unknown = 01
object_not_found = 02.
else.
*
*
Display ABAP documentation text
*
Move sy-repid to w_abapname.
Call function 'DOCU_PRINT'
exporting
dialog = 'X'
form
= 'S'
id
= 'RE'
langu = sy-langu
new_page = space
object = w_abapname
operation = 'P'
printer = space
typ
= 'E'
tables
line = t_pline.
Endif.
Endform.
Page 130
52.
READ_SCREEN_VALUES
52.1. Location.
YREPINC.
52.2. Purpose.
Provides access to screen fields before users presses enter.....
52.3. Entry.
52.4. Exit.
52.5. Called By.
Perform Read_Screen_Values
52.6. Calls.
52.7. Tables.
52.8. System Variables.
52.9. Description.
During the entry of report parameters, the parameters themselves are not accessable to variables
within the program until the user either hits the return key, or the process button. This is because
that that moment in time, the action is all happening on the presentation server and has not been
passed to SAP.
This procedure forces the values in the parameter variables to become available for use by other
procedures before return is hit, or the process button clicked.
52.10. Examples.
52.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
Read_Screen_Values
*
*
Purpose:
Provides access to screen fields before users
*
presses enter.....
*
*
Entry:
*
*
Exit:
Screen fields are available to the calling
Page 131
*
program
*
*
Called By:
Perform Read_Screen_Values
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form Read_Screen_Values.
*
Field-Symbols <f_fieldname>.
*
Data: Begin of t_dynpread occurs 0.
Include Structure dynpread.
Data: End of t_Dynpread.
*
Zap t_dynpread.
Call Function 'DYNP_VALUES_READ'
Exporting
Dyname
= syst-cprog
Dynumb
= syst-dynnr
Request
= 'A'
Tables
Dynpfields
= t_dynpread
Exceptions
Invalid_Abapworkarea = 1
Invalid_Dynprofield = 2
Invalid_Dynproname = 3
Invalid_Dynpronummer = 4
Invalid_Request
=5
No_Fielddescription = 6
Invalid_Parameter = 7
Undefind_Error
=8
Others
= 9.
Loop at t_dynpread.
Assign (t_dynpread-fieldname) to <f_fieldname>.
Move t_dynpread-fieldvalue to <f_fieldname>.
EndLoop.
EndForm.
Page 132
53.
READ_YDCSET
53.1. Location.
YBDCINC.
53.2. Purpose.
Gets the BDC profile to run
53.3. Entry.
53.3.1.Function Name
This is the function name to get settings for.
53.3.2.User Name.
Settings for a particular user only.
53.4. Exit.
53.4.1.YDCSET structure populated
53.5. Called By.
READ_YDCSET
Z_CALL_BDC
Perform Read_YDCSET using w__fname sy-uname changing w__ydcset.
53.6. Calls.
53.7. Tables.
53.8. System Variables.
SY-SUBRC INT4 X
53.9. Description.
The BDC Routines that are processed through these routines can be controlled by settings made in
thable YDCSET. The table is keyed by RFC/Transaction name and user name.
If during initialisation an entry is found for the current RFC or Transaction, then the various entries
in the YDCSET structure are completed. See section 4above for an explanation of the YDCSET
structure and table.
53.10. Examples.
w__name
like catfu-name,
w__dump(30) type c,
w__fname
like tfdir-funcname.
Perform Init_Global.
Move &1 to w__fname.
Translate w__fname to upper case.
Perform Read_YDCSET using w__fname sy-uname changing w__ydcset.
Zap t_bdcmsg.
*
* Get the function details and loop through the parameter list. If
* the variable is an export variable then initialise it. If it is an
* import variable that is optional with a proposal, set the variable
Page 133
53.11. SourceCode.
*EJECT
**********************************************************************
*
*
Procedure:
Read_YDCSet
*
*
Purpose:
Gets the BDC profile to run
*
*
Entry:
Function Name
*
This is the function name to get settings
*
for.
*
*
User Name.
*
Settings for a particular user only
*
*
Exit:
YDCSET structure populated
*
*
Called By:
Perform Read_YDCSET using w_fname sy-uname
*
changing w_ydcset.
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
*
Form Read_YDCSET using pu_funcname like tfdir-funcname
pu_uname like sy-uname
changing pc_ydcset structure ydcset.
*
Select single * from ydcset
into pc_ydcset
where funcname = pu_funcname and
uname = pu_uname.
*
* No setting for a particular function/programmer. Look for the
* generic function......
*
If sy-subrc <> 0.
Select single * from ydcset
into pc_ydcset
where funcname = pu_funcname and
uname = ''.
*
*
No entry - use the default...
*
If sy-subrc <> 0.
Select single * from ydcset
into pc_ydcset
where funcname = 'DEFAULT'.
Endif.
EndIf.
If pc_ydcset-bdcmode is initial.
Move 'N' to pc_ydcset-bdcmode.
EndIf.
If w__ydcset-bdcupmode is initial.
Move 'S' to pc_ydcset-bdcupmode.
EndIf.
EndForm.
Page 134
54.
REPHEADER
54.1. Location.
YREPINC.
54.2. Purpose.
Provides a standardized report header for use in printed reports
54.3. Entry.
54.3.1.Company Code
54.3.2.Report Title
54.4. Exit.
54.4.1.Report header produced for current report
54.5. Called By.
54.6. Calls.
UNDERLINE
54.7. Tables.
T001
54.9. Description.
54.10. Examples.
*
*
Modification History:
*
Form Top_Of_Page.
*
Data: w_title(60) type c.
*
Perform RepHeader using '' sy-title.
Concatenate Text-018 ':' p_lgnum into w_title.
Perform WriteCentre using w_title.
Psub s_matnr Text-022.
Psub s_charg Text-023.
Psub s_vltyp Text-024.
Psub s_vlpla Text-025.
Case c_on.
Page 135
54.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
Repheader.
*
*
Purpose:
Provides a standardized report header for use
*
in printed reports
*
*
Entry:
Company Code
*
Entry:
Report Title
*
*
Exit:
Report header produced for current report
*
*
*
Called By:
Perform Repheader using Company Code Title.
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form RepHeader using p_cocode like t001-bukrs
p_reptitle like sy-title.
Tables: T001.
Data: w__offset
type i.
Move False to w__grouphdr.
Move False to w__lineprinted.
*
* Top Line - Report - co - User
*
Perform UnderLine using 0 sy-linsz.
Write: / 'Report:' no-gap,sy-repid.
*
* Get the company name and centralise this within the report line
* width
*
Select single * from T001 where bukrs = P_COCODE.
compute w__offset = ( sy-linsz - strlen( t001-butxt ) ) / 2.
Position w__offset.
Write T001-butxt.
*
* User Details
*
compute w__offset = sy-linsz - 17.
Position w__offset.
Write: 'User:' no-gap,sy-uname.
*
* Line 2 - SysID and Date.
*
Write: / ' Sysid:' no-gap, sy-sysid.
compute w__offset = ( sy-linsz - 10 ) / 2.
Position w__offset.
Write: 'SAP R/' no-gap, sy-saprl.
Compute w__offset = sy-linsz - 17.
Position w__offset.
Write: 'Date:' no-gap,sy-datum.
*
* Line 3 - Page - Report Title - time.
*
write: / ' Page:' no-gap,sy-pagno.
*
* Report title.
*
compute w__offset = ( sy-linsz - STRLEN( p_reptitle ) ) / 2.
Position w__offset.
Write p_reptitle.
*
* Time
*
compute w__offset = sy-linsz - 17.
Position w__offset.
Page 136
Page 137
55.
RUNTOTALS
55.1. Location.
YREPINC.
55.2. Purpose.
Prints All sub total levels and a final run total
55.3. Entry.
55.4. Exit.
55.5. Called By.
55.6. Calls.
PRINTTOTALS
TABLELINE
55.7. Tables.
55.8. System Variables.
SY-TABIX INT4 X
SY-SUBRC INT4 X
4
4
55.9. Description.
RunTotals loops around the table of report break points initialised by calls to INITBREAK. The
current values are printed out for each numeric column on the report and then these values are added
to the next highest break level. This continues until the last record in the Break table is processed
where upon the the totals for the entire report will be printed.
55.10. Examples.
Perform CheckBreaks tables t_repdata.
Endif.
Perform Writeline tables t_repdata using Col_Normal.
EndLoop.
*
*
*
*
*
*
Final totals.
Perform RunTotals Tables t_repdata.
Any Error reports ?
Perform DisplayErrors.
Perform Writecentre using Text-013.
ENDFORM.
" DISPLAYREPORT
*&---------------------------------------------------------------------*
55.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
RunTotals
*
*
Purpose:
Prints All sub total levels and a final run total
*
*
Entry:
Report data table
*
*
Exit:
*
*
Called By:
Perform RunTotals.
Page 138
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form RunTotals.
*
Data: w__pos
type i,
w__breaklevel type i,
t__coltotals like vbak-netwr occurs 0 with header line,
t__carry
like vbak-netwr occurs 0 with header line.
*
Zap t__coltotals.
Zap t__carry.
Loop at ReportBreaks.
*
*
Carry forward previous level totals
*
Move sy-tabix to w__breaklevel.
Move ReportBreaks-Totals[] to t__carry[].
Loop at t__carry.
Move sy-tabix to w__pos.
Read Table t__coltotals index w__pos.
if sy-subrc = 0.
Compute t__coltotals = t__coltotals + t__carry.
Modify t__coltotals index w__pos.
Else.
Move t__carry to t__coltotals.
Append T__Coltotals.
EndIf.
EndLoop.
Move t__coltotals[] to ReportBreaks-totals[].
Modify ReportBreaks index w__breaklevel.
Perform PrintTotals using w__breaklevel.
EndLoop.
Perform TableLine.
EndForm.
Page 139
56.
SAVEREPORT
56.1. Location.
YREPINC.
56.2. Purpose.
Takes the currently defined report and places it in the report stack. If the report already exists in the
stack then the current record is overwritten
56.3. Entry.
56.3.1.Report Name
56.4. Exit.
56.5. Called By.
USEREPORT
Perform SaveReport using w__currep.
56.6. Calls.
56.7. Tables.
56.8. System Variables.
SY-SUBRC INT4 X
SY-TABIX INT4 X
4
4
56.9. Description.
The reporting routines can only use one report format at a time, however, in some cases a second
or third format is required, for example where a ledger listing is being produced and the user
requires a list of all the sub-items that make up the account total.
This routine takes the currently defined report and saves it in a table, along with other information
defined in the current break tables. This ensures that the total breaks are not disturbed when report
formats are switched back and forth.
56.10. Examples.
*
*
*
Perform FormatReport.
Read Table t_revenue Index 1.
Perform InitBreak using 'T_REVENUE-CENDNG' Text-015 c_no c_yes.
Perform InitBreak using 'T_REVENUE-VB'
Text-006 c_no c_yes.
Perform InitBreak using 'T_REVENUE-ENAME' Text-007 c_no c_yes.
Perform InitBreak using 'T_REVENUE-ABTEI' Text-008 c_no c_yes.
Perform InitBreak using 'T_REVENUE-KTEXT' Text-009 c_no c_yes.
Perform SaveReport using c_main_report.
And the billing report.
Zap ReportTable.
Perform BuildReport using 'VBELN0' Text-019 10 '' ''.
Perform BuildReport using 'ERDAT0' Text-020 8 'DD/MM/YY' ''.
Perform BuildReport using 'CREDT0' Text-021 11 '' ''.
56.11. SourceCode.
*EJECT
***********************************************************************
Page 140
*
*
Procedure:
SaveReport
*
*
Purpose:
Takes the currently defined report
*
and places it in the report stack. If the
*
report already exists in the stack then
*
the current record is overwritten
*
*
Entry:
Report Name
*
*
Exit:
*
*
Called By:
Perform Namereport using 'RepName'
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form SaveReport using pu_repname like t__reportstack-repname.
*
Data: w__repname like t__reportstack-repname.
*
* IS the report already here ?
*
Move pu_repname to w__repname.
Translate w__repname to upper case.
Read Table t__reportstack with key repname = w__repname.
If sy-subrc = 0.
Move ReportTable[] to t__reportstack-reports[].
Move ReportBreaks[] to t__reportstack-repbreaks[].
Modify t__reportstack index sy-tabix.
Else.
Move w__repname to t__reportstack-repname.
Move ReportTable[] to t__reportstack-reports[].
Move ReportBreaks[] to t__reportstack-repbreaks[].
Append t__reportstack.
EndIf.
Move w__repname to w__currep.
EndForm.
Page 141
57.
SETCOLOUR
57.1. Location.
YREPINC.
57.2. Purpose.
Sets the output colour
57.3. Entry.
57.3.1.Colour to set
57.4. Exit.
57.5. Called By.
WRITELINE
WLINE
PRINTTOTALS
Perform SetColour using P_Colour.
57.6. Calls.
57.7. Tables.
57.8. System Variables.
57.9. Description.
Sets the output colour to one of the standard pre-defined reporting colours used by ABAP.
57.10. Examples.
Else.
If ReportTable-Symbol = True.
Write: ' ' no-gap, ReportTable-Isyname as Symbol.
Else.
*
*
*
57.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
SetColour
*
*
Purpose:
Sets the output colour
*
*
Entry:
Colour to set
*
*
Exit:
Page 142
*
*
Called By:
Perform SetColour Using P_Colour
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form SetColour using P_Colour.
*
Data: w_colour like col_heading.
*
Move p_colour to w_colour.
Format Color = w_colour.
EndForm.
Page 143
58.
SHOW_PROGRESS
58.1. Location.
YREPINC.
58.2. Purpose.
Displays a progress message on the status line
58.3. Entry.
58.3.1.Message to display
58.4. Exit.
58.5. Called By.
Perform Show_Progress using text-023.
58.6. Calls.
58.7. Tables.
58.8. System Variables.
58.9. Description.
This routine outputs a text message to the status bar, only doing so if the message has changed.
58.10. Examples.
58.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
Show_Progress
*
*
Purpose:
Displays a progress message on the status line
*
*
Entry:
Message to display
*
*
Exit:
*
*
Called By:
Perform Show_Progress
*
*
Calls:
*
*
Modification History:
*
Form Show_Progress using pu_text.
*
Statics w_text like t100-text.
*
If w_text <> pu_text.
Move pu_text to w_text.
Call Function 'SAPGUI_PROGRESS_INDICATOR'
Exporting
*
PERCENTAGE = 0
TEXT
= w_text
Exceptions
OTHERS = 1.
Endif.
Page 144
EndForm.
Page 145
59.
SORTREP
59.1. Location.
YREPINC.
59.2. Purpose.
Sorts a report based upon at user-command.
59.3. Entry.
59.3.1.Table to sort.
59.4. Exit.
59.4.1.Table Sorted.
59.4.2.Report column table sorted on
59.4.3.Sort direction 'A' or 'D'
59.5. Called By.
WLINE
59.6. Calls.
59.7. Tables.
59.8. System Variables.
SY-STACO INT4 X
SY-CUCOL INT4 X
SY-INDEX INT4 X
SY-SUBRC INT4 X
SY-UCOMM CHAR C
4
4
4
4
59.9. Description.
By placing this call in the At User-Command section of the program, the routine will detect the
actual report column that the user wishes to sort on and then sort the report.
The report displaying procedure must then be called once more to re-display the report.
The calling program is responsible for setting PF-STATUS. The GUI named in the SET PFSTATUS call must have the sort up and sort down buttons named STUP and STDN.
59.10. Examples.
*Eject
At User-Command.
Data w_ucomm like sy-ucomm.
*
Move sy-ucomm to w_ucomm.
Case w_ucomm.
When 'STUP'.
Perform SortRep Tables T_Repdata changing w_sortfield
w_sortdir.
When 'STDN'.
Page 146
59.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
SortRep
*
*
Purpose:
Sorts a report based upon at user-command.
*
*
Entry:
Table to sort.
*
*
Exit:
Table Sorted.
*
Exit:
Report column table sorted on
*
Exit:
Sort direction 'A' or 'D'
*
*
Called By:
At user-Command.
*
Perform SortRep
*
Tables RData
*
changing p_field p_dir
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
* Get the column to sort by.
*
Form SortRep Tables p_table changing p_sortfd p_sortdir.
Field-Symbols: <SortField>, <TestField>.
Data: w__fpos type i,
" Position on screen where field is.
w__sortfd type i,
" Number of sort field in data table.
w__dist type i,
" Distance between fields
w__cucol like sy-cucol." Cursor position on report
*
* Find the report column they want to sort on. Sy-cucol is the
* current screen cursor position.
*
Move 0 to w__sortfd.
*
* add the first displayed column + the actual column on screen
*
Compute w__cucol = sy-staco + sy-cucol.
Loop At ReportTable.
Compute w__fpos = ReportTable-StartPos + ReportTable-ColWidth.
if w__fpos >= w__cucol.
Assign Component ReportTable-FieldName
of Structure p_table to <SortField>.
Exit.
EndIf.
EndLoop.
*
* If this is a valid sort field then translate the report field
* to the data table.
*
Do.
Assign Component sy-index of Structure p_table to <TestField>.
if sy-subrc <> 0.
exit.
Endif.
Describe Distance between <SortField>
and <TestField>
into w__dist.
if w__dist = 0.
If <TestField> = <SortField>.
Move sy-index to w__sortfd.
Exit.
EndIf.
Page 147
*
*
*
EndIf.
EndDo.
If not w__sortfd is Initial.
Retrieve the field name from ReportTable and Sort on it.
Page 148
60.
STRIPSTRING
60.1. Location.
YRBINC.
60.2. Purpose.
Removes specified characters from string
60.3. Entry.
60.3.1.String to remove characters from.
60.3.2.String of characters to remove
60.4. Exit.
60.4.1.Entry string with strip chars removed
60.5. Called By.
60.6. Calls.
60.7. Tables.
60.8. System Variables.
SY-INDEX INT4 X
SY-SUBRC INT4 X
SY-FDPOS INT4 X
4
4
4
60.9. Description.
The routine loops around the string containing the list of characters to remove.
For each character in the Remove string, the input string is searched. If the character exists in the
input string, then the character is removed from the input string, shortening the input string by one
character. This continues until the character from the Remove string no longer exists in the input
string. The routine then moves onto the next character in the remove string.
60.10. Examples.
60.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
StripString.
*
*
Purpose:
Removes specified characters from string
*
*
Entry:
String to remove characters from.
*
Entry:
String of characters to remove
*
*
Exit:
Entry string with strip chars removed
*
*
Called By:
Perform striptring
*
using p_string p_remove
*
changing p_out
*
*
Calls:
Page 149
*
*
Modification History:
*
* Date Reason
Version Who
*
Form StripString using p_string p_remove
changing p_out.
Data: w__remchar(1) type c,
" The character to remove
w__rempos type i,
" remove character pos
w__remlen type i,
" length of p_remove
w__fdpos
like sy-fdpos,
" position of remchar
w__cpstr(255) type c.
*
Move p_string to p_out.
Compute w__remlen = Strlen( p_remove ).
Do w__remlen times.
*
*
Get the character to remove from the string.
*
Compute w__rempos = sy-index - 1.
Move p_remove+w__rempos to w__remchar.
Search p_out for w__remchar.
While sy-subrc = 0.
Compute w__fdpos = sy-fdpos.
Move p_out to w__cpstr+0(w__fdpos).
Compute w__fdpos = sy-fdpos + 1.
Move p_out+w__fdpos to w__cpstr+sy-fdpos.
Move w__cpstr to p_out.
Search p_out for w__remchar.
EndWhile.
EndDo.
EndForm.
Page 150
61.
SUBTITLES
61.1. Location.
YREPINC.
61.2. Purpose.
Prints a list of search criteria. This routine should not be called via a user program.
61.3. Entry.
61.4. Exit.
61.5. Called By.
SORTREP
61.6. Calls.
WRITECENTRE
61.7. Tables.
61.8. System Variables.
61.9. Description.
The routine looks at the option field passed by the calling program. This contains a code which
specifies the search criteria to apply. This is then changed into words and topped/tailed with
parameter information. This is then written out.
61.10. Examples.
*
*
Modification History:
*
* Date Reason
Version Who
*
Define PSub.
Loop at &1.
Perform Subtitles using &2
&1-Sign &1-option
&1-low &1-high.
EndLoop.
End-Of-Definition.
*Eject
***********************************************************************
*
61.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
SubTitle
*
*
Purpose:
Prints a list of search criteria
*
*
Entry:
Search Criteria
*
*
Exit:
*
*
Called By:
loop at t_opts.
*
Perform Subtitles Sort sign option low high
*
Page 151
*
Calls:
WriteCentre
*
ReportLine
*
*
Modification History:
*
* Date Reason
Version Who
*
FORM SUBTITLES using p_text p_sign p_option p_low p_high.
*
* Get the column to sort by.
*
Data: w__subtitle(150) type c,
w__option(50) type c,
w__join(4)
type c,
w__sign(20)
type c,
w__plural(60) type c,
w__low(150)
type c,
w__high(150) type c.
*
* Format the input parameters.
*
Write p_low to w__low.
Write p_high to w__high.
*
* Decide on the initial wording.
*
move 'that' to w__join.
Case p_option.
When 'EQ'. Move 'are equal to' to w__option.
When 'NE'. Move 'are not equal to' to w__option.
When 'CP'. Move 'contains pattern' to w__option.
When 'NP'. Move 'does not contain pattern' to w__option.
When 'GE'. Move 'are greater than or equal to' to w__option.
When 'LT'. Move 'are less than' to w__option.
When 'LE'. Move 'are less than or equal to' to w__option.
When 'GT'. Move 'are greater than' to w__option.
When 'BT'. Move 'are between' to w__option.
When 'NB'. Move 'are not between' to w__option.
EndCase.
*
* Inclusive or exclusive.
*
if p_sign = 'I'.
Move 'Inclusive' to w__sign.
else.
Move 'Exclusive' to w__sign.
endif.
*
* Form the sentence.
*
Concatenate p_text 's' into w__plural.
if p_option <> 'BT'
and p_option <> 'NB'.
Concatenate 'For all' w__plural w__join w__option
w__low w__sign
into w__subtitle
separated by ' '.
else.
Concatenate 'For all' w__plural w__join w__option
w__low 'and' w__high w__sign
into w__subtitle
separated by ' '.
Endif.
Perform WriteCentre using w__subtitle.
EndForm.
Page 152
62.
TABLELINE
62.1. Location.
YREPINC.
62.2. Purpose.
Places a line on a report spanning the current report.
62.3. Entry.
62.4. Exit.
62.4.1.Global flag w__line printed set to true.
62.5. Called By.
GROUPHEADER
PRINTTITLES.
USEREPORT
CHECKBREAKS
PRINTTOTALS
RUNTOTALS.
Perform TableLine.
62.6. Calls.
UNDERLINE
62.7. Tables.
62.8. System Variables.
62.9. Description.
Prints an underline from the start position of the currently defined table to the last column of the
currently defined table.
62.10. Examples.
FORM GROUPHEADER using p_title
p_value.
Data: w__repline(255) type c,
w__offset
type i,
w__required
type i.
*
If w__lineprinted = True.
Perform TableLine.
EndIf.
*
* Have we enough room to print this plus column titles
*
*
* If MaxTline is 0, then the titles have not been printed, and
* we must be at the top of the page so we don't really care anyway.
62.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
Tableline.
Page 153
*
*
Purpose:
Places a line on a report spanning the current
*
report.
*
*
Entry:
none
*
*
Exit:
Global flag w__line printed set to true.
*
*
Called By:
Perform TableLine
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
FORM TABLELINE.
Data: w__maxwidth type i.
Read Table ReportTable Index 1.
Compute w__maxwidth = ReportTable-Maxwidth + 1.
Perform UnderLine using ReportTable-StartPos w__MaxWidth.
ENDFORM.
Page 154
63.
UNDERLINE
63.1. Location.
YREPINC.
63.2. Purpose.
Places a line on a report
63.3. Entry.
63.3.1.Start position
63.3.2.Width
63.4. Exit.
63.4.1.Global flag w__line printed set to true.
63.5. Called By.
REPHEADER
TABLELINE.
Perform UnderLine using 0 sy-linsz.
63.6. Calls.
63.7. Tables.
63.8. System Variables.
SY-ULINE CHAR C
255
63.9. Description.
Prints a line on the report from absolute co-ordinates.
63.10. Examples.
*
*
*
Tables: T001.
Data: w__offset
type i.
Move False to w__grouphdr.
Move False to w__lineprinted.
Top Line - Report - co - User
Perform UnderLine using 0 sy-linsz.
Write: / 'Report:' no-gap,sy-repid.
*
*
*
*
Get the company name and centralise this within the report line
width
Select single * from T001 where bukrs = P_COCODE.
compute w__offset = ( sy-linsz - strlen( t001-butxt ) ) / 2.
63.11. SourceCode.
*EJECT
***********************************************************************
*
Page 155
*
Procedure:
Underline.
*
*
Purpose:
Places a line on a report
*
*
Entry:
Startposition
*
Entry:
Width
*
*
Exit:
Global flag w__line printed set to true.
*
*
Called By:
Perform Underline using Start,Width.
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
FORM UNDERLINE using p_start type i
p_width type i.
*
Statics: w__lastline like sy-linno,
" last underline
w__lastwidth type i.
" and length
*
Data: w__repline(255) type c.
*
*
If the current line is an underline,
*
don't do another one. This aids in joining up reports of
*
different formats, unless the last line was shorter than the
*
current line.
*
If w__lastline <> sy-linno
or w__lastwidth < p_width.
Move space to w__repline.
Move sy-uline to w__repline+p_start(P_width).
Move sy-linno to w__lastline.
Move p_width to w__lastwidth.
If w__lastline = sy-linno.
Write / w__repline.
Else.
Position 1.
write w__repline.
EndIf.
Else.
Skip 2.
EndIf.
ENDFORM.
"UNDERLINE
Page 156
64.
USEREPORT
64.1. Location.
YREPINC.
64.2. Purpose.
Retreives a specified report from the report stack after saving the current report
64.3. Entry.
64.3.1.Report Name
64.4. Exit.
64.5. Called By.
64.6. Calls.
TABLELINE
SAVEREPORT
64.7. Tables.
64.8. System Variables.
SY-SUBRC INT4 X
64.9. Description.
This procedure readies the reporting routines to start prining a report format that has previously been
saved using SaveReport. The break-points and totals are all restored to their previous state, and the
report formating is also save to the state prior to the call to save report.
This enables multi-format reports to be produced whilst keeping the run totals and so forth intact.
64.10. Examples.
w_vbeln like vbak-vbeln.
*
*
*
*
64.11. SourceCode.
*EJECT
Form UseReport using pu_repname like t__reportstack-repname.
*
Data: w__repname like t__reportstack-repname.
*
Move pu_repname to w__repname.
Translate w__repname to upper case.
If w__repname <> w__currep.
*
Page 157
*
*
*
*
*
If w__lineprinted = True.
Perform TableLine.
EndIf.
Perform SaveReport using w__currep.
EndIf.
Read Table t__reportstack with key repname = w__repname.
If sy-subrc = 0.
Zap: ReportTable, ReportBreaks.
Move t__reportstack-Reports[] to ReportTable[].
Move t__reportstack-Repbreaks[] to ReportBreaks[].
Move w__repname
to w__currep.
EndIf.
EndIf.
EndForm.
Page 158
65.
WLINE
65.1. Location.
YREPINC.
65.2. Purpose.
Prints the supplied data line to the report
65.3. Entry.
65.3.1.Dataline to print
65.3.2.Colour of line.
The colour of the line should be specified using one of the colour constants defined by
SAP:
col_background
col_heading
col_normal
col_total
col_key
col_positive
col_negative
col_group
Page 159
65.4. Exit.
65.5. Called By.
GROUPHEADER
PRINTTITLES.
Perform WLine Using w__repline Col_Group.
65.6. Calls.
SETCOLOUR
65.7. Tables.
65.8. System Variables.
SY-VLINE
SY-SUBRC
SY-FDPOS
SY-LINSZ
CHAR C
INT4 X
INT4 X
INT4 X
1
4
4
4
65.9. Description.
This routine outputs data to the report, making certain that the colour attributs work correctly and
do not extend back to the start of the line.
65.10. Examples.
Move sy-vline to w__repline+w__offset.
Compute w__offset = w__offset + 1.
Move p_title to w__repline+w__offset.
Compute w__offset = w__offset + Strlen( p_title ) + 1.
Move p_value to w__repline+w__offset.
Compute w__offset = ReportTable-StartPos + ReportTable-MaxWidth.
Move sy-vline to w__repline+w__offset.
Perform WLine Using w__repline Col_Group.
Perform TableLine.
Move False to w__grouphdr.
Move False to w__lineprinted.
Endif.
ENDFORM.
" Group Header.
*Eject
***********************************************************************
65.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
WLine.
*
*
Purpose:
Prints the supplied data line to the report
*
*
Entry:
Dataline to print
*
Entry:
colour of line
*
*
Exit:
*
*
Called By:
Perform WLine using w__dataline Col_Group
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
FORM WLINE Using p_dataline p_colour.
Data: w__repline(255) type c,
w__filler(255) type c,
w__offset
type i,
Page 160
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
w__count
type i.
When you write data lines to the screen the colour formatting
extends back to column 1. This routine attempts to get rid of it
And you can't specify parameters for the colour statement.
Another byte yer bum from SAP!
Search p_dataline for sy-vline.
if sy-subrc = 0.
compute w__offset = sy-fdpos + 1.
Move p_dataline+0(w__offset) to w__filler.
Move p_dataline to w__repline.
Add on a final vertical line.
Read Table ReportTable Index 1.
compute w__offset = ReportTable-First + ReportTable-Maxwidth.
Move sy-vline to w__repline+w__offset.
else.
Move p_dataline to w__repline.
endif.
Perform Setcolour using P_Colour.
Write: / w__repline.
Format Color Off.
Here's another bum byter. You can't specify a variable position
in a write statement - like write varpos variable......
However, there is the 'POSITION' statement which I've only just
discovered after writing this the hard way.
All I want to do is clear a few spaces at the start of the line
and at the end of the line.
compute w__count = strlen( w__repline ) + 1.
do.
Position w__count.
write ' ' no-gap.
compute w__count = w__count + 1.
if w__count > sy-linsz.
exit.
endif.
enddo.
Page 161
66.
WRITECENTRE
66.1. Location.
YREPINC.
66.2. Purpose.
Centres and writes the text across the current report width
66.3. Entry.
66.3.1.Text to centre
66.4. Exit.
66.5. Called By.
SUBTITLES
Perform WriteCentre using w__subtitle.
66.6. Calls.
66.7. Tables.
66.8. System Variables.
SY-LINSZ INT4 X
66.9. Description.
This routine centres the specified text below the current report.
66.10. Examples.
separated by ' '.
else.
Concatenate 'For all' w__plural w__join w__option
w__low 'and' w__high w__sign
into w__subtitle
separated by ' '.
Endif.
Perform WriteCentre using w__subtitle.
EndForm.
*Eject
***********************************************************************
*
*
Procedure:
Checkbreaks
*
*
Purpose:
Checks and prints total breaks
66.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
WriteCentre.
*
*
Purpose:
Centres and writes the text across the current
*
report width
*
*
Entry:
Text to centre
*
*
Exit:
Page 162
*
*
Called By:
Perform WriteCentre using w__text
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
FORM WRITECENTRE using p_text.
Data: w__offset
type i,
w__repline(255) type c.
Move space to w__repline.
Compute w__offset = ( sy-linsz - strlen( p_text ) ) / 2.
Move p_text to w__repline+w__offset.
Write /001 w__repline.
ENDFORM.
Page 163
67.
WRITECOL
67.1. Location.
YREPINC.
67.2. Purpose.
Writes a single column.
67.3. Entry.
67.3.1.Data line and column to print
67.3.2.Column to use.
67.4. Exit.
67.5. Called By.
INITBREAK
Perform WriteCol using &1 &2.
67.6. Calls.
67.7. Tables.
67.8. System Variables.
SY-SUBRC INT4 X
SY-VLINE CHAR C
4
1
67.9. Description.
This subroutine takes a line of text and places it in a specific column on the current report.
67.10. Examples.
*
*
Modification History:
*
* Date Reason
Version Who
*
Define WriteTable.
Loop at &1.
Perform WriteCol using &1 &2.
EndLoop.
End-Of-Definition.
*eject
**********************************************************************
*
*
Procedure:
WriteColumn
*
67.11. SourceCode.
*EJECT
**********************************************************************
*
*
Procedure:
WriteColumn
*
*
Purpose:
Writes a single column.
Page 164
*
*
Entry:
Data line and column to print
*
Entry:
Column to use.
*
*
Exit:
*
*
Called By:
Perform WriteCol using p_column p_data.
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form WriteCol using p_data p_fieldname.
*
Data: w__fieldname(10) type c,
" Upper case column name
w__data(255) type c,
" Data to print
w__pos type i.
*
Move p_fieldname to w__fieldname.
Move p_data to w__data.
Translate w__fieldname to upper case.
*
* Find the Report table entry for this column.
*
if sy-subrc = 0.
Write /001 ''.
Loop at ReportTable.
Compute w__pos = ReportTable-StartPos + 1.
Write at w__pos sy-vline no-gap.
If ReportTable-FieldName = w__fieldname.
Format Color Col_Normal.
Write at (ReportTable-ColWidth) w__data.
Format Color Off.
EndIf.
EndLoop.
Read table ReportTable Index 1.
Compute w__pos = ReportTable-StartPos
+ ReportTable-MaxWidth + 1.
Write at w__pos sy-vline no-gap.
EndIf.
EndForm.
Page 165
68.
WRITELINE
68.1. Location.
YREPINC.
68.2. Purpose.
Writes a data line to the screen, creating hide fields at the same time.
68.3. Entry.
68.3.1.Table work area containing report data
68.3.2.Colour to use to print the data in.
68.4. Exit.
68.5. Called By.
68.6. Calls.
68.7. Tables.
68.8. System Variables.
SY-VLINE CHAR C
SY-TABIX INT4 X
1
4
68.9. Description.
Looping through a table structure defined by successive calls to BuildReport the WriteLine routine
takes positioning information and places the relevant information on the report.
This is achieved by using ASSIGN to indirectly access the fields in the table structure itself. An
entire line is output complete with vertical bars.
At the same time this is occuring, the routine 'Hides' the variables output to the report for later use
should the report have drill-down capabilities.
'Hidden' variables can be recalled in the following manner:
At Line-Selection.
*
* If the user selects a line, take them to the programmers screen.
*
Data: w_bname like usr02-bname,
w_pname like trdir-name.
*
If w_state = '0'.
Move '' to w_bname.
Read Line sy-lilli field value t_users-bname into w_bname.
if not w_bname is initial.
Perform DoUsers using w_bname.
EndIf.
Else.
Move '' to w_pname.
Read Line sy-lilli field value t_programs-name into w_pname
t_programs-bname into w_gname.
if not w_pname is initial.
Perform DoDl using w_pname p_outdir.
EndIf.
Page 166
EndIf.
68.10. Examples.
Sort t_lqua by matnr.
Loop at t_lqua.
If w_matnr <> t_lqua-matnr.
Concatenate t_lqua-matnr ':' t_lqua-maktx into w_text.
Perform GroupHeader using Text-022 w_text.
Move t_lqua-matnr to w_matnr.
EndIf.
Perform WriteLine using t_lqua Col_Normal.
EndLoop.
Perform EndReport.
EndForm.
*
Form EndReport.
Perform TableLine.
Perform WriteCentre using text-015.
68.11. SourceCode.
*Eject
***********************************************************************
*
*
Procedure:
WriteLine
*
*
Purpose:
Writes a data line to the screen, creating
*
hide fields at the same time.
*
*
Entry:
Table containing report data
*
Entry:
Colour to use to print the data in.
*
*
Exit:
*
*
Called By:
Perform WriteLine using TableName P_Colour
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form WriteLine using P_DataTable P_Colour.
*
Constants: c__blanks(100) type c value ' '.
*
Data: t__coltotals like vbak-netwr occurs 0 with header line,
w__pos
Type i,
w__spaces type i,
w__type(1) type c,
w__symbol(2) type c.
*
* Do we need to add a run total break ?
*
If w__runtotal = True.
Perform Initbreak using '*' 'Run Total:' c_no c_yes.
Move False to w__runtotal.
EndIf.
Write /001 ''.
Loop at ReportTable.
*
*
Point to the relevant field.
*
Assign Component ReportTable-FieldName
of structure P_DataTable to <RField>.
Compute w__pos = reportTable-StartPos + 1.
Position w__Pos.
Write: sy-vline no-gap.
*
*
Check box ?
*
Case True.
Page 167
*
*
*
When ReportTable-CheckBox.
Centre the check box within the column
w__spaces = ( ReportTable-ColWidth - 1 ) / 2.
Write at (w__spaces) c__blanks no-gap.
Write <RField> as CheckBox no-gap.
Hide <Rfield>.
When ReportTable-Icon.
If ReportTable-hotspot <> True.
Write: ' ' no-gap, ReportTable-Isyname as icon.
Else.
Write: ' ' no-gap, ReportTable-Isyname
as icon Hotspot on.
EndIf.
When ReportTable-Symbol.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
Page 168
Page 169
69.
WRITESYMBOL
69.1. Location.
YREPINC.
69.2. Purpose.
Writes symbol to the screen. The symbol can be written as a hotspot.
69.3. Entry.
69.3.1.Symbol name to use.
This is one of the symbols declared by the standard ABAP include <symbols>
69.3.2.Hotspot flag.
This should either be True or False. True enables the symbol as a hotspot.
69.4. Exit.
69.5. Called By.
WRITELINE
Perform WriteSymbol using ReportTable-Isyname ReportTable-Hotspot.
69.6. Calls.
69.7. Tables.
69.8. System Variables.
69.9. Description.
This routine writes a pre-defined symbol to the screen or report. If required, the symbo, can also be
designated as a hotspot.
69.10. Examples.
EndIf.
When ReportTable-Symbol.
*
*
*
*
*
*
*
*
*
69.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
WriteSymbol
*
*
Purpose:
Writes symbol to the screen. The symbol can
Page 170
*
be written as a hotspot.
*
*
Entry:
Symbol name to use
*
Entry:
Hotspot flag.
*
*
Exit:
*
*
Called By:
Perform WriteSymbol using w_symbol w_hotspot.
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form WriteSymbol using p_symbol p_hotspot.
If p_hotspot <> True.
Write: ' ' no-gap, p_symbol
as Symbol.
Else.
Write: ' ' no-gap, p_symbol
as Symbol Hotspot on.
EndIf.
EndForm.
Page 171
70.
WRITEVALUE
70.1. Location.
YREPINC.
70.2. Purpose.
Outputs a specific value to the report paying attention to formatting masks etc
70.3. Entry.
70.3.1.Width of output field
This is the width of the output field in characters.
70.3.2.Value to write
The value to write to the report
70.3.4.Currency Field
This parameter must be a string, however, it can either specify a currency mask literal or a
variable or field name containing a currency mask
70.3.5.Unit field
In the same manner as the currency field above, this field specifies a Unit mask to use
when writing the value to the report.
70.4. Exit.
70.5. Called By.
WRITELINE
PRINTTOTALS
Perform WriteValue using
70.6. Calls.
GETMASK
Page 172
ReportTable-ColWidth
<RField>
ReportTable-ConvExit
ReportTable-Currency
ReportTable-Unit
ReportTable-Format.
70.7. Tables.
70.8. System Variables.
70.9. Description.
This routine outputs a report variable to a specific column on the report.
formatting options specified are applied.
70.10. Examples.
*
*
*
If ReportTable-Symbol = True.
Write: ' ' no-gap, ReportTable-Isyname as Symbol.
Else.
Set the output colour.
Perform SetColour using P_Colour.
Perform WriteValue using ReportTable-ColWidth
<RField>
ReportTable-ConvExit
ReportTable-Currency
ReportTable-Unit
ReportTable-Format.
Hide <RField>.
EndIf.
70.11. SourceCode.
*EJECT
***********************************************************************
*
*
Procedure:
WriteValue
*
*
Purpose:
Outputs a specific value to the report paying
*
attention to formatting masks etc
*
*
Entry:
Width of output field
*
Entry:
Value to write
*
Entry:
Conversion exit routine
*
Entry:
Currency Field
*
Entry:
Unit field
*
Entry:
Other Format field.
*
*
Exit:
*
*
Called By:
Perform WriteValue using p_width
*
p_value
*
p_convexit
*
p_currency
*
p_unit
*
p_format.
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
*
* Print Hierachy.
*
* 1. If there is a convexit use that
* 2. Check currency - use if present
* 3. Check Unit - use if present
* 4. Just print it.
*
Form Writevalue using p_width p_value p_convexit
p_currency p_unit p_format.
*
Data w__fcode(10) type c.
" Unit/Currency code
*
Page 173
In doing so,
any
*
*
Page 174
71.
ZBDC_BATCH_ON
71.1. Location.
YBDCINC.
71.2. Purpose.
Sets a flag that causes the BDC routines to create a batch table if the BDC errors
71.3. Entry.
71.4. Exit.
71.5. Called By.
71.6. Calls.
71.7. Tables.
71.8. System Variables.
71.9. Description.
Signifies that should this BDC session fail, a Batch (SM35) session should be created. This applies
for this one BDC call only.
This routine is now obsolete, but is here for backwards compatability. See BDC Options in section
4above and Read_YDCSet in section 53above
71.10. Examples.
71.11. SourceCode.
*EJECT
**********************************************************************
*
*
Procedure:
ZBDC_Batch_On
*
*
Purpose:
Sets a flag that causes the BDC routines
*
to create a batch table if the BDC errors
*
*
Entry:
None
*
*
Exit:
None
*
*
Called By:
Perform ZBDC_Batch_On
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form ZBDC_Batch_On.
Move True to w__bdcbatch.
EndForm.
Page 175
ZDO_BDC
Page 176
72.
ZBDC_CLOSE_GROUP
72.1. Location.
YBDCINC.
72.2. Purpose.
Closes a BDC Batch group
72.3. Entry.
72.3.1.None.
72.4. Exit.
72.4.1.Status 0 - Ok.
1 - BDC Group not open
2 - Queue Error
3 - Other problems
72.6. Calls.
72.7. Tables.
72.8. System Variables.
SY-SUBRC INT4 X
72.9. Description.
After creating a BDC session this routine should be called to close the group.
72.10. Examples.
If w__bdcbatch = True.
Get Time.
Concatenate p_trans '_' sy-uname sy-uzeit+0(5) into w__group.
Perform ZBDC_Open_Group using w__group changing w__istat.
If w__istat = 0.
Perform ZBDC_Insert using p_trans changing w__istat.
If w__istat = 0.
Perform ZBDC_Close_Group changing w__istat.
EndIf.
EndIf.
EndIf.
*
*
*
Mail a user ?
If not w__ydcset-genmail is initial.
72.11. SourceCode.
*EJECT
**********************************************************************
*
*
Procedure:
ZBDC_CLOSE_GROUP
*
Page 177
*
Purpose:
Closes a BDC Batch group
*
*
Entry:
None.
*
*
Exit:
Status 0 - Ok.
*
1 - BDC Group not open
*
2 - Queue Error
*
3 - Other problems
*
*
Called By:
Perform ZBDC_Close_Group
*
changing w_status
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form ZBDC_Close_Group changing p_status like sy-subrc.
Move 0 to p_status.
Call Function 'BDC_CLOSE_GROUP'
Exceptions
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS
= 3.
Move sy-subrc to p_status.
Endform.
" BDC_CLOSE_GROUP
Page 178
73.
ZBDC_DUMP_ON
73.1. Location.
YBDCINC.
73.2. Purpose.
Sets a flag that causes the BDC routines to dump the BDC table to the printer before running it. As
it's reset at the start of each new bdc the 'off' is not required.
73.3. Entry.
73.3.1.None
73.4. Exit.
73.4.1.None
73.5. Called By.
73.6. Calls.
73.7. Tables.
73.8. System Variables.
73.9. Description.
Sets a flag that causes the BDC routines to dump the BDC table to the printer before running it. As
it's reset at the start of each new bdc the 'off' is not required.
This routine is now obsolete, but is here for backwards compatability. See BDC Options in section
4above and Read_YDCSet in section 53above
73.10. Examples.
73.11. SourceCode.
*EJECT
**********************************************************************
*
*
Procedure:
ZBDC_Dump_on
*
*
Purpose:
Sets a flag that causes the BDC routines
*
to dump the BDC table to the printer
*
before running it. As it's reset at the
*
start of each new bdc the 'off' is
*
not required.
*
*
Entry:
None
*
*
Exit:
None
*
*
Called By:
Perform ZBDC_Dump_On
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
Page 179
*
Form ZBDC_Dump_On.
Move True to w__dumpbdc.
EndForm.
Page 180
74.
ZBDC_FIELD
74.1. Location.
YBDCINC.
74.2. Purpose.
Fills BDC Data table with field info
74.3. Entry.
74.3.1.Field name
This is the field name that should be filled with the specified value.
74.3.2.Field Value
The value field contains the value to be placed on the screen. Note that numeric data fields
of types F, P and I should be written to a character field first before calling this routine, as
should date fields.
The command line can be accessed using the field name 'BDC_OKCODE'.
74.3.2.1.
BDC_OKCODES.
BDC Ok codes are used to 'press buttons' on screens displayed by SAP. Various
codes can be specified, either as numeric codes in the form '/nn', or as alpha
codes of the format '=aaaa'.
BDC Codes can be found by running the relevant transaction to the point just prior
to clicking the button you want to use in the session.
Enter the command '/H' in the command line and press the enter key.
Click the button you are interested in. The program will then break.
Examine variable sy-ucomm. This normally contains the code you require. The
table below contains some commonly used BDC codes.
Numeric
/0
/1
/2
/3
/4
/8
/10
/11
/12
/13
/14
/15
Page 181
Alpha
=ENT
=HELP
=CS
=BACK
=BU
=SICH
=RW
=PRI
DLT
=EXIT
%EX
%SC
=P-=P=P++
=P+
FKey
F1
F2
F3
F4
F8
F10
F11
F11
F12
F13
F14
F15
Action
Enter
Help
Select (Previously PICK)
Back
List possible entries
Execute
Menu
Post
Save
Cancel or Roll Back Worl
Print
Delete
Return to previous screen
Exit
Find By
Top Of List
Previous page
Bottom of list
Next Page
74.4. Exit.
74.5. Called By.
ZBDC_FILLSCREEN
ZBDC_SCROLL
Perform ZBDC_Field using t__d021s-fnam <f__field>.
74.6. Calls.
74.7. Tables.
74.8. System Variables.
74.9. Description.
This routine checks to see if there is an open BDC session. If not, the BDC tables used to contain
the BDC data are cleared.
Then the standard BDC using the field name and value provided are entered into the table.
74.10. Examples.
*
* Ok to proceed with this ?
*
If w_status = c_ok.
Zap t_bdcmsg.
Perform NewBdc.
Perform ZBDC_Screen using 'SAPLCORU' 0100.
Perform ZBDC_Field using 'CORUF-AUFNR' w_aufnr.
Perform ZBDC_Field using 'CORUF-VORNR' w_vornr.
Perform ZBDC_Field using 'BDC_OKCODE' c_enter.
Perform ZBDC_Screen using 'SAPLCORU' 0150.
If not w_endru is initial.
Perform ZBDC_Field using 'CORUF-ENDRU' True.
Else.
Perform ZBDC_Field using 'CORUF-TEILR' True.
74.11. SourceCode.
*EJECT
**********************************************************************
*
*
Procedure:
ZBDC_Field
*
*
Purpose:
Fills BDC Data table with field info
*
*
Entry:
Field name
*
Field Value
*
Exit:
*
*
Called By:
Perform BDC_field using 'FIELD' 'VALUE'
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form ZBDC_Field using p_fname p_fvalue.
*
* New BDC Session ??
Page 182
If W__BDCOpen = False.
Zap ZBDC_Table.
Move True to w__BDCOpen.
EndIf.
Clear ZBDC_Table.
Move p_fname to zbdc_table-fnam.
Move p_fvalue to zbdc_table-fval.
Append zbdc_table.
EndForm.
Page 183
75.
ZBDC_FILLSCREEN
75.1. Location.
YBDCINC.
75.2. Purpose.
Creates a screen group and then the relevant field entries from a structure
75.3. Entry.
75.3.1.Program name,
This is the program name of the Transaction you are calling. This is normally of the form
'SAPLY.....'.
75.3.3.Structure to use.
This is the screen structure that is used by the transaction as it populates the fields on the
screen.
75.4. Exit.
75.5. Called By.
75.6. Calls.
75.7. Tables.
75.8. System Variables.
SY-SUBRC INT4 X
75.9. Description.
The routine first retrieves the dynpro field listing for the relevant screen. This details all the fields
on the screen.
Using this field list, the routine first checks to see if the field is editable. This is signalled by two
flags in the d021 structure:
Dependant on the bits set in t__d021s-flg1 and t_-d021s-fmb1, the field is either editable or not. If
the field is editable, the routine then checks to see if there is a value for the field.
If a value is found, the value is formatted accordingly (Dates and numbers written to char fields etc)
and then output to the field.
The routine also recognises the differences between 3.x and 4.x screen fields and acts accordingly.
75.10. Examples.
*
Data: w_trans type Transaction_Code,
Page 184
*
*
Perform NewBdc.
If not pu_lt01-Matnr is initial.
Perform ZBDC_FillScreen using c_sapml03t 0101 pu_lt01.
Perform ZBDC_Field
using 'BDC_OKCODE' c_enter.
Perform ZBDC_FillScreen using c_sapml03t 0102 pu_lt01.
Perform ZBDC_Field
using 'BDC_OKCODE' c_enter.
Perform Z_Call_bdc tables t_bdcmsg using c_lt01.
Else.
LT09 - create su. No Werks....
75.11. SourceCode.
*EJECT
**********************************************************************
*
*
Procedure:
ZBDC_FillScreen
*
*
Purpose:
Creates a screen group and then the
*
relevant field entries from a structure
*
*
Entry:
Program name,
*
Screen number/actual screen No
*
*
SAP has the ability to provide sub-screens
*
and so forth. In some cases, the batch
*
screen number actaully uses another
*
screen definition.
*
*
Therefore in the above, the first screen
*
number is the number to use in the BDC
*
calls, the second is the number where the
*
actual fields are defined.
*
*
Structure to use.
*
*
Exit:
*
*
Called By:
Perform ZBDC_FillScreen using 'SAPML04I'
*
'0223'
*
w_stru.
*
*
Calls:
ZBDC_Screen
*
ZBDC_Field
*
*
Modification History:
*
* Date Reason
Version Who
*
Form ZBDC_FillScreen using p_program type Program_Name
p_screen
p_struc.
*
Constants: c_flg1edt type x value '80', " Field edit flags
c_fmb1ges type x value '20'.
*
Data: Begin Of w__dynpro_30,
" Screen name FOR 30+
Name(8) type c,
Scrn(4) type n,
End of w__dynpro_30,
Begin Of w__dynpro_40,
" Screen name FOR 40+
Name(40) type c,
Scrn(4) type n,
End of w__dynpro_40,
w__d020s
like d020s,
" Screen header
t__d021s
like d021s occurs 0 " Field List
with header line,
t__d022s
like d022S occurs 0, " Flow Logic
t__d023s
like d023s occurs 0, " Match code
*
w__sfnam
like d021s-fnam,
" Structure name
Page 185
w__stble
like d021s-fnam,
" Table name (Dumped)
w__type(1) type c,
" Field type
w__dfield(10) type c,
" Fld for date trans
w__nfield(20) type c,
" Fld for nc trans
w_scrn(4)
type n,
" Screen for BDC Data
w_subscrn(4) type n.
" Actual screen def
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
Field-Symbols <f__field>.
Get the screen information.
If p_screen ca '/'.
Split p_screen at '/' into w_scrn w_subscrn.
Else.
Move p_screen to w_scrn.
Move p_screen to w_subscrn.
Endif.
If sy-saprl+0(1) = 3.
Move p_program to w__dynpro_30-name.
Move w_subscrn to w__dynpro_30-scrn.
Import Dynpro w__d020s t__d021s t__d022s t__d023s
id w__dynpro_30.
Else.
Move p_program to w__dynpro_40-name.
Move w_subscrn to w__dynpro_40-scrn.
Import Dynpro w__d020s t__d021s t__d022s t__d023s
id w__dynpro_40.
EndIf.
Set up the screen bdc record.
Perform ZBDC_Screen using p_program w_scrn.
And loop round the field list.
Loop at t__d021s.
Process this field ?
if t__d021s-flg1 o c_flg1edt.
if t__d021s-fmb1 z c_fmb1ges.
Get the actual field name....
Split t__d021s-fnam at '-' into w__stble w__sfnam.
If not w__sfnam is Initial.
Assign component w__sfnam
of structure p_struc to <f__field>.
If sy-subrc = 0.
If not <f__field> is initial.
*
*
*
*
Page 186
Endcase.
EndIf.
EndIf.
EndIf.
Endif.
Endif.
EndLoop.
EndForm.
Page 187
76.
ZBDC_INSERT
76.1. Location.
YBDCINC.
76.2. Purpose.
Starts a new BDC session
76.3. Entry.
76.3.1.Transaction code
76.4. Exit.
76.4.1.Status of Insert
76.5. Called By.
ZDO_BDC
Perform ZBDC_Insert using p_trans changing w__istat.
76.6. Calls.
76.7. Tables.
76.8. System Variables.
SY-SUBRC INT4 X
76.9. Description.
This function creates a new BDC batch session.
76.10. Examples.
*
*
*
*
76.11. SourceCode.
*eject
**********************************************************************
*
*
Procedure:
ZBDC_INSERT
*
*
Purpose:
Starts a new BDC session
*
*
Entry:
Transaction code,
Page 188
*
BDC Table is full.
*
*
Exit:
Status of Insert!
*
*
Called By:
Perform ZBDC_INSERT using w_trans
*
Changing w_status
*
FORM ZBDC_INSERT using p_trans Like TSTC-TCODE
changing p_status like sy-subrc.
Move 0 to p_status.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE
= p_trans
TABLES
DYNPROTAB
= ZBDC_Table
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN
=2
QUEUE_ERROR = 3
TCODE_INVALID = 4
OTHERS
= 5.
Move sy-subrc to p_status.
ENDFORM.
" BDC_INSERT
Page 189
77.
ZBDC_OPEN_GROUP
77.1. Location.
YBDCINC.
77.2. Purpose.
Starts a new BDC session
77.3. Entry.
77.3.1.Group Name to use for batch
77.4. Exit.
77.4.1.Status of open:
CLIENT_INVALID
=1
DESTINATION_INVALID = 2
GROUP_INVALID
=3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR
=6
QUEUE_ERROR
=7
RUNNING
=8
SYSTEM_LOCK_ERROR = 9
USER_INVALID
= 10
OTHERS
= 11.
77.6. Calls.
77.7. Tables.
77.8. System Variables.
SY-UNAME CHAR C
SY-MANDT CLNT C
SY-SUBRC INT4 X
12
3
4
77.9. Description.
Starts a new BDC Session.
77.10. Examples.
Importing MESSAGE_TEXT_OUTPUT = p_text.
*
*
*
Page 190
77.11. SourceCode.
*EJECT
**********************************************************************
*
*
Procedure:
ZBDC_Open_Group
*
*
Purpose:
Starts a new BDC session
*
*
Entry:
Group Name to use for batch
*
*
Exit:
Status of open!
*
*
Called By:
Perform ZBDC_OPEN_GROUP using w_group
*
Changing p_status
*
Form ZBDC_OPEN_GROUP using p_group like apqi-groupid
changing p_status like sy-subrc.
*
Data: w_user like apqi-userid.
" Avoid ex check errors
*
Move 0 to p_status.
Move sy-uname to w_user.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
*
CLIENT
= SY-MANDT
*
DEST
= FILLER8
GROUP
= p_group
*
HOLDDATE
= FILLER8
KEEP
= True
USER
= w_user
EXCEPTIONS
CLIENT_INVALID
=1
DESTINATION_INVALID = 2
GROUP_INVALID
=3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR
=6
QUEUE_ERROR
=7
RUNNING
=8
SYSTEM_LOCK_ERROR = 9
USER_INVALID
= 10
OTHERS
= 11.
Move sy-subrc to p_status.
EndForm.
Page 191
78.
ZBDC_SCREEN
78.1. Location.
YBDCINC.
78.2. Purpose.
Starts a new screen in a BDC Session
78.3. Entry.
78.3.1.Program name to run.
78.3.2.Screen number to use.
78.4. Exit.
78.5. Called By.
ZBDC_FILLSCREEN
ZBDC_SCROLL
Perform ZBDC_Screen using p_program w_scrn.
78.6. Calls.
78.7. Tables.
78.8. System Variables.
78.9. Description.
Adds a new Screen to a BDC table.
78.10. Examples.
EndIf.
*
* Ok to proceed with this ?
*
If w_status = c_ok.
Zap t_bdcmsg.
Perform NewBdc.
Perform ZBDC_Screen using 'SAPLCORU' 0100.
Perform ZBDC_Field using 'CORUF-AUFNR' w_aufnr.
Perform ZBDC_Field using 'CORUF-VORNR' w_vornr.
Perform ZBDC_Field using 'BDC_OKCODE' c_enter.
Perform ZBDC_Screen using 'SAPLCORU' 0150.
If not w_endru is initial.
Perform ZBDC_Field using 'CORUF-ENDRU' True.
Else.
78.11. SourceCode.
*EJECT
**********************************************************************
*
*
Procedure:
ZBDC_Screen
*
*
Purpose:
Starts a new screen in a BDC Session
*
*
Entry:
Program name to run.
Page 192
*
Screen number to use.
*
Exit:
*
*
Called By:
Perform BDC_Screen using 'SAPSSYM0' ,0103'
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form ZBDC_Screen using p_program like bdcdata-program
p_dynpro like bdcdata-dynpro.
*
* New BDC Session ??
*
If W__BDCOpen = False.
Zap ZBDC_Table.
Move True to w__bdcopen.
EndIf.
Clear zbdc_table.
Move p_program to zbdc_table-program.
Move p_dynpro to zbdc_table-dynpro.
Move True to zbdc_table-dynbegin.
Append zbdc_table.
EndForm.
Page 193
79.
ZBDC_SCROLL
79.1. Location.
YBDCINC.
79.2. Purpose.
Scrolls a screen so that the relevant row of the displayed table becomes visible.
79.3. Entry.
79.3.1.Program name.
The program name that would be specified for ZBDC_Screen (See 78above)
79.3.2.Screen number.
The screen number for the BDC Screen as would be specified for ZBDC Screen.
79.4. Exit.
79.4.1.The offset on the current page of the required record.
79.5. Called By.
79.6. Calls.
ZBDC_FIELD
ZBDC_SCREEN
79.7. Tables.
79.8. System Variables.
79.9. Description.
This function produces the relevant BDC Table entries to scroll a table to a required position. The
function then returns the offset into the table display for the required row that was being sought.
In order for this to work, the data has to be collated in the same manner as it is in the table field.
The routine calculates the 'page' in which the required record lies by using the maximum number of
displayed lines. The remainder from that calculation is the offset into the displayed table, which is
passed back tot he calling routine.
Page 194
Note, you should always check to make certain there is not a 'Move To' function available with the
command. This is generally called '=POPO'.
79.10. Examples.
*
PERFORM ZBDC_SCREEN USING C_SAPML03T '0142'.
if w_lgpla_ix <> 0.
*
*
*
*
*
*
*
79.11. SourceCode.
*EJECT
**********************************************************************
*
*
Procedure:
ZBDC_Scroll
*
*
Purpose:
Scrolls a screen so that the relevant row
*
of the displayed table becomes visible.
*
*
Entry:
Program name,
*
Screen number,
*
BDC Code for 'One down'
*
Maximum number of lines displayed on the
*
screen.
*
The position of the required record in
*
the displayed table.
*
*
Note:
The position of the required record in the
*
table must be found by constructing the
*
table in the same manner that SAP uses.
*
*
Exit:
The offset on the current page of the
*
required record
*
*
Called By:
Perform ZBDC_scroll 'SAPML04I'
*
'0223'
*
"=Down"
*
15
*
31
*
*
Calls:
ZBDC_Screen
*
ZBDC_Field
*
*
Modification History:
*
* Date Reason
Version Who
*
Form ZBDC_Scroll using p_prog
type Program_Name
p_screen
p_down
p_maxlines type i
p_index
like sy-tabix
changing p_offset type i.
*
* Scrolling behaviour.
*
* When a table is scrolled up or down using the scroll buttons the
* table moves up or down one page at a time unless the number of
* lines left in the table is less than the number of lines
* displayable in which case the remainder (or the start) of the table
* is displayed.
*
Page 195
If w__pages > 0.
Subtract 1 from p_offset.
do.
Perform Zbdc_Field using 'BDC_OKCODE' p_down.
Perform Zbdc_Screen using p_prog p_screen.
Subtract 1 from w__pages.
If w__pages <= p_maxlines.
Exit.
EndIf.
enddo.
EndIf.
*
EndForm.
Page 196
80.
ZBDC_SUBSCRIPT
80.1. Location.
YBDCINC.
80.2. Purpose.
Creates a subscripted entry in the BDC table.
80.3. Entry.
80.3.1.Field name as a string
80.3.2.Subscript to use
80.3.3.Value to use
80.4. Exit.
80.4.1.BDC Table updated.
80.5. Called By.
80.6. Calls.
ZBDC_FIELD
USING W_FIELD
P_VALUE
80.7. Tables.
80.8. System Variables.
80.9. Description.
Formats a subscripted variable for use in a BDC.
80.10. Examples.
*
*
*
80.11. SourceCode.
*EJECT
**********************************************************************
*
*
Procedure:
ZBDC_Subscript
*
*
Purpose:
Creates a subscripted entry in the
Page 197
*
BDC table.
*
*
Entry:
Field name as a string
*
Entry:
Subscript to use
*
Entry:
Value to use
*
*
Exit:
BDC Table updated.
*
*
Called By:
Perform ZBDC_Subscript using 'RM07M-SELKZ'
*
7
*
w_selkz.
*
*
Calls:
ZBDC_Field.
*
*
Modification History:
*
* Date Reason
Version Who
*
Form ZBDC_Subscript using p_fname p_subscript p_value.
*
Data: w_subscript(2) type n,
w_field(30) type c.
*
Move p_subscript to w_subscript.
Concatenate p_fname '(' w_subscript ')' into w_field.
Perform ZBDC_Field using w_field p_value.
EndForm.
Page 198
81.
ZDO_BDC
81.1. Location.
YBDCINC.
81.2. Purpose.
Runs a specified BDC Session
81.3. Entry.
81.3.1.Transaction Code
81.3.2.Mode
A
E
N
81.3.3.Update Type
A
S
Tables tb_messages
using pu_trans
w__ydcset-bdcmode
w__ydcset-bdcupmode
changing
w__msgid
w__msgno
w__text.
81.6. Calls.
ZBDC_OPEN_GROUP
ZBDC_INSERT ZBDC_CLOSE_GROUP
81.7. Tables.
81.8. System Variables.
SY-SUBRC
SY-MSGID
SY-MSGNO
SY-MSGV2
SY-MSGV3
SY-MSGV4
SY-UNAME
Page 199
INT4 X
4
CHAR C
2
NUMC N
3
CHAR C 50
CHAR C 50
CHAR C 50
CHAR C
12
81.9. Description.
Using the Call transaction command the specifed transaction is run. If there are any errors,
signified by sy-subrc not being zero, then the appropriate text message is retrieved.
If sy-subrc is zero, then the message log is scanned for any Error ('E' class) messages, or aborts.
('A' class). If one is found then the appropriate message is extracted from the message table.
If an error occurs and the batch create flag is set then a batch is created automatically.
81.10. Examples.
*
Perform
Perform
Perform
Perform
Perform
NewBdc.
ZBDC_FillScreen using c_sapml03t 0101 pu_lt01.
ZBDC_Field
using 'BDC_OKCODE' '/00'.
ZBDC_FillScreen using c_sapml03t 0102 pu_lt01.
ZBDC_Field
using 'BDC_OKCODE' '/00'.
81.11. SourceCode.
*EJECT
**********************************************************************
*
*
Procedure:
ZDo_BDC
*
*
Purpose:
Runs a specified BDC Session
*
*
Entry:
Transaction Code
*
Mode:
*
Update Type
*
*
Table - p_messages - contains batch msgs
*
*
Exit:
MsgId, Error and message if failed.
*
*
Called By:
Perform ZDo_BDC Using 'MM02' 'N' 'S'
*
Changing w_msgid w_err w_errt
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form ZDo_BDC Tables p_messages structure bdcmsgcoll
using p_trans like tstc-tcode
p_mode like bdc_struc-bdcmode
p_update like bdc_struc-bdcupmode
changing p_msgid like sy-msgid
p_msgno like sy-msgno
p_text type status_text.
*
Data: w__msgv1 like sy-msgv1,
" Message variables
w__msgv2 like sy-msgv2,
w__msgv3 like sy-msgv3,
w__msgv4 like sy-msgv4,
w__subrc like sy-subrc,
w__exmsg type status_text,
w__group like apqi-groupid,
" BDC Group name
w__istat type i.
" BDC Insert status
*
Zap p_messages.
Clear p_msgid.
Page 200
Clear p_msgno.
Clear p_text.
*
*
*
*
*
*
*
*
*
*
*
*
Page 201
*
*
*
*
*
*
*
*
*
*
*
*
Page 202
82.
Z_CALL_BDC
82.1. Location.
YBDCINC.
82.2. Purpose.
Runs BDC with new style parameters and taking default settings from ydcset
82.3. Entry.
82.3.1.Message Table
82.3.2.Transaction to use
82.3.3.Table - p_messages - contains batch msgs
82.4. Exit.
82.4.1.Table p_messages filled with BDC Messages
82.5. Called By.
82.6. Calls.
READ_YDCSET
ZDO_BDC
82.7. Tables.
82.8. System Variables.
SY-UNAME CHAR C
12
82.9. Description.
82.10. Examples.
*
*
*
*
Perform NewBdc.
If not pu_lt01-Matnr is initial.
Perform ZBDC_FillScreen using c_sapml03t 0101 pu_lt01.
Perform ZBDC_Field
using 'BDC_OKCODE' c_enter.
Perform ZBDC_FillScreen using c_sapml03t 0102 pu_lt01.
Perform ZBDC_Field
using 'BDC_OKCODE' c_enter.
Perform Z_Call_bdc tables t_bdcmsg using c_lt01.
Else.
LT09 - create su. No Werks....
Move '' to pu_lt01-werks.
Condense pu_lt01-lenum.
Perform ZBDC_FillScreen using c_sapml03t 0173 pu_lt01.
82.11. SourceCode.
*eject
**********************************************************************
*
*
Procedure:
Z_Call_BDC
*
Page 203
*
Purpose:
Runs BDC with new style parameters and
*
taking default settings from ydcset
*
*
Entry:
Message Table
*
Transaction to use
*
*
Table - p_messages - contains batch msgs
*
*
Exit:
Table p_messages filled with BDC Messages
*
*
Called By:
Perform Z_Call_BDC
*
Tables t_messages using w_tcode
*
*
Calls:
*
*
Modification History:
*
* Date Reason
Version Who
*
Form z_Call_BDC Tables tb_messages structure bdcmsgcoll
using pu_trans type Transaction_Code.
*
Data: w__msgid like sy-msgid,
" BDC Status result
w__msgno like sy-msgno,
w__fname like tfdir-funcname,
w__text like t100-text.
*
* BDC Defaults set ??
*
If w__ydcset-funcname is initial.
Move pu_trans to w__fname.
Perform Read_YDCSET using w__fname sy-uname changing w__ydcset.
Move False to w__BDCBatch.
Move False to w__dumpbdc.
Else.
Move w__ydcset-crbatch to w__BDCBatch.
Move w__ydcset-dumpbdc to w__dumpbdc.
EndIf.
*
Perform ZDo_BDC Tables tb_messages using pu_trans
w__ydcset-bdcmode
w__ydcset-bdcupmode
changing w__msgid
w__msgno
w__text.
*
EndForm.
Page 204