METHOD_PROPOSAL

<< Click to Display Table of Contents >>

Navigation:  All About ABAP Technique > English > ABAP Tutorial > ABAP Workbench Tools > Enhancement > Business Add-Ins (BADI) > Business Add-Ins (BADI) Examples > ZBADI_HU_AUTOPACK >

METHOD_PROPOSAL

method IF_EX_BADI_HU_AUTOPACK~METHOD_PROPOSAL .
 
 
data: tmp_num(10)       type N,
       tbl_huheader       type huhdr_proposal,
       tbl_huitem         type HUITM_PROPOSAL,
       tbl_messages       type HUITEM_MESSAGES,
       tbl_PACKGOODs     type packgood,
       ch_HU             type c.
 
clear: tmp_num, tbl_huheader,
        tbl_huitem, tbl_packgoods.
 
if if_loop < 2 and ct_hdr_proposal is initial
                and not it_packgoods is initial.
 
*---> HU header
  MOVE 1 TO tmp_NUM.
  CONCATENATE '$' tmp_NUM INTO tbl_huheader-exidv.
  select single mara~matnr into tbl_huheader-VHILM
          from mara inner join makt on mara~matnr = makt~matnr
          where mara~mtart = 'Z1LE' and
                makt~spras = 'E'   and
                MARA~VHART ne ''   and
                makt~MAKTG = 'HU'.
  if sy-subrc ne 0.
    message id     'ZWM'
            type   'W'
            number '000'
            with   space
'Packaging material Z1LE dengan deskripsi HU tidak ditemukan'.
    exit.
  endif.
 
  append tbl_huheader to ct_hdr_proposal.
 
*---> HU item
  loop at it_PACKGOODS into tbl_PACKGOODS.
 
    CONCATENATE '$' tmp_NUM INTO tbl_huitem-EXIDV.
     tbl_huitem-BELNR      = tbl_PACKGOODs-DOCNUM.
     tbl_huitem-POSNR      = tbl_PACKGOODs-DOCITEM.
     tbl_huitem-WERKS      = tbl_PACKGOODs-WERKS.
     tbl_huitem-LGORT      = tbl_PACKGOODs-LGORT.
     tbl_huitem-MATNR      = tbl_PACKGOODs-MATNR.
     tbl_huitem-CHARG      = tbl_PACKGOODs-CHARG.
     tbl_huitem-vfdat      = tbl_PACKGOODs-vfdat.
     tbl_huitem-BESTQ      = tbl_PACKGOODs-BESTQ.
     tbl_huitem-qplos      = tbl_PACKGOODs-qplos.
     tbl_huitem-sobkz      = tbl_PACKGOODs-sobkz.
     tbl_huitem-sonum      = tbl_PACKGOODs-sonum.
     tbl_huitem-quantity   = tbl_PACKGOODs-MAXQUA.
     tbl_huitem-meins      = tbl_PACKGOODs-qunit_a.
     tbl_huitem-VELIN      = '1'.
 
    APPEND tbl_huitem TO CT_ITEMS.
 
  endloop.
 
endif.
 
 
*---> Check messages
loop at ct_messages into tbl_messages
                    where msgty na 'ES'.
     tbl_messages-msgty = 'S'.
    modify ct_messages from tbl_messages
            index sy-tabix transporting msgty.
endloop.
 
endmethod.