Go on link..

link us with ...

Tuesday, December 21, 2010

Download delivary details to ztable using Outward movement

*&---------------------------------------------------------------------*
*& Report ZVVF_MR025_WEIGHBRIDGE_FILEGET
*
*& *
*&---------------------------------------------------------------------*
REPORT ZVVF_MR025_WEIGHBRIDGE_FILEGET no standard page
heading line-size 110 MESSAGE-ID ZMM .

*----------------------------------------------------------------------
** Module Sales *
*----------------------------------------------------------------------
** Objective: Down load WEIGHBRIDGE(Delivery) text file data to Ztable
** Program : Updates tables (X) Download data (X)
** Output Lists () ALV
**
** Technical Spec No : VVF_TS09_MM025_WBSD_FILEFROMWB_V1.0
** Date Created :
** Author :
** Location :
**---------------------------------------------------------------------*
* External Dependencies
**---------------------------------------------------------------------*
*
**---------------------------------------------------------------------*
* Amendment History
**---------------------------------------------------------------------*
* Who Change ID Reason
*** ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*---------------------------------------------------------------------*
**TABLES :
*---------------------------------------------------------------------*
TABLES : ZVVF_MT25_OUTMOV. "Weigh Bridge Down Loaded Details
*---------------------------------------------------------------------*
**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.
*---------------------------------------------------------------------*
**CONSTANTS :
*---------------------------------------------------------------------*
*CONSTANTS C_PATH TYPE STRING VALUE '/VVFuture/upload/fi/'.

*---------------------------------------------------------------------*
**INTERNAL TABLES :
*---------------------------------------------------------------------*

DATA : IT_BRIDGE TYPE TABLE OF ZVVF_MT25_OUTMOV WITH HEADER LINE.

DATA : IT_MOVE TYPE TABLE OF ZVVF_MT25_OUTMOV WITH HEADER LINE.

DATA : BEGIN OF IT_lips OCCURS 0,
VBELN LIKE lips-VBELN,
posnr LIKE lips-posnr,
WERKS LIKE lips-WERKS,
matnr LIKE lips-matnr,
charg LIKE lips-charg,
LFIMG LIKE lips-LFIMG,
END OF IT_lips.

DATA : BEGIN OF IT_msg OCCURS 0,
VBELN LIKE lips-VBELN,
END OF IT_msg.

DATA : BEGIN OF IT_SUM OCCURS 0,
VBELN LIKE ZVVF_MT25_OUTMOV-VBELN,
WERKS LIKE ZVVF_MT25_OUTMOV-WERKS,
LFIMG LIKE ZVVF_MT25_OUTMOV-LFIMG,
END OF IT_SUM.

*---------------------------------------------------------------------*
**WORK AREA :
*---------------------------------------------------------------------*
DATA : WA_BRIDGE LIKE LINE OF IT_BRIDGE,
WA_MOVE LIKE LINE OF IT_MOVE ,
WA_SUM LIKE LINE OF IT_SUM,
WA_lips LIKE LINE OF IT_lips.
*---------------------------------------------------------------------*
**DATA :
*---------------------------------------------------------------------*
DATA: W_FILENAME TYPE STRING,
W_UNIXFN TYPE STRING,
w_lines type i,
W_GMENGE(17) TYPE C,
W_TMENGE(17) TYPE C,
W_ZLFIMG(17) TYPE C,
W_LFIMG like lips-lfimg.
DATA : MD_NUMBER TYPE MBLNR,
W_PSTYP LIKE EKPO-PSTYP,
w_input like lips-vbeln,
w_slip like ZVVF_MT25_OUTMOV-zfile.
.
*---------------------------------------------------------------------*
**INITIALIZATION :
*---------------------------------------------------------------------*
INITIALIZATION.

*---------------------------------------------------------------------*
**SELECTION-SCREEN :
*---------------------------------------------------------------------*

SELECTION-SCREEN:BEGIN OF BLOCK BL1 WITH FRAME .

PARAMETER:
pr_file type ZFILE,
pr_path type ZFILE.
SELECTION-SCREEN END OF BLOCK BL1.
*---------------------------------------------------------------------*
**AT SELECTION-SCREEN :
*---------------------------------------------------------------------*
AT SELECTION-SCREEN.
perform check_data.

*---------------------------------------------------------------------*
**START-OF-SELECTION :
*---------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM SAVE_ON_UNIX_SERVE.
PERFORM RECORD_COUNT.
*&---------------------------------------------------------------------*
*& Form RECORD_COUNT
*&---------------------------------------------------------------------*
FORM RECORD_COUNT .
WRITE : /01 'Total Records :',w_lines.
ENDFORM. " RECORD_COUNT
*&---------------------------------------------------------------------*
*& Form SAVE_ON_UNIX_SERVE
*&---------------------------------------------------------------------*
FORM SAVE_ON_UNIX_SERVE .

DATA : W_UNIX_FILE TYPE RLGRAP-FILENAME.
DATA : ERRFLAG.
DATA : WA_DETAIL TYPE STRING.

DATA : BEGIN OF IT_PO OCCURS 0,
VBELN LIKE ZVVF_MT25_OUTMOV-VBELN,
WERKS LIKE ZVVF_MT25_OUTMOV-WERKS,
GMENGE LIKE ZVVF_MT25_OUTMOV-GMENGE,
TMENGE LIKE ZVVF_MT25_OUTMOV-TMENGE,
ZLFIMG LIKE ZVVF_MT25_OUTMOV-LFIMG,
ZSLIPNO LIKE ZVVF_MT25_OUTMOV-ZSLIPNO,
END OF IT_PO.

DATA : WA_PO LIKE LINE OF IT_PO.
DATA :begin of itab occurs 0,

text(255) type c,

end of itab .
DATA : WA_LINE LIKE LINE OF itab.
DATA : DELIMITER(1) VALUE ','.


W_UNIX_FILE = pr_file.
CONCATENATE pr_PATH '/' W_UNIX_FILE '.txt' INTO W_UNIXFN .

CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = w_UNIXFN
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
TABLES
DATA_TAB = ITAB.

IF SY-SUBRC NE 0.


ERRFLAG = 'X'.
MESSAGE I002(MG) WITH W_UNIXFN.
MESSAGE A099(MG).
ENDIF.
LOOP AT ITAB INTO WA_LINE.

SPLIT WA_LINE AT DELIMITER INTO
WA_PO-VBELN
WA_PO-WERKS
W_GMENGE
W_TMENGE
W_ZLFIMG
WA_PO-ZSLIPNO
IN CHARACTER MODE .

WA_PO-GMENGE = W_GMENGE.
WA_PO-TMENGE = W_TMENGE.
WA_PO-ZLFIMG = W_ZLFIMG.
perform MATNR_FORMAT_INPUT using WA_PO-VBELN.

IF NOT WA_PO IS INITIAL.
APPEND WA_PO TO IT_PO.
ENDIF.
CLEAR : W_ZLFIMG,W_TMENGE,W_GMENGE.
ENDLOOP.
describe table IT_PO lines w_lines.
if w_lines ne 0.
clear ERRFLAG.
endif.


IF NOT IT_PO[] IS INITIAL.

SELECT vbeln posnr werks matnr charg lfimg FROM lips INTO CORRESPONDING
FIELDS
OF TABLE IT_lips FOR ALL ENTRIES IN IT_PO WHERE VBELN = IT_PO-VBELN AND
WERKS = IT_PO-WERKS and
charg ne ' '.
LOOP AT IT_lips INTO WA_lips.
MOVE-CORRESPONDING WA_lips TO WA_SUM.
COLLECT WA_SUM INTO IT_SUM.
ENDLOOP.

endif.

LOOP AT IT_po INTO WA_po.
READ TABLE IT_SUM INTO WA_SUM WITH KEY VBELN = WA_po-VBELN
WERKS = WA_po-WERKS.
IF SY-SUBRC = 0.


UPDATE ZVVF_MT25_OUTMOV SET lfimg = WA_SUM-lfimg
zlfimg = WA_po-zlfimg
gmenge = WA_po-gmenge
tmenge = WA_po-tmenge
zfile = pr_file
charg = ' '
zdown = 'X'
zslipno = WA_po-zslipno
where
VBELN = WA_po-VBELN and
WERKS = WA_po-WERKS.
if sy-subrc = 4.

it_msg-vbeln = WA_po-VBELN.
append it_msg.

endif.



endif.

clear : wa_bridge,wa_po,wa_sum.
endloop.



IF ERRFLAG = 'X'.
FORMAT COLOR = 6.
WRITE : /01 'File unable to download' , 132 ''.
FORMAT COLOR OFF.
ELSE.

if not it_msg[] is initial.
FORMAT COLOR = 6.
WRITE : /'Following Delivery Documents are not',
'uploaded to Weighbridge'.
loop at it_msg.
write : /2 it_msg-vbeln.
endloop.

FORMAT COLOR OFF.
else.


FORMAT COLOR = 5.
WRITE : /'File Successfuly Downloaded from local drive to Table',
'ZVVF_MT25_OUTMOV', 132 ''.
WRITE : / W_UNIXFN , 132 ''.
FORMAT COLOR OFF.
endif.
ENDIF.

ENDFORM. " SAVE_ON_UNIX_SERVE
*&--------------------------------------------------------------------*
*& Form check_data
*&--------------------------------------------------------------------*
* check data
*---------------------------------------------------------------------*
form check_data.

select single zfile into w_slip from ZVVF_MT25_OUTMOV where
zfile = pr_file .
* werks = pr_plant.
if sy-subrc = 0.
message e130 with pr_file.
endif.

endform.

*&--------------------------------------------------------------------*
*& 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.

No comments:

link us...

For Visitors

if you want to publish or Add something on ERP, SAP , SAP FUNCTIONAL, SAP ABAP then mail us along with your email-id. contain must be yours

email-id :- avinashkr_raj@yahoo.com(any email)

email-id :- avinaskr_raj.abap@blogger.com ( use only gmail)