SAP HR关于双信息类型写入

参考下面代码:

* 0021 55555555555555555555555555555BEGIN XIAOYONG 20200429 双信息类型 0021 0528 测试通过
  IF is_input-it_p0021[] IS NOT INITIAL.
    CLEAR:lt_p0021[],lt_newp0021[], lt_fields[].
    SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_p0021 FROM pa0021
      FOR ALL ENTRIES IN is_input-it_p0021
      WHERE pernr = is_input-it_p0021-pernr
        AND subty = is_input-it_p0021-subty
        AND begda <= sy-datum
        AND endda >= sy-datum.
    SORT lt_p0021 BY pernr subty.
    CLEAR:lt_p0528[].
    SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_p0528 FROM pa0528
     FOR ALL ENTRIES IN is_input-it_p0021
     WHERE pernr = is_input-it_p0021-pernr
       AND subty = is_input-it_p0021-subty
       AND begda <= sy-datum
       AND endda >= sy-datum.
    SORT lt_p0528 BY pernr subty.
    LOOP AT is_input-it_p0021 ASSIGNING FIELD-SYMBOL().
      IF -begda IS INITIAL.
        -begda = sy-datum.
      ENDIF.
      IF -endda IS INITIAL.
        -endda = '99991231'.
      ENDIF.
      CLEAR:lt_newp0021[].
      lo_descr ?= cl_abap_typedescr=>describe_by_data( ls_p0021 ).
      lt_fields = lo_descr->get_ddic_field_list( p_langu = '1'
                                                 p_including_substructres = abap_true ).
      READ TABLE  lt_p0021 ASSIGNING FIELD-SYMBOL() WITH KEY pernr = -pernr
                                                                       subty = -subty BINARY SEARCH.
      IF sy-subrc = 0.
        LOOP AT lt_fields ASSIGNING .
          ASSIGN COMPONENT -fieldname OF STRUCTURE  TO .
          IF sy-subrc = 0 AND  IS NOT INITIAL.
            IF  IS ASSIGNED .
              UNASSIGN .
            ENDIF.
            ASSIGN COMPONENT -fieldname OF STRUCTURE  TO .
            IF sy-subrc = 0.
               = .
            ENDIF.
          ENDIF.
        ENDLOOP.
        APPEND  TO lt_newp0021.
      ELSE.
        APPEND INITIAL LINE TO lt_newp0021 ASSIGNING .
        LOOP AT lt_fields ASSIGNING .
          ASSIGN COMPONENT -fieldname OF STRUCTURE  TO .
          IF sy-subrc = 0 AND  IS NOT INITIAL.
            IF  IS ASSIGNED .
              UNASSIGN .
            ENDIF.
            ASSIGN COMPONENT -fieldname OF STRUCTURE  TO .
            IF sy-subrc = 0.
               = .
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDIF.
      CLEAR:lt_fields[].
      lo_descr ?= cl_abap_typedescr=>describe_by_data( ls_p0528 ).
      lt_fields = lo_descr->get_ddic_field_list( p_langu = '1'
                                                 p_including_substructres = abap_true ).
      CLEAR:lt_newp0528[].
      READ TABLE lt_p0528 ASSIGNING FIELD-SYMBOL() WITH KEY pernr = -pernr
                                                                     subty = -subty BINARY SEARCH.
      IF sy-subrc = 0.
        LOOP AT lt_fields ASSIGNING .
          ASSIGN COMPONENT -fieldname OF STRUCTURE  TO .
          IF sy-subrc = 0 AND  IS NOT INITIAL.
            IF  IS ASSIGNED .
              UNASSIGN .
            ENDIF.
            ASSIGN COMPONENT -fieldname OF STRUCTURE  TO .
            IF sy-subrc = 0.
               = .
            ENDIF.
          ENDIF.
        ENDLOOP.
        ASSIGN COMPONENT 'INFTY' OF  STRUCTURE  TO .
        IF sy-subrc = 0.
           = '0528'.
        ENDIF.
        ASSIGN COMPONENT 'LAND1' OF  STRUCTURE  TO .
        IF sy-subrc = 0.
           = 'CN'.
        ENDIF.
        APPEND  TO lt_newp0528.
      ELSE.
        APPEND INITIAL LINE TO lt_newp0528 ASSIGNING .
        LOOP AT lt_fields ASSIGNING .
          ASSIGN COMPONENT -fieldname OF STRUCTURE  TO .
          IF sy-subrc = 0 AND  IS NOT INITIAL.
            IF  IS ASSIGNED .
              UNASSIGN .
            ENDIF.
            ASSIGN COMPONENT -fieldname OF STRUCTURE  TO .
            IF sy-subrc = 0.
               = .
            ENDIF.
          ENDIF.
        ENDLOOP.
        ASSIGN COMPONENT 'INFTY' OF  STRUCTURE  TO .
        IF sy-subrc = 0.
           = '0528'.
        ENDIF.
        ASSIGN COMPONENT 'LAND1' OF  STRUCTURE  TO .
        IF sy-subrc = 0.
           = 'CN'.
        ENDIF.
      ENDIF.
      CLEAR:ls_pskey.
      MOVE-CORRESPONDING  TO ls_pskey.
      PERFORM frm_lock_per_data  USING ls_pskey-pernr 'X' CHANGING es_output-message.
      IF es_output-message-msgtx = 'E'.
        EXIT.
      ENDIF.
      CALL FUNCTION 'HR_INFOTYPE_OPERATION'
        EXPORTING
          infty            = '0021'
          number           = ls_pskey-pernr
          subtype          = ls_pskey-subty
          objectid         = ls_pskey-objps
          lockindicator    = ls_pskey-sprps
          validityend      = ls_pskey-endda
          validitybegin    = ls_pskey-begda
          recordnumber     = ls_pskey-seqnr
          record           = 
          secondary_record = 
          operation        = 'INS'
          tclas            = 'A'
          nocommit         = 'X'
          view_identifier  = '28'
          dialog_mode      = '0'
        IMPORTING
          return           = ls_return.
      IF ls_return-type = 'E' OR ls_return-type = 'A' .
        es_output-message-msgtx = 'E'.
        MESSAGE ID ls_return-id TYPE ls_return-type NUMBER ls_return-number INTO es_output-message-msgty
           WITH ls_return-message_v1
                ls_return-message_v2
                ls_return-message_v3
                ls_return-message_v4.
        PERFORM frm_lock_per_data  USING ls_pskey-pernr '' CHANGING es_output-message.
        EXIT.
      ENDIF.
      PERFORM frm_lock_per_data  USING ls_pskey-pernr '' CHANGING es_output-message.
* CLEAR:,.
    ENDLOOP.
    IF es_output-message-msgtx = 'E'.
      ROLLBACK WORK.
      CALL FUNCTION 'RHOM_ALL_BUFFER_INIT'.
      CALL FUNCTION 'HR_PSBUFFER_INITIALIZE'.
      EXIT.
    ENDIF.
  ENDIF.
*0021 55555555555555555555end xiaoyong 20200429

按照上面代码能写入双信息类型

你可能感兴趣的:(abap)