************************************************************************
Report to View Detail Of Material Master BASIC DATA.
Start Date 07.05.2007
Request No.-GR3K931783
************************************************************************
TABLES: mara,marc,makt.
DATA: gi_mara LIKE mara OCCURS 1 WITH HEADER LINE,
gi_marc LIKE marc OCCURS 1 WITH HEADER LINE,
gi_makt LIKE makt OCCURS 1 WITH HEADER LINE.
DATA: BEGIN OF gi_download OCCURS 1,
matnr LIKE mara-matnr,"material no
maktx LIKE makt-maktx,"material description
matkl LIKE mara-matkl,"material group
werks LIKE marc-werks,"plant
ekgrp LIKE marc-ekgrp,"purchasing group
spart LIKE mara-spart,"division
meins LIKE mara-meins,"base uit of measure
bismt LIKE mara-bismt,"old material no.
prdha LIKE mara-prdha,"product hierarchy
brgew LIKE mara-brgew,"gross weight
ntgew LIKE mara-ntgew,"net weight
gewei LIKE mara-gewei,"weight unit
volum LIKE mara-volum,"volume
voleh LIKE mara-voleh,"volume unit
zeinr LIKE mara-zeinr,"document no.
zeiar LIKE mara-zeiar,"document type
zeivr LIKE mara-zeivr,"document version
zeifo LIKE mara-zeifo,"page format of document
blanz LIKE mara-blanz,"number of sheets
spras LIKE makt-spras,"language key
END OF gi_download.
DATA: BEGIN OF gi_fieldnames OCCURS 1,
mandt(50),
END OF gi_fieldnames.
*file path and file name data declaration.
DATA: stripped_name LIKE rlgrap-filename,
file_path LIKE rlgrap-filename.
DATA: inpath LIKE ltran-path01,
file LIKE ltran-file01,
outpath LIKE ltran-path02.
Field Symbols ************
FIELD-SYMBOLS
FIELD-SYMBOLS
FIELD-SYMBOLS
FIELD-SYMBOLS
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECTION-SCREEN: SKIP.
SELECT-OPTIONS: s_werks FOR marc-werks.
SELECT-OPTIONS: s_ekgrp FOR marc-ekgrp.
SELECT-OPTIONS: s_matnr FOR mara-matnr.
SELECT-OPTIONS: s_matkl FOR mara-matkl.
SELECT-OPTIONS: s_spart FOR mara-spart.
SELECTION-SCREEN: SKIP.
PARAMETER fnm TYPE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN: SKIP.
SELECTION-SCREEN: END OF BLOCK b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR fnm.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
static = 'X'
CHANGING
file_name = fnm
EXCEPTIONS
mask_too_long = 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.
*For fetching the baisc data.
START-OF-SELECTION.
*******************************************************************
*Getting the general data based on material no,division and material
*group.
*******************************************************************
SELECT * FROM mara INTO TABLE gi_mara
WHERE matnr IN s_matnr
AND spart IN s_spart
AND matkl IN s_matkl.
*******************************************************************
*Getting the plant data based on material no,plant and purchasing
*group.
*******************************************************************
IF NOT gi_mara[] IS INITIAL.
SELECT * FROM marc INTO TABLE gi_marc
FOR ALL ENTRIES IN gi_mara
WHERE matnr EQ gi_mara-matnr
AND werks IN s_werks
AND ekgrp IN s_ekgrp.
ENDIF.
***********************************************************
*Getting the material description based on material no
***********************************************************
IF NOT gi_mara[] IS INITIAL.
SELECT * FROM makt INTO TABLE gi_makt
FOR ALL ENTRIES IN gi_mara
WHERE matnr = gi_mara-matnr.
ENDIF.
Fetching all data into single internal table ********
SORT gi_mara BY matnr.
SORT gi_makt BY matnr.
SORT gi_marc BY matnr.
******Transfering the data into gi_download********
IF s_werks] IS INITIAL and s_ekgrp[ IS INITIAL.
LOOP AT gi_mara ASSIGNING
MOVE-CORRESPONDING
READ TABLE gi_marc ASSIGNING
WITH KEY matnr =
BINARY SEARCH.
IF sy-subrc = 0.
MOVE
MOVE
ENDIF.
READ TABLE gi_makt ASSIGNING
WITH KEY matnr =
BINARY SEARCH.
IF sy-subrc = 0.
MOVE
MOVE
ENDIF.
APPEND gi_download.
CLEAR gi_download.
ENDLOOP.
ELSE.
LOOP AT gi_marc ASSIGNING
READ TABLE gi_mara ASSIGNING
WITH KEY matnr =
BINARY SEARCH.
IF sy-subrc = 0.
MOVE-CORRESPONDING
ENDIF.
READ TABLE gi_makt ASSIGNING
WITH KEY matnr =
BINARY SEARCH.
IF sy-subrc = 0.
MOVE
MOVE
ENDIF.
MOVE
MOVE
APPEND gi_download.
CLEAR gi_download.
ENDLOOP.
ENDIF.
IF gi_download[] IS INITIAL.
MESSAGE i001(sa) WITH 'Data not found'.
LEAVE LIST-PROCESSING.
ENDIF.
********Downloading the basic data*********
gi_fieldnames-mandt = 'Material no'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Material description'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Material group'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Plant'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Purchasing group'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Division'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Base uit of measure'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Old material no.'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Product hierarchy'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Gross weight'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Net weight'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Weight unit'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Volume'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Volume unit'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Document no.'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Document type'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Document version'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Page format of document'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Number of sheets'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Language key'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
EXPORTING
full_name = fnm
IMPORTING
stripped_name = stripped_name
file_path = file_path
EXCEPTIONS
x_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.
CLEAR fnm.
CONCATENATE file_path stripped_name INTO fnm.
CLEAR: inpath,file,stripped_name,file_path,outpath.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = fnm
filetype = 'DAT'
TABLES
data_tab = gi_download
fieldnames = gi_fieldnames
EXCEPTIONS
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
OTHERS = 10.
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
MESSAGE i003(sa) WITH 'File downloaded successfuly' fnm.
ENDIF.
ALSO READ:
- Uploading Data From Excel Sheet To Internal Table Using FM ALSM_EXCEL_TO_INTERNAL_TABLE.
- Uploading Images From PC To An Internal Table Using FM BDS_BUSINESSDOCUMENT_CREATEF.
- Uploading Data To The FTP Server Using FM GUI_UPLOAD And FILE_GET_NAME.
- Sample Program For Creating XML File On Presentation Server.
- Uploading Multiple Files At One Time.
RETURN TO MAIN INDEX:
- Sample Programs On Uploading & Downloading Files.
- Sample Programs On HR ABAP.
- Sample Report Programs On ALV List/ Grid Display.
- Sample Programs On Selection Screen.
- Sample Programs On BDC.
.....Back To MAIN INDEX.
Indeed a shitty piece of junk code...
ReplyDelete