-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathZRFII02.abap
1942 lines (1845 loc) · 68.2 KB
/
ZRFII02.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
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*&--------------------------------------------------------------------
*& Author : HS.Jeong
*& Creation Date : 06/10/2003
*& Specification By : hs.jeong
*& Pattern : Report 1-2
*& Development Request No : UD1K902603
*& Addl documentation :
*& Description : PI Budget/Actual Report
*&
*&
*& Modification Log
*& Date Developer Request ID Description
*&--------------------------------------------------------------------
REPORT zrfii02 MESSAGE-ID zmfi.
TYPE-POOLS: slis, vrm.
INCLUDE <icon>.
INCLUDE <symbol>.
CLASS cl_gui_resources DEFINITION LOAD.
CONSTANTS:
c_f2code LIKE sy-ucomm VALUE '&ETA'.
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv,
gs_layout TYPE slis_layout_alv,
gt_sp_group TYPE slis_t_sp_group_alv,
gt_events TYPE slis_t_event,
gt_sorts TYPE slis_t_sortinfo_alv WITH HEADER LINE,
gs_prnt TYPE slis_print_alv.
DATA: wa_repid LIKE sy-repid,
wa_var_save(1) TYPE c VALUE 'A',
wa_default(1) TYPE c,
wa_exit(1) TYPE c,
wa_variant LIKE disvariant,
wa_var LIKE disvariant,
wa_alv_function_name(30) TYPE c VALUE 'REUSE_ALV_GRID_LIST',
wa_alv_get_info_name(40) TYPE c.
*--- ALV
DATA : w_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
w_eventcat TYPE slis_t_event WITH HEADER LINE,
w_selfield TYPE slis_selfield,
w_sortcat TYPE slis_t_sortinfo_alv WITH HEADER LINE,
w_col_pos TYPE i,
w_program LIKE sy-repid,
w_top_of_page TYPE slis_t_listheader,
w_line1 TYPE slis_listheader.
*DATA: gt_list_top_of_page TYPE slis_t_listheader.
*----------------------------------------------------------------------
*
* define tables and internal structure
*
*----------------------------------------------------------------------
*
TABLES: aufk, impr, fmfctr, ripasw, codia.
DATA: it_out TYPE TABLE OF impr WITH HEADER LINE.
DATA: it_imzo TYPE TABLE OF imzo WITH HEADER LINE.
DATA: it_impr TYPE TABLE OF impr WITH HEADER LINE.
*DATA : it_budget LIKE zfi_io_budget OCCURS 0 WITH HEADER LINE.
*DATA : it_actual LIKE zfi_io_actual OCCURS 0 WITH HEADER LINE.
*
DATA : it_budget LIKE zfi_pi_budget OCCURS 0 WITH HEADER LINE.
DATA : it_actual LIKE zfi_pi_actual_act OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF gt_out OCCURS 0,
posid LIKE impr-posid,
kostl LIKE impr-kostl,
key(2),
act(20),
gjahr LIKE impr-gjahr,
prnam LIKE impr-prnam,
tot LIKE cosp-wtg001,
before LIKE cosp-wtg001,
last LIKE cosp-wtg001,
year LIKE cosp-wtg001,
year1 LIKE cosp-wtg001,
year2 LIKE cosp-wtg001,
year3 LIKE cosp-wtg001,
year4 LIKE cosp-wtg001,
year5 LIKE cosp-wtg001,
after LIKE cosp-wtg001,
* POSNR LIKE IMPR-POSNR,
posnr LIKE impr-posnr,
aufnr LIKE aufk-aufnr,
chkbox TYPE c,
light TYPE c,
tabcolor TYPE slis_t_specialcol_alv,
END OF gt_out.
*---Temp
DATA: BEGIN OF gt_temp OCCURS 0,
posid LIKE impr-posid,
kostl LIKE impr-kostl,
act(10),
tot LIKE cosp-wtg001,
before LIKE cosp-wtg001,
last LIKE cosp-wtg001,
year LIKE cosp-wtg001,
year1 LIKE cosp-wtg001,
year2 LIKE cosp-wtg001,
year3 LIKE cosp-wtg001,
year4 LIKE cosp-wtg001,
year5 LIKE cosp-wtg001,
after LIKE cosp-wtg001,
posnr LIKE impr-posnr,
aufnr LIKE aufk-aufnr,
chkbox TYPE c,
light TYPE c,
tabcolor TYPE slis_t_specialcol_alv,
**
ktext LIKE aufk-ktext,
akstl LIKE aufk-akstl,
**
END OF gt_temp.
*----for combox
DATA: it_val TYPE vrm_values,
w_line LIKE LINE OF it_val.
*---WORK AREA
DATA : wa_t_cnt TYPE i,
wa_before LIKE imzo-gjahr,
wa_last LIKE imzo-gjahr,
wa_year LIKE imzo-gjahr,
wa_year1 LIKE imzo-gjahr,
wa_year2 LIKE imzo-gjahr,
wa_year3 LIKE imzo-gjahr,
wa_year4 LIKE imzo-gjahr,
wa_year5 LIKE imzo-gjahr,
wa_year6 LIKE imzo-gjahr,
wa_after LIKE imzo-gjahr,
wa_before_txt(10),
wa_after_txt(10).
DATA : wa_before_amt LIKE cosp-wtg001,
wa_after_amt LIKE cosp-wtg001.
*---Currenty
DATA : wa_n_tot LIKE cosp-wtg001,
wa_n_before LIKE cosp-wtg001,
wa_n_last LIKE cosp-wtg001,
wa_n_year LIKE cosp-wtg001,
wa_n_year1 LIKE cosp-wtg001,
wa_n_year2 LIKE cosp-wtg001,
wa_n_year3 LIKE cosp-wtg001,
wa_n_year4 LIKE cosp-wtg001,
wa_n_year5 LIKE cosp-wtg001,
wa_n_after LIKE cosp-wtg001.
*---Actual
DATA : wa_a_tot LIKE cosp-wtg001,
wa_a_before LIKE cosp-wtg001,
wa_a_last LIKE cosp-wtg001,
wa_a_year LIKE cosp-wtg001,
wa_a_year1 LIKE cosp-wtg001,
wa_a_year2 LIKE cosp-wtg001,
wa_a_year3 LIKE cosp-wtg001,
wa_a_year4 LIKE cosp-wtg001,
wa_a_year5 LIKE cosp-wtg001,
wa_a_after LIKE cosp-wtg001.
*---Commitment
DATA : wa_c_tot LIKE cosp-wtg001,
wa_c_before LIKE cosp-wtg001,
wa_c_last LIKE cosp-wtg001,
wa_c_year LIKE cosp-wtg001,
wa_c_year1 LIKE cosp-wtg001,
wa_c_year2 LIKE cosp-wtg001,
wa_c_year3 LIKE cosp-wtg001,
wa_c_year4 LIKE cosp-wtg001,
wa_c_year5 LIKE cosp-wtg001,
wa_c_after LIKE cosp-wtg001.
*---Downpayment
DATA : wa_d_tot LIKE cosp-wtg001,
wa_d_before LIKE cosp-wtg001,
wa_d_last LIKE cosp-wtg001,
wa_d_year LIKE cosp-wtg001,
wa_d_year1 LIKE cosp-wtg001,
wa_d_year2 LIKE cosp-wtg001,
wa_d_year3 LIKE cosp-wtg001,
wa_d_year4 LIKE cosp-wtg001,
wa_d_year5 LIKE cosp-wtg001,
wa_d_after LIKE cosp-wtg001.
DATA : wa_gjahr LIKE impr-gjahr,
wa_prnam LIKE impr-prnam.
*----2004/03/24
*Issue Number : FI-20041118-007, Requested by Robin Simmons
*Changed on 2004/12/08, by WSKIM
*---Start
RANGES r_posid FOR impr-posid.
*---End
*----------------------------------------------------------------------
*
* SELECTION-SCREEN
*
*----------------------------------------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK s1 WITH FRAME TITLE c010.
SELECT-OPTIONS: s_prnam FOR impr-prnam MEMORY ID imt OBLIGATORY
*Issue Number : FI-20041118-007, Requested by Robin Simmons
*Changed on 2004/11/30, by WSKIM
*---Start
DEFAULT 'HMMA0001'.
*---End
PARAMETERS: p_ayear LIKE impr-gjahr MEMORY ID gjr OBLIGATORY
DEFAULT sy-datum+0(4),
p_fiscal LIKE impr-gjahr.
PARAMETERS: p_auth(1) TYPE c DEFAULT 'X' NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK s1.
SELECTION-SCREEN BEGIN OF BLOCK s2 WITH FRAME TITLE c020.
** overall
**SELECTION-SCREEN BEGIN OF BLOCK jhr.
**SELECTION-SCREEN BEGIN OF LINE.
**PARAMETER: p_oall LIKE raip1-geswt DEFAULT 'X'
** RADIOBUTTON GROUP wrt.
**SELECTION-SCREEN COMMENT (25) p03
** FOR FIELD p_oall.
**SELECTION-SCREEN END OF LINE.
** year
**SELECTION-SCREEN BEGIN OF LINE.
**PARAMETER: p_year LIKE raip1-jhrwt
** RADIOBUTTON GROUP wrt.
**SELECTION-SCREEN COMMENT (25) p04
** FOR FIELD p_year.
**SELECTION-SCREEN POSITION 33.
**PARAMETER: p_gjahr LIKE bpja-gjahr.
**SELECTION-SCREEN END OF LINE.
**SELECTION-SCREEN END OF BLOCK jhr.
SELECTION-SCREEN END OF BLOCK s2.
*--------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK s3 WITH FRAME TITLE c030.
PARAMETERS : p_r1 RADIOBUTTON GROUP g1,
p_r2 RADIOBUTTON GROUP g1.
PARAMETERS : p_posid LIKE impr-posid.
SELECT-OPTIONS:
s_kostl FOR impr-kostl.
SELECTION-SCREEN END OF BLOCK s3.
*------------------------------------------------*
PARAMETERS: p_act(2) TYPE c AS LISTBOX VISIBLE LENGTH 25
DEFAULT '01'. " OBLIGATORY.
SELECTION-SCREEN BEGIN OF BLOCK s4 WITH FRAME TITLE c040.
PARAMETERS : p_chk1 AS CHECKBOX ,"DEFAULT 'X',
p_chk2 AS CHECKBOX ."DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK s4.
SELECT-OPTIONS: so_ippos FOR ripasw-ippos.
SELECTION-SCREEN BEGIN OF BLOCK s5 WITH FRAME TITLE text-030.
PARAMETERS : p_low AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK s5.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME.
PARAMETERS :
p_layout LIKE disvariant-variant. "LAYOUT
SELECTION-SCREEN END OF BLOCK b2.
*----------------------------------------------------------------------*
* at selection screen *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'P_ACT'
values = it_val.
*----------------------------------------------------------------------
*
* AT SELECTION-SCREEN ON VALUE-REQUEST
*
*----------------------------------------------------------------------
*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_layout.
PERFORM f4_variant CHANGING p_layout.
*----------------------------------------------------------------------
*
* INITIALIZATION
*
*----------------------------------------------------------------------
*
INITIALIZATION.
* ==> Change Variant saving type
wa_var_save = 'A'.
* ==> Change first mode GRID or LIST
wa_alv_function_name = 'REUSE_ALV_GRID_DISPLAY'.
* wa_alv_function_name = 'REUSE_ALV_LIST_DISPLAY'.
REFRESH : gt_fieldcat.
CLEAR : gs_layout.
*--title set
c010 = 'Run Parameter'.
c020 = 'Select option'.
c030 = 'Select option'.
* p03 = 'Overall values'.
* p04 = 'Annual values (year)'.
wa_repid = sy-repid.
* for combo box
REFRESH : it_val.
CLEAR : it_val.
w_line-key = '01'.
w_line-text = 'All'.
APPEND w_line TO it_val.
w_line-key = '02'.
w_line-text = 'Plan'.
APPEND w_line TO it_val.
w_line-key = '03'.
w_line-text = 'Ori Bud'.
APPEND w_line TO it_val.
w_line-key = '04'.
w_line-text = 'Supplement'.
APPEND w_line TO it_val.
w_line-key = '05'.
w_line-text = 'Return'.
APPEND w_line TO it_val.
w_line-key = '06'.
w_line-text = 'Current Budget'.
APPEND w_line TO it_val.
w_line-key = '07'.
w_line-text = 'Actual'.
APPEND w_line TO it_val.
w_line-key = '08'.
w_line-text = 'Comm'.
APPEND w_line TO it_val.
*Issue Number : FI-20041118-007, Requested by Robin Simmons
*Changed on 2004/11/30, by WSKIM
*---Start
* w_line-key = '09'.
* w_line-text = 'Downpayment'.
* APPEND w_line TO it_val.
* w_line-key = '10'.
* w_line-text = 'Residual'.
w_line-key = '09'.
w_line-text = 'Available'.
APPEND w_line TO it_val.
w_line-key = '10'.
w_line-text = 'Downpayment'.
*---End
APPEND w_line TO it_val.
*---------------------------------------------------------------------
* M A I N
*
*---------------------------------------------------------------------
END-OF-SELECTION.
IF p_r2 = 'X'.
EXPORT s_prnam p_ayear p_act p_posid s_kostl it_val
p_chk1 p_chk2 p_fiscal p_low TO MEMORY.
SUBMIT zrfii02s AND RETURN.
EXIT.
ENDIF.
PERFORM set_year.
* ==> 5. build field category
PERFORM build_field_category
USING :
'POSID' 'Position ID' '16' 'X' 'C' ' ' ' ' ' ' ' ' 'CHAR',
'KOSTL' 'CostCener' '10' 'X' 'L' ' ' ' ' ' ' ' ' 'CHAR',
'ACT' 'Activity' '16' 'X' 'L' ' ' ' ' ' ' ' ' 'CHAR',
'TOT' 'Total' '15' 'X' 'R' ' ' ' ' ' ' ' ' 'CURR',
'BEFORE' wa_before_txt '15' ' ' 'R' ' ' ' ' ' ' ' ' 'CURR' ,
'LAST' wa_last '15' ' ' 'R' ' ' ' ' ' ' ' ' 'CURR',
'YEAR' wa_year '15' ' ' 'R' ' ' ' ' ' ' ' ' 'CURR',
'YEAR1' wa_year1 '15' ' ' 'R' ' ' ' ' ' ' ' ' 'CURR',
'YEAR2' wa_year2 '15' ' ' 'R' ' ' ' ' ' ' ' ' 'CURR',
'YEAR3' wa_year3 '15' ' ' 'R' ' ' ' ' ' ' ' ' 'CURR',
'YEAR4' wa_year4 '15' ' ' 'R' ' ' ' ' ' ' ' ' 'CURR',
'YEAR5' wa_year5 '15' ' ' 'R' ' ' ' ' ' ' ' ' 'CURR',
'AFTER' wa_after_txt '15' ' ' 'R' ' ' ' ' ' ' ' ' 'CURR'.
* ==> 6. build sorts info
REFRESH gt_sorts.
PERFORM build_sort_table
USING :
'1' 'POSID' 'X' 'X' '*'.
* ==> 1. select data from db
PERFORM select_data.
IF gt_out[] IS INITIAL.
MESSAGE s000(zmfi) WITH 'No found data '.
EXIT.
ENDIF.
* ==> 2. set variant default
PERFORM set_variant CHANGING wa_var.
* ==> 3. set layout for alv style
PERFORM set_layout CHANGING gs_layout.
* ==> 4. set events for alv
PERFORM set_events CHANGING gt_events.
*===> 5. set event for top-of-page grid.
PERFORM set_build_event.
*===>
PERFORM comment_build USING w_top_of_page[].
* ==> 7. call function display alv.
CALL FUNCTION wa_alv_function_name
EXPORTING
i_callback_program = wa_repid
i_callback_pf_status_set = 'ALV_EVENT_PF_STATUS_SET'
i_callback_user_command = 'ALV_EVENT_USER_COMMAND'
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
it_special_groups = gt_sp_group[]
it_sort = gt_sorts[]
* IT_FILTER =
i_default = wa_default
i_save = wa_var_save
is_variant = wa_var
* it_events = gt_events[]
it_events = w_eventcat[]
is_print = gs_prnt
* IT_EVENT_EXIT =
* I_SCREEN_START_COLUMN = 10
* I_SCREEN_START_LINE = 2
* I_SCREEN_END_COLUMN = 80
* I_SCREEN_END_LINE = 23
TABLES
t_outtab = gt_out.
***********************************************************************
*
*&---------------------------------------------------------------------
*& Form select_data
*&---------------------------------------------------------------------
FORM select_data.
DATA : wa_posid(20),
wa_pos TYPE i.
**Issue Number : FI-20041118-007, Requested by Robin Simmons
*Changed on 2004/12/09, by WSKIM
*---Start
* CONCATENATE p_posid '%' INTO wa_posid.
PERFORM range_posid USING p_posid.
*---End
SELECT * INTO CORRESPONDING FIELDS OF TABLE it_out FROM impr
WHERE gjahr = p_ayear
*---Start
* AND posid LIKE wa_posid
AND posid IN r_posid
*---End
AND prnam IN s_prnam
AND kostl IN s_kostl.
*---make gt_out by activity
LOOP AT it_out.
*---2003/12/16 jh smodify
IF p_low = 'X'. "low level pi
CHECK it_out-posid+7(4) <> 0000.
ENDIF.
PERFORM get_activity
USING it_out-kostl it_out-posid it_out-gjahr it_out-prnam.
ENDLOOP.
SORT gt_out BY posid key kostl ASCENDING.
LOOP AT gt_out.
MOVE gt_out-gjahr TO wa_gjahr.
MOVE gt_out-prnam TO wa_prnam.
AT NEW posid.
PERFORM cal_pi_budget USING gt_out-posid
wa_gjahr
wa_prnam.
PERFORM cal_pi_actual USING gt_out-posid
wa_gjahr
wa_prnam.
CLEAR : wa_gjahr, wa_prnam.
ENDAT.
*Issue Number : FI-20041118-007, Requested by Robin Simmons
*Changed on 2004/12/01, by WSKIM
*---Start
IF p_fiscal <> space.
MOVE p_fiscal TO gt_out-gjahr.
ENDIF.
*---End
IF gt_out-key =< 06.
PERFORM get_pi_budget USING gt_out-posid gt_out-key
gt_out-gjahr gt_out-prnam.
ELSEIF gt_out-key > 06.
PERFORM get_pi_actual USING gt_out-posid gt_out-key
gt_out-gjahr gt_out-prnam.
ENDIF.
*---CAL Available.
*Issue Number : FI-20041118-007, Requested by Robin Simmons
*Changed on 2004/12/01, by WSKIM
*---Start
* IF gt_out-key = '10'.
IF gt_out-key = '09'.
* IF p_chk2 = 'X' AND p_chk1 = ' '.
* PERFORM get_pi_budget2 USING gt_out-posid gt_out-key
* gt_out-gjahr gt_out-prnam.
*---End
gt_out-tot = wa_n_tot - wa_a_tot - wa_c_tot.
gt_out-before = wa_n_before - wa_a_before - wa_c_before.
gt_out-last = wa_n_last - wa_a_last - wa_c_last.
gt_out-year = wa_n_year - wa_a_year - wa_c_year.
gt_out-year1 = wa_n_year1 - wa_a_year1 - wa_c_year1.
gt_out-year2 = wa_n_year2 - wa_a_year2 - wa_c_year2.
gt_out-year3 = wa_n_year3 - wa_a_year3 - wa_c_year3.
gt_out-year4 = wa_n_year4 - wa_a_year4 - wa_c_year4.
gt_out-year5 = wa_n_year5 - wa_a_year5 - wa_c_year5.
gt_out-after = wa_n_after - wa_a_after - wa_c_after.
*---Start
IF p_fiscal <> space.
gt_out-tot = gt_out-before + gt_out-last + gt_out-year
+ gt_out-year1 + gt_out-year2 + gt_out-year3
+ gt_out-year4 + gt_out-year5 + gt_out-after .
ENDIF.
*---End
MODIFY gt_out.
*---Start
*begin insert
* PERFORM clear_dummy.
ELSEIF p_fiscal NE space AND ( gt_out-key = '02' OR
gt_out-key = '03' OR gt_out-key = '04' OR gt_out-key = '05'
OR gt_out-key = '06' ).
gt_out-tot = gt_out-last + gt_out-year + gt_out-year1 +
gt_out-year2 + gt_out-year3 + gt_out-year4 +
gt_out-year5 + gt_out-before + gt_out-after.
MODIFY gt_out.
*---End
*---Start
* ENDIF.
* PERFORM clear_dummy.
ENDIF.
AT END OF posid.
PERFORM clear_dummy.
ENDAT.
*---End
ENDLOOP.
*------2003/04/16
IF p_chk1 = ' ' AND p_chk2 = ' '.
*Issue Number : FI-20041118-007, Requested by Robin Simmons
*Changed on 2004/12/01, by WSKIM
*---Start
* IF p_act = '10'.
IF p_act = '09'.
*---End
LOOP AT gt_out.
*---Start
* IF gt_out-key = '10'.
IF gt_out-key = '09'.
*---End
CONTINUE.
ELSE.
DELETE gt_out.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
SORT gt_out ASCENDING BY posid kostl key.
ENDFORM. " select_data
*---------------------------------------------------------------------*
* FORM alv_event_pf_status_set
*---------------------------------------------------------------------*
FORM alv_event_pf_status_set USING rt_extab TYPE slis_t_extab.
"#EC *
IF wa_alv_function_name = 'REUSE_ALV_GRID_DISPLAY'.
SET PF-STATUS 'STANDARD_GRID' EXCLUDING rt_extab.
ELSE.
SET PF-STATUS 'STANDARD' EXCLUDING rt_extab.
ENDIF.
SET TITLEBAR 'STANDARD'.
ENDFORM. "alv_event_pf_status_set
*---------------------------------------------------------------------*
* FORM alv_event_user_command
*---------------------------------------------------------------------*
FORM alv_event_user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
"#EC *
CASE r_ucomm.
* ---------------------------------- processing on double click.
WHEN '&IC1'.
READ TABLE gt_out INDEX rs_selfield-tabindex.
CASE rs_selfield-fieldname.
* WHEN 'AUFNR'.
* SET PARAMETER ID 'ANR' FIELD gt_out-aufnr.
* CALL TRANSACTION 'KO03' AND SKIP FIRST SCREEN.
WHEN 'ACT'.
IF gt_out-key = '02'.
SET PARAMETER ID 'IMT' FIELD gt_out-prnam.
SET PARAMETER ID 'IMP' FIELD gt_out-posid.
SET PARAMETER ID 'GJR' FIELD p_ayear.
CALL TRANSACTION 'IM36' AND SKIP FIRST SCREEN.
ELSEIF gt_out-key = '03'.
SET PARAMETER ID 'IMT' FIELD gt_out-prnam.
SET PARAMETER ID 'IMP' FIELD gt_out-posid.
SET PARAMETER ID 'GJR' FIELD p_ayear.
CALL TRANSACTION 'IM33' AND SKIP FIRST SCREEN.
ELSEIF gt_out-key = '04'.
SET PARAMETER ID 'IMT' FIELD gt_out-prnam.
SET PARAMETER ID 'IMP' FIELD gt_out-posid.
SET PARAMETER ID 'GJR' FIELD p_ayear.
CALL TRANSACTION 'IM31' AND SKIP FIRST SCREEN.
ELSEIF gt_out-key = '05'.
SET PARAMETER ID 'IMT' FIELD gt_out-prnam.
SET PARAMETER ID 'IMP' FIELD gt_out-posid.
SET PARAMETER ID 'GJR' FIELD p_ayear.
CALL TRANSACTION 'IM39' AND SKIP FIRST SCREEN.
ELSEIF gt_out-key = '07' OR gt_out-key = '08' OR
*Issue Number : FI-20041118-007, Requested by Robin Simmons
*Changed on 2004/12/01, by WSKIM
*---Start
* gt_out-key = '09'.
gt_out-key = '09' or gt_out-key = '10' or gt_out-key = '06'.
*---End
SET PARAMETER ID 'IMT' FIELD s_prnam-low.
SET PARAMETER ID 'IMP' FIELD gt_out-posid.
SET PARAMETER ID 'GJR' FIELD p_ayear.
CALL TRANSACTION 'ZIMR' AND SKIP FIRST SCREEN.
ENDIF.
WHEN 'POSID'.
SET PARAMETER ID 'IMT' FIELD s_prnam-low.
SET PARAMETER ID 'IMP' FIELD gt_out-posid.
SET PARAMETER ID 'GJR' FIELD p_ayear.
SET PARAMETER ID 'IPPOS' FIELD so_ippos-low.
CALL TRANSACTION 'ZIMR' AND SKIP FIRST SCREEN.
ENDCASE.
* ---------------------------------- switching view type grid or list
WHEN 'LIST' OR 'GRID'.
PERFORM switch_list_or_grid USING r_ucomm.
ENDCASE.
CHECK r_ucomm EQ 'LIST' OR
r_ucomm EQ 'GRID'.
rs_selfield-exit = 'X'.
ENDFORM. "alv_event_user_command
*&---------------------------------------------------------------------
*& Form set_variant
*&---------------------------------------------------------------------
FORM set_variant CHANGING cs_vari TYPE disvariant.
CHECK p_layout NE space.
cs_vari-report = sy-repid.
cs_vari-handle = space.
cs_vari-log_group = space.
cs_vari-username = space.
cs_vari-variant = p_layout.
cs_vari-text = space.
cs_vari-dependvars = space.
ENDFORM. " set_variant
*&---------------------------------------------------------------------
*& Form set_events
*&---------------------------------------------------------------------
FORM set_events CHANGING ct_events TYPE slis_t_event.
FIELD-SYMBOLS: <ls_event> TYPE slis_alv_event.
DATA: l_event TYPE lvc_fname.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = ct_events
EXCEPTIONS
list_type_wrong = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
DELETE ct_events WHERE name NE 'END_OF_PAGE'
AND name NE 'TOP_OF_PAGE'
AND name NE 'TOP_OF_LIST'
AND name NE 'END_OF_LIST'.
LOOP AT ct_events ASSIGNING <ls_event>.
CONCATENATE 'ALV_EVENT_'
<ls_event>-name
INTO <ls_event>-form.
ENDLOOP.
ENDIF.
ENDFORM. " f01_set_evts
*&---------------------------------------------------------------------
*& Form set_layout
*&---------------------------------------------------------------------
FORM set_layout CHANGING cs_layo TYPE slis_layout_alv.
*... Display options
cs_layo-colwidth_optimize = space.
"?????
cs_layo-no_colhead = space.
cs_layo-no_hotspot = space.
cs_layo-zebra = ' '.
cs_layo-no_vline = space.
cs_layo-cell_merge = space.
cs_layo-no_min_linesize = space.
cs_layo-min_linesize = space.
cs_layo-max_linesize = space.
cs_layo-window_titlebar = space.
cs_layo-no_uline_hs = space.
*... Edit
cs_layo-edit = ' '."space.
cs_layo-edit_mode = ' '."space.
*... Exceptions
cs_layo-lights_fieldname = ' '.
"=> ??? ??? ???
cs_layo-lights_tabname = space.
cs_layo-lights_rollname = space.
cs_layo-lights_condense = space.
*... Sums
cs_layo-no_sumchoice = space.
cs_layo-no_totalline = space.
cs_layo-totals_before_items = space.
cs_layo-totals_only = space.
cs_layo-totals_text = space.
cs_layo-no_subchoice = space.
cs_layo-no_subtotals = space.
cs_layo-subtotals_text = space.
cs_layo-numc_sum = 'X'.
cs_layo-no_unit_splitting = space.
*... Interaction
cs_layo-box_fieldname = ' '.
cs_layo-box_tabname = space.
cs_layo-box_rollname = space.
cs_layo-expand_fieldname = space.
cs_layo-hotspot_fieldname = space.
cs_layo-no_input = ' '.
cs_layo-f2code = space.
cs_layo-confirmation_prompt = space.
cs_layo-key_hotspot = space.
cs_layo-flexible_key = space.
cs_layo-reprep = space.
cs_layo-group_buttons = 'X'.
cs_layo-no_keyfix = space.
cs_layo-get_selinfos = space.
cs_layo-group_change_edit = 'X'.
cs_layo-no_scrolling = space.
cs_layo-expand_all = space.
cs_layo-no_author = space.
*... Detailed screen
cs_layo-detail_popup = 'X'.
cs_layo-detail_initial_lines = space.
cs_layo-detail_titlebar = space.
*... PF-status
cs_layo-def_status = space.
*... Display variants
cs_layo-header_text = space.
cs_layo-item_text = space.
cs_layo-default_item = space.
*... colour
cs_layo-info_fieldname = space.
cs_layo-coltab_fieldname = 'TABCOLOR'.
*... others
cs_layo-list_append = space.
ENDFORM. " set_layout
*---------------------------------------------------------------------*
* FORM f01_alv_event_top_of_page
*---------------------------------------------------------------------*
FORM alv_event_top_of_page. "#EC CALLED
* WRITE : /(10) 'nvestment Program' , p_prnam.
* /(10) 'BBBBBBB', BKPF-BUKRS INVERSE COLOR 1 INPUT ON,
* (20) 'CCCCCCC', BKPF-BELNR INPUT ON.
ENDFORM. "alv_event_top_of_page
*---------------------------------------------------------------------*
* FORM alv_event_top_of_LIST *
*---------------------------------------------------------------------*
FORM alv_event_top_of_list. "#EC CALLED
ENDFORM. "alv_event_top_of_page
*---------------------------------------------------------------------*
* FORM f01_alv_event_end_of_page
*---------------------------------------------------------------------*
FORM alv_event_end_of_page.
* NEW-LINE.
* ULINE.
* DATA: l_page(10).
* WRITE : sy-pagno TO l_page.
* WRITE: /(120) l_page CENTERED.
*
ENDFORM. "alv_event_end_of_page
*---------------------------------------------------------------------*
* FORM f01_alv_event_end_of_list
*---------------------------------------------------------------------*
FORM alv_event_end_of_list.
ENDFORM. "alv_event_end_of_list
*&---------------------------------------------------------------------*
*& Form dispaly_heager
*----------------------------------------------------------------------*
FORM display_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
* i_logo = 'Z_HYUNDAI_LOGO'
* i_logo = 'ENJOYSAP_LOGO'
it_list_commentary = w_top_of_page.
ENDFORM. " top_of_page
*&---------------------------------------------------------------------
*& Form switch_list_or_grid
*&---------------------------------------------------------------------
FORM switch_list_or_grid USING r_ucomm.
DATA: ls_vari TYPE disvariant,
ls_slis_layo TYPE slis_layout_alv,
lt_slis_fcat TYPE slis_t_fieldcat_alv,
lt_slis_sort TYPE slis_t_sortinfo_alv,
lt_slis_filt TYPE slis_t_filter_alv,
ls_slis_prnt TYPE slis_print_alv.
IF r_ucomm = 'LIST' AND
wa_alv_function_name = 'REUSE_ALV_LIST_DISPLY'.
EXIT.
ENDIF.
IF r_ucomm = 'GRID' AND
wa_alv_function_name = 'REUSE_ALV_GRID_DISPLAY'.
EXIT.
ENDIF.
CASE wa_alv_function_name.
WHEN 'REUSE_ALV_LIST_DISPLAY'.
wa_alv_get_info_name = 'REUSE_ALV_LIST_LAYOUT_INFO_GET'.
WHEN 'REUSE_ALV_GRID_DISPLAY'.
wa_alv_get_info_name = 'REUSE_ALV_GRID_LAYOUT_INFO_GET'.
ENDCASE.
CALL FUNCTION wa_alv_get_info_name
IMPORTING
es_layout = ls_slis_layo
et_fieldcat = lt_slis_fcat
et_sort = lt_slis_sort
et_filter = lt_slis_filt
es_variant = ls_vari
EXCEPTIONS
no_infos = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF r_ucomm = 'LIST'.
wa_alv_function_name = 'REUSE_ALV_LIST_DISPLAY'.
CALL FUNCTION wa_alv_function_name
EXPORTING
i_callback_program = wa_repid
i_callback_pf_status_set = 'ALV_EVENT_PF_STATUS_SET'
i_callback_user_command = 'ALV_EVENT_USER_COMMAND'
is_layout = ls_slis_layo
it_fieldcat = lt_slis_fcat
it_sort = lt_slis_sort
it_filter = lt_slis_filt
i_default = ' ' "gs_test-vari_default
i_save = wa_var_save
is_variant = ls_vari
is_print = ls_slis_prnt
it_events = gt_events[]
TABLES
t_outtab = gt_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDIF.
IF r_ucomm = 'GRID'.
wa_alv_function_name = 'REUSE_ALV_GRID_DISPLAY'.
CALL FUNCTION wa_alv_function_name
EXPORTING
i_callback_program = wa_repid
i_callback_pf_status_set = 'ALV_EVENT_PF_STATUS_SET'
i_callback_user_command = 'ALV_EVENT_USER_COMMAND'
is_layout = ls_slis_layo
it_fieldcat = lt_slis_fcat
it_sort = lt_slis_sort
it_filter = lt_slis_filt
i_default = ' ' "gs_test-vari_default
i_save = wa_var_save
is_variant = ls_vari
is_print = ls_slis_prnt
* it_events = gt_events[]
TABLES
t_outtab = gt_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDIF.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " switch_list_or_grid
*&--------------------------------------------------------------------
*& Form make_field_category
*&--------------------------------------------------------------------
FORM build_field_category USING
p_fieldname " field name
p_title " field title
p_outputlen " length
p_key "
p_just "
p_noout "
p_edit "
p_cfield " currency field nam
p_qfield " quantity field nam
p_type " Type
.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = p_fieldname.
* ls_fieldcat-seltext_s = p_title.
* ls_fieldcat-seltext_m = p_title.
ls_fieldcat-seltext_l = p_title.
ls_fieldcat-outputlen = p_outputlen.
ls_fieldcat-key = p_key.
ls_fieldcat-just = p_just.
ls_fieldcat-edit = p_edit.
ls_fieldcat-no_out = p_noout.
ls_fieldcat-cfieldname = p_cfield.
ls_fieldcat-qfieldname = p_qfield.
ls_fieldcat-datatype = p_type.
IF p_fieldname = 'TOT'.
ls_fieldcat-emphasize = 'C700'.
ENDIF.
APPEND ls_fieldcat TO gt_fieldcat.
ENDFORM. " fill_field_category
*&---------------------------------------------------------------------*
*& Form f4_variant
*&---------------------------------------------------------------------*
FORM f4_variant CHANGING c_variant TYPE disvariant-variant.
DATA: ls_variant TYPE disvariant,
l_exit TYPE char1.
ls_variant-report = sy-repid.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = ls_variant
i_save = 'A'
* it_default_fieldcat =
IMPORTING
e_exit = l_exit
es_variant = ls_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 2.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF l_exit EQ space.
c_variant = ls_variant-variant.
ENDIF.
ENDIF.
ENDFORM. " f4_variant
*&---------------------------------------------------------------------*
*& Form build_sort_table
*&---------------------------------------------------------------------*
FORM build_sort_table USING p_spos
p_fieldname
p_up
p_subtot
p_group.
DATA: ls_sort TYPE slis_sortinfo_alv.
ls_sort-spos = p_spos.
ls_sort-fieldname = p_fieldname.
ls_sort-up = p_up.
ls_sort-subtot = p_subtot.
ls_sort-group = p_group.
APPEND ls_sort TO gt_sorts.
ENDFORM. " build_sort_table
*&---------------------------------------------------------------------*
*& Form set_line_color
*&---------------------------------------------------------------------*
FORM set_line_color USING p_color.
DATA: ls_fieldcat TYPE slis_fieldcat_alv,
lt_color TYPE slis_t_specialcol_alv,
ls_color TYPE slis_specialcol_alv.