Thursday, November 8, 2018

ABAP Webdynpro

hello again fellas, here's my documentation about Webdynpro ABAP.




  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
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
METHOD wddomodifyview .
*  BREAK-POINT.
    DATA lo_nd_leave_req TYPE REF TO if_wd_context_node.
  DATA lo_el_context TYPE REF TO if_wd_context_element.
  DATA ls_context TYPE wd_this->element_context.
    DATA lo_el_leave_req TYPE REF TO if_wd_context_element.
    DATA ls_leave_req TYPE wd_this->element_leave_req.
    DATA lv_disable_butt TYPE boolean.
    DATA lv_approve_butt TYPE boolean.
*   navigate from <CONTEXT> to <LEAVE_REQ> via lead selection
    lo_nd_leave_req = wd_context->get_child_node( name = wd_this->wdctx_leave_req ).

*   @TODO handle non existant child
*   IF lo_nd_leave_req IS INITIAL.
*   ENDIF.

*   get element via lead selection
    lo_el_leave_req = lo_nd_leave_req->get_element( ).
*   @TODO handle not set lead selection
    IF lo_el_leave_req IS INITIAL.
    ENDIF.

*   get all declared attributes
    lo_el_leave_req->get_static_attributes(
      IMPORTING
        static_attributes = ls_leave_req ).
IF  ls_leave_req-status(6) eq 'Delete' or  ls_leave_req-status(6) eq 'Reject'
  or ls_leave_req-status(7) eq 'Approve'  .

     lv_disable_butt = abap_false..

*       DATA lo_el_context TYPE REF TO if_wd_context_element.
*       DATA ls_context TYPE wd_this->element_context.
*       DATA lv_disable_butt TYPE wd_this->element_context-disable_butt.

*      get element via lead selection
       lo_el_context = wd_context->get_element( ).

*      @TODO handle not set lead selection
       IF lo_el_context IS INITIAL.
       ENDIF.

*      @TODO fill attribute
*      lv_disable_butt = 1.

*      set single attribute
       lo_el_context->set_attribute(
         name =  `DISABLE_BUTT`
         value = lv_disable_butt ).

      IF ls_leave_req-status(7) eq 'Approve' .
lv_approve_butt = abap_true.
         lo_el_context->set_attribute(
         name =  `APPRV_BUTT`
         value = lv_approve_butt ).
      ENDIF.
**     set single attribute
*      lo_el_context->set_attribute(
*        name =  `DISABLE_BUTT`
*        value = lv_disable_butt ).

ELSEif ls_leave_req-status(10) eq 'In Process'.
       lo_el_context = wd_context->get_element( ).
  lv_approve_butt = abap_true.
         lo_el_context->set_attribute(
         name =  `APPRV_BUTT`
         value = lv_approve_butt ).
         lo_el_context->set_attribute(
         name =  `DISABLE_BUTT`
         value = lv_approve_butt ).
ENDIF.

**for differentiate SK and SKT

*  DATA lo_el_context TYPE REF TO if_wd_context_element.
*  DATA ls_context TYPE wd_this->element_context.
  DATA lv_apprv_butt TYPE wd_this->element_context-apprv_butt.


IF sy-uname(3) eq 'SKT'.

*  DATA lo_el_context TYPE REF TO if_wd_context_element.
*  DATA ls_context TYPE wd_this->element_context.
*  DATA lv_disable_butt TYPE wd_this->element_context-disable_butt.

* get element via lead selection
  lo_el_context = wd_context->get_element( ).

* @TODO handle not set lead selection
  IF lo_el_context IS INITIAL.
  ENDIF.

* @TODO fill attribute
* lv_disable_butt = 1.

* set single attribute
  lo_el_context->set_attribute(
    name =  `DISABLE_BUTT`
    value = abap_false ).

* get element via lead selection
  lo_el_context = wd_context->get_element( ).

* @TODO handle not set lead selection
  IF lo_el_context IS INITIAL.
  ENDIF.

* @TODO fill attribute
* lv_apprv_butt = 1.

* set single attribute
if LS_LEAVE_REQ-STATUS(10) eq 'In Process'.
  lo_el_context->set_attribute(
    name =  `APPRV_BUTT`
    value = abap_true ).
ELSEIF LS_LEAVE_REQ-STATUS(8) eq 'Approved'.
  lo_el_context->set_attribute(
    name =  `APPRV_BUTT`
    value = abap_true ).
ELSe.
  lo_el_context->set_attribute(
    name =  `APPRV_BUTT`
    value = abap_false ).
endif.


ELSEIF sy-uname(2) eq 'SK'.

*    DATA lo_el_context TYPE REF TO if_wd_context_element.
*    DATA ls_context TYPE wd_this->element_context.
    DATA lv_vis_detail TYPE wd_this->element_context-vis_detail.

*   get element via lead selection
    lo_el_context = wd_context->get_element( ).

*   @TODO handle not set lead selection
    IF lo_el_context IS INITIAL.
    ENDIF.

*   @TODO fill attribute
*   lv_vis_detail = 1.

**   set single attribute
*    lo_el_context->set_attribute(
*      name =  `VIS_DETAIL`
*      value = lv_vis_detail ).

        lo_el_context->set_attribute(
          name =  `VIS_DETAIL`
          value = abap_false ).

* get element via lead selection
  lo_el_context = wd_context->get_element( ).

* @TODO handle not set lead selection
  IF lo_el_context IS INITIAL.
  ENDIF.

* @TODO fill attribute
* lv_apprv_butt = 1.

* set single attribute
  lo_el_context->set_attribute(
    name =  `APPRV_BUTT`
    value = abap_false ).

ENDIF.
**
ENDMETHOD.




METHOD wddoinit .
 TYPES :
        BEGIN OF ty_data,
        pernr         TYPE pernr_D,
        guid          TYPE guid_32,
        awart         TYPE T554T-AWART,
        atext         TYPE T554T-ATEXT,
        begda         TYPE PA2001-BEGDA,
        beguz         TYPE PA2001-beguz,
        endda         TYPE PA2001-endda,
        enduz         TYPE PA2001-enduz,
        ename         TYPE PA0001-ENAME,
        status        TYPE TIM_REQ_STATUS,
        abstd         TYPE P2001-STDAZ,
        abwtg         TYPE P2001-ABWTG,
        apprv         TYPE PA0001-ENAME,
        note          TYPE TIM_REQ_NOTICE,
        apprv2        TYPE PA0001-ENAME,
        textawart     TYPE CHAR2_256,
        attch         TYPE char4,
        guid_doc      TYPE SWW_WIID,
        END OF ty_data.

DATA:  it_data TYPE TABLE OF ty_data,
       lx_data TYPE ty_data,
       context_node type ref to if_wd_context_node,
       context_node2 type ref to if_wd_context_node.


*  DATA : wdev LIKE REF TO CL_WD_CUSTOM_EVENT.
  DATA : lo_componentcontroller TYPE REF TO ig_componentcontroller .
  DATA lv_return TYPE boolean.
  DATA lo_nd_input TYPE REF TO if_wd_context_node.
  DATA lo_el_input TYPE REF TO if_wd_context_element.
  DATA ls_input TYPE wd_this->element_input.
  DATA lv_visible_input TYPE wd_this->element_input-visible_input.


 DATA lr_view_controller TYPE REF TO cl_wdr_view.


   DATA lo_el_context TYPE REF TO if_wd_context_element.
   DATA ls_context TYPE wd_this->element_context.
   DATA lv_vis_detail TYPE wd_this->element_context-vis_detail.

*  get element via lead selection
   lo_el_context = wd_context->get_element( ).

*  @TODO handle not set lead selection
   IF lo_el_context IS INITIAL.
   ENDIF.

*  @TODO fill attribute
  lv_vis_detail = '02'.

*  set single attribute
   lo_el_context->set_attribute(
     name =  `VIS_DETAIL`
     value = abap_true ).



   lr_view_controller ?= wd_this->wd_get_api( ).

   lr_view_controller->if_wd_view_controller~register_on_enter_for_f4( register_on_enter = abap_true ).


  lo_componentcontroller =   wd_this->get_componentcontroller_ctr( ).
  lv_return = lo_componentcontroller->check_admin( ).
  lo_nd_input = wd_context->get_child_node( name = wd_this->wdctx_input ).
  lo_el_input = lo_nd_input->get_element( ).

  IF lv_return = abap_true.
    lv_visible_input = abap_true.
  ELSE.
    lv_visible_input = abap_false.
  ENDIF.

  lo_el_input->set_attribute( name =  `VISIBLE_INPUT` value = lv_visible_input ).


*  DATA lo_el_context TYPE REF TO if_wd_context_element.
*  DATA ls_context TYPE wd_this->element_context.
  DATA lv_dateinput TYPE wd_this->element_context-dateinput.

* get element via lead selection
  lo_el_context = wd_context->get_element( ).

* @TODO handle not set lead selection
  IF lo_el_context IS INITIAL.
  ENDIF.

* @TODO fill attribute
 lv_dateinput = sy-datum.

* set single attribute
  lo_el_context->set_attribute(
    name =  `DATEINPUT`
    value = lv_dateinput ).

******

   DATA lo_nd_leave_req TYPE REF TO if_wd_context_node.

   DATA lo_el_leave_req TYPE REF TO if_wd_context_element.
   DATA ls_leave_req TYPE wd_this->element_leave_req.
   DATA lv_begda TYPE wd_this->element_leave_req-begda.

*  navigate from <CONTEXT> to <LEAVE_REQ> via lead selection
*   lo_nd_leave_req = wd_context->get_child_node( name = wd_this->wdctx_leave_req ).
   lo_nd_leave_req = wd_context->get_child_node( name = wd_this->wdctx_leave_req ).

*  @TODO handle non existant child
*  IF lo_nd_leave_req IS INITIAL.
*  ENDIF.

*  get element via lead selection
   lo_el_leave_req = lo_nd_leave_req->get_element( ).

*  alternative access  via index
*  lo_el_leave_req = lo_nd_leave_req->get_element( index = 1 ).

*  @TODO handle not set lead selection
   IF lo_el_leave_req IS INITIAL.
   ENDIF.

*  @TODO fill attribute
  lv_begda = sy-datum.

*  set single attribute
   lo_el_leave_req->set_attribute(
     name =  `BEGDA`
     value = lv_begda ).



******

    DATA lo_el_contextaf TYPE REF TO if_wd_context_element.
    DATA ls_contextaf TYPE wd_this->element_context.
    DATA lv_dateafter TYPE wd_this->element_context-dateafter.

*   get element via lead selection
    lo_el_contextaf = wd_context->get_element( ).

*   @TODO handle not set lead selection
    IF lo_el_contextaf IS INITIAL.
    ENDIF.

*   @TODO fill attribute
   lv_dateafter = sy-datum ."+ 90.

*   set single attribute
    lo_el_contextaf->set_attribute(
      name =  `DATEAFTER`
      value = lv_dateafter ).

**********
*  DATA lo_nd_leave_req TYPE REF TO if_wd_context_node.

*  DATA lo_el_leave_req TYPE REF TO if_wd_context_element.
*  DATA ls_leave_req TYPE wd_this->element_leave_req.
  DATA lv_endda TYPE wd_this->element_leave_req-endda.

* navigate from <CONTEXT> to <LEAVE_REQ> via lead selection
*  lo_nd_leave_req = wd_context->get_child_node( name = wd_this->wdctx_leave_req ).

* @TODO handle non existant child
* IF lo_nd_leave_req IS INITIAL.
* ENDIF.

* get element via lead selection
*  lo_el_leave_req = lo_nd_leave_req->get_element( ).

* @TODO handle not set lead selection
  IF lo_el_leave_req IS INITIAL.
  ENDIF.

* @TODO fill attribute
 lv_endda = sy-datum.

* set single attribute
  lo_el_leave_req->set_attribute(
    name =  `ENDDA`
    value = lv_endda ).


**********
*  DATA lo_nd_leave_req TYPE REF TO if_wd_context_node.
*
*  DATA lo_el_leave_req TYPE REF TO if_wd_context_element.
*  DATA ls_leave_req TYPE wd_this->element_leave_req.
  DATA lv_pernr TYPE wd_this->element_leave_req-pernr.

* navigate from <CONTEXT> to <LEAVE_REQ> via lead selection
  lo_nd_leave_req = wd_context->get_child_node( name = wd_this->wdctx_leave_req ).

* @TODO handle non existant child
* IF lo_nd_leave_req IS INITIAL.
* ENDIF.

* get element via lead selection
  lo_el_leave_req = lo_nd_leave_req->get_element( ).

* @TODO handle not set lead selection
  IF lo_el_leave_req IS INITIAL.
  ENDIF.

* @TODO fill attribute
DATA : ld_usrid TYPE P0105-USRID,
       ld_pernr TYPE P0105-PERNR.
*ld_usrid = sy-uname.
*    CALL FUNCTION 'RP_GET_PERNR_FROM_USERID'
*      EXPORTING
*        begda     = sy-datum
*        endda     = sy-datum
*        usrid     = ld_usrid
*        usrty     = '0001'
*      IMPORTING
*        usr_pernr = ld_pernr
*      EXCEPTIONS
*        retcd     = 1
*        OTHERS    = 2.
* lv_pernr = ld_pernr.
*
** set single attribute
*  lo_el_leave_req->set_attribute(
*    name =  `PERNR`
*    value = lv_pernr ).


 me->trans_date(
   CHANGING
     pa_startdate = sy-datum
     pa_dateinput = sy-datum
 ).

*  DATA lo_nd_leave_req TYPE REF TO if_wd_context_node.
*
*  DATA lo_el_leave_req TYPE REF TO if_wd_context_element.
*  DATA ls_leave_req TYPE wd_this->element_leave_req.
  DATA lv_awart TYPE wd_this->element_leave_req-awart.

* navigate from <CONTEXT> to <LEAVE_REQ> via lead selection
  lo_nd_leave_req = wd_context->get_child_node( name = wd_this->wdctx_leave_req ).

* @TODO handle non existant child
* IF lo_nd_leave_req IS INITIAL.
* ENDIF.

* get element via lead selection
  lo_el_leave_req = lo_nd_leave_req->get_element( ).

* @TODO handle not set lead selection
  IF lo_el_leave_req IS INITIAL.
  ENDIF.

* @TODO fill attribute
 lv_awart = 'C000'.

* set single attribute
  lo_el_leave_req->set_attribute(
    name =  `AWART`
    value = lv_awart ).


DATA : lx_t554s TYPE t554s.
DATA : lx_t554t TYPE t554t.

SELECT SINGLE * FROM t554t INTO CORRESPONDING FIELDS OF   lx_t554t
        WHERE sprsl EQ 'En' AND moabw EQ '90'
          and awart = lv_awart.
      SELECT SINGLE * FROM t554s INTO CORRESPONDING FIELDS OF  lx_t554s
        WHERE
        subty = lv_awart AND
              endda = '99991231'.

       lo_el_leave_req->set_attribute(
    name =  `TEXTAWART`
    value = lx_t554t-atext ).




       DATA lo_nd_textbutton TYPE REF TO if_wd_context_node.

   DATA lo_el_textbutton TYPE REF TO if_wd_context_element.
   DATA ls_textbutton TYPE wd_this->element_textbutton.
   DATA lv_save_flag TYPE wd_this->element_textbutton-save_flag.

*  navigate from <CONTEXT> to <TEXTBUTTON> via lead selection
   lo_nd_textbutton = wd_context->get_child_node( name = wd_this->wdctx_textbutton ).

*  @TODO handle non existant child
*  IF lo_nd_textbutton IS INITIAL.
*  ENDIF.

*  get element via lead selection
   lo_el_textbutton = lo_nd_textbutton->get_element( ).

*  @TODO handle not set lead selection
   IF lo_el_textbutton IS INITIAL.
   ENDIF.

*  @TODO fill attribute
  lv_save_flag = abap_false.

*  set single attribute
   lo_el_textbutton->set_attribute(
     name =  `SAVE_FLAG`
     value = lv_save_flag ).

*     DATA lo_nd_textbutton TYPE REF TO if_wd_context_node.
*
*     DATA lo_el_textbutton TYPE REF TO if_wd_context_element.
*     DATA ls_textbutton TYPE wd_this->element_textbutton.
     DATA lv_notes_flag TYPE wd_this->element_textbutton-notes_flag.

*    navigate from <CONTEXT> to <TEXTBUTTON> via lead selection
     lo_nd_textbutton = wd_context->get_child_node( name = wd_this->wdctx_textbutton ).

*    @TODO handle non existant child
*    IF lo_nd_textbutton IS INITIAL.
*    ENDIF.

*    get element via lead selection
     lo_el_textbutton = lo_nd_textbutton->get_element( ).

*    @TODO handle not set lead selection
     IF lo_el_textbutton IS INITIAL.
     ENDIF.

*    @TODO fill attribute
    lv_notes_flag = abap_true.

*    set single attribute
     lo_el_textbutton->set_attribute(
       name =  `NOTES_FLAG`
       value = lv_notes_flag ).

*  DATA lo_nd_leave_req TYPE REF TO if_wd_context_node.
*
*  DATA lo_el_leave_req TYPE REF TO if_wd_context_element.
*  DATA ls_leave_req TYPE wd_this->element_leave_req.
  DATA lv_pernr_vis TYPE wd_this->element_leave_req-pernr_vis.

* navigate from <CONTEXT> to <LEAVE_REQ> via lead selection
  lo_nd_leave_req = wd_context->get_child_node( name = wd_this->wdctx_leave_req ).

* @TODO handle non existant child
* IF lo_nd_leave_req IS INITIAL.
* ENDIF.

* get element via lead selection
  lo_el_leave_req = lo_nd_leave_req->get_element( ).

* @TODO handle not set lead selection
  IF lo_el_leave_req IS INITIAL.
  ENDIF.

* @TODO fill attribute
 lv_pernr_vis = abap_false.

* set single attribute
  lo_el_leave_req->set_attribute(
    name =  `PERNR_VIS`
    value = lv_pernr_vis ).


ENDMETHOD.

No comments:

Post a Comment