Tuesday, November 29, 2016

Upload Result Recording

  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
SELECT * FROM QALS INTO TABLE i_QALS
  WHERE prueflos  IN S_IIN AND
        enstehdat IN S_CO AND
        werk      IN S_PL AND
        art       IN S_IT AND
        matnr     IN S_MN AND
        pastrterm IN s_iibdt AND
        paendterm IN s_iiedt AND
        slwbez ne space .
*        ART eq 'Z3'.

 SELECT * FROM QASE INTO TABLE I_QASE
   WHERE prueflos IN S_IIN AND
         probenr  IN s_ipn  .

 SELECT * FROM jest INTO TABLE i_jest
   FOR ALL ENTRIES IN i_QALS
   WHERE objnr = i_qals-objnr AND inact eq space AND
   ( stat eq 'I0212 ' or stat eq 'I0002').

 LOOP AT i_QALS INTO s_QALS .
   READ TABLE i_jest WITH KEY objnr = s_qals-objnr TRANSPORTING NO FIELDS .
   IF sy-subrc ne 0.
     delete i_QALS  WHERE objnr eq s_QALS-objnr .
   ENDIF.

 ENDLOOP.

 SELECT * FROM MAKT INTO TABLE i_makt
   FOR ALL ENTRIES IN i_qals
   WHERE matnr eq i_qals-SELMATNR AND spras eq 'En'.

SELECT * FROM qamv INTO TABLE i_qamv
  FOR ALL ENTRIES IN i_qals
  WHERE prueflos eq i_qals-prueflos.

LOOP AT I_QALS INTO S_QALS.

G_INSPLOT = S_QALS-prueflos.
G_HANDHELD = ''.

CALL FUNCTION 'BAPI_INSPOPER_GETLIST'
 EXPORTING
   INSPLOT                    = G_INSPLOT
   HANDHELD_APPLICATION       = G_HANDHELD
 IMPORTING
   RETURN                     = G_RETURN
   RETURN2                    = G_RETURN2
 TABLES
   INSPOPER_LIST              = I_INSPOPER
   HANDHELD_WORKLIST          = I_HANDHELD
          .

IF G_RETURN-type ne 'S'.
CONTINUE.
ELSE.
CLEAR g_tbx. DESCRIBE TABLE I_INSPOPER LINES g_tbx.
ENDIF.

loop at I_INSPOPER into S_INSPOPER.
* S_EXCEL-inspection_lot_number          = s_qals-PRUEFLOS  .
  CONCATENATE ' ' ''s_qals-PRUEFLOS INTO S_EXCEL-inspection_lot_number.
*  CONCATENATE '=TEXT(0,"'s_qals-PRUEFLOS'")' INTO S_EXCEL-inspection_lot_number.
 S_EXCEL-material_number                = s_qals-SELMATNR  .
 s_excel-operation                      = S_INSPOPER-inspoper.
 s_excel-operation_description          = S_INSPOPER-txt_oper.

* s_excel-insp_point          = s_qals-PRUEFLOS.


READ TABLE i_makt INTO s_makt WITH KEY matnr = s_qals-SELMATNR.
IF sy-subrc eq 0.
  S_EXCEL-material_number_desc = s_makt-MAKTX.
ENDIF.

g_insplot2 = s_qals-PRUEFLOS.
G_inspoper = S_INSPOPER-inspoper.

CALL FUNCTION 'BAPI_INSPOPER_GETDETAIL'
  EXPORTING
    insplot                            = g_insplot2     "                            s_qals-PRUEFLOS
    inspoper                           = G_inspoper     "                          S_INSPOPER-inspoper
   READ_INSPPOINTS                    = 'X'
   READ_CHAR_REQUIREMENTS             = 'X'
   READ_CHAR_RESULTS                  = 'X'
   READ_SAMPLE_RESULTS                = 'X'
   READ_SINGLE_RESULTS                = 'X'
   READ_CHARS_WITH_CLASSES            = 'X'
   READ_CHARS_WITHOUT_RECORDING       = 'X'
   RES_ORG                            = ' '
   CHAR_FILTER_NO                     = '1   '
   CHAR_FILTER_TCODE                  = 'QE11'
   MAX_INSPPOINTS                     = 100
   INSPPOINT_FROM                     = 0
   HANDHELD_APPLICATION               = ' '
   RESULT_COPY                        = ' '
 IMPORTING
   OPERATION                          = G_OPERATION
   INSPPOINT_REQUIREMENTS             = G_INSPPOINT_REQUIREMENTS
   RETURN                             = g_RETURN3
 TABLES
   INSPPOINTS                         = i_INSPPOINTS
   CHAR_REQUIREMENTS                  = i_CHAR_REQUIREMENTS
   CHAR_RESULTS                       = i_CHAR_RESULTS
   SAMPLE_RESULTS                     = i_SAMPLE_RESULTS
   SINGLE_RESULTS                     = i_SINGLE_RESULTS
          .
READ TABLE i_CHAR_REQUIREMENTS INTO s_CHAR_REQUIREMENTS INDEX 1.
IF sy-subrc eq 0.
S_EXCEL-mic_code = s_char_requirements-mstr_char.
READ TABLE i_qamv INTO s_qamv WITH KEY verwmerkm = S_EXCEL-mic_code.
IF sy-subrc eq 0.
*s_excel-upper = s_qamv-TOLERANZOB .
    WRITE s_qamv-TOLERANZOB to g_c1.
    WRITE s_qamv-TOLERANZUN to g_c2.
    SPLIT g_c1 at ',' INTO g_c3 g_c4.
    SPLIT g_c2 at ',' INTO g_c5 g_c6.
*    CONCATENATE '=TEXT(0,"'g_c3'")' INTO s_excel-upper.
    CONCATENATE '' ''g_c3 INTO s_excel-upper.
    CONCATENATE '' ''g_c5 INTO s_excel-lower.
*    CONCATENATE '=TEXT(0,"'g_c5'")' INTO s_excel-lower.
*s_excel-lower = s_qamv-TOLERANZUN .


S_EXCEL-mic_description = s_qamv-kurztext.
S_EXCEL-number_or_sample = s_qamv-sollstpumf. CONDENSE S_EXCEL-number_or_sample.
S_EXCEL-uom              = s_CHAR_REQUIREMENTS-meas_unit.

if s_qamv-pmethode IS INITIAL.
*  s_excel-insp_method_code = ''.
  CLEAR s_excel-insp_method_code.
else.
  s_excel-insp_method_code = s_qamv-pmethode.
endif.

CONDENSE s_excel-insp_method_code.

s_excel-insp_methode_desc = ''.

APPEND s_excel to i_excel.
ENDIF.


ENDIF.

ENDLOOP.
ENDLOOP.

Example Upload Infotypes

 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
FORM F_UPLOAD_INFOTYPE_0015  USING    VALUE(P_0272)
                                      P_LI_HR   STRUCTURE ZTA_HR_ADDPAYMNT
                             CHANGING P_LI_HR_LOG
                                      P_LI_HR_STATUS.

DATA :
      px_infty                TYPE   PRELP-INFTY,
      px_number               TYPE   P0001-PERNR           ,
      px_subtype              TYPE   P0001-SUBTY           ,
      px_OBJECTID             TYPE   P0001-OBJPS           ,
      px_LOCKINDICATOR        TYPE   P0001-SPRPS           ,
      px_VALIDITYEND          TYPE   P0001-ENDDA           ,
      px_validitybegin        TYPE   P0001-BEGDA           ,
      px_RECORDNUMBER         TYPE   P0001-SEQNR           ,
      px_record               TYPE   p0015,c               ,
      px_operation            TYPE   PSPAR-ACTIO           ,
      px_TCLAS                TYPE   PSPAR-TCLAS           ,
      px_DIALOG_MODE          TYPE   C VALUE '0'           , "DEFAULT 'A'
      px_nocommit             TYPE   c                     ,
*     px_VIEW_IDENTIFIER      TYPE   BAPI_STAND-NO_COMMIT  ,
*     px_SECONDARY_RECORD     TYPE   P0003-VIEKN           ,
      px_return               TYPE   BAPIRETURN1           , "STRUCTURE  BAPIRETURN1 "OPTIONAL
      px_key                  TYPE   BAPIPAKEY             ,
      px3_number              TYPE   bapip0001-pernr       ,
      px3_return              TYPE   bapireturn1           ,
      lx4_wait                TYPE   bapita-wait           ,
      lx4_retn                TYPE   bapiret2              .
      .

px_infty = '0015'.
px3_number = px_number = P_LI_HR-pernr.
px_subtype = P_LI_HR-SUBTY.
px_validitybegin = P_LI_HR-BEGDA.

P_LI_HR-BETRG = P_LI_HR-BETRG / 100.
MOVE-CORRESPONDING P_LI_HR to px_record.
px_operation = 'INS'.
px_nocommit = 'X'.

CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
  EXPORTING
    NUMBER        = px3_number
  IMPORTING
    RETURN        = px3_return
          .

if px3_return-TYPE ne 'E'.
 CALL FUNCTION 'HR_INFOTYPE_OPERATION'
      EXPORTING
        infty                  = px_infty
        number                 = px_number
        subtype                = px_subtype
*       OBJECTID               = px_OBJECTID
*       LOCKINDICATOR          = px_LOCKINDICATOR
*       VALIDITYEND            = px_VALIDITYEND
        validitybegin          = px_validitybegin
*       RECORDNUMBER           = px_RECORDNUMBER
        record                 = px_record
        operation              = px_operation
*       TCLAS                  = px_TCLAS
*       DIALOG_MODE            = px_DIALOG_MODE
        nocommit               = px_nocommit
*       VIEW_IDENTIFIER        = px_VIEW_IDENTIFIER
*       SECONDARY_RECORD       = px_SECONDARY_RECORD
      IMPORTING
        return                 = px_return
        key                    = px_key.
 IF px_return-type IS INITIAL.


      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait   = lx4_wait
        IMPORTING
          return = lx4_retn.

*    ENDIF.

    p_li_hr_status     = '@08@'.
    p_li_hr_log       = 'Success updated Additional Payment'.
  ELSE.
*    p_li_hr_log    = 'Additional Payment Failed'.
    p_li_hr_log    = px_return-MESSAGE.
    p_li_hr_status = '@0A@'.
  ENDIF.

*px3_number =
  CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
    EXPORTING
      number = px3_number
    IMPORTING
      return = px3_return.

  ELSE.
    p_li_hr_log    = 'Pernr is being used.'.
    p_li_hr_status = '@0A@'.
  ENDIF.

Maintaining HRP Table Example

  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
FORM F_UPD5  TABLES   PT_0105 "STRUCTURE < GT_0009 #local# >
                        "Insert a correct name for <...>
             USING    G_CP
                      flag.
*TABLES : PPLOG,P1001.
DATA:
      lv_flag TYPE c,
      gv_BUFFER_C TYPE i,
      gv_BUFFO_OB TYPE i,
      gv_PLOG_TAB TYPE i VALUE '2',
      gv_TB_BUFFE TYPE i,
      gv_TB_PLOG_ TYPE i,

      gv_type     TYPE x VALUE '0000000000',
      gv_typec(10)     TYPE c,

      i_BUFFER_TAB       TYPE TABLE OF HRBUFFER        ,
      s_BUFFER_TAB       TYPE HRBUFFER        ,
      i_BUFFO_TAB        TYPE TABLE OF P1000           ,
      s_BUFFO_TAB        TYPE P1000           ,
      i_PLOG_TAB_TAB     TYPE TABLE OF HRDBTAB         ,
      S_PLOG_TAB_TAB     TYPE HRDBTAB         ,
      i_TB_BUFFER_TAB    TYPE TABLE OF HRTBUFFER       ,
      i_TB_PLOG_TAB_TAB  TYPE TABLE OF HRTBUFFER       ,

      S_0105 TYPE PA0105,
      G_CPC(10) TYPE C,
      gv_data(45) type c,
      gv_prozt TYPE prozt VALUE '0.00',
      gv_pc(40) TYPE c,
      gv_tab TYPE char30 VALUE 'P1001',
      lv_tabix TYPE sy-tabix,
      s_hrp5585 TYPE p5585,
      i_hrp5585 TYPE TABLE OF p5585,
      g_pernr type BAPIP0001-PERNR
      .
FIELD-SYMBOLS : <P1001_VDATA> TYPE hrip1001.

FIELD-SYMBOLS : <PPNNN>,<sclas>,<sobid>,
                <wplog_hlp> type any.

      DATA : GV_VTASK       LIKE HRRHAP-VTASK VALUE 'D',
             GV_COMMIT_FLG  LIKE HRRHAP-COMMIT_FLG VALUE 'X'.

READ TABLE PT_0105 INTO S_0105 INDEX 1.

CHECK S_0105 IS NOT INITIAL.
**FOR CENTRAL PERSON

s_BUFFO_TAB-PLVAR = '01'.
s_BUFFO_TAB-OTYPE = 'CP'.
s_BUFFO_TAB-objid = g_cp.
s_BUFFO_TAB-infty = '1000'.
s_BUFFO_TAB-ISTAT = '1'.
s_BUFFO_TAB-begda = sy-datum.
s_BUFFO_TAB-endda = '99991231'.
s_BUFFO_TAB-langu = 'E'.
s_BUFFO_TAB-aedtm = sy-datum.
s_BUFFO_TAB-uname = sy-uname.
APPEND S_BUFFO_TAB to I_BUFFO_TAB.

CLEAR lv_tabix.

  S_PLOG_TAB_TAB-plvar = '01'.
  S_PLOG_TAB_TAB-otype = 'CP'.
  S_PLOG_TAB_TAB-objid = g_cp.
  S_PLOG_TAB_TAB-infty = '5585'.
  S_PLOG_TAB_TAB-istat = '1'.
  S_PLOG_TAB_TAB-begda = sy-datum.
  S_PLOG_TAB_TAB-endda = '99991231'.
  S_PLOG_TAB_TAB-aedtm = sy-datum.
  S_PLOG_TAB_TAB-uname = sy-uname.

S_PLOG_TAB_TAB-opera = 'I'. S_PLOG_TAB_TAB-PRIMARY_WF = 'X'.
APPEND S_PLOG_TAB_TAB to i_PLOG_TAB_TAB .
CLEAR S_PLOG_TAB_TAB .
GV_BUFFO_OB = 1.
GV_plog_tab = 1.
CALL FUNCTION 'RH_SET_BUFFER_PLOG_TAB'
        EXPORTING
          buffer_count_imp       = gv_BUFFER_C
          buffo_object_count_imp = gv_BUFFO_OB
          plog_tab_count_imp     = gv_PLOG_TAB
          tb_buffer_count_imp    = gv_TB_BUFFE
          tb_plog_tab_count_imp  = gv_TB_PLOG_
        TABLES
          buffer_tab             = i_BUFFER_TAB
          buffo_tab              = i_BUFFO_TAB
          plog_tab_tab           = i_PLOG_TAB_TAB
          tb_buffer_tab          = i_TB_BUFFER_TAB
          tb_plog_tab_tab        = i_TB_PLOG_TAB_TAB.


IF SY-SUBRC EQ 0.
*      lv_flag = 'X'.
*      EXPORT lv_flag to MEMORY id sy-uname.
      CALL FUNCTION 'RH_UPDATE_DATABASE'
        EXPORTING
          vtask        = GV_VTASK
          commit_flg   = GV_COMMIT_FLG  "VWMCOMMIT
          clear_buffer = ' '
        EXCEPTIONS
          corr_exit    = 04.


      MOVE-CORRESPONDING S_0105 to s_hrp5585.
      s_hrp5585-plvar = '01'.
      s_hrp5585-otype = 'CP'.
      s_hrp5585-objid = g_cp.
      s_hrp5585-istat = '1'.
      s_hrp5585-begda = sy-datum.
      s_hrp5585-endda = '99991231'.
      s_hrp5585-infty = '5583'.

      s_hrp5585-AEDTM = sy-datum.
      s_hrp5585-UNAME = sy-uname.
      CLEAR s_hrp5585-subty.
      APPEND s_hrp5585 to i_hrp5585.



      CALL FUNCTION 'RH_UPDATE_INFTY'
        EXPORTING
          VTASK                     = 'D'
*         ORDER_FLG                 = 'X'
*         COMMIT_FLG                = 'X'
*         AUTHY                     = 'X'
*         PPPAR_IMP                 =
*         OLD_TABNR_NEW_LANGU       = ' '
         REPID                     = sy-cprog
*         FORM                      = ' '
*         KEEP_LUPD                 =
*         WORKF_ACTV                = 'X'
        TABLES
          INNNN                     = i_hrp5585[]
*         ILFCODE                   =
       EXCEPTIONS
         ERROR_DURING_UPDATE       = 1
         NO_AUTHORIZATION          = 2
         REPID_FORM_INITIAL        = 3
         CORR_EXIT                 = 4
         OTHERS                    = 5
                .
      IF SY-SUBRC <> 0.
* Implement suitable error handling here
      ELSE.
        flag = 'X'.
      ENDIF.




ENDIF.
ENDFORM.