`

Read & Write Operations on App.Server Files Using CL_RSAN_UT_APPSERV_FILE_READER

    博客分类:
  • ABAP
EXT 
阅读更多
Class Methods used in the sample Code

CL_RSAN_UT_FILES F4 F4 Help for Choosing File Name from   GUI or App. Server
CL_RSAN_UT_APPSERV_FILE_WRITER: APPSERVER_FILE_WRITE Write Data to Specified File on Application Server
CL_RSAN_UT_APPSERV_FILE_READER: APPSERVER_FILE_READ Read Specified File from Application Server

Sample Code
One Form routine in sample code narrates how the list materials selected from MAKT table can be written to application server file.  Another form-routine narrates how to read the contents of file using the methods listed in above table.


*&--------------------------------------------------------------------
*& Report  ZVK_CL_RSAN_UT_APPSERV
*&
*&--------------------------------------------------------------------
*& Purpose : Use of Class CL_RSAN_UT_APPSERV_FILE_READER &
*&           CL_RSAN_UT_APPSERV_FILE_WRITER for Read/write operations
*&           on Application Server Files
*&--------------------------------------------------------------------
REPORT  zvk_cl_rsan_ut_appserv.
** Text Elements
* p_matnr  - Material from - to
* p_filenm  - File Name
TYPE-POOLS : rsanm, abap.
TABLES : mara.
 
TYPES : BEGIN OF ty_makt,
matnr TYPE matnr,
maktx TYPE maktx,
END OF ty_makt.
 
DATA : lt_makt TYPE STANDARD TABLE OF ty_makt,
ls_makt TYPE ty_makt,
lt_file_table TYPE rsanm_file_table,
ls_file_table TYPE rsanm_file_line.
 
DATA : lv_applserv         TYPE char01,
lv_title            TYPE string,
lv_gui_extension    TYPE string,
lv_gui_ext_filter   TYPE string,
lv_canceled         TYPE as4flag,
lv_applserv_logical TYPE as4flag,
lv_applserv_al11    TYPE as4flag,
lv_file_name        TYPE string,
lv_lines_written    TYPE i.
 
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
SELECT-OPTIONS : p_matnr FOR mara-matnr OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
 
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME.
PARAMETERS : p_filenm LIKE ibipparms-path OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b2.
 
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_filenm.
CLEAR : lv_canceled , lv_file_name.
MOVE 'X' TO lv_applserv.
MOVE 'Select File from Application Server' TO lv_title.
MOVE ' ' TO lv_applserv_logical.
MOVE 'X' TO lv_applserv_al11.
 
CALL METHOD cl_rsan_ut_files=>f4
EXPORTING
i_applserv         = lv_applserv
i_title            = lv_title
i_gui_extension    = lv_gui_extension
i_gui_ext_filter   = lv_gui_ext_filter
i_applserv_logical = lv_applserv_logical
i_applserv_al11    = lv_applserv_al11
IMPORTING
e_canceled         = lv_canceled
CHANGING
c_file_name        = lv_file_name
EXCEPTIONS
failed             = 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.
ELSE.
IF lv_canceled NE 'X'.
MOVE lv_file_name TO p_filenm.
ENDIF.
ENDIF.
 
START-OF-SELECTION.
MOVE p_filenm TO lv_file_name.
PERFORM extract_data.
PERFORM convert_data.
PERFORM write_data_to_appserver.
PERFORM read_data_from_appserver.
*&--------------------------------------------------------------------
*&      Form  extract_data
*&-------------------------------------------------------------------
*       text
*---------------------------------------------------------------------
FORM extract_data.
REFRESH : lt_makt.
SELECT matnr maktx
FROM makt
INTO TABLE lt_makt
WHERE matnr IN p_matnr
AND   spras EQ sy-langu.
IF sy-subrc NE 0.
MESSAGE 'No data selected' TYPE 'I' DISPLAY LIKE 'E'.
STOP.
ENDIF.
ENDFORM.                    "extract_data

*&-------------------------------------------------------------------
*&      Form  convert_data
*&-------------------------------------------------------------------
*       text
*--------------------------------------------------------------------
FORM convert_data.
REFRESH : lt_file_table.
CLEAR   : ls_file_table.
IF lt_makt[] IS NOT INITIAL.
LOOP AT lt_makt INTO ls_makt.
CLEAR : ls_file_table.
CONCATENATE ls_makt-matnr
ls_makt-maktx INTO ls_file_table
SEPARATED BY '|'.
APPEND ls_file_table TO lt_file_table.
ENDLOOP.
ENDIF.
ENDFORM.                    "convert_data
 
*&--------------------------------------------------------------------
*&      Form  write_data_to_appserver
*&--------------------------------------------------------------------
* Form routine for Creating the File in Application Server
* =========================================================
* Parameter i_overwrite has relevant if an existing file is chosen to
* write the contents
* if Value of Parameter i_overwrite is 'X' then File is overwritten
* otherwise the data is appended to existing file.
* =========================================================
*----------------------------------------------------------------------*
FORM write_data_to_appserver.
IF lt_file_table[] IS NOT INITIAL.
CLEAR : lv_lines_written.
CALL METHOD cl_rsan_ut_appserv_file_writer=>appserver_file_write
EXPORTING
i_filename      = lv_file_name
i_overwrite     = abap_true
i_data_tab      = lt_file_table
IMPORTING
e_lines_written = lv_lines_written
EXCEPTIONS
open_failed     = 1
write_failed    = 2
close_failed    = 3
OTHERS          = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
WRITE :/ 'Data written to ',
lv_file_name.
WRITE :/ 'No of Lines Written ',
lv_lines_written.
ENDIF.
ENDIF.
ENDFORM.                    "write_data_to_appserver
 
*&--------------------------------------------------------------------
*&      Form  read_data_from_appserver
*&--------------------------------------------------------------------
* Form routine to read the contents of the file in application serveR
*---------------------------------------------------------------------
FORM read_data_from_appserver.
REFRESH : lt_file_table.
CALL METHOD cl_rsan_ut_appserv_file_reader=>appserver_file_read
EXPORTING
i_filename   = lv_file_name
CHANGING
c_data_tab   = lt_file_table
EXCEPTIONS
open_failed  = 1
read_failed  = 2
close_failed = 3
OTHERS       = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
WRITE :/ 'Contents of file ', lv_file_name.
WRITE :/ '================================='.
LOOP AT lt_file_table INTO ls_file_table.
WRITE :/ ls_file_table.
ENDLOOP.
ENDIF.
ENDFORM.                    "read_data_from_appserver
分享到:
评论

相关推荐

    RSA.rar_Caín_rsa_rsa 数字签名_大数分解_密码学

    RSA算法是第一个能同时用于加密和数字签名的算法,也易于理解和操作。RSA是被研究得最广泛的公钥算法,从提出到现在已近二十年,经历了各种攻击的考验,逐渐为人们接受,普遍认为是目前最优秀的公钥方案之一。...

    andreibarsan.github.io:AndreiBârsan的博客

    DR:我是AndreiBârsan,拥有我自己的帖子和相关媒体(例如,张贴的屏幕截图和图表),但是该网站的源代码是根据MIT许可发布的。 所有网站内容,除了帖子和相关媒体的版权(c)2015 Authors-根据MIT许可发布。 ...

    RSAN:IJCAI 2020论文“用于联合实体和关系提取的特定于关系的关注网络”的源代码

    IJCAI 2020论文“”的源代码 先决条件 火炬(1.0.1) 恩特克 麻木 六 代码 ├──config.py ├──数据├──DataLoader.py ├──data_prepare.py ├──eval_utils.py ├──杂项│├──init.py │├──...

    Gürsan Mobilya-crx插件

    gürsan家具为您提供装饰解决方案。 在线平台,您可以在其中找到具有许多建议的产品。 我们在办公家具领域的创新思路,我们的原始设计和优质服务在此过程中,直到销售后,我们提供国内外的着名项目,为您的工作空间...

    《计算机网络安全》测试题十六文.pdf

    RSAn4060"等字符串很可能是扫描错误或随机字符。对于这些内容,我们只能推测这可能是加密测试的一部分,也可能是在扫描过程中产生的噪音数据。 6. 特定字符串:"Bob"和"Alice"可能是测试题中用于描述通信双方的代号...

    Presentations:各种介绍。 但是,如果没有扬声器,它们可能不会好......(我自己或其他人)

    Mihai Bîrsan的演讲,正如描述中所提及的,不仅提供了“幻灯片”和代码,还可能包括了其他辅助材料,这些都旨在增强观众的理解和参与。 "JavaScript"是标签,这意味着这个演示可能专注于JavaScript这门编程语言。...

    doc-tr:PHP文档的土耳其语翻译

    磐yöntemikulanırsanızkullanın,çevirmenlerimizinbirçokdilde AMA mutlaka PHP ILE kodlamayapabildiğini,komutsatırından混帐kullanabildiğini,GitHub的kullanabildiğini,HTML已经XML belgelerü...

Global site tag (gtag.js) - Google Analytics