设为首页 收藏本站
查看: 1165|回复: 0

[经验分享] SAP and ABAP Memory总结

[复制链接]

尚未签到

发表于 2015-9-17 11:14:33 | 显示全部楼层 |阅读模式
(一)          Difference Between SAP and ABAP Memory   
(1)、读取和使用方法不同
SAP内存使用SET/GET parameters方法;
SET PARAMETER ID 'MAT' field p_matnr.
GET PARAMETER ID 'MAT' field p_matnr.

ABAP内存使用 EXPORT IMPORT  方法;
export p_matnr = p_matnr to memory id 'ZTESTMAT'.
import p_matnr = p_matnr from memory id 'ZTESTMAT'
(2)、共享范围不同
SAP内存可以被所有的主session访问,内存数据可以在同一个session中不同程序之间,或者不同session之间共享数据;
ABAP内存只能在同个session的不同程序之间共享数据;
(3)、作用范围不同
SAP内存在整个终端session时间内都有效;
ABAP内存只能在一个session时间内有效;
(4)、使用一般原则
SAP内存用于屏幕默认值输入;
ABAP内存用于模块之间传替数据
Can any one tell me what is the difference between ABAP Memory and SAP Memory?
Answers 1:-
Within a main session, when ever you start an application program, it opens up an internal sessions with in the main session. The internal session has a memory area that contains the ABAP program and its associated data.  So when ever you want to  pass data between two internal sessions, then you can use ABAP Memory (i.e import, export).  
When comes to SAP memory (also known as global memory), if the data has to be passed b/w two main sessions, we can use SAP Memory(SPA/GPA Parameters).  SAP Memory can also be used to pass data b/w internal sessions.  
Neelima
Answers 2:-
SAP Memory
SAP memory is a memory area to which all main sessions within a SAPgui have access. You can use SAP memory either to pass data from one program to another within a session, or to pass data from one session to another.  Application programs that use SAP memory must do so using SPA/GPA parameters (also known as SET/GET parameters). These parameters can be set either for a particular user or for a particular program using the SET PARAMETER statement. Other ABAP programs can then retrieve the set parameters using the GET PARAMETER statement. The most frequent use of SPA/GPA parameters is to fill input fields on screens  
ABAP/4 Memory
ABAP memory is a memory area that all ABAP programs within the same internal session can access using the EXPORT and IMPORT statements. Data within this area remains intact during a whole sequence of program calls. To pass data
to a program which you are calling, the data needs to be placed in ABAP memory before the call is made. The internal session of the called program then replaces that of the calling program. The program called can then read from the ABAP memory. If control is then returned to the program which made the initial call, the same process operates in reverse.  
SAP memory
The SAP memory, otherwise known as the global memory, is available to a user during the entire duration of a terminal session. Its contents are retained across transaction boundaries as well as external and internal sessions. The SET PARAMETER and GET PARAMETER statements allow you to write to, or read from, the SAP memory.   
ABAP/4 memory
The contents of the ABAP/4 memory are retained only during the lifetime of an external session (see also Organization of Modularization Units). You can retain or pass data across internal sessions. The EXPORT TO MEMORY and IMPORT FROM MEMORY statements allow you to write data to, or read data from, the ABAP memory.   
(二)          Passing data from one ABAP program to another
1. You have to define an internal table ITAB in program AAA.   
2. In the program AAA you export your ITAB to the memory.  
    EXPORT ITAB TO MEMORY ID 'TD' (ID is the name of memory, you don't need to create it ).   
3. In program BBB you have to declare The same table (same table's name and same fields).   
4. In BBB you can import ITAB :  
    IMPORT ITAB FROM MEMORY ID 'TD'   
5. Now you can export it to AAA after modifications.  
    EXPORT ITAB TO MEMORY ID 'TD'  
6. In AAA :  
    IMPORT ITAB FROM MEMORY ID 'TD'  
This solution is independant to SUBMIT.   
(三)          Example:     
两个程序010和011,选择屏幕是一样的. 010是ALV行显示的,011是WRITE显示的.需要达到的效果是: 点击:MATNR字段则将010的选择屏幕传到011的选择屏幕中去;点击VBELN,则将当前行的VBELN传到011的选择屏幕中去.
Program:010
1.定义010的选择屏幕:
selection-screen begin of block b1 with frame title bt1.
  parameters  PL_BUKRS like VBRK-BUKRS memory id P_BUKRS default '1000'.
  select-options PI_KUNRG for VBRK-KUNRG.
  select-options PI_FKDAT for VBRK-FKDAT.
  select-options PI_VBELN for VBRK-VBELN.
  select-options PI_VGBEL for VBRP-VGBEL.
selection-screen end of block b1.
2.010中定义USERCOMMAND事件:
form user_command using i_ucomm like sy-ucomm is_selfield type slis_selfield.
case i_ucomm.
    when '&IC1'.
      CASE is_selfield-fieldname.
        WHEN 'VBELN'.
            read table itab index is_selfield-tabindex.      "change
            EXPORT ITAB-VBELN TO MEMORY ID 'PT_VBELN'.
            EXPORT is_selfield-fieldname TO MEMORY ID 'PP_FIELD'.
            CALL TRANSACTION 'ZF011' AND SKIP FIRST SCREEN.
        WHEN 'MATNR'.
            EXPORT is_selfield-fieldname TO MEMORY ID 'PP_FIELD'.
            EXPORT PI_KUNRG to memory id 'PP_KUNRG'.   "add
            EXPORT PI_VGBEL TO MEMORY ID 'PP_VGBEL'.   "add
            EXPORT PI_VBELN to memory id 'PP_VBELN'.   "add
            EXPORT PI_FKDAT TO MEMORY ID 'PP_PKDAT'.   "add
            CALL TRANSACTION 'ZF011' AND SKIP FIRST SCREEN.
      ENDCASE.
endcase.
endform. "user_command
  
3.011中定义选择屏幕(这里就不需要定义MEMORY ID):
selection-screen begin of block b1 with frame title bt1.
parameters PL_BUKRS like VBRK-BUKRS memory id PP_BUKRS default '1000'.
select-options PI_KUNRG for VBRK-KUNRG .
select-options PI_FKDAT for VBRK-FKDAT.
select-options PI_VBELN for VBRK-VBELN .
select-options PI_VGBEL for VBRP-VGBEL .
selection-screen end of block b1.

4.011中接收010中传过来的值
DATA : ME_VBELN LIKE VBRK-VBELN .
DATA : ME_FIELD(30) TYPE C . “定义ME_FIELD是为了接收is_selfield-fieldname的MEMORY ID 'PP_FIELD',因为MEMORY不是一个字段,也不是一个内表,只能用这种方式来传输
CLEAR :ME_VBELN ,ME_FIELD.
IMPORT is_selfield-fieldname = ME_FIELD FROM MEMORY ID 'PP_FIELD'.
IF ME_FIELD = 'VBELN'.
    IMPORT ITAB-VBELN = ME_VBELN FROM MEMORY ID 'PT_VBELN'.
ELSE .
    IMPORT PI_VBELN = PI_VBELN from MEMORY ID 'PP_VBELN'.
ENDIF .
  
IMPORT PI_FKDAT = PI_FKDAT FROM MEMORY ID 'PP_PKDAT'.
IF NOT ME_VBELN IS INITIAL .  “表示选择了VBELN
    PI_VBELN-SIGN = 'I'.
    PI_VBELN-OPTION = 'EQ'.
    PI_VBELN-LOW = ME_VBELN .  “只选择单值,所以传LOW就可以拉
    APPEND PI_VBELN .
ENDIF .:

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-114884-1-1.html 上篇帖子: Mini SAP 6.2 安装 ABAP/4 编程 下篇帖子: .NET 调用SAP Web Service(转)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表