SAP SD BAPI MAP

From SapWiki
Revision as of 16:51, 6 April 2020 by WikiSysop (talk | contribs)

ver INCLUDE L2032FXX, ejemplo:

*---------------------------------------------------------------------*
FORM move_item_data_out.

* ITEMS
  REFRESH order_items_bapi_out.
  LOOP AT www_order_items_imp.

    CLEAR order_items_bapi_out.

    MOVE www_order_items_imp-posnr  TO order_items_bapi_out-itm_number.
    MOVE www_order_items_imp-posex  TO order_items_bapi_out-po_itm_no.
    MOVE www_order_items_imp-matnr  TO order_items_bapi_out-material.
    MOVE www_order_items_imp-matwa  TO order_items_bapi_out-mat_entrd.
    MOVE www_order_items_imp-arktx  TO order_items_bapi_out-short_text.
    MOVE www_order_items_imp-netwr  TO order_items_bapi_out-net_value.
    MOVE www_order_items_imp-kzkfg  TO order_items_bapi_out-configured.
    MOVE www_order_items_imp-waerk  TO order_items_bapi_out-currency.
    MOVE www_order_items_imp-kzwi1  TO order_items_bapi_out-subtotal_1.
    MOVE www_order_items_imp-kzwi2  TO order_items_bapi_out-subtotal_2.
    MOVE www_order_items_imp-kzwi3  TO order_items_bapi_out-subtotal_3.
    MOVE www_order_items_imp-kzwi4  TO order_items_bapi_out-subtotal_4.
    MOVE www_order_items_imp-kzwi5  TO order_items_bapi_out-subtotal_5.
    MOVE www_order_items_imp-kzwi6  TO order_items_bapi_out-subtotal_6.
    MOVE www_order_items_imp-vrkme  TO order_items_bapi_out-sales_unit.
    MOVE www_order_items_imp-mngwt  TO order_items_bapi_out-qty_req_dt.
    MOVE www_order_items_imp-edatu  TO order_items_bapi_out-dlv_date.
    MOVE www_order_items_imp-wzeitc TO order_items_bapi_out-repl_time.

    MOVE www_order_items_imp-bstkd   TO order_items_bapi_out-purch_no_c.
    MOVE www_order_items_imp-bstdk   TO order_items_bapi_out-purch_date.
    MOVE www_order_items_imp-bsark   TO order_items_bapi_out-po_method.
    MOVE www_order_items_imp-ihrez   TO order_items_bapi_out-ref_1.
    MOVE www_order_items_imp-bstkd_e TO order_items_bapi_out-purch_no_s.
    MOVE www_order_items_imp-bstdk_e TO order_items_bapi_out-po_dat_s.
    MOVE www_order_items_imp-bsark_e TO order_items_bapi_out-po_meth_s.
    MOVE www_order_items_imp-ihrez_e TO order_items_bapi_out-ref_1_s.
    MOVE www_order_items_imp-posex_e TO order_items_bapi_out-po_itm_no_s.
* 4.0 Erweiterungen1
* move internal format  into external format
    IF NOT www_order_items_imp-waerk IS INITIAL.
      IF NOT www_order_items_imp-netwr IS INITIAL.
        CLEAR order_items_bapi_out-net_value1.
        CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_EXTERNAL'
          EXPORTING
            currency        = www_order_items_imp-waerk
            amount_internal = www_order_items_imp-netwr1
          IMPORTING
            amount_external = order_items_bapi_out-net_value1.
      ENDIF.
    ENDIF.
* 4.0C Erweiterungen
    CALL FUNCTION 'UNIT_OF_MEASURE_SAP_TO_ISO'
      EXPORTING
        sap_code    = www_order_items_imp-vrkme
      IMPORTING
        iso_code    = order_items_bapi_out-s_unit_iso
      EXCEPTIONS
        not_found   = 01
        no_iso_code = 02.
    IF NOT www_order_items_imp-waerk IS INITIAL.
      CALL FUNCTION 'CURRENCY_CODE_SAP_TO_ISO'
        EXPORTING
          sap_code  = www_order_items_imp-waerk
        IMPORTING
          iso_code  = order_items_bapi_out-curr_iso
        EXCEPTIONS
          not_found = 01.
    ENDIF.

    MOVE www_order_items_imp-kwmeng  TO order_items_bapi_out-req_qty.
    MOVE www_order_items_imp-werks   TO order_items_bapi_out-plant.

* 4.6A Enhancement                                                     *
    IF NOT www_order_items_imp-waerk IS INITIAL.
      IF NOT www_order_items_imp-mwsbp IS INITIAL.
        CLEAR order_items_bapi_out-tx_doc_cur.
        CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_EXTERNAL'
          EXPORTING
            currency        = www_order_items_imp-waerk
            amount_internal = www_order_items_imp-mwsbp
          IMPORTING
            amount_external = order_items_bapi_out-tx_doc_cur.
      ENDIF.
* subtotal 1
      IF NOT www_order_items_imp-kozw1 IS INITIAL.
        CLEAR order_items_bapi_out-subtotal1.
        CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_EXTERNAL'
          EXPORTING
            currency        = www_order_items_imp-waerk
            amount_internal = www_order_items_imp-kozw1
          IMPORTING
            amount_external = order_items_bapi_out-subtotal1.
      ENDIF.
* subtotal 2
      IF NOT www_order_items_imp-kozw2 IS INITIAL.
        CLEAR order_items_bapi_out-subtotal2.
        CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_EXTERNAL'
          EXPORTING
            currency        = www_order_items_imp-waerk
            amount_internal = www_order_items_imp-kozw2
          IMPORTING
            amount_external = order_items_bapi_out-subtotal2.
      ENDIF.
* subtotal 3
      IF NOT www_order_items_imp-kozw3 IS INITIAL.
        CLEAR order_items_bapi_out-subtotal3.
        CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_EXTERNAL'
          EXPORTING
            currency        = www_order_items_imp-waerk
            amount_internal = www_order_items_imp-kozw3
          IMPORTING
            amount_external = order_items_bapi_out-subtotal3.
      ENDIF.
* subtotal 4
      IF NOT www_order_items_imp-kozw4 IS INITIAL.
        CLEAR order_items_bapi_out-subtotal4.
        CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_EXTERNAL'
          EXPORTING
            currency        = www_order_items_imp-waerk
            amount_internal = www_order_items_imp-kozw4
          IMPORTING
            amount_external = order_items_bapi_out-subtotal4.
      ENDIF.
* subtotal 5
      IF NOT www_order_items_imp-kozw5 IS INITIAL.
        CLEAR order_items_bapi_out-subtotal5.
        CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_EXTERNAL'
          EXPORTING
            currency        = www_order_items_imp-waerk
            amount_internal = www_order_items_imp-kozw5
          IMPORTING
            amount_external = order_items_bapi_out-subtotal5.
      ENDIF.
* subtotal 6
      IF NOT www_order_items_imp-kozw6 IS INITIAL.
        CLEAR order_items_bapi_out-subtotal6.
        CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_EXTERNAL'
          EXPORTING
            currency        = www_order_items_imp-waerk
            amount_internal = www_order_items_imp-kozw6
          IMPORTING
            amount_external = order_items_bapi_out-subtotal6.
      ENDIF.
    ENDIF.

    PACK www_order_items_imp-zmengc  TO order_items_bapi_out-target_qty.
    MOVE www_order_items_imp-zieme   TO order_items_bapi_out-target_qu.

    CALL FUNCTION 'UNIT_OF_MEASURE_SAP_TO_ISO'
      EXPORTING
        sap_code    = www_order_items_imp-zieme
      IMPORTING
        iso_code    = order_items_bapi_out-t_unit_iso
      EXCEPTIONS
        not_found   = 01
        no_iso_code = 02.

    MOVE www_order_items_imp-pstyv TO order_items_bapi_out-item_categ.
    MOVE www_order_items_imp-vstel TO order_items_bapi_out-ship_point.
    MOVE www_order_items_imp-uepos TO order_items_bapi_out-hg_lv_item.

    MOVE www_order_items_imp-kdmat TO order_items_bapi_out-cust_mat.
    MOVE www_order_items_imp-kztlf TO order_items_bapi_out-part_dlv.
    MOVE www_order_items_imp-abgru TO order_items_bapi_out-reason_rej.
    MOVE www_order_items_imp-faksp TO order_items_bapi_out-bill_block.
    MOVE www_order_items_imp-lgort TO order_items_bapi_out-stge_loc.
    MOVE www_order_items_imp-prodh TO order_items_bapi_out-prod_hier.
    MOVE www_order_items_imp-matkl TO order_items_bapi_out-matl_group.
    MOVE www_order_items_imp-sgt_rcat TO order_items_bapi_out-req_segment."Segmentation

    APPEND order_items_bapi_out.

  ENDLOOP.

ENDFORM.