Program for Background Job for COGI BDC CORUAFFW

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
IV_WERKS  Importing Type  WERKS_D
IV_MATNR  Importing Type  MATNR

METHOD fix_cogi_error.
  DATA:
        ls_option_bdc TYPE ctu_params,
        lt_bdcdata TYPE TABLE OF bdcdata,
        lv_werks_bdcval TYPE bdc_fval,
        lv_matnr_bdcval TYPE bdc_fval,
        lt_messtab TYPE TABLE OF bdcmsgcoll,
        lv_matnr TYPE matnr,
        lv_count TYPE i,
        ctu_params TYPE ctu_params.

  lv_werks_bdcval = iv_werks.
  SELECT SINGLE matnr_ext
    FROM materialid
    INTO lv_matnr_bdcval
    WHERE matnr_int = iv_matnr.

  SELECT SINGLE  COUNT( * )
    INTO lv_count
    FROM affw
    WHERE matnr = iv_matnr AND
    werks = iv_werks.

  UPDATE affw SET budat = sy-datum  WHERE matnr = iv_matnr AND
                                          werks = iv_werks.

  bdc_dynpro( EXPORTING program = 'CORUAFFW'
                        dynpro = '1000'
  CHANGING bdcdata = lt_bdcdata ).
  bdc_fields( EXPORTING fnam = 'S_WERKS-LOW' fval = lv_werks_bdcval
  CHANGING bdcdata = lt_bdcdata ).
  bdc_fields( EXPORTING fnam = 'S_MATNR-LOW' fval = lv_matnr_bdcval
  CHANGING bdcdata = lt_bdcdata ).
  bdc_fields( EXPORTING fnam = 'R_CUMUL' fval = 'X'
  CHANGING bdcdata = lt_bdcdata ).
  bdc_fields( EXPORTING fnam = 'BDC_OKCODE' fval = '=ONLI'
  CHANGING bdcdata = lt_bdcdata ).

  bdc_dynpro( EXPORTING program = 'SAPLSLVC_FULLSCREEN'
                        dynpro = '0500'
  CHANGING bdcdata = lt_bdcdata ).
  bdc_fields( EXPORTING fnam = 'BDC_OKCODE' fval = '=&ALL'
  CHANGING bdcdata = lt_bdcdata ).
  bdc_dynpro( EXPORTING program = 'SAPLSLVC_FULLSCREEN'
                        dynpro = '0500'
  CHANGING bdcdata = lt_bdcdata ).
  bdc_fields( EXPORTING fnam = 'BDC_OKCODE' fval = '=BU'
  CHANGING bdcdata = lt_bdcdata ).

  ls_option_bdc-dismode = 'A'."'A'. "'N'.
  ls_option_bdc-updmode = 'S'.
  ls_option_bdc-nobinpt = 'X'.
  CALL TRANSACTION 'COGI' USING  lt_bdcdata
        OPTIONS FROM ls_option_bdc
        MESSAGES INTO lt_messtab[].

  DO lv_count TIMES.
    CLEAR lt_bdcdata.


    bdc_dynpro( EXPORTING program = 'CORUAFFW' dynpro = '1000'
    CHANGING bdcdata = lt_bdcdata ).
    bdc_fields( EXPORTING fnam = 'S_WERKS-LOW' fval = lv_werks_bdcval
    CHANGING bdcdata = lt_bdcdata ).
    bdc_fields( EXPORTING fnam = 'S_MATNR-LOW' fval = lv_matnr_bdcval
    CHANGING bdcdata = lt_bdcdata ).
    IF sy-index = 1.
      bdc_fields( EXPORTING fnam = 'R_CUMUL' fval = 'X'
      CHANGING bdcdata = lt_bdcdata ).
    ELSE.
      bdc_fields( EXPORTING fnam = 'R_CUMUL' fval = ''
     CHANGING bdcdata = lt_bdcdata ).
      bdc_fields( EXPORTING fnam = 'R_SINGLE' fval = 'X'
     CHANGING bdcdata = lt_bdcdata ).
    ENDIF.
    bdc_fields( EXPORTING fnam = 'BDC_OKCODE' fval = '=ONLI'
    CHANGING bdcdata = lt_bdcdata ).

    bdc_dynpro( EXPORTING program = 'SAPLSLVC_FULLSCREEN' dynpro = '0500'
    CHANGING bdcdata = lt_bdcdata ).
    bdc_fields( EXPORTING fnam = 'BDC_OKCODE' fval = '=KORR'
    CHANGING bdcdata = lt_bdcdata ).

    bdc_dynpro( EXPORTING program = 'SAPLCOWB' dynpro = '0130'
    CHANGING bdcdata = lt_bdcdata ).
    bdc_fields( EXPORTING fnam = 'BDC_OKCODE' fval = '=MALL'
    CHANGING bdcdata = lt_bdcdata ).

    bdc_dynpro( EXPORTING program = 'SAPLCOWB' dynpro = '0130'
    CHANGING bdcdata = lt_bdcdata ).
    bdc_fields( EXPORTING fnam = 'BDC_OKCODE' fval = '=CHFI'
    CHANGING bdcdata = lt_bdcdata ).

    bdc_dynpro( EXPORTING program = 'SAPLCOWB' dynpro = '0130'
      CHANGING bdcdata = lt_bdcdata ).
    bdc_fields( EXPORTING fnam = 'BDC_OKCODE' fval = '=WEIT'
    CHANGING bdcdata = lt_bdcdata ).

    CALL TRANSACTION 'COGI' USING  lt_bdcdata
          OPTIONS FROM ls_option_bdc
          "MODE   ls_option_bdc-dismode "'N'
          "N-фон E-только ошибки A-все экраны
          "UPDATE ls_option_bdc-updmode "'S'
          "S-синхронно A-асинхронно L-локально
          MESSAGES INTO lt_messtab[].

    SELECT SINGLE  matnr
      INTO lv_matnr
      FROM affw
      WHERE matnr = iv_matnr AND
            werks = iv_werks.
    IF sy-subrc > 0.
      EXIT.
    ENDIF.
  ENDDO.
ENDMETHOD.

Добавить комментарий

Ваш адрес email не будет опубликован.