ITPub博客

首页 > Linux操作系统 > Linux操作系统 > memory id SAP例子理解

memory id SAP例子理解

原创 Linux操作系统 作者:aoyq 时间:2009-08-31 17:19:52 0 删除 编辑

REPORT  ZHR_TEST_010                            .
tables:VBRK, VBRP.
*2.在010中定义USERCOMMAND事件:
DATA TEXT1(10) VALUE 'Exporting'.

DATA ITAB LIKE SBOOK OCCURS 0 WITH HEADER LINE.

DO 5 TIMES.
  ITAB-BOOKID = 100 + SY-INDEX.
  APPEND ITAB.
ENDDO.

EXPORT TEXT1
       TEXT2 FROM 'Literal'      "将‘literal’字符串以text2为名字,存到MEMORY ID 'TEXT'里
  TO MEMORY ID 'text'.

EXPORT ITAB
  TO MEMORY ID 'table'.


SUBMIT ZHR_TEST_020 AND RETURN.

SUBMIT ZHR_TEST_030.

****************************

*&---------------------------------------------------------------------*
*& Report  ZHR_TEST_020                                                *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  ZHR_TEST_020                            .
DATA: TEXT1(10),
      TEXT3 LIKE TEXT1 VALUE 'Initial'.

IMPORT TEXT3 FROM MEMORY ID 'text'.
WRITE: / SY-SUBRC, TEXT3.
IMPORT TEXT1 FROM MEMORY ID 'text'.
WRITE: / SY-SUBRC, TEXT1.
IMPORT TEXT1 to TEXT1 FROM MEMORY ID 'text'.
WRITE: / SY-SUBRC, TEXT1.
************************************************************************
*IMPORT [TO ] [TO ] ... FROM MEMORY ID .
*
*This statement reads the data objects specified in the list from a cluster in memory.
* If you do not use the TO option, the data object in memory is assigned
* to the data object in the program with the same name. If you do use the option,
* the data object is read from memory into the field . The name identifies
* the cluster in memory. It may be up to 32 characters long

IMPORT TEXT2 TO TEXT1 FROM MEMORY ID 'text'.   "将MEMORY ID ‘text’中字段‘text2’的内容读到text1里
WRITE: / SY-SUBRC, TEXT1.

WRITE: /  TEXT3.

****************************

*&---------------------------------------------------------------------*
*& Report  ZHR_TEST_030                                                *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  ZHR_TEST_030                            .
DATA JTAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.

IMPORT ITAB TO JTAB FROM MEMORY ID 'table'.

LOOP AT JTAB.
  WRITE / JTAB-BOOKID.
ENDLOOP.

free memory id 'text'.
free memory id 'table'.

**********************************************

*********************************************

以下是结果:

    0  Initial
    0  Exporting
    0  Exporting
    0  Literal
Initial

00000101
00000102
00000103
00000104
00000105

*&---------------------------------------------------------------------*
*& Report  ZHR_TEST_040                                                *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  ZHR_TEST_040                            .


DATA: TEXT(10) VALUE '0123456789',
      IDEN(3)  VALUE 'XYZ'.

WRITE: / 'iden1', IDEN .
EXPORT TEXT TO MEMORY ID IDEN.
WRITE: / 'iden2', IDEN .
WRITE: / 'text1', TEXT.

TEXT = 'xxxxxxxxxx'.
IMPORT TEXT FROM MEMORY ID IDEN.
WRITE: / SY-SUBRC, TEXT.

FREE MEMORY.

TEXT = 'xxxxxxxxxx'.
IMPORT TEXT FROM MEMORY ID IDEN.
WRITE: / SY-SUBRC, TEXT.
***************************************************

结果:

iden1 XYZ
iden2 XYZ
text1 0123456789
    0  0123456789
    4  xxxxxxxxxx

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7762936/viewspace-613643/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 崩溃的我
下一篇: ehr 项目笔记
请登录后发表评论 登录
全部评论

注册时间:2008-06-13

  • 博文量
    23
  • 访问量
    45174