[BOR] Bussiness Object Repository
DEFINITIONS :
The Business Object Repository (BOR) is the object-oriented repository in the R/3 System. It contains the SAP business object types and SAP interface types as well as their components, such as methods, attributes and events.
well, first things first, you need to make an BOR, in order to get any work around of workflow, simply just go to tcode 'SWO1' and hit enter.
from the above picture we know 5 elements of BOR, which is :
- Interface
- Key Fields
- Attributes
- Methods
- Events
this is needed to Arranges the various interfaces in accordance with the component hierarchy, enabling functions to be searched and retrieved quickly and simply.
Key Fields
this is need to run the entire bor, this bor needs an input to get all the data but not run the method yet.
Attributes
this one function is using the Key Fields before to get specific data needed in the method.
Methods
like an Function Module but this method stores locally inside BOR, and can not be called globally.
Events
Contain any event needed to call this bor, for example, if i want to using this bor on my workflow, i need to call this event i listed inside my bor. so that bor and workflow can run simultaneouly.
And Here's my BOR Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | ***** Implementation of object type ZBORDEVPLN ***** INCLUDE <OBJECT>. BEGIN_DATA OBJECT. " Do not change.. DATA is generated * only private members may be inserted into structure private DATA: " begin of private, " to declare private attributes remove comments and " insert private attributes here ... " end of private, BEGIN OF KEY, GUID LIKE ZTB_GUIDMAP_9004-GUID, END OF KEY, EMP_MAIL TYPE PA0105-USRID_LONG, EMP_NAME TYPE PA0001-ENAME, EMP_PERNR TYPE ZTB_GUIDMAP_9004-PERNR, APPRV1_MAIL TYPE PA0105-USRID_LONG, APPRV1_NAME TYPE PA0001-ENAME, GTIME TYPE ZTB_GUIDMAP_9004-UZEIT, GDATE TYPE ZTB_GUIDMAP_9004-DATUM, APPRV1_PERNR TYPE ZTB_GUIDMAP_9004-PERNR. END_DATA OBJECT. " Do not change.. DATA is generated BEGIN_METHOD GET_DATA CHANGING CONTAINER. DATA : guid TYPE guid_32, lx_9004 TYPE ztb_guidmap_9004, emp_pernr TYPE pernr_D, emp_mail TYPE COMM_ID_LONG, emp_name TYPE emnam, app1_pernr TYPE pernr_D, app1_mail TYPE COMM_ID_LONG, app1_name TYPE emnam, USER TYPE UNAME , IMP_PERNR TYPE PERNR_D , PERNR TYPE PERNR_D , SUBRC TYPE SUBRC , ENAME TYPE EMNAM , mail TYPE COMM_ID_LONG . *BREAK-POINT. SWC_GET_PROPERTY self 'GUID' guid. IF guid IS INITIAL. READ TABLE container WITH KEY element = 'GUID'. IF sy-subrc EQ 0. object-key-guid = container-value. guid = container-value. endif. ENDIF. SELECT SINGLE * FROM ztb_guidmap_9004 into CORRESPONDING FIELDS OF lx_9004 WHERE guid = guid. CHECK lx_9004 IS NOT INITIAL. IMP_PERNR = lx_9004-pernr. CALL FUNCTION 'ZHR_GET_UID' EXPORTING user = USER IMP_PERNR = IMP_PERNR IMPORTING PERNR = PERNR SUBRC = SUBRC ENAME = ENAME mail = mail . CALL FUNCTION 'ZHR_GET_APPUID' EXPORTING pernr = IMP_PERNR IMPORTING APP_PERNR = app1_pernr APP_MAIL = app1_mail APP_NAME = app1_name . OBJECT-EMP_MAIL = emp_mail = mail . OBJECT-EMP_PERNR = emp_pernr = IMP_PERNR . OBJECT-EMP_NAME = emp_name = ENAME . OBJECT-apprv1_mail = app1_mail . OBJECT-apprv1_pernr = app1_pernr . OBJECT-apprv1_name = app1_name . DATA : debug. * WHILE debug eq space.. * * ENDWHILE. DATA : t_date TYPE datum. DATA : t_time TYPE uzeit VALUE '0007000'. * t_date = object-gdate = lx_9004-datum + 1. t_date = object-gdate = lx_9004-datum + 1. * t_time = sy-uzeit + 500. object-gtime = t_time. SWC_SET_ELEMENT CONTAINER 'emp_mail' OBJECT-EMP_MAIL . SWC_SET_ELEMENT CONTAINER 'emp_pernr' OBJECT-EMP_PERNR . SWC_SET_ELEMENT CONTAINER 'emp_name' OBJECT-EMP_NAME . SWC_SET_ELEMENT CONTAINER 'apprv1_mail' OBJECT-apprv1_mail . SWC_SET_ELEMENT CONTAINER 'apprv1_pernr' OBJECT-apprv1_pernr . SWC_SET_ELEMENT CONTAINER 'apprv1_name' OBJECT-apprv1_name . SWC_SET_ELEMENT CONTAINER 'gdate' OBJECT-gdate . SWC_SET_ELEMENT CONTAINER 'gtime' OBJECT-gtime . SWC_SET_ELEMENT CONTAINER 'EMP_PERNR' OBJECT-EMP_PERNR . SWC_SET_ELEMENT CONTAINER 'EMP_MAIL' OBJECT-EMP_MAIL . SWC_SET_ELEMENT CONTAINER 'EMP_NAME' OBJECT-EMP_NAME . SWC_SET_ELEMENT CONTAINER 'APP1_NAME' OBJECT-apprv1_name . SWC_SET_ELEMENT CONTAINER 'APP1_MAIL' OBJECT-apprv1_mail . SWC_SET_ELEMENT CONTAINER 'APP1_PERNR' OBJECT-apprv1_pernr . * SWC_SET_ELEMENT CONTAINER 'DATE' object-date . * SWC_SET_ELEMENT CONTAINER 'TIME' object-time . *swc_set_element container 'p_var1 ' p_var1 . END_METHOD. GET_PROPERTY EMP_MAIL CHANGING CONTAINER. SWC_SET_ELEMENT CONTAINER 'emp_mail' OBJECT-EMP_MAIL. END_PROPERTY. GET_PROPERTY EMP_PERNR CHANGING CONTAINER. SWC_SET_ELEMENT CONTAINER 'emp_pernr' OBJECT-EMP_PERNR. END_PROPERTY. GET_PROPERTY EMP_NAME CHANGING CONTAINER. SWC_SET_ELEMENT CONTAINER 'emp_name' OBJECT-EMP_NAME. END_PROPERTY. GET_PROPERTY APPRV1_MAIL CHANGING CONTAINER. SWC_SET_ELEMENT CONTAINER 'apprv1_mail' OBJECT-APPRV1_MAIL. END_PROPERTY. GET_PROPERTY APPRV1_PERNR CHANGING CONTAINER. SWC_SET_ELEMENT CONTAINER 'apprv1_pernr' OBJECT-APPRV1_PERNR. END_PROPERTY. GET_PROPERTY APPRV1_NAME CHANGING CONTAINER. SWC_SET_ELEMENT CONTAINER 'apprv1_name' OBJECT-APPRV1_NAME. END_PROPERTY. BEGIN_METHOD SENT_MAIL_APP1 CHANGING CONTAINER. DATA: GUID TYPE ZTB_GUIDMAP_9004-GUID. SWC_GET_ELEMENT CONTAINER 'guid' GUID. DATA: APP1_MAIL TYPE PA0105-USRID_LONG, ERROR_TYPE TYPE ZTB_GUIDMAP_9004-ZRETURN. DATA :name TYPE emnam. DATA :content TYPE TABLE OF SOLISTI1. DATA : TOSENT TYPE COMM_ID_LONG , OBJ_NAME TYPE SO_OBJ_NAM , OBJ_DESCR TYPE SO_OBJ_DES , STATUS TYPE CHAR1 , MESSAGE TYPE CHAR255 , debug TYPE char1 VALUE 'X'. *DATA : guid TYPE guid_32. *SWC_GET_PROPERTY self 'GUID' guid. * for debuging only * WHILE debug eq 'X'. * * * ENDWHILE. DATA : invoke TYPE swotinvoke . PERFORM get_data TABLES container CHANGING invoke . swc_get_element container 'apprv1_name' OBJECT-APPRV1_NAME. SWC_gET_ELEMENT CONTAINER 'apprv1_pernr' OBJECT-APPRV1_PERNR. SWC_gET_ELEMENT CONTAINER 'apprv1_mail' OBJECT-APPRV1_MAIL. name = OBJECT-APPRV1_NAME. * guid = OBJECT-key-guid. CALL FUNCTION 'ZHR_SENT_MAIL_REQ' EXPORTING name = name guid = guid tables content = content . CHECK name IS NOT INITIAL AND content IS NOT INITIAL. TOSENT = OBJECT-APPRV1_MAIL. OBJ_NAME = 'Email'. *OBJ_DESCR = 'Permohonan Pengajuan Plan'. OBJ_DESCR = '[MOHON REVIEW] RPI '. CALL FUNCTION 'ZHR_SENT_MAIL' EXPORTING tosent = TOSENT obj_name = OBJ_NAME obj_descr = OBJ_DESCR * IMPORTING * STATUS = * MESSAGE = TABLES content = content . SWC_SET_ELEMENT CONTAINER 'app1_mail' APP1_MAIL. SWC_SET_ELEMENT CONTAINER 'ERROR_TYPE' ERROR_TYPE. END_METHOD. BEGIN_METHOD SENT_MAIL_EMP_APP CHANGING CONTAINER. DATA: GUID TYPE ZTB_GUIDMAP_9004-GUID. SWC_GET_ELEMENT CONTAINER 'guid' GUID. DATA: APP1_MAIL TYPE PA0105-USRID_LONG, ERROR_TYPE TYPE ZTB_GUIDMAP_9004-ZRETURN. DATA :name TYPE emnam. DATA :content TYPE TABLE OF SOLISTI1. DATA : TOSENT TYPE COMM_ID_LONG , OBJ_NAME TYPE SO_OBJ_NAM , OBJ_DESCR TYPE SO_OBJ_DES , STATUS TYPE CHAR1 , MESSAGE TYPE CHAR255 , debug TYPE char1 VALUE 'X'. DATA : invoke TYPE swotinvoke . * for debuging only * WHILE debug eq 'X'. * * ENDWHILE. PERFORM get_data TABLES container CHANGING invoke . swc_get_element container 'apprv1_name' OBJECT-APPRV1_NAME. swc_get_element container 'emp_name' OBJECT-emp_name. SWC_gET_ELEMENT CONTAINER 'apprv1_pernr' OBJECT-APPRV1_PERNR. SWC_gET_ELEMENT CONTAINER 'apprv1_mail' OBJECT-APPRV1_MAIL. name = OBJECT-emp_name. CALL FUNCTION 'ZHR_SENT_MAIL_APP' EXPORTING name = name guid = guid tables content = content . * . CHECK name IS NOT INITIAL AND content IS NOT INITIAL. TOSENT = OBJECT-APPRV1_MAIL. OBJ_NAME = 'Email'. OBJ_DESCR = '[INFORMASI REVIEW] PERSETUJUAN RPI'. *OBJ_DESCR = '[INFORMASI REVIEW] PERSETUJUAN RENCANA PEMBELAJARAN INDIVIDU'. *OBJ_DESCR = 'Persetujuan Pengajuan Plan'. CALL FUNCTION 'ZHR_SENT_MAIL' EXPORTING tosent = TOSENT obj_name = OBJ_NAME obj_descr = OBJ_DESCR * IMPORTING * STATUS = * MESSAGE = TABLES content = content . END_METHOD. BEGIN_METHOD SENT_MAIL_EMP_REJ CHANGING CONTAINER. *DATA: * GUID TYPE ZTB_GUIDMAP_9004-GUID. * SWC_GET_ELEMENT CONTAINER 'guid' GUID. DATA: GUID TYPE ZTB_GUIDMAP_9004-GUID. SWC_GET_ELEMENT CONTAINER 'guid' GUID. DATA: APP1_MAIL TYPE PA0105-USRID_LONG, ERROR_TYPE TYPE ZTB_GUIDMAP_9004-ZRETURN. DATA :name TYPE emnam. DATA :content TYPE TABLE OF SOLISTI1. DATA : TOSENT TYPE COMM_ID_LONG , OBJ_NAME TYPE SO_OBJ_NAM , OBJ_DESCR TYPE SO_OBJ_DES , STATUS TYPE CHAR1 , MESSAGE TYPE CHAR255 , debug TYPE char1 VALUE 'X'. DATA : invoke TYPE swotinvoke . * for debuging only * WHILE debug eq 'X'. * * ENDWHILE. PERFORM get_data TABLES container CHANGING invoke . swc_get_element container 'apprv1_name' OBJECT-APPRV1_NAME. swc_get_element container 'emp_name' OBJECT-emp_name. SWC_gET_ELEMENT CONTAINER 'apprv1_pernr' OBJECT-APPRV1_PERNR. SWC_gET_ELEMENT CONTAINER 'apprv1_mail' OBJECT-APPRV1_MAIL. name = OBJECT-emp_name. CALL FUNCTION 'ZHR_SENT_MAIL_REJ' EXPORTING name = name guid = guid tables content = content . * . CHECK name IS NOT INITIAL AND content IS NOT INITIAL. TOSENT = OBJECT-APPRV1_MAIL. OBJ_NAME = 'Email'. OBJ_DESCR = '[INFORMASI REVIEW] REVISI RPI'. *OBJ_DESCR = '[INFORMASI REVIEW] REVISI RENCANA PEMBELAJARAN INDIVIDU'. *OBJ_DESCR = 'Persetujuan Pengajuan Plan'. CALL FUNCTION 'ZHR_SENT_MAIL' EXPORTING tosent = TOSENT obj_name = OBJ_NAME obj_descr = OBJ_DESCR * IMPORTING * STATUS = * MESSAGE = TABLES content = content . END_METHOD. BEGIN_METHOD SENT_REMINDER_EMAIL CHANGING CONTAINER. DATA: GUID TYPE ZTB_GUIDMAP_9004-GUID, count TYPE ztb_guidmap_9004-infty, need_wait TYPE p9004-flag1. DATA t_date TYPE datum. DATA t_time TYPE uzeit. * * DATA :content TYPE TABLE OF SOLISTI1. * DATA :name TYPE emnam. *DATA * GUID TYPE ZTB_GUIDMAP_9004-GUID. SWC_GET_ELEMENT CONTAINER 'guid' GUID. DATA: APP1_MAIL TYPE PA0105-USRID_LONG, ERROR_TYPE TYPE ZTB_GUIDMAP_9004-ZRETURN. DATA :name TYPE emnam. DATA :content TYPE TABLE OF SOLISTI1. DATA : TOSENT TYPE COMM_ID_LONG , OBJ_NAME TYPE SO_OBJ_NAM , OBJ_DESCR TYPE SO_OBJ_DES , STATUS TYPE CHAR1 , MESSAGE TYPE CHAR255 , debug TYPE char1 ."VALUE 'X'. DATA : invoke TYPE swotinvoke . PERFORM get_data TABLES container CHANGING invoke . SWC_GET_ELEMENT CONTAINER 'guid' GUID. SWC_GET_ELEMENT CONTAINER 'count' count. SWC_GET_ELEMENT CONTAINER 'need_wait' need_wait. SWC_GET_ELEMENT CONTAINER 'gdate' t_date. SWC_GET_ELEMENT CONTAINER 'gtime' t_time. * for debugging only * DATA : debug TYPE c. * WHILE debug eq space.. * ENDWHILE. add 1 to count. CONDENSE count. IF count eq '200'. need_wait = 'X'. ENDIF. if t_date IS NOT INITIAL. * DATA :f if t_date ne sy-datum. t_date = t_date + 1. * ENDIF. swc_set_element container 'gdate' t_date. ENDIF. *DATA : invoke TYPE swotinvoke . PERFORM get_data TABLES container CHANGING invoke . swc_get_element container 'apprv1_name' OBJECT-APPRV1_NAME. SWC_gET_ELEMENT CONTAINER 'apprv1_pernr' OBJECT-APPRV1_PERNR. SWC_gET_ELEMENT CONTAINER 'apprv1_mail' OBJECT-APPRV1_MAIL. name = OBJECT-APPRV1_NAME. * guid = OBJECT-key-guid. * DATA debug TYPE c. * WHILE debug IS INITIAL. * ENDWHILE. CALL FUNCTION 'ZHR_SENT_MAIL_WAIT' EXPORTING name = name guid = guid tables content = content . CHECK name IS NOT INITIAL AND content IS NOT INITIAL. TOSENT = OBJECT-APPRV1_MAIL. OBJ_NAME = 'Email'. OBJ_DESCR = '[REMINDER] REVIEW RPI'. *OBJ_DESCR = '[REMINDER] REVIEW RENCANA PEMBELAJARAN INDIVIDU'. *OBJ_DESCR = 'Permohonan Pengajuan Plan'. DATA : lx_9004 TYPE ztb_guidmap_9004. DATA : lt_9004 TYPE TABLE OF ztb_guidmap_9004. SELECT * FROM ztb_guidmap_9004 INTO CORRESPONDING FIELDS OF TABLE lt_9004 WHERE guid = GUID. IF sy-subrc eq 0. SORT lt_9004 DESCENDING by status_item. READ TABLE lt_9004 INTO lx_9004 INDEX 1. IF lx_9004-status_item eq '1' . * if lx_9004-datum ne sy-datum. CALL FUNCTION 'ZHR_SENT_MAIL' EXPORTING tosent = TOSENT obj_name = OBJ_NAME obj_descr = OBJ_DESCR * IMPORTING * STATUS = * MESSAGE = TABLES content = content . * ENDIF. ENDIF. ENDIF. IF GUID IS NOT INITIAL. * DATA : lx_9004 TYPE ztb_guidmap_9004. * DATA : lt_9004 TYPE TABLE OF ztb_guidmap_9004. * * SELECT * FROM ztb_guidmap_9004 INTO CORRESPONDING FIELDS OF TABLE lt_9004 WHERE guid = GUID. ** IF sy-subrc eq 0. * SORT lt_9004 DESCENDING by status_item. * READ TABLE lt_9004 INTO lx_9004 INDEX 1. * either the request is approve or reject, ends loop sent email IF lx_9004-status_item eq '6' or lx_9004-status_item eq '2'. need_wait = 'X'. ENDIF. * ENDIF. ENDIF. swc_set_element container 'count' count. SWC_sET_ELEMENT CONTAINER 'need_wait' need_wait. END_METHOD. GET_PROPERTY GTIME CHANGING CONTAINER. DATA : t_time TYPE sy-uzeit VALUE '000700'. object-gtime = t_time. SWC_SET_ELEMENT CONTAINER 'gtime' OBJECT-GTIME. END_PROPERTY. GET_PROPERTY GDATE CHANGING CONTAINER. DATA :date TYPE datum. *READ TABLE container WITH KEY 'GUID'. IF OBJECT-key-guid IS NOT INITIAL. "sy-subrc eq 0. DATA lx_9004 TYPE ztb_guidmap_9004. DATA guid TYPE guid_32. guid = object-key-guid. ENDIF. SWC_GET_PROPERTY self 'GUID' guid. IF guid IS INITIAL.. READ TABLE container WITH KEY element = 'GUID'. IF sy-subrc EQ 0. guid = container-value. ENDIF. ENDIF. if guid is NOT INITIAL. SELECT SINGLE * FROM ztb_guidmap_9004 into CORRESPONDING FIELDS OF lx_9004 WHERE guid = OBJECT-key-guid. date = lx_9004-datum + 1. "container-value. object-gdate = date. ENDIF. SWC_SET_ELEMENT CONTAINER 'gdate' OBJECT-gdate. END_PROPERTY. |
No comments:
Post a Comment