TABLES: t001l, "Storage Locations
mara, "General Material Data
makt, "Material Descriptions
mbew, "Material Valuation
marc. "Plant Data for Material
DATA: bapi_head LIKE bapimathead,
bapi_makt LIKE bapi_makt, "Material Description
bapi_mara1 LIKE bapi_mara, "Client Data
bapi_marax LIKE bapi_marax,
bapi_marc1 LIKE bapi_marc, "Plant View
bapi_marcx LIKE bapi_marcx,
bapi_mbew1 LIKE bapi_mbew, "Accounting View
bapi_mbewx LIKE bapi_mbewx,
bapi_mard1 LIKE bapi_mard, "Storage View
bapi_mardx LIKE bapi_mardx,
bapi_return LIKE bapiret2.
DATA: BEGIN OF int_makt OCCURS 100.
INCLUDE STRUCTURE bapi_makt.
DATA: END OF int_makt.
DATA: BEGIN OF it_data OCCURS 0,
mat_type(4),
ind_sec(1),
plant(4),
stge_loc(4),
mat_desc(40),
base_uom(3),
old_matno(18),
matl_group(9),
document(22),
po_unit(3),
pur_valkey(4),
mfr_no(10),
manu_mat(40),
vendor_lookup(10),
mrp_type(2),
mrp_ctrler(3),
sm_key(3),
proc_type(1),
sloc_exprc(4),
stge_bin(10),
issue_unit(3),
cc_ph_inv(1),
price_ctrl(1),
val_class(4),
moving_pr(11),
price_unit(5),
profit_ctr(10),
matnr(18),
END OF it_data,
is_data LIKE it_data.
DATA: BEGIN OF it_error OCCURS 0,
mat_type(4),
ind_sec(1),
plant(4),
stge_loc(4),
mat_desc(40),
base_uom(3),
old_matno(18),
matl_group(9),
document(22),
po_unit(3),
pur_valkey(4),
mfr_no(10),
manu_mat(40),
vendor_lookup(10),
mrp_type(2),
mrp_ctrler(3),
sm_key(3),
proc_type(1),
sloc_exprc(4),
stge_bin(10),
issue_unit(3),
cc_ph_inv(1),
price_ctrl(1),
val_class(4),
moving_pr(11),
price_unit(5),
profit_ctr(10),
matnr(18),
END OF it_error,
is_error LIKE it_error.
DATA: bdc_tab LIKE bdcdata OCCURS 0 WITH HEADER LINE.
DATA : g_file TYPE string.
DATA : BEGIN OF data_mat OCCURS 0,
datastring TYPE string,
END OF data_mat.
DATA: record(500).
DATA: gv_count TYPE i VALUE 0.
DATA lv_string TYPE string.
TYPES: BEGIN OF ty_string_tab,
line(255),
END OF ty_string_tab.
DATA i_string_tab TYPE STANDARD TABLE OF ty_string_tab.
********************------SELECTION SCREEN----**************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_file TYPE ibipparms-path.
PARAMETERS: r_local RADIOBUTTON GROUP radi,
r_apps RADIOBUTTON GROUP radi.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-003.
PARAMETERS : p_downld LIKE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b2.
*******************AT SELECTION SCREEN *********************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = p_file.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_downld.
PERFORM get_local_file USING p_downld.
*----------------------------------------------------------------------*
* S T A R T O F S E L E C T I O N
*----------------------------------------------------------------------*
START-OF-SELECTION.
g_file = p_file.
PERFORM upload USING g_file. "Upload takes the file from the presentation
PERFORM conversion_extendedview.
PERFORM download_errors.
*&---------------------------------------------------------------------*
*& Form upload
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM upload USING lv_file .
IF r_apps = 'X'.
OPEN DATASET lv_file
FOR INPUT IN TEXT MODE
ENCODING DEFAULT.
IF sy-subrc <> 0.
WRITE: / text-002, sy-subrc.
STOP.
ELSE.
DO.
READ DATASET lv_file INTO record.
SPLIT record AT '~' INTO
it_data-mat_type
it_data-ind_sec
it_data-plant
it_data-stge_loc
it_data-mat_desc
it_data-base_uom
it_data-old_matno
it_data-matl_group
it_data-document
it_data-po_unit
it_data-pur_valkey
it_data-mfr_no
it_data-manu_mat
it_data-vendor_lookup
it_data-mrp_type
it_data-mrp_ctrler
it_data-sm_key
it_data-proc_type
it_data-sloc_exprc
it_data-stge_bin
it_data-issue_unit
it_data-cc_ph_inv
it_data-price_ctrl
it_data-val_class
it_data-moving_pr
it_data-price_unit
it_data-profit_ctr
it_data-matnr.
APPEND it_data.
CLEAR it_data.
ENDDO.
CLOSE DATASET lv_file.
ENDFORM. " upload
*&---------------------------------------------------------------------*
*& Form conversion_extendedview
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM conversion_extendedview .
DATA: lv_matnr LIKE mara-matnr,
lv_lifnr LIKE lfb1-lifnr.
LOOP AT it_data INTO is_data.
CLEAR: lv_matnr,
lv_lifnr.
SELECT SINGLE matnr FROM mara INTO lv_matnr
WHERE bismt = is_data-old_matno AND
meins = is_data-base_uom.
IF sy-subrc NE 0.
MOVE is_data TO is_error.
APPEND is_error TO it_error.
CLEAR is_error.
CONTINUE.
ENDIF.
SELECT SINGLE lifnr INTO lv_lifnr FROM lfb1
WHERE altkn = is_data-vendor_lookup.
IF sy-subrc EQ 0.
SELECT SINGLE lifnr INTO lv_lifnr FROM lfa1
WHERE lifnr = lv_lifnr AND
ktokk = 'ZMNF'.
IF sy-subrc NE 0.
lv_lifnr = ' '.
ENDIF.
ELSE.
lv_lifnr = ' '.
ENDIF.
ENDLOOP.
* WRITE: 'Total Records in Error', gv_count.
PERFORM concatenate_into_string.
PERFORM download_data.
ENDFORM. "conversion_extendedview
*&---------------------------------------------------------------------*
*& Form get_local_file
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_DOWNLOAD text
*----------------------------------------------------------------------*
FORM get_local_file USING p_p_download.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
mask = ',*.*,*.*.'
mode = 'S'
title = 'Lookup for Upload file'(013)
IMPORTING
filename = p_p_download
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
ENDIF.
ENDFORM. " get_local_file
*&---------------------------------------------------------------------*
*& Form concatenate_into_string
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM concatenate_into_string .
DATA: lw_error LIKE LINE OF it_error.
DATA: lw_tab_string LIKE LINE OF i_string_tab,
lw_matnr(10),
lw_plant(3),
lw_stloc(4).
LOOP AT it_error INTO is_error.
MOVE is_error-old_matno TO lw_matnr.
MOVE is_error-plant TO lw_plant.
MOVE is_error-stge_loc TO lw_stloc.
CONCATENATE lw_matnr lw_plant lw_stloc INTO lv_string SEPARATED BY '~'.
MOVE lv_string TO lw_tab_string.
APPEND lw_tab_string TO i_string_tab.
CLEAR: lv_string, lw_tab_string.
ENDLOOP.
ENDFORM. " concatenate_into_string
*&---------------------------------------------------------------------*
*& Form download_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM download_data .
DATA: lv_file TYPE string.
* Move file name to filename of type string acceptable by GUI_DOWNLOAD
lv_file = p_downld.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.