`

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
分享到:
评论

相关推荐

    S变换+Sockwell R G , Mansinha L , Lowe R P . Localization of the complex spectrum: the S transformJ

    s变换用的高斯窗函数( 高斯窗是指数窗的一种,它也无负的旁瓣,而且没有旁瓣波动,因而不回引起计算谱中假的极大值或极小值,而且高斯窗频率窗函数的主瓣比指数窗的主瓣窄,分辨率比指数窗有所提高。

    2021科大讯飞车辆贷违预测大赛冠军源码+全部资料.zip

    2021科大讯飞车辆贷违预测大赛冠军源码+全部资料.zip [资源说明] 1、该项目是团队成员近期最新开发,代码完整,资料齐全,含设计文档等 2、上传的项目源码经过严格测试,功能完善且能正常运行,请放心下载使用! 3、本项目适合计算机相关专业(人工智能、通信工程、自动化、电子信息、物联网等)的高校学生、教师、科研工作者、行业从业者下载使用,可借鉴学习,也可直接作为毕业设计、课程设计、作业、项目初期立项演示等,也适合小白学习进阶,遇到问题不懂就问,欢迎交流。 4、如果基础还行,可以在此代码基础上进行修改,以实现其他功能,也可直接用于毕设、课设、作业等。 5、不懂配置和运行,可远程教学 欢迎下载,学习使用!

    AI图像处理工具包-一键抠图、背景切换、旧照片修复、人像漫画化、视频卡通化(Python+OpenCV+Dlib+TensorFlow).zip

    AI图像处理工具包-一键抠图、背景切换、旧照片修复、人像漫画化、视频卡通化(Python+OpenCV+Dlib+TensorFlow).zip [资源说明] 1、该项目是团队成员近期最新开发,代码完整,资料齐全,含设计文档等 2、上传的项目源码经过严格测试,功能完善且能正常运行,请放心下载使用! 3、本项目适合计算机相关专业(人工智能、通信工程、自动化、电子信息、物联网等)的高校学生、教师、科研工作者、行业从业者下载使用,可借鉴学习,也可直接作为毕业设计、课程设计、作业、项目初期立项演示等,也适合小白学习进阶,遇到问题不懂就问,欢迎交流。 4、如果基础还行,可以在此代码基础上进行修改,以实现其他功能,也可直接用于毕设、课设、作业等。 5、不懂配置和运行,可远程教学 欢迎下载,学习使用!

    基于java+springboot+vue+mysql的远程教育网站设计与实现.docx

    基于java+springboot+vue+mysql的远程教育网站设计与实现.docx

    springboot005学生心理咨询评估系统(源码+数据库+论文+PPT+包调试+一对一指导)

    毕业设计资料,计算机毕业设计,源码,毕业论文,毕业答辩,答辩PPT,Java毕业设计,php毕业设计,ASP.NET毕业设计,毕业指导,计算机作业,php作业,java作业,ASP.NET作业,编程作业,管理系统,网站,app,毕业设计学习,Java学习,php学习,ASP.NET学习,java课程,php课程,ASP.NET课程,答辩技巧,SQLSERVER数据库,Mysql数据库,jdbc,SSM框架,SpringBoot框架,Html5,小程序

    蓝牙串口助手,可以连接HC-05等蓝牙模块,实现单片机设备与手机通讯,安卓手机,蓝牙调试助手,具有按键功能!

    蓝牙串口助手,可以连接HC-05等蓝牙模块,实现单片机设备与手机通讯,安卓手机,蓝牙调试助手,具有按键功能!

    TriLib-2-Model-Loading-Package-2.3.7.unitypackage

    TriLib 2 是一个跨平台的运行时 3D 模型导入器

    “人力资源+大数据+薪酬报告+涨薪调薪”

    人力资源+大数据+薪酬报告+涨薪调薪,在学习、工作生活中,越来越多的事务都会使用到报告,通常情况下,报告的内容含量大、篇幅较长。那么什么样的薪酬报告才是有效的呢?以下是小编精心整理的调薪申请报告,欢迎大家分享。相信老板看到这样的报告,一定会考虑涨薪的哦。

Global site tag (gtag.js) - Google Analytics