Fazla Stok Tüketimi (Küsüratsız)
Orantısal olarak bölüştürerek stok tüketimi (küsürat bırakmadan)
*&---------------------------------------------------------------------*
*& Report ZPP_FAZLA_STOK_TUKETIM
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZPP_FAZLA_STOK_TUKETIM.
TABLES: MSEG.
DATA: BEGIN OF GT_COLL_MSEG OCCURS 0,
MATNR LIKE MSEG-MATNR,
AUFNR LIKE MSEG-AUFNR,
WERKS LIKE MSEG-WERKS,
* LGORT LIKE MSEG-LGORT,
BWART LIKE MSEG-BWART,
MENGE LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
END OF GT_COLL_MSEG.
DATA: GT_MSEG LIKE STANDARD TABLE OF MSEG.
DATA: BEGIN OF gt_mlz_sip_top OCCURS 0,
MATNR LIKE MSEG-MATNR,
AUFNR LIKE MSEG-AUFNR,
WERKS LIKE MSEG-WERKS,
LGORT LIKE MSEG-LGORT,
GIREN LIKE MSEG-MENGE,
CIKAN LIKE MSEG-MENGE,
TOPLAM LIKE MSEG-MENGE,
GENEL_TOPLAM LIKE MSEG-MENGE,
ORAN_AU TYPE FLOAT, "AUFNR Oranı
MEINS LIKE MSEG-MEINS,
END OF gt_mlz_sip_top.
DATA: BEGIN OF gt_genel_toplam OCCURS 0,
MATNR LIKE MSEG-MATNR,
GIREN LIKE MSEG-MENGE,
CIKAN LIKE MSEG-MENGE,
TOPLAM LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
END OF gt_genel_toplam.
DATA: BEGIN OF gt_clabs OCCURS 0,
MATNR LIKE mchb-MATNR,
WERKS LIKE mchb-WERKS,
LGORT LIKE mchb-LGORT,
CHARG LIKE mchb-CHARG,
CLABS LIKE mchb-CLABS,
END OF gt_clabs.
*DATA: BEGIN OF gt_clabs_coll OCCURS 0,
* MATNR LIKE mchb-MATNR,
* WERKS LIKE mchb-WERKS,
* LGORT LIKE mchb-LGORT,
* CLABS LIKE mchb-CLABS,
* END OF gt_clabs_coll.
DATA: BEGIN OF GT_HAREKET OCCURS 0,
MATNR LIKE MSEG-MATNR,
AUFNR LIKE MSEG-AUFNR,
WERKS LIKE MSEG-WERKS,
LGORT LIKE MSEG-LGORT,
CHARG LIKE mchb-CHARG,
CLABS LIKE mchb-CLABS,
* ORAN_CH TYPE ZPP_ORAN_CH, "charg ORANI
ORAN_AU TYPE ZPP_ORAN_AU, "AUFNR Oranı
* ORAN_CH_STR3 TYPE P DECIMALS 3, "charg ORANI
ORAN_AU_STR3 TYPE P DECIMALS 3, "AUFNR Oranı
MENGE LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
TOPLAM LIKE MSEG-MENGE,
HAREKET_MIK LIKE mchb-CLABS,
KUMULE LIKE mchb-CLABS,
FARK LIKE mchb-CLABS,
YENI_MIKTAR LIKE mchb-CLABS,
END OF GT_HAREKET.
DATA: BEGIN OF GT_AUFNR_OBJNR OCCURS 0,
AUFNR LIKE CAUFV-AUFNR,
OBJNR LIKE CAUFV-OBJNR,
STATUS LIKE JSTAT,
END OF GT_AUFNR_OBJNR.
DATA: STATUS LIKE STANDARD TABLE OF JSTAT WITH HEADER LINE.
DATA: LV_AYIN_ILK_GUNU LIKE SY-DATUM.
DATA: LV_AYIN_SON_GUNU LIKE SY-DATUM.
DATA: gs_layout TYPE slis_layout_alv,
gt_fieldcat TYPE slis_fieldcat_alv OCCURS 1 WITH HEADER LINE,
gv_repid LIKE sy-repid VALUE sy-repid,
gv_title TYPE lvc_title.
RANGES: S_LGORT FOR MCHB-LGORT.
RANGES: S_JSTATUS FOR JSTAT-STAT. "ZPP_S_RANGE_J_STATUS
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
SELECT-OPTIONS : S_WERKS FOR MSEG-WERKS,
S_MATNR FOR MSEG-MATNR.
*PARAMETERS : P_TARIH LIKE SY-DATUM.
SELECTION-SCREEN: END OF BLOCK b1.
*-------------------------------------------------------------------
INITIALIZATION.
*-------------------------------------------------------------------
REFRESH S_LGORT[].
S_LGORT-SIGN = `I`.
S_LGORT-option = `EQ`.
S_LGORT-LOW = `9300`.
APPEND S_LGORT.
* P_TARIH = sy-datum.
*-------------------------------------------------------------------
START-OF-SELECTION.
*-------------------------------------------------------------------
*perform check_selection.
perform prepare_selection.
perform get_data.
perform process_data.
perform prepare_bapi.
PERFORM prepare_display.
PERFORM display_result.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form GET_DATA .
DATA XNDX LIKE SY-TABIX.
SELECT MATNR
WERKS
LGORT
CHARG
CLABS
INTO TABLE gt_clabs
FROM MCHB
WHERE MATNR IN S_MATNR
AND WERKS IN S_WERKS
AND LGORT IN S_LGORT "9300
and clabs ne 0.
IF gt_clabs[] IS NOT INITIAL.
SELECT * FROM MSEG INTO TABLE GT_MSEG
FOR ALL ENTRIES IN gt_clabs
WHERE MATNR EQ gt_clabs-MATNR
AND WERKS EQ gt_clabs-WERKS
AND CPUDT_MKPF between
LV_AYIN_ILK_GUNU AND LV_AYIN_SON_GUNU
AND ( BWART EQ `261` OR BWART EQ `262` )
.
ENDIF.
*-
*-STATUS ELEMESİ
*-
IF GT_MSEG[] IS NOT INITIAL.
SELECT AUFNR OBJNR
FROM CAUFV
INTO CORRESPONDING FIELDS OF TABLE GT_AUFNR_OBJNR
FOR ALL ENTRIES IN GT_MSEG
WHERE AUFNR = GT_MSEG-AUFNR.
data LS_AUF_OBJ like line of GT_AUFNR_OBJNR .
LOOP AT GT_AUFNR_OBJNR INTO LS_AUF_OBJ.
call function `STATUS_READ`
exporting
* CLIENT = SY-MANDT
OBJNR = LS_AUF_OBJ-OBJNR
ONLY_ACTIVE = `X`
* IMPORTING
* OBTYP =
* STSMA =
* STONR =
TABLES
STATUS = STATUS
* EXCEPTIONS
* OBJECT_NOT_FOUND = 1
* OTHERS = 2
.
*HERHANGİ BİRİ VARSA SİL.
*ZPP_S_RANGE_J_STATUS
*I0009` `I0012` `I0013` `I0043` `I0045` `I0046` `I0076`
LOOP AT STATUS WHERE STAT IN S_JSTATUS.
DELETE GT_MSEG WHERE AUFNR EQ LS_AUF_OBJ-AUFNR.
EXIT.
ENDLOOP.
endloop.
ENDIF.
*-
*-
*-
DATA LS_mseg LIKE LINE OF GT_MSEG.
DATA LS_coll_mseg like line of GT_COLL_MSEG.
LOOP AT GT_MSEG INTO LS_mseg.
MOVE-CORRESPONDING LS_mseg TO LS_coll_mseg.
COLLECT LS_coll_mseg INTO GT_COLL_MSEG.
ENDLOOP.
SORT GT_COLL_MSEG BY MATNR AUFNR ."WERKS LGORT.
*data ls_clabs like line of gt_clabs.
*data ls_clabs_coll like line of gt_clabs_coll.
*loop at gt_clabs into ls_clabs.
* move-corresponding ls_clabs to ls_clabs_coll .
* collect ls_clabs_coll into gt_clabs_coll .
*endloop.
endform. " GET_DATA
*&---------------------------------------------------------------------*
*& Form PREPARE_SELECTION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form PREPARE_SELECTION .
data LV_TARIH LIKE SY-DATUM.
* P_TARIH = sy-datum.
LV_TARIH = sy-datum.
* LV_TARIH = P_TARIH.
CONCATENATE LV_TARIH(6) `01` INTO LV_AYIN_ILK_GUNU.
CALL FUNCTION `LAST_DAY_OF_MONTHS`
EXPORTING
day_in = LV_AYIN_ILK_GUNU
IMPORTING
last_day_of_month = LV_AYIN_SON_GUNU.
"meho
CLEAR S_JSTATUS.
S_JSTATUS-SIGN = `I`.
S_JSTATUS-OPTION = `EQ`.
*S_JSTATUS-LOW = `I0009`. APPEND S_JSTATUS.
*S_JSTATUS-LOW = `I0012`. APPEND S_JSTATUS.
S_JSTATUS-LOW = `I0013`. APPEND S_JSTATUS.
S_JSTATUS-LOW = `I0043`. APPEND S_JSTATUS.
*S_JSTATUS-LOW = `I0045`. APPEND S_JSTATUS.
S_JSTATUS-LOW = `I0046`. APPEND S_JSTATUS.
S_JSTATUS-LOW = `I0076`. APPEND S_JSTATUS.
*I0009@` `I0012` `I0013` `I0043` `I0045` `I0046` `I0076`
endform. " PREPARE_SELECTION
*&---------------------------------------------------------------------*
*& Form PREPARE_DISPLAY
*&---------------------------------------------------------------------*
FORM prepare_display.
CALL FUNCTION `REUSE_ALV_FIELDCATALOG_MERGE`
EXPORTING
i_program_name = gv_repid
i_internal_tabname = `GT_HAREKET`
i_inclname = gv_repid
CHANGING
ct_fieldcat = gt_fieldcat[].
LOOP AT gt_fieldcat.
CASE gt_fieldcat-fieldname.
WHEN `MATNR`.
WHEN `AUFNR`.
WHEN `MEINS`.
WHEN `GIREN`. gt_fieldcat-seltext_l = `Giren`.
gt_fieldcat-seltext_m = `Giren`.
gt_fieldcat-seltext_s = `Giren`.
gt_fieldcat-REPTEXT_DDIC = `Giren`.
MODIFY gt_fieldcat.
WHEN `CIKAN`. gt_fieldcat-seltext_l = `Çıkan`.
gt_fieldcat-seltext_m = `Çıkan`.
gt_fieldcat-seltext_s = `Çıkan`.
gt_fieldcat-REPTEXT_DDIC = `Çıkan`.
MODIFY gt_fieldcat.
WHEN `TOPLAM`. gt_fieldcat-seltext_l = `Toplam`.
gt_fieldcat-seltext_m = `Toplam`.
gt_fieldcat-seltext_s = `Toplam`.
gt_fieldcat-REPTEXT_DDIC = `Toplam`.
MODIFY gt_fieldcat.
WHEN `GENEL_TOPLAM`. gt_fieldcat-seltext_l = `Genel Tpl`.
gt_fieldcat-seltext_m = `Genel Tpl`.
gt_fieldcat-seltext_s = `Genel Tpl`.
gt_fieldcat-REPTEXT_DDIC = `Genel Toplam`.
MODIFY gt_fieldcat.
WHEN `CLABS`.
gt_fieldcat-seltext_l = `Stok`.
gt_fieldcat-seltext_m = `Stok`.
gt_fieldcat-seltext_s = `Stok`.
gt_fieldcat-REPTEXT_DDIC = `Stok`.
MODIFY gt_fieldcat.
*
*
*
* WHEN `CLABS_TOPLAM`.
* gt_fieldcat-seltext_l = `Toplam Thdz.Stok`.
* gt_fieldcat-seltext_m = `Toplam Thdz.Stok`.
* gt_fieldcat-seltext_s = `Toplam Thdz.Stok`.
* gt_fieldcat-REPTEXT_DDIC = `Toplam Thdz.Stok`.
* MODIFY gt_fieldcat.
WHEN `HAREKET_MIK`. gt_fieldcat-seltext_l = `Hareket Mik.`.
gt_fieldcat-seltext_m = `Hareket Mik.`.
gt_fieldcat-seltext_s = `Hareket Mik.`.
gt_fieldcat-REPTEXT_DDIC = `Hareket Mik.`.
MODIFY gt_fieldcat.
WHEN `KUMULE`. DELETE gt_fieldcat.
WHEN `FARK`. DELETE gt_fieldcat.
WHEN `YENI_MIKTAR`. DELETE gt_fieldcat .
ENDCASE.
ENDLOOP.
*gt_fieldcat-FIELDNAME = `ORAN_CH_STR3`.
* gt_fieldcat-TABNAME = `GT_HAREKET`.
* gt_fieldcat-seltext_l = `Parti Oranı`.
* gt_fieldcat-seltext_m = `Parti Oranı`.
* gt_fieldcat-seltext_s = `Parti Oranı`.
* gt_fieldcat-DATATYPE = `QUAN`.
* gt_fieldcat-INTTYPE = `P`.
* gt_fieldcat-INTLEN = 3.
*APPEND gt_fieldcat.
*gt_fieldcat-FIELDNAME = `ORAN_AU_STR3`.
* gt_fieldcat-TABNAME = `GT_HAREKET`.
* gt_fieldcat-seltext_l = `Sipariş Oranı`.
* gt_fieldcat-seltext_m = `Sipariş Oranı`.
* gt_fieldcat-seltext_s = `Sipariş Oranı`.
* gt_fieldcat-DATATYPE = `QUAN`.
* gt_fieldcat-INTTYPE = `P`.
* gt_fieldcat-INTLEN = 3.
*APPEND gt_fieldcat.
ENDFORM. " prepare_display
*&---------------------------------------------------------------------*
*& Form DISPLAY_RESULT
*&---------------------------------------------------------------------*
FORM display_result.
gs_layout-colwidth_optimize = `X`.
gs_layout-zebra = `X` .
* gv_title = `.....................`.
CALL FUNCTION `REUSE_ALV_GRID_DISPLAY`
EXPORTING
i_callback_program = gv_repid
i_save = `X`
is_layout = gs_layout
i_grid_title = gv_title
i_callback_user_command = `USER_COMMAND`
i_callback_pf_status_set = `SET_PF_STATUS_FUNC`
it_fieldcat = gt_fieldcat[]
TABLES
t_outtab = GT_HAREKET[].
ENDFORM. " DISPLAY_RESULT
*&---------------------------------------------------------------------*
*& Form PROCESS_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form PROCESS_DATA .
DATA LS_coll_mseg like line of GT_COLL_MSEG.
DATA ls_mlz_sip_top like line of gt_mlz_sip_top.
DATA LS_genel_toplam like line of gt_genel_toplam.
DATA XNDX LIKE SY-TABIX.
LOOP AT GT_COLL_MSEG INTO LS_coll_mseg.
CLEAR ls_mlz_sip_top.
ls_mlz_sip_top-MATNR = LS_coll_mseg-MATNR.
* ls_mlz_sip_top-MAKTX = LS_coll_mseg-MEINS.
ls_mlz_sip_top-AUFNR = LS_coll_mseg-AUFNR.
ls_mlz_sip_top-werks = LS_coll_mseg-werks.
ls_mlz_sip_top-lgort = `9300`.
ls_mlz_sip_top-MEINS = LS_coll_mseg-MEINS.
case LS_coll_mseg-bwart.
when `261`. ls_mlz_sip_top-GIREN = LS_coll_mseg-MENGE.
ls_mlz_sip_top-TOPLAM = LS_coll_mseg-MENGE.
when `262`. ls_mlz_sip_top-CIKAN = LS_coll_mseg-MENGE.
ls_mlz_sip_top-TOPLAM = LS_coll_mseg-MENGE * -1.
ENDCASE.
MOVE-CORRESPONDING ls_mlz_sip_top to LS_genel_toplam.
COLLECT LS_genel_toplam INTO gt_genel_toplam.
COLLECT ls_mlz_sip_top INTO gt_mlz_sip_top.
ENDLOOP.
SORT gt_genel_toplam BY MATNR MEINS.
LOOP AT gt_mlz_sip_top INTO ls_mlz_sip_top .
XNDX = SY-TABIX.
READ TABLE gt_genel_toplam
INTO LS_genel_toplam
WITH KEY MATNR = ls_mlz_sip_top-MATNR
MEINS = ls_mlz_sip_top-MEINS.
IF SY-SUBRC EQ 0.
ls_mlz_sip_top-GENEL_TOPLAM = LS_genel_toplam-TOPLAM.
IF ls_mlz_sip_top-GENEL_TOPLAM NE 0.
ls_mlz_sip_top-ORAN_AU = ls_mlz_sip_top-TOPLAM /
ls_mlz_sip_top-GENEL_TOPLAM.
ENDIF.
MODIFY gt_mlz_sip_top FROM ls_mlz_sip_top INDEX XNDX.
ENDIF.
ENDLOOP.
endform. " PROCESS_DATA
*&---------------------------------------------------------------------*
*& Form PREPARE_BAPI
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form PREPARE_BAPI .
data ls_mlz_sip_top like line of gt_mlz_sip_top.
data ls_hareket like line of GT_HAREKET.
data ls_hareket_farkli like line of GT_HAREKET.
data ls_clabs like line of gt_clabs.
data XNDX LIKE SY-TABIX.
LOOP AT gt_mlz_sip_top into ls_mlz_sip_top.
LOOP AT gt_clabs into ls_clabs
WHERE MATNR = ls_mlz_sip_top-MATNR
AND WERKS = ls_mlz_sip_top-WERKS.
clear ls_hareket.
move-corresponding ls_mlz_sip_top to ls_hareket.
ls_hareket-MENGE = ls_mlz_sip_top-GENEL_TOPLAM.
ls_hareket-CHARG = ls_clabs-CHARG.
ls_hareket-CLABS = ls_clabs-CLABS.
ls_hareket-ORAN_AU_STR3 = ls_hareket-ORAN_AU.
ls_hareket-HAREKET_MIK = ls_hareket-CLABS *
ls_hareket-ORAN_AU.
append ls_hareket to gt_hareket.
ENDLOOP."gt_clabs
ENDLOOP."gt_mlz_sip_top
SORT gt_hareket BY MATNR
CHARG
HAREKET_MIK.
data lv_KUMULE like mchb-CLABS.
CLEAR lv_KUMULE.
LOOP AT gt_hareket INTO LS_hareket.
XNDX = SY-TABIX.
ON CHANGE OF LS_hareket-CHARG.
CLEAR lv_KUMULE.
ENDON.
lv_KUMULE = lv_KUMULE + LS_hareket-HAREKET_MIK.
LS_hareket-KUMULE = lv_KUMULE.
LS_hareket-FARK = lv_KUMULE - LS_hareket-CLABS .
MODIFY gt_hareket FROM LS_hareket INDEX XNDX.
ENDLOOP.
*LOOP AT gt_hareket INTO LS_hareket.
* XNDX = SY-TABIX.
* ls_hareket_farkli = LS_hareket.
* AT END OF CHARG.
* ls_hareket_farkli-HAREKET_MIK = ls_hareket_farkli-HAREKET_MIK +
* ls_hareket_farkli-FARK.
* ENDAT.
* MODIFY gt_hareket FROM ls_hareket_farkli INDEX XNDX.
*ENDLOOP.
*DATA: LV_KUMULE LIKE MCHB-CLABS.
DATA: LV_SAYAC LIKE SY-TABIX.
DATA: LV_SAY2 LIKE SY-TABIX.
LOOP AT GT_CLABS INTO LS_CLABS.
"MATNR VE CHARG ile döndüreceğiz
LV_SAYAC = 0.
LOOP AT GT_HAREKET INTO LS_HAREKET
WHERE MATNR = LS_CLABS-MATNR
AND CHARG = LS_CLABS-CHARG.
LV_SAYAC = LV_SAYAC + 1.
ENDLOOP.
CLEAR lv_KUMULE.
CLEAR LV_SAY2.
LOOP AT GT_HAREKET INTO LS_HAREKET
WHERE MATNR = LS_CLABS-MATNR
AND CHARG = LS_CLABS-CHARG.
XNDX = SY-TABIX.
LV_SAY2 = LV_SAY2 + 1.
IF LV_SAY2 = LV_SAYAC.
LS_HAREKET-YENI_MIKTAR = LS_hareket-CLABS - lv_KUMULE.
lv_KUMULE = lv_KUMULE + LS_hareket-HAREKET_MIK.
LS_hareket-HAREKET_MIK = LS_HAREKET-YENI_MIKTAR.
clear LS_HAREKET-YENI_MIKTAR.
*LS_HAREKET-YENI_MIKTAR = LS_HAREKET-HAREKET_MIK + LS_HAREKET-FARK.
MODIFY GT_HAREKET FROM LS_HAREKET INDEX XNDX .
CLEAR lv_KUMULE.
ELSE.
lv_KUMULE = lv_KUMULE + LS_hareket-HAREKET_MIK.
ENDIF.
ENDLOOP.
ENDLOOP.
endform. " PREPARE_BAPI
*&---------------------------------------------------------------------*
*& FORM USER_COMMAND
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* -->B_BUTTON TEXT
* -->I_SECILEN TEXT
*----------------------------------------------------------------------*
FORM user_command
USING b_button LIKE sy-ucomm i_secilen TYPE slis_selfield.
DATA read_code LIKE sy-ucomm .
read_code = b_button.
CASE read_code.
WHEN: `&F03` ,`&F05` , `&F12` .
LEAVE TO SCREEN 0.
WHEN `TUKET` . PERFORM TUKET .
ENDCASE.
ENDFORM. "USER_COMMAND
*&---------------------------------------------------------------------*
*& FORM SET_PF_STATUS_FUNC
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* -->LT_EXTAB TEXT
*----------------------------------------------------------------------*
FORM set_pf_status_func USING lt_extab .
SET PF-STATUS `STANDARD_FULLSCREEN`.
ENDFORM. "SET_PF_STATUS_FUNC
*&---------------------------------------------------------------------*
*& FORM TUKET
*&---------------------------------------------------------------------*
FORM TUKET .
data: gm_header type bapi2017_gm_head_01.
data: gm_code type bapi2017_gm_code.
data: gm_headret type bapi2017_gm_head_ret.
data: gm_item type table of
bapi2017_gm_item_create with header line.
data: gm_return type bapiret2 occurs 0.
data: gm_retmtd type bapi2017_gm_head_ret-mat_doc.
clear: gm_return, gm_retmtd. refresh gm_return.
data ls_hareket like line of GT_HAREKET.
data ls_clabs like line of gt_clabs.
data XNDX LIKE SY-TABIX.
DATA: LT_ERETURN LIKE STANDARD TABLE OF BAPIRET2.
DATA: LT_rETURN_COLL LIKE STANDARD TABLE OF BAPIRET2.
DATA: LS_ERETURN LIKE BAPIRET2.
DATA: LS_E_Sayac LIKE sy-tabIx.
gm_header-pstng_date = sy-datum.
gm_header-doc_date = sy-datum.
gm_code-gm_code = `03`. " MB11
DATA: LV_KUMULE LIKE MCHB-CLABS.
DATA: LV_SAYAC LIKE SY-TABIX.
REFRESH LT_rETURN_COLL.
LOOP AT GT_CLABS INTO LS_CLABS.
"MATNR VE CHARG ile döndüreceğiz
REFRESH gm_item.
CLEAR LV_KUMULE.
CLEAR LV_SAYAC.
LOOP AT GT_HAREKET INTO LS_HAREKET
WHERE MATNR = LS_CLABS-MATNR
AND CHARG = LS_CLABS-CHARG
AND HAREKET_MIK > 0.
XNDX = SY-TABIX.
refresh gm_item.
LV_KUMULE = LV_KUMULE + LS_HAREKET-hAREKET_MIK.
gm_item-MATERIAL = LS_HAREKET-MATNR.
gm_item-PLANT = LS_HAREKET-WERKS.
gm_item-BATCH = LS_HAREKET-CHARG.
gm_item-STGE_LOC = `9300`. "LS_HAREKET-LGORT.
gm_item-MOVE_TYPE = `261`.
* IF LS_HAREKET-YENI_MIKTAR IS INITIAL.
gm_item-ENTRY_QNT = LS_HAREKET-hAREKET_MIK.
* ELSE.
* gm_item-ENTRY_QNT = LS_HAREKET-YENI_MIKTAR .
* ENDIF.
gm_item-ENTRY_UOM = LS_HAREKET-MEINS.
gm_item-ORDERID = LS_HAREKET-AUFNR.
*
APPEND gm_item.
REFRESH LT_ERETURN.
call function `BAPI_GOODSMVT_CREATE`
exporting
GOODSMVT_HEADER = gm_header
GOODSMVT_CODE = gm_code
* TESTRUN = ` `
* GOODSMVT_REF_EWM =
* IMPORTING
* GOODSMVT_HEADRET =
* MATERIALDOCUMENT =
* MATDOCUMENTYEAR =
tables
GOODSMVT_ITEM = gm_item
* GOODSMVT_SERIALNUMBER =
RETURN = LT_ERETURN
* GOODSMVT_SERV_PART_DATA =
* EXTENSIONIN =
.
LS_E_Sayac = 0.
LOOP AT LT_ERETURN INTO LS_ERETURN.
IF LS_ERETURN-TYPE = `E`.
LS_E_Sayac = LS_E_Sayac + 1.
ENDIF.
APPEND LS_ERETURN TO LT_rETURN_COLL.
ENDLOOP.
IF LS_E_Sayac IS INITIAL.
call function `BAPI_TRANSACTION_COMMIT`
exporting
wait = `X`
importing
return = LS_ERETURN.
ENDIF.
ENDLOOP.
ENDLOOP.
IF LT_rETURN_COLL[] IS NOT INITIAL.
CALL FUNCTION `ZC14ALD_BAPIRET2_SHOW`
TABLES
I_BAPIRET2_TAB = LT_rETURN_COLL. " BAPIRET2
ENDIF.
LEAVE TO SCREEN 0.
ENDFORM. "SET_PF_STATUS_FUNC