*&---------------------------------------------------------------------*
*& Report ZVVF_MR025_WEIGHBRIDGE_GR
*&---------------------------------------------------------------------*
REPORT ZVVF_MR025_WEIGHBRIDGE_GR NO STANDARD PAGE HEADING LINE-SIZE 110
MESSAGE-ID ZMM .
*----------------------------------------------------------------------
** Module Sales *
*----------------------------------------------------------------------
** Objective: Posting Goods Movement
** Program : Updates tables (X) Download data ( )
** Output Lists (X) ALV
**
**---------------------------------------------------------------------*
* External Dependencies
**---------------------------------------------------------------------*
*
**---------------------------------------------------------------------*
* Amendment History
**---------------------------------------------------------------------*
* Who Change ID Reason
*** ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*---------------------------------------------------------------------**
* Type-pools
*----------------------------------------------------------------------*
TYPE-POOLS : SLIS.
*---------------------------------------------------------------------*
**TABLES :
*---------------------------------------------------------------------*
TABLES : ZVVF_MT25_BRIDGE. " Weigh Bridge Down Loaded Details
*---------------------------------------------------------------------*
**CONSTANTS :
*---------------------------------------------------------------------*
*--- For ALV ----*
CONSTANTS: C_TOP_OF_PAGE_DB TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE_DB',
C_TCODE TYPE SY-TCODE VALUE 'ZMR025_POST1'.
*---------------------------------------------------------------------*
**TYPES :
*---------------------------------------------------------------------*
DATA : BEGIN OF TY_DETAIL,
PO_NUMBER TYPE BAPI2017_GM_ITEM_CREATE-PO_NUMBER,
PO_ITEM TYPE BAPI2017_GM_ITEM_CREATE-PO_ITEM,
MATERIAL TYPE BAPI2017_GM_ITEM_CREATE-MATERIAL,
VENDOR TYPE BAPI2017_GM_ITEM_CREATE-VENDOR,
PLANT TYPE BAPI2017_GM_ITEM_CREATE-PLANT,
STGE_LOC TYPE BAPI2017_GM_ITEM_CREATE-STGE_LOC,
MOVE_TYPE TYPE BAPI2017_GM_ITEM_CREATE-MOVE_TYPE,
ENTRY_QNT TYPE BAPI2017_GM_ITEM_CREATE-ENTRY_QNT,
ENTRY_UOM TYPE BAPI2017_GM_ITEM_CREATE-ENTRY_UOM,
ENTRY_UOM_ISO TYPE BAPI2017_GM_ITEM_CREATE-ENTRY_UOM_ISO,
MVT_IND TYPE BAPI2017_GM_ITEM_CREATE-MVT_IND,
ITEM_TEXT TYPE BAPI2017_GM_ITEM_CREATE-ITEM_TEXT,
VENDRBATCH TYPE BAPI2017_GM_ITEM_CREATE-VENDRBATCH,
ST_UN_QTYY_1 TYPE BAPI2017_GM_ITEM_CREATE-ST_UN_QTYY_1,
QUANTITY TYPE BAPI2017_GM_ITEM_CREATE-QUANTITY,
PO_PR_QNT TYPE BAPI2017_GM_ITEM_CREATE-PO_PR_QNT,
IND_PROPOSE_QUANX TYPE BAPI2017_GM_ITEM_CREATE-IND_PROPOSE_QUANX,
BASE_UOM TYPE BAPI2017_GM_ITEM_CREATE-BASE_UOM.
DATA : END OF TY_DETAIL.
*---------------------------------------------------------------------*
**DATA :
*---------------------------------------------------------------------*
DATA : W_REPID LIKE SY-REPID,
W_ANS TYPE N,
W_OK LIKE SY-UCOMM,
W_SGTXT LIKE MSEG-SGTXT,
W_INPUT LIKE MSEG-MATNR,
W_CNT TYPE N,
W_CNT1 TYPE N,
W_IDX LIKE SY-INDEX,
W_QTY LIKE MSEG-MENGE,
W_MENGE LIKE MSEG-MENGE.
*---------------------------------------------------------------------*
**INTERNAL TABLES :
*---------------------------------------------------------------------*
*--- For ALV ----*
DATA: IT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
IT_EVENTS TYPE SLIS_T_EVENT,
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
*---------------*
DATA: IT_PODAT TYPE TABLE OF ZVVF_MT25_BRIDGE WITH HEADER LINE.
DATA : IT_BAPI_HEADER TYPE STANDARD TABLE OF BAPI2017_GM_HEAD_01 WITH
HEADER LINE.
DATA : IT_BAPI_DETAIL TYPE STANDARD TABLE OF BAPI2017_GM_ITEM_CREATE
WITH HEADER LINE.
DATA : MD_NUMBER TYPE MBLNR.
DATA: BEGIN OF ITABRES OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA: END OF ITABRES.
DATA: BEGIN OF IT_MSG OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA: END OF IT_MSG.
DATA : IT_DETAIL LIKE STANDARD TABLE OF TY_DETAIL WITH HEADER LINE.
DATA: BEGIN OF IT_BATCH OCCURS 0,
CHARG LIKE LIPS-CHARG,
LFIMG LIKE LIPS-LFIMG,
END OF IT_BATCH.
*---------------------------------------------------------------------*
**WORK AREAS
*---------------------------------------------------------------------*
DATA: WA_PODAT LIKE LINE OF IT_PODAT,
WA_PODAT1 TYPE ZVVF_MT25_BRIDG1,
WA_LAYOUT TYPE SLIS_LAYOUT_ALV. " For ALV
*---------------------------------------------------------------------*
**SELECTION SCREEN
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
**INITIALIZATION :
*---------------------------------------------------------------------*
INITIALIZATION.
W_REPID = SY-REPID.
*---------------------------------------------------------------------*
**AT SELECTION SCREEN :
*---------------------------------------------------------------------*
AT SELECTION-SCREEN.
*---------------------------------------------------------------------*
**START OF SELECTION :
*---------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM CHECK_DATA.
LOOP AT IT_PODAT INTO WA_PODAT.
PERFORM MATNR_FORMAT USING WA_PODAT-MATNR.
PERFORM MATNR_FORMAT USING WA_PODAT-LIFNR.
MODIFY IT_PODAT FROM WA_PODAT TRANSPORTING MATNR LIFNR.
ENDLOOP.
CLEAR W_INPUT.
*---------------------------------------------------------------------*
**END OF SELECTION :
*---------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM FIELDCAT_INIT USING IT_FIELDCAT[].
PERFORM EVENTTAB_BUILD USING IT_EVENTS[].
PERFORM COMMENT_BUILD USING IT_LIST_TOP_OF_PAGE[].
PERFORM LAYOUT_BUILD USING WA_LAYOUT.
PERFORM WRITE_ALV_GRID.
EXPORT IT_MSG TO MEMORY ID 'ZVV7'.
CALL TRANSACTION C_TCODE .
LEAVE PROGRAM.
*&---------------------------------------------------------------------*
*& Form Check_DATA
*&---------------------------------------------------------------------*
* Check DATA
*----------------------------------------------------------------------*
FORM CHECK_DATA.
**Select all PO which not yet posted
SELECT * FROM ZVVF_MT25_BRIDGE INTO CORRESPONDING FIELDS OF TABLE
IT_PODAT WHERE ZPOST NE 'X' AND ZBLCK NE 'X'.
IF SY-SUBRC NE 0.
MESSAGE E005.
ENDIF.
ENDFORM. "Check_DATA
*&--------------------------------------------------------------------*
*& Form fieldcat_init
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->IT_FIELDCATtext
*---------------------------------------------------------------------*
FORM FIELDCAT_INIT USING LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA : WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA :W_POS TYPE I VALUE 0.
W_POS = W_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = W_POS.
WA_FIELDCAT-TABNAME = 'IT_PODAT'.
WA_FIELDCAT-FIELDNAME = 'ZPOST'.
WA_FIELDCAT-SELTEXT_M = 'Post GR'.
WA_FIELDCAT-EMPHASIZE = 'C410'.
WA_FIELDCAT-OUTPUTLEN = '1'.
WA_FIELDCAT-CHECKBOX = 'X'.
WA_FIELDCAT-EDIT = 'X'.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
W_POS = W_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = W_POS.
WA_FIELDCAT-TABNAME = 'IT_PODAT'.
WA_FIELDCAT-FIELDNAME = 'BWART'.
WA_FIELDCAT-SELTEXT_M = 'Movement Type'.
WA_FIELDCAT-EMPHASIZE = 'C410'.
WA_FIELDCAT-OUTPUTLEN = '15'.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
W_POS = W_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = W_POS.
WA_FIELDCAT-TABNAME = 'IT_PODAT'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO No.'.
WA_FIELDCAT-EMPHASIZE = 'C410'.
WA_FIELDCAT-OUTPUTLEN = '15'.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
W_POS = W_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = W_POS.
WA_FIELDCAT-TABNAME = 'IT_PODAT'.
WA_FIELDCAT-FIELDNAME = 'EBELP'.
WA_FIELDCAT-SELTEXT_M = 'PO Item'.
WA_FIELDCAT-EMPHASIZE = 'C410'.
WA_FIELDCAT-OUTPUTLEN = '15'.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
W_POS = W_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = W_POS.
WA_FIELDCAT-TABNAME = 'IT_PODAT'.
WA_FIELDCAT-FIELDNAME = 'ZSLIPNO'.
WA_FIELDCAT-SELTEXT_M = 'Slip No.'.
WA_FIELDCAT-EMPHASIZE = 'C410'.
WA_FIELDCAT-OUTPUTLEN = '15'.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
W_POS = W_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = W_POS.
WA_FIELDCAT-TABNAME = 'IT_PODAT'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'Material'.
WA_FIELDCAT-EMPHASIZE = 'C410'.
WA_FIELDCAT-OUTPUTLEN = '15'.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
W_POS = W_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = W_POS.
WA_FIELDCAT-TABNAME = 'IT_PODAT'.
WA_FIELDCAT-FIELDNAME = 'LIFNR'.
WA_FIELDCAT-SELTEXT_M = 'Vendor Acc.'.
WA_FIELDCAT-EMPHASIZE = 'C410'.
WA_FIELDCAT-OUTPUTLEN = '15'.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
W_POS = W_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = W_POS.
WA_FIELDCAT-TABNAME = 'IT_PODAT'.
WA_FIELDCAT-FIELDNAME = 'WERKS'.
WA_FIELDCAT-SELTEXT_M = 'Plant'.
WA_FIELDCAT-EMPHASIZE = 'C410'.
WA_FIELDCAT-OUTPUTLEN = '15'.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
W_POS = W_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = W_POS.
WA_FIELDCAT-TABNAME = 'IT_PODAT'.
WA_FIELDCAT-FIELDNAME = 'FRBNR'.
WA_FIELDCAT-SELTEXT_M = 'Truck No.'.
WA_FIELDCAT-EMPHASIZE = 'C410'.
WA_FIELDCAT-OUTPUTLEN = '15'.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
W_POS = W_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = W_POS.
WA_FIELDCAT-TABNAME = 'IT_PODAT'.
WA_FIELDCAT-FIELDNAME = 'XBLNR'.
WA_FIELDCAT-SELTEXT_M = 'Delivery/LR No.'.
WA_FIELDCAT-EMPHASIZE = 'C410'.
WA_FIELDCAT-OUTPUTLEN = '15'.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
W_POS = W_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = W_POS.
WA_FIELDCAT-TABNAME = 'IT_PODAT'.
WA_FIELDCAT-FIELDNAME = 'BKTXT'.
WA_FIELDCAT-SELTEXT_M = 'Bill of Lading'.
WA_FIELDCAT-DO_SUM = 'X'.
WA_FIELDCAT-EMPHASIZE = 'C410'.
WA_FIELDCAT-OUTPUTLEN = '15'.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
W_POS = W_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = W_POS.
WA_FIELDCAT-TABNAME = 'IT_PODAT'.
WA_FIELDCAT-FIELDNAME = 'LSMNG'.
WA_FIELDCAT-SELTEXT_M = 'Delivered Qty.'.
WA_FIELDCAT-DO_SUM = 'X'.
WA_FIELDCAT-EMPHASIZE = 'C410'.
WA_FIELDCAT-OUTPUTLEN = '15'.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
W_POS = W_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = W_POS.
WA_FIELDCAT-TABNAME = 'IT_PODAT'.
WA_FIELDCAT-FIELDNAME = 'GMEINS'.
WA_FIELDCAT-SELTEXT_M = 'Gross Wt.'.
WA_FIELDCAT-EMPHASIZE = 'C410'.
WA_FIELDCAT-OUTPUTLEN = '15'.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
W_POS = W_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = W_POS.
WA_FIELDCAT-TABNAME = 'IT_PODAT'.
WA_FIELDCAT-FIELDNAME = 'TMEINS'.
WA_FIELDCAT-SELTEXT_M = 'Tare Wt.'.
WA_FIELDCAT-EMPHASIZE = 'C410'.
WA_FIELDCAT-OUTPUTLEN = '15'.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
W_POS = W_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = W_POS.
WA_FIELDCAT-TABNAME = 'IT_PODAT'.
WA_FIELDCAT-FIELDNAME = 'MENGE'.
WA_FIELDCAT-SELTEXT_M = 'Net Wt.'.
WA_FIELDCAT-DO_SUM = 'X'.
WA_FIELDCAT-EMPHASIZE = 'C410'.
WA_FIELDCAT-OUTPUTLEN = '15'.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
W_POS = W_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = W_POS.
WA_FIELDCAT-TABNAME = 'IT_PODAT'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'UOM'.
WA_FIELDCAT-EMPHASIZE = 'C410'.
WA_FIELDCAT-OUTPUTLEN = '5'.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
W_POS = W_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = W_POS.
WA_FIELDCAT-TABNAME = 'IT_PODAT'.
WA_FIELDCAT-FIELDNAME = 'NAME1'.
WA_FIELDCAT-SELTEXT_M = 'Transporter'.
WA_FIELDCAT-EMPHASIZE = 'C410'.
WA_FIELDCAT-OUTPUTLEN = '20'.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
W_POS = W_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = W_POS.
WA_FIELDCAT-TABNAME = 'IT_PODAT'.
WA_FIELDCAT-FIELDNAME = 'GRUND'.
WA_FIELDCAT-SELTEXT_M = 'Reason for Movement'.
WA_FIELDCAT-EMPHASIZE = 'C410'.
WA_FIELDCAT-OUTPUTLEN = '15'.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
ENDFORM. " fieldcat_init
*&---------------------------------------------------------------------*
*& Form eventtab_build
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_it_EVENTS[] text
*----------------------------------------------------------------------*
FORM EVENTTAB_BUILD USING LT_EVENTS TYPE SLIS_T_EVENT.
DATA: WA_EVENT TYPE SLIS_ALV_EVENT.
DATA: C_TOP_OF_PAGE TYPE SLIS_FORMNAME.
C_TOP_OF_PAGE = C_TOP_OF_PAGE_DB.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = LT_EVENTS.
READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO WA_EVENT.
IF SY-SUBRC <> 0.
MOVE C_TOP_OF_PAGE TO WA_EVENT-FORM.
APPEND WA_EVENT TO LT_EVENTS.
ELSE.
MOVE C_TOP_OF_PAGE TO WA_EVENT-FORM.
MODIFY LT_EVENTS FROM WA_EVENT INDEX SY-TABIX .
ENDIF.
ENDFORM. " eventtab_build
*&---------------------------------------------------------------------*
*& Form comment_build
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_it_LIST_TOP_OF_PAGE[] text
*----------------------------------------------------------------------*
FORM COMMENT_BUILD USING LT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA: WA_LINE TYPE SLIS_LISTHEADER.
CLEAR WA_LINE.
WA_LINE-TYP = 'H'.
WA_LINE-INFO = 'VVF LTD. Mumbai'.
APPEND WA_LINE TO LT_TOP_OF_PAGE.
WA_LINE-TYP = 'H'.
WA_LINE-INFO = SY-ULINE.
APPEND WA_LINE TO LT_TOP_OF_PAGE.
WA_LINE-TYP = 'H'.
WA_LINE-INFO = 'Post Goods Movement'.
APPEND WA_LINE TO LT_TOP_OF_PAGE.
ENDFORM. " comment_build
*&---------------------------------------------------------------------*
*& Form layout_build
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_WA_layout text
*----------------------------------------------------------------------*
FORM LAYOUT_BUILD USING WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
WA_LAYOUT-ZEBRA = 'X'.
WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
WA_LAYOUT-NO_TOTALLINE = 'X'.
* wa_layout-edit = 'X'.
ENDFORM. " layout_build
*&---------------------------------------------------------------------*
*& Form write_alv_grid
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM WRITE_ALV_GRID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
I_BACKGROUND_ID = 'ALV_BACKGROUND'
I_CALLBACK_TOP_OF_PAGE = C_TOP_OF_PAGE_DB
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT[]
IT_EVENTS = IT_EVENTS[]
I_SAVE = 'A'
TABLES
T_OUTTAB = IT_PODAT
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " write_alv_grid
*&---------------------------------------------------------------------*
*& Form PF_STATUS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM PF_STATUS USING EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'ZSTANDARD1'.
ENDFORM. "PF_STATUS
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM USER_COMMAND USING OK_CODE TYPE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
IF OK_CODE = '&DATA_SAVE'.
PERFORM POST_GR.
***when BACK leave screen
ELSEIF OK_CODE = 'OUT'.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = TEXT-003
TEXT_QUESTION = TEXT-004
DEFAULT_BUTTON = '2'
DISPLAY_CANCEL_BUTTON = ' '
IMPORTING
ANSWER = W_ANS
EXCEPTIONS
TEXT_NOT_FOUND = 1
OTHERS = 2.
IF W_ANS = '1'.
SET SCREEN 0.
LEAVE SCREEN.
ELSE.
LEAVE SCREEN.
ENDIF.
ENDIF.
ENDFORM. "USER_COMMAND
*---------------------------------------------------------------------*
* FORM TOP_OF_PAGE_DB *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE_DB.
*
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LIST_TOP_OF_PAGE
I_LOGO = ' '.
ENDFORM. "top_of_page_db
*&--------------------------------------------------------------------*
*& Form MATNR_FORMAT
*&--------------------------------------------------------------------*
* MATNR FORMAT
*---------------------------------------------------------------------*
FORM MATNR_FORMAT USING W_INPUT.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = W_INPUT
IMPORTING
OUTPUT = W_INPUT.
ENDFORM. "MATNR_FORMAT
*&--------------------------------------------------------------------*
*& Form post_gr
*&--------------------------------------------------------------------*
* post gr
*---------------------------------------------------------------------*
FORM POST_GR.
SORT IT_PODAT STABLE BY EBELN.
LOOP AT IT_PODAT WHERE ZPOST = 'X'.
MOVE-CORRESPONDING IT_PODAT TO WA_PODAT.
AT NEW EBELN.
IT_BAPI_HEADER-PSTNG_DATE = SY-DATUM.
IT_BAPI_HEADER-DOC_DATE = SY-DATUM.
IT_BAPI_HEADER-HEADER_TXT = WA_PODAT-BKTXT.
IT_BAPI_HEADER-BILL_OF_LADING = WA_PODAT-FRBNR.
IT_BAPI_HEADER-REF_DOC_NO = WA_PODAT-XBLNR.
APPEND IT_BAPI_HEADER.
ENDAT.
CONCATENATE WA_PODAT-GMEINS WA_PODAT-TMEINS INTO W_SGTXT
SEPARATED BY '/'.
PERFORM MATNR_FORMAT_INPUT USING WA_PODAT-MATNR.
*w_cnt = 1.
IF WA_PODAT-BWART = '101' AND
( WA_PODAT-LSMNG GT WA_PODAT-MENGE ).
SELECT CHARG LFIMG FROM LIPS INTO CORRESPONDING FIELDS OF TABLE IT_BATCH
WHERE VGBEL = WA_PODAT-EBELN AND
VGPOS = WA_PODAT-EBELP AND
VBELN = WA_PODAT-XBLNR AND " Added By Vinod
CHARG NE ' '.
IF SY-SUBRC = 0.
DESCRIBE TABLE IT_BATCH LINES W_CNT.
ENDIF.
*w_cnt = w_cnt + 1.
*w_cnt = 2.
W_QTY = WA_PODAT-LSMNG - WA_PODAT-MENGE.
IF W_QTY NE 0.
IT_BATCH-CHARG = 'BL01'.
IT_BATCH-LFIMG = W_QTY.
APPEND IT_BATCH.
ENDIF.
W_MENGE = WA_PODAT-MENGE.
LOOP AT IT_BATCH.
PERFORM CALL_BAPI.
ENDLOOP.
*--inserted on 07-06-2005 by vinod.
elseif WA_PODAT-BWART = '101'.
IF WA_PODAT-MENGE GE WA_PODAT-LSMNG.
SELECT CHARG LFIMG FROM LIPS INTO CORRESPONDING FIELDS OF TABLE IT_BATCH
WHERE VGBEL = WA_PODAT-EBELN AND
VGPOS = WA_PODAT-EBELP AND
VBELN = WA_PODAT-XBLNR AND " Added By Vinod
CHARG NE ' '.
ENDIF.
* ENDIF.
LOOP AT IT_BATCH.
MOVE WA_PODAT-EBELN TO IT_BAPI_DETAIL-PO_NUMBER .
MOVE WA_PODAT-EBELP TO IT_BAPI_DETAIL-PO_ITEM.
MOVE WA_PODAT-MATNR TO IT_BAPI_DETAIL-MATERIAL .
* MOVE WA_PODAT-WERKS TO IT_BAPI_DETAIL-PLANT .
MOVE WA_PODAT-LGORT TO IT_BAPI_DETAIL-STGE_LOC .
* MOVE WA_PODAT-MENGE TO IT_BAPI_DETAIL-ENTRY_QNT .
IT_BAPI_DETAIL-BATCH = IT_BATCH-CHARG.
MOVE IT_BATCH-LFIMG TO IT_BAPI_DETAIL-ENTRY_QNT .
MOVE WA_PODAT-BWART TO IT_BAPI_DETAIL-MOVE_TYPE.
MOVE WA_PODAT-MEINS TO IT_BAPI_DETAIL-ENTRY_UOM .
MOVE WA_PODAT-MEINS TO IT_BAPI_DETAIL-ENTRY_UOM_ISO.
IT_BAPI_DETAIL-MVT_IND = WA_PODAT-KZBEW.
MOVE W_SGTXT TO IT_BAPI_DETAIL-ITEM_TEXT .
MOVE WA_PODAT-MEINS TO IT_BAPI_DETAIL-BASE_UOM.
IT_BAPI_DETAIL-UNLOAD_PT = 'Through Weighbridge'.
IT_BAPI_DETAIL-MOVE_REAS = WA_PODAT-GRUND.
APPEND IT_BAPI_DETAIL.
ENDLOOP.
*---end of insertions.
ELSE.
*-------------------------------COMMENTED BY VINOD FOR MULTIPLE BATCHES.
MOVE WA_PODAT-EBELN TO IT_BAPI_DETAIL-PO_NUMBER .
MOVE WA_PODAT-EBELP TO IT_BAPI_DETAIL-PO_ITEM.
MOVE WA_PODAT-MATNR TO IT_BAPI_DETAIL-MATERIAL .
* MOVE WA_PODAT-WERKS TO IT_BAPI_DETAIL-PLANT .
MOVE WA_PODAT-LGORT TO IT_BAPI_DETAIL-STGE_LOC .
MOVE WA_PODAT-MENGE TO IT_BAPI_DETAIL-ENTRY_QNT .
* IF WA_PODAT-BWART = '101'.
* IF WA_PODAT-MENGE GE WA_PODAT-LSMNG."CHANGED BY VINOD FROM 'GT'
* "TO 'GE'.
* MOVE WA_PODAT-LSMNG TO IT_BAPI_DETAIL-ENTRY_QNT .
*
**-----ADDED BY VINOD FOR INSERTING THE BATCH
*SELECT CHARG LFIMG FROM LIPS INTO CORRESPONDING FIELDS OF TABLE
*IT_BATCH
* WHERE VGBEL = WA_PODAT-EBELN AND
* VGPOS = WA_PODAT-EBELP AND
* VBELN = WA_PODAT-XBLNR AND " Added By Vinod
* CHARG NE ' '.
**-----END OF ADDITIONS FOR INSERTING THE BATCH
* ENDIF.
* ENDIF.
**-----ADDED BY VINOD FOR INSERTING THE BATCH
* LOOP AT IT_BATCH.
* IT_BAPI_DETAIL-BATCH = IT_BATCH-CHARG.
* ENDLOOP.
*
*
**-----END OF ADDITIONS FOR INSERTING THE BATCH
*
MOVE WA_PODAT-BWART TO IT_BAPI_DETAIL-MOVE_TYPE.
MOVE WA_PODAT-MEINS TO IT_BAPI_DETAIL-ENTRY_UOM .
MOVE WA_PODAT-MEINS TO IT_BAPI_DETAIL-ENTRY_UOM_ISO.
IT_BAPI_DETAIL-MVT_IND = WA_PODAT-KZBEW.
MOVE W_SGTXT TO IT_BAPI_DETAIL-ITEM_TEXT .
MOVE WA_PODAT-MEINS TO IT_BAPI_DETAIL-BASE_UOM.
IT_BAPI_DETAIL-UNLOAD_PT = 'Through Weighbridge'.
IT_BAPI_DETAIL-MOVE_REAS = WA_PODAT-GRUND.
APPEND IT_BAPI_DETAIL.
ENDIF.
****----------------------------------------------------END OF COMMENTS
*---------------------------------CODE ADDED AFTER COMMENTING ABOVE CODE
* IF WA_PODAT-BWART = '101'.
* IF WA_PODAT-MENGE GE WA_PODAT-LSMNG.
*
*SELECT CHARG LFIMG FROM LIPS INTO CORRESPONDING FIELDS OF TABLE
*IT_BATCH
* WHERE VGBEL = WA_PODAT-EBELN AND
* VGPOS = WA_PODAT-EBELP AND
* VBELN = WA_PODAT-XBLNR AND " Added By Vinod
* CHARG NE ' '.
* ENDIF.
* ENDIF.
*
* LOOP AT IT_BATCH.
*
* MOVE WA_PODAT-EBELN TO IT_BAPI_DETAIL-PO_NUMBER .
* MOVE WA_PODAT-EBELP TO IT_BAPI_DETAIL-PO_ITEM.
* MOVE WA_PODAT-MATNR TO IT_BAPI_DETAIL-MATERIAL .
** MOVE WA_PODAT-WERKS TO IT_BAPI_DETAIL-PLANT .
* MOVE WA_PODAT-LGORT TO IT_BAPI_DETAIL-STGE_LOC .
** MOVE WA_PODAT-MENGE TO IT_BAPI_DETAIL-ENTRY_QNT .
* IT_BAPI_DETAIL-BATCH = IT_BATCH-CHARG.
* MOVE IT_BATCH-LFIMG TO IT_BAPI_DETAIL-ENTRY_QNT .
* MOVE WA_PODAT-BWART TO IT_BAPI_DETAIL-MOVE_TYPE.
* MOVE WA_PODAT-MEINS TO IT_BAPI_DETAIL-ENTRY_UOM .
* MOVE WA_PODAT-MEINS TO IT_BAPI_DETAIL-ENTRY_UOM_ISO.
* IT_BAPI_DETAIL-MVT_IND = WA_PODAT-KZBEW.
* MOVE W_SGTXT TO IT_BAPI_DETAIL-ITEM_TEXT .
* MOVE WA_PODAT-MEINS TO IT_BAPI_DETAIL-BASE_UOM.
* IT_BAPI_DETAIL-UNLOAD_PT = 'Through Weighbridge'.
* IT_BAPI_DETAIL-MOVE_REAS = WA_PODAT-GRUND.
* APPEND IT_BAPI_DETAIL.
*
* ENDLOOP.
*
*--------------------------END OF CODE ADDED AFTER COMMENTING ABOVE CODE
CLEAR : W_SGTXT,W_QTY,W_CNT,W_CNT1,W_MENGE,IT_BATCH.
REFRESH : IT_BATCH.
AT END OF EBELN.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
GOODSMVT_HEADER = IT_BAPI_HEADER
GOODSMVT_CODE = '01'
* TESTRUN = ' '
IMPORTING
* GOODSMVT_HEADRET =
MATERIALDOCUMENT = MD_NUMBER
* MATDOCUMENTYEAR =
TABLES
GOODSMVT_ITEM = IT_BAPI_DETAIL
* GOODSMVT_SERIALNUMBER =
RETURN = ITABRES .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
APPEND LINES OF ITABRES TO IT_MSG.
IF NOT MD_NUMBER IS INITIAL.
WA_PODAT-MBLNR = MD_NUMBER.
WA_PODAT-BUDAT = SY-DATUM.
WA_PODAT-YYEAR = SY-DATUM+0(4).
MOVE-CORRESPONDING WA_PODAT TO WA_PODAT1.
MODIFY ZVVF_MT25_BRIDG1 FROM WA_PODAT1.
* UPDATE ZVVF_MT25_BRIDGE SET
* Zpost = WA_PODAT-Zpost
* mblnr = MD_NUMBER
* budat = SY-DATUM
* YYEAR = SY-DATUM+0(4)
* WHERE EBELN = WA_PODAT-EBELN AND
* EBELP = WA_PODAT-EBELP .
IF SY-SUBRC = 0.
DELETE FROM ZVVF_MT25_BRIDGE WHERE EBELN = WA_PODAT-EBELN AND
EBELP = WA_PODAT-EBELP .
ENDIF.
READ TABLE IT_PODAT WITH KEY EBELN = WA_PODAT-EBELN
EBELP = WA_PODAT-EBELP .
IF SY-SUBRC = 0.
UPDATE MSEG SET LSMNG = IT_PODAT-LSMNG
WHERE MBLNR = MD_NUMBER .
ENDIF.
MESSAGE S124 WITH MD_NUMBER.
SET SCREEN 0.
LEAVE SCREEN.
ENDIF.
REFRESH : IT_BAPI_DETAIL,IT_BAPI_HEADER,ITABRES.
CLEAR : MD_NUMBER,IT_BAPI_DETAIL,IT_BAPI_HEADER,ITABRES.
ENDAT.
CLEAR : WA_PODAT.
ENDLOOP.
ENDFORM. "post_gr
*&--------------------------------------------------------------------*
*& Form CALL_BAPI
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM CALL_BAPI.
IF IT_BATCH-CHARG = 'BL01'.
READ TABLE IT_BATCH INDEX W_CNT.
IT_BAPI_DETAIL-BATCH = IT_BATCH-CHARG.
IT_BAPI_DETAIL-STGE_LOC = 'BL01'.
IT_BAPI_DETAIL-ENTRY_QNT = W_QTY.
IT_BAPI_DETAIL-STCK_TYPE = 'S'.
ELSE.
IF W_MENGE LT 0.
W_MENGE = 0.
ENDIF.
IF W_MENGE GE IT_BATCH-LFIMG .
IT_BAPI_DETAIL-BATCH = IT_BATCH-CHARG.
MOVE WA_PODAT-LGORT TO IT_BAPI_DETAIL-STGE_LOC .
MOVE IT_BATCH-LFIMG TO IT_BAPI_DETAIL-ENTRY_QNT .
ELSE.
IT_BAPI_DETAIL-BATCH = IT_BATCH-CHARG.
MOVE WA_PODAT-LGORT TO IT_BAPI_DETAIL-STGE_LOC .
MOVE W_MENGE TO IT_BAPI_DETAIL-ENTRY_QNT.
ENDIF.
W_MENGE = W_MENGE - IT_BATCH-LFIMG.
ENDIF.
MOVE WA_PODAT-EBELN TO IT_BAPI_DETAIL-PO_NUMBER .
MOVE WA_PODAT-EBELP TO IT_BAPI_DETAIL-PO_ITEM.
MOVE WA_PODAT-MATNR TO IT_BAPI_DETAIL-MATERIAL .
* MOVE WA_PODAT-WERKS TO IT_BAPI_DETAIL-PLANT .
MOVE WA_PODAT-BWART TO IT_BAPI_DETAIL-MOVE_TYPE.
MOVE WA_PODAT-MEINS TO IT_BAPI_DETAIL-ENTRY_UOM .
MOVE WA_PODAT-MEINS TO IT_BAPI_DETAIL-ENTRY_UOM_ISO.
IT_BAPI_DETAIL-MVT_IND = WA_PODAT-KZBEW.
MOVE W_SGTXT TO IT_BAPI_DETAIL-ITEM_TEXT .
MOVE WA_PODAT-MEINS TO IT_BAPI_DETAIL-BASE_UOM.
IT_BAPI_DETAIL-UNLOAD_PT = 'Through Weighbridge'.
IT_BAPI_DETAIL-MOVE_REAS = WA_PODAT-GRUND.
*added by vinod for exiting if w_menge is 0.
if IT_BAPI_DETAIL-ENTRY_QNT NE '0'.
APPEND IT_BAPI_DETAIL.
endif.
*end of addition by vinod for exiting if w_menge is 0.
* APPEND IT_BAPI_DETAIL.
ENDFORM. "CALL_BAPI
*&--------------------------------------------------------------------*
*& Form MATNR_FORMAT_INPUT
*&--------------------------------------------------------------------*
* MATNR FORMAT INPUT
*---------------------------------------------------------------------*
FORM MATNR_FORMAT_INPUT USING W_INPUT.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = W_INPUT
IMPORTING
OUTPUT = W_INPUT.
ENDFORM. "MATNR_FORMAT_INPUT
No comments:
Post a Comment