涉及两个BAPI:录入数量BAPI_MATPHYSINV_COUNT
修改数量:BAPI_MATPHYSINV_CHANGECOUNT
REPORT ZSC_133 NO STANDARD PAGE HEADING
MESSAGE-ID zsc.
TABLES:
ISEG,IKPF.
type-pools: slis.
DATA:g_variant LIKE disvariant.
DATA: it_alv TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA gt_fieldcat TYPE lvc_t_fcat .
DATA ls_fcat TYPE lvc_s_fcat .
DATA: g_status_set TYPE slis_formname,
g_layout TYPE slis_layout_alv, " alv layout
g_sort TYPE slis_t_sortinfo_alv, " ALV sort table
g_user_command TYPE slis_formname VALUE 'USER_COMMAND',
g_events TYPE slis_t_event.
*ALV相关声明
TYPE-POOLS: slis.
DATA: wcl_container TYPE REF TO cl_gui_custom_container, "一个容器
wcl_alv TYPE REF TO cl_gui_alv_grid. "一个ALV对象
DATA gs_layout TYPE lvc_s_layo .
*data:count type i.
DATA: INPUT TYPE KCDE_INTERN_STRUC OCCURS 100 WITH HEADER LINE.
DATA: begin of t_itab.
INCLUDE STRUCTURE ISEG. "atflv
DATA: NAME1 TYPE t001w-NAME1.
DATA: LGOBE TYPE t001l-LGOBE.
DATA: MAKTX TYPE MAKT-MAKTX.
DATA: TDATE(10) TYPE C.
DATA: end of t_itab.
DATA: BEGIN OF T_HEAD.
data: IBLNR LIKE IKPF-IBLNR.
DATA: GJAHR LIKE IKPF-GJAHR.
DATA: ZLDAT LIKE IKPF-ZLDAT.
DATA: END OF T_HEAD.
DATA: gt_output LIKE TABLE OF t_itab.
DATA: gt_head like TABLE OF t_head.
DATA: GT_UP LIKE ISEG OCCURS 0 WITH HEADER LINE.
DATA: GT_UPDATE LIKE ISEG OCCURS 0 WITH HEADER LINE.
DATA: GT_UPHEAD LIKE IKPF OCCURS 0 WITH HEADER LINE.
DATA: T_DATE LIKE ISEG-ZLDAT.
DATA: T_I TYPE I.
data: T_IBLNR LIKE IKPF-IBLNR.
data: T_ZSTAT LIKE IKPF-ZSTAT.
DATA: T_XZAEL LIKE ISEG-XZAEL.
DATA: T_MESSAGE TYPE BAPIRET2-MESSAGE.
data: ITEMS LIKE BAPI_PHYSINV_ITEM OCCURS 0 WITH HEADER LINE.
data: C_ITEMS LIKE BAPI_PHYSINV_COUNT_ITEMS OCCURS 0 WITH HEADER LINE.
DATA: HEAD LIKE BAPI_PHYSINV_HEAD OCCURS 0 WITH HEADER LINE.
DATA: RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
DATA: SERIALNUMBERS LIKE BAPI_PHYSINV_SERIALNUMBERS OCCURS 0.
DATA: T_UNIT TYPE ISEG-ERFME.
DATA: T_P TYPE I.
*****************************
*----------------------------------------------------------------------*
* INTERNAL TABLES AND WORK AREAS *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* GLOBAL VARIABLES *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* PARAMETERS AND SELECT-OPTIONS *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK rad1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:
P_IBLNR FOR ISEG-IBLNR,
P_GJAHR FOR ISEG-GJAHR DEFAULT SY-DATUM+0(4).
PARAMETERS: r1 RADIOBUTTON GROUP rad1 DEFAULT 'X',
r2 RADIOBUTTON GROUP rad1,
r3 RADIOBUTTON GROUP rad1 .
PARAMETERS: P_LFILE LIKE RLGRAP-FILENAME .
SELECTION-SCREEN END OF BLOCK rad1.
************************************************************************
* MAIN PROCESS *
************************************************************************
*----------------------------------------------------------------------*
* INITIALIZATION *
*----------------------------------------------------------------------*
*INITIALIZATION.
**----------------------------------------------------------------------
* START-OF-SELECTION *
*----------------------------------------------------------------------*
*****取数
if r1 = 'X'.
if P_IBLNR[] is INITIAL or P_GJAHR[] is INITIAL.
MESSAGE i000 WITH '查询条件:凭证、年度不能为空!'.
STOP.
endif.
PERFORM get_data.
endif.
***导入
if r2 = 'X'OR r3 = 'X'.
PERFORM GET_FILENAME USING P_LFILE
CHANGING P_LFILE.
if p_lfile <> ''.
PERFORM up_data.
endif.
endif.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA .
select ISEG~IBLNR ISEG~GJAHR
ISEG~WERKS T001W~NAME1
ISEG~LGORT t001l~LGOBE
ISEG~ZEILI ISEG~MATNR MAKT~MAKTX
ISEG~CHARG ISEG~BSTAR
ISEG~MENGE ISEG~MEINS ISEG~ERFMG ISEG~ERFME
ISEG~ZLDAT
ISEG~XZAEL
* ISEG~ZLDAT AS TDATE
INTO CORRESPONDING FIELDS OF TABLE GT_OUTPUT
FROM ISEG
JOIN T001W ON ISEG~WERKS = T001W~WERKS
JOIN T001L ON ISEG~WERKS = T001L~WERKS AND ISEG~LGORT = T001L~LGORT
JOIN MAKT ON ISEG~MATNR = MAKT~MATNR
WHERE ISEG~IBLNR IN P_IBLNR AND
ISEG~GJAHR IN P_GJAHR AND
MAKT~SPRAS = 1.
LOOP AT GT_OUTPUT INTO T_ITAB.
IF T_ITAB-ZLDAT <> '' AND T_ITAB-ZLDAT <> '00000000'.
T_ITAB-TDATE = T_ITAB-ZLDAT.
replace all occurrences of '-' in T_ITAB-TDATE with space.
replace all occurrences of '.' in T_ITAB-TDATE with space.
condense T_ITAB-TDATE no-gaps.
MODIFY GT_OUTPUT FROM T_ITAB.
ENDIF.
ENDLOOP.
***呈现
PERFORM display_data.
ENDFORM. " GET_DATA
FORM display_data.
IF gt_output[] is INITIAL.
return.
ENDIF.
* sort gt_display by PRUEFLOS MERKNR.
PERFORM display_alv TABLES gt_output USING '库存盘点信息'.
ENDFORM. "DISPLAY_DATA
FORM build_fieldcat.
REFRESH it_alv.
PERFORM alv_append USING 'IBLNR' '盘点凭证' .
PERFORM alv_append USING 'GJAHR' '年度' .
PERFORM alv_append USING 'WERKS' '工厂' .
PERFORM alv_append USING 'NAME1' '工厂名称' .
PERFORM alv_append USING 'LGORT' '库存地点' .
PERFORM alv_append USING 'LGOBE' '库存名称'.
PERFORM alv_append USING 'ZEILI' '行号'.
PERFORM alv_append USING 'MATNR' '产品代码' .
PERFORM alv_append USING 'MAKTX' '产品名称' .
PERFORM alv_append USING 'CHARG' '批次' .
PERFORM alv_append USING 'BSTAR' '存货类型' .
PERFORM alv_append USING 'ERFMG' '盘点数量' .
PERFORM alv_append USING 'ERFME' '盘点单位' .
* PERFORM alv_append USING 'ZLDAT' '盘点日期'.
PERFORM alv_append USING 'TDATE' '盘点日期'.
PERFORM alv_append USING 'XZAEL' '盘点标记'.
* PERFORM alv_append USING 'MENGE' '基本数量' .
* PERFORM alv_append USING 'MEINS' '基本单位'.
ENDFORM. " file_upload
*&---------------------------------------------------------------------*
*& incluede FORM display_ALV *
*&---------------------------------------------------------------------*
FORM display_ALV TABLES it_data USING title.
PERFORM build_fieldcat.
g_layout-colwidth_optimize = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = it_alv[]
is_variant = g_variant
i_save = 'X'
is_layout = g_layout
i_grid_title = title
TABLES
t_outtab = it_data
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM.
*&--------------------------------------------------------------------*
*& Form alv_append
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->FIELDNAME text
* -->SELTEXT_1 text
*---------------------------------------------------------------------*
FORM alv_append USING fieldname seltext_1.
CLEAR it_alv.
it_alv-fieldname = fieldname.
it_alv-seltext_l = seltext_1.
APPEND it_alv.
ENDFORM. "alv_append
*&---------------------------------------------------------------------*
*& Form UP_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UP_DATA .
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
FILENAME = P_LFILE
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 256
I_END_ROW = 65536
TABLES
INTERN = INPUT
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE E000(zsc) WITH '文件路径有误!'.
ENDIF.
LOOP AT INPUT.
IF input-row = '0001'.
CONTINUE. "第一行是字段名,直接跳过
ELSE.
CASE INPUT-COL.
WHEN '0001'.
GT_UP-IBLNR = INPUT-VALUE. "盘点凭证
WHEN '0002'.
GT_UP-GJAHR = INPUT-VALUE. "年度
WHEN '003'.
GT_UP-WERKS = INPUT-VALUE.
WHEN '005'.
GT_UP-LGORT = INPUT-VALUE.
WHEN '0007'.
GT_UP-ZEILI = INPUT-VALUE. "行号
WHEN '0008'.
GT_UP-MATNR = INPUT-VALUE. "
WHEN '0010'.
GT_UP-CHARG = INPUT-VALUE. "
WHEN '0012'.
GT_UP-ERFMG = INPUT-VALUE. "盘点数量
GT_UP-MENGE = INPUT-VALUE. "基本数量
WHEN '0014'.
GT_UP-ZLDAT = INPUT-VALUE. "盘点日期
ENDCASE.
AT END OF ROW.
APPEND GT_UP.
CLEAR GT_UP.
ENDAT.
ENDIF.
ENDLOOP.
***做处理
CLEAR:GT_UPDATE.
CLEAR:ITEMS.
T_I = 0.
LOOP AT GT_UP.
****盘点标记
SELECT SINGLE DSTAT
INTO T_ZSTAT
FROM IKPF
WHERE IKPF~IBLNR = GT_UP-IBLNR AND
IKPF~GJAHR = GT_UP-GJAHR .
IF T_ZSTAT = 'X'.
CONCATENATE '凭证号:' GT_UP-IBLNR '年度:' GT_UP-GJAHR '提示:已经全部过账,不允许再导入!' INTO T_MESSAGE.
CONDENSE T_MESSAGE.
MESSAGE I000(zsc) WITH T_MESSAGE.
STOP.
ENDIF.
SELECT SINGLE XDIFF
INTO T_XZAEL
FROM ISEG
WHERE ISEG~IBLNR = GT_UP-IBLNR AND
ISEG~GJAHR = GT_UP-GJAHR AND
ISEG~ZEILI = GT_UP-ZEILI.
IF T_XZAEL = 'X'.
CONCATENATE '凭证号:' GT_UP-IBLNR '年度:' GT_UP-GJAHR '项目号:' GT_UP-ZEILI '提示:已经过账,不允许再导入!' INTO T_MESSAGE.
CONDENSE T_MESSAGE.
MESSAGE I000(zsc) WITH T_MESSAGE.
STOP.
ENDIF.
***检测日期
* replace all occurrences of '-' in GT_UP-ZLDAT with space.
* condense GT_UP-ZLDAT no-gaps.
IF GT_UP-ZLDAT = ''OR GT_UP-ZLDAT = '00000000'.
MESSAGE I000(zsc) WITH '盘点日期不能为空,请核对导入文件!'.
STOP.
ENDIF.
IF T_I = 0.
T_DATE = GT_UP-ZLDAT.
T_I = T_I + 1.
ELSE.
IF GT_UP-ZLDAT <> T_DATE.
MESSAGE I000(zsc) WITH '盘点日期不一致,请核对导入文件!'.
STOP.
ENDIF.
ENDIF.
SELECT *
INTO CORRESPONDING FIELDS OF GT_UPDATE
FROM ISEG
WHERE ISEG~IBLNR = GT_UP-IBLNR AND
ISEG~GJAHR = GT_UP-GJAHR AND
ISEG~ZEILI = GT_UP-ZEILI.
ENDSELECT.
IF SY-SUBRC = 0.
IF R2 = 'X' AND GT_UPDATE-XZAEL = 'X'.
CONCATENATE '凭证号:' GT_UP-IBLNR '年度:' GT_UP-GJAHR '项目号:' GT_UP-ZEILI '提示:已经盘点过,请选择批量修改!' INTO T_MESSAGE.
CONDENSE T_MESSAGE.
MESSAGE I000(zsc) WITH T_MESSAGE.
STOP.
ENDIF.
IF R3 = 'X' AND GT_UPDATE-XZAEL = ''.
CONCATENATE '凭证号:' GT_UP-IBLNR '年度:' GT_UP-GJAHR '项目号:' GT_UP-ZEILI '提示:还未盘点,请选择批量输入!' INTO T_MESSAGE.
CONDENSE T_MESSAGE.
MESSAGE I000(zsc) WITH T_MESSAGE.
STOP.
ENDIF.
***检测明细项目
if GT_UP-MATNR = GT_UPDATE-MATNR AND GT_UP-WERKS = GT_UPDATE-WERKS AND GT_UPDATE-LGORT = GT_UP-LGORT AND GT_UP-CHARG = GT_UPDATE-CHARG.
ELSE.
CONCATENATE '凭证号:' GT_UP-IBLNR '年度:' GT_UP-GJAHR '项目号:' GT_UP-ZEILI '提示:物料、工厂、库存、批次有不对,请核对!' INTO T_MESSAGE.
CONDENSE T_MESSAGE.
MESSAGE I000(zsc) WITH T_MESSAGE.
STOP.
ENDIF.
* IF GT_UP-ERFMG <> ''.
*** 调BAPI 2013.4.19 jwy add
* ITEMS-PHYSINVENTORY = GT_UPDATE-IBLNR.
* ITEMS-FISCALYEAR = GT_UPDATE-GJAHR.
* ITEMS-ITEM = GT_UPDATE-ZEILI.
* ITEMS-MATERIAL = GT_UPDATE-MATNR.
* ITEMS-PLANT = GT_UPDATE-WERKS.
* ITEMS-STGE_LOC = GT_UPDATE-LGORT.
* ITEMS-BATCH = GT_UPDATE-CHARG.
* ITEMS-SPEC_STOCK = GT_UPDATE-SOBKZ.
* ITEMS-STOCK_TYPE = GT_UPDATE-BSTAR.
* ITEMS-SALES_ORD = GT_UPDATE-KDAUF.
* ITEMS-S_ORD_ITEM = GT_UPDATE-KDPOS.
* ITEMS-SCHED_LINE = GT_UPDATE-KDEIN.
* ITEMS-VENDOR = GT_UPDATE-LIFNR.
* ITEMS-CUSTOMER = GT_UPDATE-KUNNR.
* ITEMS-PRODBINLOC = GT_UPDATE-
GT_UPDATE-ERFMG = GT_UP-ERFMG.
GT_UPDATE-MENGE = GT_UP-MENGE.
GT_UPDATE-USNAZ = SY-UNAME.
GT_UPDATE-ZLDAT = GT_UP-ZLDAT.
GT_UPDATE-XZAEL = 'X'.
T_HEAD-IBLNR = GT_UP-IBLNR.
T_HEAD-GJAHR = GT_UP-GJAHR.
T_HEAD-ZLDAT = GT_UP-ZLDAT.
APPEND T_HEAD TO GT_HEAD.
CLEAR T_HEAD.
APPEND GT_UPDATE.
CLEAR:GT_UPDATE.
* ENDIF.
* MODIFY GT_UPDATE.
ENDIF.
ENDLOOP.
***处理抬头
T_P = 0.
CLEAR:GT_UPHEAD.
sort GT_HEAD by IBLNR GJAHR.
DELETE ADJACENT DUPLICATES FROM GT_HEAD COMPARING ALL FIELDS.
CLEAR:HEAD,ITEMS,C_ITEMS.
*** 2013.4.19 取盘点项目数据
LOOP AT GT_HEAD INTO T_HEAD.
T_I = 0.
CALL FUNCTION 'BAPI_MATPHYSINV_GETDETAIL'
EXPORTING
PHYSINVENTORY = T_HEAD-IBLNR
FISCALYEAR = T_HEAD-GJAHR
IMPORTING
HEAD = HEAD
TABLES
ITEMS = ITEMS
RETURN = RETURN
EXCEPTIONS
OTHERS = 01.
if SY-SUBRC <> 0.
MESSAGE I000(zsc) WITH '取数失败!'.
STOP.
endif.
****处理
REFRESH C_ITEMS.
CLEAR:C_ITEMS.
LOOP AT GT_UPDATE WHERE IBLNR = T_HEAD-IBLNR AND GJAHR = T_HEAD-GJAHR.
* READ TABLE ITEMS WITH KEY PHYSINVENTORY = GT_UPDATE-IBLNR AND FISCALYEAR = GT_UPDATE-
C_ITEMS-ITEM = GT_UPDATE-ZEILI.
C_ITEMS-MATERIAL = GT_UPDATE-MATNR.
C_ITEMS-BATCH = GT_UPDATE-CHARG.
C_ITEMS-ENTRY_QNT = GT_UPDATE-ERFMG.
C_ITEMS-ENTRY_UOM = GT_UPDATE-ERFME.
if GT_UPDATE-ERFMG = 0.
C_ITEMS-ZERO_COUNT = 'X'.
endif.
****单位转换
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
EXPORTING
INPUT = T_UNIT
LANGUAGE = sy-langu
IMPORTING
OUTPUT = GT_UPDATE-ERFME
EXCEPTIONS
UNIT_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
C_ITEMS-ENTRY_UOM = T_UNIT.
ELSE.
* MESSAGE I000(zsc) WITH '单位转换出错!'.
* STOP.
ENDIF.
APPEND C_ITEMS.
CLEAR: C_ITEMS.
ENDLOOP.
****单位转换
****修改数量MI05
* CALL FUNCTION 'BAPI_MATPHYSINV_CHANGECOUNT'
* EXPORTING
* PERCENTAGE_VARIANCE = T_HEAD-IBLNR
* FISCALYEAR = T_HEAD-GJAHR
** PHYSINVENTORY = OBJECT-KEY-PHYSINVENTORY
* TABLES
* ITEMS = C_ITEMS
* RETURN = RETURN
* SERIALNUMBERS = SERIALNUMBERS
* EXCEPTIONS
* OTHERS = 01.
****录入数量MI04
if r2 = 'X'.
CALL FUNCTION 'BAPI_MATPHYSINV_COUNT'
EXPORTING
PHYSINVENTORY = T_HEAD-IBLNR
FISCALYEAR = T_HEAD-GJAHR
* PERCENTAGE_VARIANCE = PERCENTAGE_VARIANCE
COUNT_DATE = T_HEAD-ZLDAT
TABLES
ITEMS = C_ITEMS
RETURN = RETURN
* SERIALNUMBERS = SERIALNUMBERS
* EXTENSIONIN = EXTENSIONIN
EXCEPTIONS
OTHERS = 1.
endif.
if r3 = 'X'.
CALL FUNCTION 'BAPI_MATPHYSINV_CHANGECOUNT'
EXPORTING
PHYSINVENTORY = T_HEAD-IBLNR
FISCALYEAR = T_HEAD-GJAHR
* PERCENTAGE_VARIANCE = PERCENTAGE_VARIANCE
TABLES
ITEMS = C_ITEMS
RETURN = RETURN
* SERIALNUMBERS = SERIALNUMBERS
* EXTENSIONIN = EXTENSIONIN
EXCEPTIONS
OTHERS = 1.
endif.
LOOP AT RETURN WHERE TYPE = 'E'.
CONCATENATE T_MESSAGE ',' RETURN-MESSAGE INTO T_MESSAGE.
CONDENSE T_MESSAGE.
T_I = 1.
ENDLOOP.
IF T_I = 0.
COMMIT WORK.
IF SY-SUBRC = 0.
T_P = 1.
* MESSAGE S000(zsc) WITH '数据上传成功!'.
ELSE.
MESSAGE S000(zsc) WITH '数据上传失败!'.
STOP.
ENDIF.
ELSE.
MESSAGE I000(zsc) WITH T_MESSAGE.
STOP.
ENDIF.
REFRESH return.
CLEAR:return.
ENDLOOP.
IF T_P = 1.
MESSAGE S000(zsc) WITH '数据上传成功!'.
ENDIF.
* IF GT_UPDATE[] IS INITIAL.
* MESSAGE I000(zsc) WITH '不存在需要修改的记录行,请核对导入文件!'.
* ELSE.
* MODIFY ISEG FROM TABLE GT_UPDATE.
*
* IF SY-SUBRC = 0.
** MESSAGE S000(zsc) WITH '数据上传成功!'.
* ELSE.
* MESSAGE E000(zsc) WITH '数据上传失败!'.
* ENDIF.
* ENDIF.
* LOOP AT GT_HEAD INTO T_HEAD.
* SELECT *
* INTO CORRESPONDING FIELDS OF GT_UPHEAD
* FROM IKPF
* WHERE IKPF~IBLNR = T_HEAD-IBLNR AND
* IKPF~GJAHR = T_HEAD-GJAHR .
* ENDSELECT.
* IF SY-SUBRC = 0.
* GT_UPHEAD-ZLDAT = T_HEAD-ZLDAT.
*****判断是否全部盘点
* SELECT SINGLE IBLNR INTO T_IBLNR
* FROM ISEG
* WHERE ISEG~IBLNR = T_HEAD-IBLNR AND
* ISEG~GJAHR = T_HEAD-GJAHR AND
* ISEG~XZAEL <> 'X'.
* IF SY-SUBRC = 0.
* GT_UPHEAD-ZSTAT = 'A'.
* ELSE.
* GT_UPHEAD-ZSTAT = 'X'.
* ENDIF.
* APPEND GT_UPHEAD.
* CLEAR:GT_UPHEAD.
* ENDIF.
* ENDLOOP.
*
* IF GT_UPHEAD[] IS INITIAL.
* MESSAGE I000(zsc) WITH '不存在需要修改的记录行,请核对导入文件!'.
* ELSE.
* MODIFY IKPF FROM TABLE GT_UPHEAD.
* IF SY-SUBRC = 0.
* MESSAGE S000(zsc) WITH '数据上传成功!'.
* ELSE.
* MESSAGE E000(zsc) WITH '数据上传失败!'.
* STOP.
* ENDIF.
* ENDIF.
****
* PERFORM get_data.
ENDFORM. " UP_DATA
*&---------------------------------------------------------------------*
*& Form get_filename
*&---------------------------------------------------------------------*
FORM GET_FILENAME USING P_PATH LIKE RLGRAP-FILENAME
CHANGING P_FILE LIKE RLGRAP-FILENAME.
DATA:L_WRK_FILENAME LIKE RLGRAP-FILENAME,
L_WRK_MASK LIKE LGRWO-EXP_FILE.
* mask
L_WRK_MASK = ',*.xls,*.xls.'.
* get file name
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_PATH = P_FILE
MASK = L_WRK_MASK
MODE = 'O'
IMPORTING
FILENAME = L_WRK_FILENAME
EXCEPTIONS
INV_WINSYS = 01
NO_BATCH = 02
SELECTION_CANCEL = 03
SELECTION_ERROR = 04
OTHERS = 05.
IF SY-SUBRC = 0.
P_FILE = L_WRK_FILENAME.
ELSE.
ENDIF.
ENDFORM. " get_filename