REPORT : zmm_gi201.
TABLES : mara.
TYPES : BEGIN OF ty_out,
sno TYPE i,
matnr TYPE mara-matnr,
maktx TYPE makt-maktx,
menge TYPE ekbe-menge,
meins TYPE mara-meins,
mblnr TYPE mblnr,
END OF ty_out.
TYPES : BEGIN OF ty_doc,
mblnr TYPE mblnr,
END OF ty_doc.
DATA it_doc TYPE TABLE OF ty_doc WITH HEADER LINE.
DATA it_mara TYPE TABLE OF mara WITH HEADER LINE.
DATA it_makt TYPE TABLE OF makt WITH HEADER LINE.
DATA it_out TYPE TABLE OF ty_out WITH HEADER LINE.
"""""
DATA it_head TYPE bapi2017_gm_head_01.
DATA it_code TYPE bapi2017_gm_code.
DATA goodsmvt_headret LIKE bapi2017_gm_head_ret.
DATA materialdocument TYPE bapi2017_gm_head_ret-mat_doc.
DATA matdocumentyear TYPE bapi2017_gm_head_ret-doc_year.
DATA it_item TYPE TABLE OF bapi2017_gm_item_create WITH HEADER LINE.
DATA it_return TYPE TABLE OF bapiret2 WITH HEADER LINE.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS s_matnr FOR mara-matnr.
PARAMETERS p_werks TYPE marc-werks OBLIGATORY.
PARAMETERS p_date TYPE sy-datum OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
SELECT * FROM mara INTO TABLE it_mara WHERE matnr IN s_matnr.
IF it_mara[] IS NOT INITIAL.
SELECT * FROM makt INTO TABLE it_makt FOR ALL ENTRIES IN it_mara WHERE matnr = it_mara-matnr
AND spras = 'EN'. .
ENDIF.
LOOP AT it_mara.
it_out-sno = it_out-sno + 1.
it_out-matnr = it_mara-matnr.
it_out-meins = it_mara-meins.
READ TABLE it_makt WITH KEY matnr = it_mara-matnr.
IF sy-subrc = 0.
it_out-maktx = it_makt-maktx.
ENDIF.
APPEND it_out.
ENDLOOP.
DATA it_fieldcat TYPE slis_t_fieldcat_alv.
DATA wa_fieldcat TYPE slis_fieldcat_alv.
wa_fieldcat-fieldname = 'SNO'.
wa_fieldcat-tabname = 'IT_OUT'.
wa_fieldcat-seltext_l = 'SNO'.
wa_fieldcat-outputlen = '04'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-tabname = 'IT_OUT'.
wa_fieldcat-seltext_l = 'Material'.
wa_fieldcat-outputlen = '05'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MAKTX'.
wa_fieldcat-tabname = 'IT_OUT'.
wa_fieldcat-seltext_l = 'Description'.
wa_fieldcat-outputlen = '30'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MENGE'.
wa_fieldcat-tabname = 'IT_OUT'.
wa_fieldcat-edit = 'X'.
wa_fieldcat-qfieldname = 'MEINS'.
wa_fieldcat-no_zero = 'X'.
wa_fieldcat-ref_tabname = 'MSEG'.
wa_fieldcat-ref_fieldname = 'MENGE'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MEINS'.
wa_fieldcat-tabname = 'IT_OUT'.
wa_fieldcat-seltext_l = 'Uom'.
wa_fieldcat-outputlen = '03'.
wa_fieldcat-ref_tabname = 'MARA'.
wa_fieldcat-ref_fieldname = 'MEINS'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MBLNR'.
wa_fieldcat-tabname = 'IT_OUT'.
wa_fieldcat-seltext_l = 'Material Doc'.
wa_fieldcat-outputlen = '12'.
wa_fieldcat-ref_tabname = 'MSEG'.
wa_fieldcat-ref_fieldname = 'MBLNR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
DATA: g_repid LIKE sy-repid.
DATA: variant_detail LIKE disvariant.
g_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_callback_top_of_page = 'TOP-OF-PAGE '
* is_layout = gs_layout
* it_sort = gt_sort[]
i_callback_user_command = 'STAT'
it_fieldcat = it_fieldcat[]
* IT_EVENTS = GT_EVENTS[]
i_save = 'U'
is_variant = variant_detail
* I_GRID_SETTINGS = LC_GLAY "IMPORTANT
i_callback_pf_status_set = 'FORM_PF_STATUS' "NOW
TABLES
t_outtab = it_out.
FORM top-of-page.
DATA: t_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader.
DATA ztime(10) TYPE c.
DATA time TYPE sy-uzeit.
time = sy-uzeit.
WRITE time TO ztime.
wa_header-typ = 'H'.
wa_header-info = '201 -Consumption for cost center from warehouse'.
APPEND wa_header TO t_header.
CLEAR wa_header.
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info.
APPEND wa_header TO t_header.
CLEAR: wa_header.
wa_header-typ = 'S'.
wa_header-key = 'Time: '.
wa_header-info = ztime.
APPEND wa_header TO t_header.
CLEAR: wa_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
ENDFORM.
FORM form_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'GUI_STATUS' OF PROGRAM g_repid.
ENDFORM.
FORM stat USING ls_ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "NEW
selfield-refresh = 'X'.
IF ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid.
ENDIF.
IF NOT ref_grid IS INITIAL.
CALL METHOD ref_grid->check_changed_data.
ENDIF.
CASE ls_ucomm.
WHEN '&DATA_SAVE'.
it_item-move_type = '201'.
it_item-plant = p_werks .
LOOP AT it_out WHERE menge IS NOT INITIAL.
it_item-material = it_out-matnr.
it_item-stge_loc = p_werks.
it_item-costcenter = p_werks.
it_item-entry_qnt = it_out-menge.
APPEND it_item.
ENDLOOP.
it_head-pstng_date = p_date.
it_head-doc_date = p_date.
it_head-pr_uname = sy-uname.
it_code-gm_code = '03'.
IF it_item[] IS NOT INITIAL.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = it_head
goodsmvt_code = it_code
* TESTRUN = ' '
* GOODSMVT_REF_EWM =
IMPORTING
goodsmvt_headret = goodsmvt_headret
materialdocument = materialdocument
matdocumentyear = matdocumentyear
TABLES
goodsmvt_item = it_item
* GOODSMVT_SERIALNUMBER =
return = it_return.
* GOODSMVT_SERV_PART_DATA =
* EXTENSIONIN =
COMMIT WORK AND WAIT.
IF materialdocument IS NOT INITIAL.
it_doc-mblnr = materialdocument.
APPEND it_doc.
ENDIF.
IF materialdocument IS INITIAL.
MESSAGE it_return-message TYPE 'W'.
ENDIF.
REFRESH it_item.
REFRESH it_out.
ENDIF.
LOOP AT IT_OUT.
IT_OUT-MBLNR = materialdocument.
MODIFY IT_OUT.
ENDLOOP.
ENDCASE.
ENDFORM.
TABLES : mara.
TYPES : BEGIN OF ty_out,
sno TYPE i,
matnr TYPE mara-matnr,
maktx TYPE makt-maktx,
menge TYPE ekbe-menge,
meins TYPE mara-meins,
mblnr TYPE mblnr,
END OF ty_out.
TYPES : BEGIN OF ty_doc,
mblnr TYPE mblnr,
END OF ty_doc.
DATA it_doc TYPE TABLE OF ty_doc WITH HEADER LINE.
DATA it_mara TYPE TABLE OF mara WITH HEADER LINE.
DATA it_makt TYPE TABLE OF makt WITH HEADER LINE.
DATA it_out TYPE TABLE OF ty_out WITH HEADER LINE.
"""""
DATA it_head TYPE bapi2017_gm_head_01.
DATA it_code TYPE bapi2017_gm_code.
DATA goodsmvt_headret LIKE bapi2017_gm_head_ret.
DATA materialdocument TYPE bapi2017_gm_head_ret-mat_doc.
DATA matdocumentyear TYPE bapi2017_gm_head_ret-doc_year.
DATA it_item TYPE TABLE OF bapi2017_gm_item_create WITH HEADER LINE.
DATA it_return TYPE TABLE OF bapiret2 WITH HEADER LINE.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS s_matnr FOR mara-matnr.
PARAMETERS p_werks TYPE marc-werks OBLIGATORY.
PARAMETERS p_date TYPE sy-datum OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
SELECT * FROM mara INTO TABLE it_mara WHERE matnr IN s_matnr.
IF it_mara[] IS NOT INITIAL.
SELECT * FROM makt INTO TABLE it_makt FOR ALL ENTRIES IN it_mara WHERE matnr = it_mara-matnr
AND spras = 'EN'. .
ENDIF.
LOOP AT it_mara.
it_out-sno = it_out-sno + 1.
it_out-matnr = it_mara-matnr.
it_out-meins = it_mara-meins.
READ TABLE it_makt WITH KEY matnr = it_mara-matnr.
IF sy-subrc = 0.
it_out-maktx = it_makt-maktx.
ENDIF.
APPEND it_out.
ENDLOOP.
DATA it_fieldcat TYPE slis_t_fieldcat_alv.
DATA wa_fieldcat TYPE slis_fieldcat_alv.
wa_fieldcat-fieldname = 'SNO'.
wa_fieldcat-tabname = 'IT_OUT'.
wa_fieldcat-seltext_l = 'SNO'.
wa_fieldcat-outputlen = '04'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-tabname = 'IT_OUT'.
wa_fieldcat-seltext_l = 'Material'.
wa_fieldcat-outputlen = '05'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MAKTX'.
wa_fieldcat-tabname = 'IT_OUT'.
wa_fieldcat-seltext_l = 'Description'.
wa_fieldcat-outputlen = '30'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MENGE'.
wa_fieldcat-tabname = 'IT_OUT'.
wa_fieldcat-edit = 'X'.
wa_fieldcat-qfieldname = 'MEINS'.
wa_fieldcat-no_zero = 'X'.
wa_fieldcat-ref_tabname = 'MSEG'.
wa_fieldcat-ref_fieldname = 'MENGE'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MEINS'.
wa_fieldcat-tabname = 'IT_OUT'.
wa_fieldcat-seltext_l = 'Uom'.
wa_fieldcat-outputlen = '03'.
wa_fieldcat-ref_tabname = 'MARA'.
wa_fieldcat-ref_fieldname = 'MEINS'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MBLNR'.
wa_fieldcat-tabname = 'IT_OUT'.
wa_fieldcat-seltext_l = 'Material Doc'.
wa_fieldcat-outputlen = '12'.
wa_fieldcat-ref_tabname = 'MSEG'.
wa_fieldcat-ref_fieldname = 'MBLNR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
DATA: g_repid LIKE sy-repid.
DATA: variant_detail LIKE disvariant.
g_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_callback_top_of_page = 'TOP-OF-PAGE '
* is_layout = gs_layout
* it_sort = gt_sort[]
i_callback_user_command = 'STAT'
it_fieldcat = it_fieldcat[]
* IT_EVENTS = GT_EVENTS[]
i_save = 'U'
is_variant = variant_detail
* I_GRID_SETTINGS = LC_GLAY "IMPORTANT
i_callback_pf_status_set = 'FORM_PF_STATUS' "NOW
TABLES
t_outtab = it_out.
FORM top-of-page.
DATA: t_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader.
DATA ztime(10) TYPE c.
DATA time TYPE sy-uzeit.
time = sy-uzeit.
WRITE time TO ztime.
wa_header-typ = 'H'.
wa_header-info = '201 -Consumption for cost center from warehouse'.
APPEND wa_header TO t_header.
CLEAR wa_header.
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info.
APPEND wa_header TO t_header.
CLEAR: wa_header.
wa_header-typ = 'S'.
wa_header-key = 'Time: '.
wa_header-info = ztime.
APPEND wa_header TO t_header.
CLEAR: wa_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
ENDFORM.
FORM form_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'GUI_STATUS' OF PROGRAM g_repid.
ENDFORM.
FORM stat USING ls_ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "NEW
selfield-refresh = 'X'.
IF ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid.
ENDIF.
IF NOT ref_grid IS INITIAL.
CALL METHOD ref_grid->check_changed_data.
ENDIF.
CASE ls_ucomm.
WHEN '&DATA_SAVE'.
it_item-move_type = '201'.
it_item-plant = p_werks .
LOOP AT it_out WHERE menge IS NOT INITIAL.
it_item-material = it_out-matnr.
it_item-stge_loc = p_werks.
it_item-costcenter = p_werks.
it_item-entry_qnt = it_out-menge.
APPEND it_item.
ENDLOOP.
it_head-pstng_date = p_date.
it_head-doc_date = p_date.
it_head-pr_uname = sy-uname.
it_code-gm_code = '03'.
IF it_item[] IS NOT INITIAL.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = it_head
goodsmvt_code = it_code
* TESTRUN = ' '
* GOODSMVT_REF_EWM =
IMPORTING
goodsmvt_headret = goodsmvt_headret
materialdocument = materialdocument
matdocumentyear = matdocumentyear
TABLES
goodsmvt_item = it_item
* GOODSMVT_SERIALNUMBER =
return = it_return.
* GOODSMVT_SERV_PART_DATA =
* EXTENSIONIN =
COMMIT WORK AND WAIT.
IF materialdocument IS NOT INITIAL.
it_doc-mblnr = materialdocument.
APPEND it_doc.
ENDIF.
IF materialdocument IS INITIAL.
MESSAGE it_return-message TYPE 'W'.
ENDIF.
REFRESH it_item.
REFRESH it_out.
ENDIF.
LOOP AT IT_OUT.
IT_OUT-MBLNR = materialdocument.
MODIFY IT_OUT.
ENDLOOP.
ENDCASE.
ENDFORM.
No comments:
Post a Comment