VHUPRT2HU CREATE HUS

Aus SAP Wiki ツ
"Include packaging and finshed goods to create the hu and to pack.
        ls_packdata-prthus-huheads = VALUE #( ( hunum = '1' factor = 1 roothu = 1 packlevel = 00001 exidv2 = iv_pal ) ).
        ls_packdata-prthus-huitems = VALUE #(
                                              "1st DUMMY entry for finsihed goods
                                              ( huitemid = 1 hunum = '$DUMMY' huitem = 000002 itemtype = 'Z' pgid = 1
                                               matnr = lv_fin_goods_no maktx = lv_fin_goods_maktx charg = lv_charg_no
                                               xchar = 'X' xchpf = 'X' docitem = 000001 werks = '1000' lgort = '1000'
                                               qty_a = 1 tqty_a = 1 qunit_a = lv_fin_goods_meins qty_b = 1 tqty_b = 1
                                               qunit_b = lv_fin_goods_meins packgroup = 0 packlevel = 1 roothu = '$DUMMY' )
*
                                               "2nd DUMMY entry (not assigned to finished goods or packaging, but needed)
                                               ( huitemid = 2 hunum = '$DUMMY' huitem = 000001 itemtype = 'D' pgid = 0
                                               matnr = '' maktx = '' charg = ''
                                               xchar = '' xchpf = '' docitem = 000000 werks = '' lgort = '' sub_hunr = '1'
                                               qty_a = 1 tqty_a = 1 qunit_a = '' qty_b = 1 tqty_b = 1 qunit_b = ''
                                               packgroup = 0 packlevel = 1 roothu = '$DUMMY' )
*
                                               "1st entry for packaging
                                               ( huitemid = 3 hunum = '1' huitem = 000001 itemtype = 'A' pgid = 0
                                               matnr = lv_packaging_no maktx = lv_packaging_maktx charg = ''
                                               xchar = '' xchpf = '' vhart = 'SCM1' magrv = 'PMG1'  docitem = 000000
                                               werks = '' lgort = '' sub_hunr = '1' qty_a = 1 tqty_a = 1
                                               qunit_a = lv_packaging_meins qty_b = 1 tqty_b = 1 qunit_b = lv_packaging_meins
                                               packgroup = 0 packlevel = 2 roothu = '1' )

                                               "2nd entry for finsihed goods
                                               ( huitemid = 4 hunum = '1' huitem = 000002 itemtype = 'C' pgid = 1
                                               matnr = lv_fin_goods_no maktx = lv_fin_goods_maktx charg = lv_charg_no
                                               xchar = 'X' xchpf = 'X' docitem = 000001 werks = '1000' lgort = '1000' sub_hunr = '1'
                                               qty_a = iv_counter_of_pieces tqty_a = iv_counter_of_pieces qunit_a = lv_fin_goods_meins
                                               qty_b = iv_counter_of_pieces tqty_b = iv_counter_of_pieces
                                               qunit_b = lv_fin_goods_meins packgroup = 0 packlevel = 2 roothu = '1' )

                                         ).

        ls_packdata-prthus-next_hunum = '1'.
        CONDENSE ls_packdata-prthus-next_hunum.
        ls_packdata-prthus-next_huitemid = 4.
        ls_packdata-ctrl-pdpara-requ_stat_save = '1'.
        ls_packdata-ctrl-pdpara-hu_status = ''.

        CALL FUNCTION 'VHUPRT2HU_CREATE_HUS'
          EXPORTING
            prthus             = ls_packdata-prthus
            requ_packstat_save = ls_packdata-ctrl-pdpara-requ_stat_save
            hustatus           = ls_packdata-ctrl-pdpara-hu_status
          IMPORTING
            hus                = ls_packdata-hus
          EXCEPTIONS
            hu_not_found       = 1
            packinstr_injured  = 2
            OTHERS             = 3.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
           WITH   sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
           INTO   DATA(lv_message).
        ELSE.
          COMMIT WORK AND WAIT.
        ENDIF.

Dieses Wiki wird privat in Freizeit nach bestem Wissen und Gewissen gepflegt und dient primär als eigene Wissenssammlung für die tägliche Arbeit im SAP-ERP-Umfeld.
Alle dargestellten Softwareprodukte, auch in Form von Screenshots, sind Eigentum der SAP SE. Ihre Marken, vgl. Link, sind u.a.: SAP®, ABAP®, SAP Fiori®, SAP HANA®, SAP S/4HANA®, SAP S/4HANA® Cloud