Copy Customer-Material Info Record Data

FORM frm_upload USING value(ps_i_tabindex) LIKE sy-tabix
                                value(pc_i_fieldname) TYPE slis_fieldname
                            CHANGING
                                 value(l_subrc) LIKE sy-subrc
                                 value(l_msgtx) TYPE msgtx.
  CLEAR:l_subrc,l_msgtx.

  DATA:BEGIN OF ls_knmt_key,
    vkorg LIKE knmt-vkorg,
    vtweg LIKE knmt-vtweg,
    kunnr LIKE knmt-kunnr,
    matnr LIKE knmt-matnr,
    END OF ls_knmt_key.
  DATA:BEGIN OF yknmt OCCURS 1.
          INCLUDE STRUCTURE knmt.
  DATA:updkz(1),
        END OF yknmt.
  DATA:BEGIN OF xknmt OCCURS 1.
          INCLUDE STRUCTURE knmt.
  DATA:updkz(1),
        END OF xknmt.

  DATA:
        lt_catalog  LIKE tcatalog OCCURS 0 WITH HEADER LINE,
        lv_tdname   LIKE thead-tdname.
  DATA:
        charx TYPE c VALUE 'X'.

  CONSTANTS:
        lc_tdname_knmt LIKE thead-tdobject VALUE 'KNMT'.

  READ TABLE gt_list WITH KEY sel = 'X'.
  IF sy-subrc <> 0.
    l_subrc = 4.
    l_msgtx = 'Please select one row at least!'.
    RETURN.
  ENDIF.

  LOOP AT gt_list WHERE sel = 'X'.
    CLEAR xknmt.
    MOVE-CORRESPONDING gt_list TO xknmt.
    xknmt-matnr = gt_list-newmt.
    xknmt-updkz = 'I'.

    xknmt-ernam = sy-uname.
    xknmt-erdat = sy-datum.
    xknmt-meins = gt_list-meins.
    APPEND xknmt.
  ENDLOOP.

  LOOP AT xknmt.
    ls_knmt_key-vkorg = xknmt-vkorg.
    ls_knmt_key-vtweg = xknmt-vtweg.
    ls_knmt_key-kunnr = xknmt-kunnr.
    ls_knmt_key-matnr = xknmt-matnr.

    lv_tdname = ls_knmt_key.

    CALL FUNCTION 'SD_TEXT_UPDKZ_GET_FROM_CATALOG'
      EXPORTING
        cat_tdobject = lc_tdname_knmt
        cat_tdname   = lv_tdname
        cat_refresh  = space
      TABLES
        cat_table    = lt_catalog
      EXCEPTIONS
        OTHERS       = 0.
  ENDLOOP.

*  LOOP AT yknmt WHERE updkz EQ updkz_delete.
*    ls_knmt_key-vkorg = yknmt-vkorg.
*    ls_knmt_key-vtweg = yknmt-vtweg.
*    ls_knmt_key-kunnr = yknmt-kunnr.
*    ls_knmt_key-matnr = yknmt-matnr.
*
*    lv_tdname = ls_knmt_key.
*    CALL FUNCTION 'SD_TEXT_UPDKZ_GET_FROM_CATALOG'
*      EXPORTING
*        cat_tdobject = lc_tdname_knmt
*        cat_tdname   = lv_tdname
*        cat_refresh  = space
*      TABLES
*        cat_table    = lt_catalog
*      EXCEPTIONS
*        OTHERS       = 0.
*  ENDLOOP.

  CALL FUNCTION 'RV_CUSTOMER_MATERIAL_UPDATE' IN UPDATE TASK
    TABLES
      xknmt_tab    = xknmt
      yknmt_tab    = yknmt
      tcatalog_tab = lt_catalog.

  LOOP AT lt_catalog WHERE tdobject = lc_tdname_knmt.
    CALL FUNCTION 'COMMIT_TEXT'
      EXPORTING
        object = lc_tdname_knmt
        name   = lt_catalog-tdname
        keep   = charx.
  ENDLOOP.

  COMMIT WORK.

  l_subrc = 0.
  l_msgtx = 'Upload successfully'.
ENDFORM.

你可能感兴趣的:(ABAP,Function)